TeX - LaTeX Asked by user227450 on May 2, 2021
I have a hard time making a table that would have predefined dimensions (the whole page) and cells centered horizontally and vertically. I have found solutions for each of those problems individually,but they does not work together. Solutions that I have found so far took me to this point:
documentclass[12pt,a4paper]{article}
usepackage[utf8]{inputenc}
usepackage[czech]{babel}
usepackage[T1]{fontenc}
usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{graphicx}
usepackage[total={17cm,25.7cm}, top=2cm, left=2cm, includefoot, bindingoffset=-0.63cm]{geometry}
%usepackage[twoside, hscale=0.88, vscale=0.88, bindingoffset=0cm]{geometry}
usepackage{tikz}
usepackage{array}
usepackage{booktabs,adjustbox}
newcommand{finalcells}[2]{%
begingroupsbox0{begin{minipage}{3cm}raggedright#1end{minipage}}%
sbox2{begin{minipage}{3cm}raggedright#2end{minipage}}%
xdeffinalheight{thedimexprht0+dp0+smallskipamountrelax}%
xdeffinalheightB{thedimexprht2+dp2+smallskipamountrelax}%
ifdimfinalheightB>finalheight
globalletfinalheightfinalheightB
fiendgroup
begin{minipage}[t][finalheight][t]{3cm}raggedright#1end{minipage}&
begin{minipage}[t][finalheight][t]{3cm}raggedright#2end{minipage}}
begin{document}
{setlength{extrarowheight}{3.5 cm}
%setlength{tabcolsep}{4.25cm}
begin{tabular}{| m{8.5cm} | m{8.5cm} |}
hline
asdasd & •
hline
• & •
hline
• & •
hline
• & •
hline
• & •
hline
• & •
hline
end{tabular}
}
end{document}
It creates the table witch predefined dimensions, but the text is not centered.
The thing that I actually want is to make two-sided (playing) cards that would match after the printing.
Thank for any advice.
Your friend in such cases is the command
rule[-5em]{0pt}{10em}
which adds an invisible rule above and below the contents of each cell -- dimensions as per choice
The pros an cons of various types of vertical and horizontal padding are discussed at many places on this site including --
Column and row padding in tables
The new P
type of column gives the horizontal and vertical centering which you look for
-- with centering
for horizontal centering and m{}
giving the vertical centering in the command
newcolumntype{P}[1]{>{rule[-5em]{0pt}{10em}centeringarraybackslash}m{#1textwidth}}
The width of each column is defined as a percentage of the text width by simply entering P{0.4}
thereby meaning the column will take up 40% of the text width
documentclass[12pt,a4paper]{article}
usepackage[utf8]{inputenc}
usepackage[czech]{babel}
usepackage[T1]{fontenc}
usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{graphicx}
usepackage[total={17cm,25.7cm}, top=2cm, left=2cm, includefoot, bindingoffset=-0.63cm]{geometry}
%usepackage[twoside, hscale=0.88, vscale=0.88, bindingoffset=0cm]{geometry}
usepackage{tikz}
usepackage{array}
usepackage{booktabs,adjustbox}
%
%newcommand{finalcells}[2]{%
% begingroupsbox0{begin{minipage}{3cm}centering#1end{minipage}}%
% sbox2{begin{minipage}{3cm}centering#2end{minipage}}%
% xdeffinalheight{thedimexprht0+dp0+smallskipamountrelax}%
% xdeffinalheightB{thedimexprht2+dp2+smallskipamountrelax}%
% ifdimfinalheightB>finalheight
% globalletfinalheightfinalheightB
% fiendgroup
% begin{minipage}[t][finalheight][t]{3cm}centering#1end{minipage}&
% begin{minipage}[t][finalheight][t]{3cm}centering#2end{minipage}}
newcolumntype{P}[1]{>{rule[-5em]{0pt}{10em}centeringarraybackslash}m{#1textwidth}}
begin{document}
% {setlength{extrarowheight}{3.5 cm}
%setlength{tabcolsep}{4.25cm}
begin{tabular}{| P{0.4} | P{0.4} |}
hline
asdasd & •
hline
• & •
hline
• & •
hline
• & •
hline
• & •
hline
• & •
hline
end{tabular}
% }
end{document}
Answered by js bibra on May 2, 2021
It is not clear what you like to have. More empty space above/below cell contents? What should happen, if you have longer text in cells, for example if it is break in four lines?
I guess, that the following (much simpler) solution gives what you like to get:
documentclass[12pt,a4paper]{article}
usepackage[total={17cm,25.7cm},
top=2cm, left=2cm,
includefoot, bindingoffset=-0.63cm]{geometry}
usepackage[czech]{babel}
usepackage[T1]{fontenc}
usepackage{array, booktabs}
usepackage[column=O]{cellspace} % for additiona vertical space above/below cells contets
setlengthcellspacetoplimit{22pt}
setlengthcellspacebottomlimit{22pt}
usepackage{adjustbox}
usepackage{lipsum}
begin{document}
begin{tabular}{| >{centeringarraybackslash}O{m{8.5cm}}
| >{centeringarraybackslash}O{m{8.5cm}} |}
hline
asdasd & lipsum[1][1-3]
hline
• & •
hline
• & •
hline
• & •
hline
end{tabular}
end{document}
Answered by Zarko on May 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP