TeX - LaTeX Asked on December 22, 2020
My problems:
This is my MWE:
documentclass[a4paper,12pt,oneside,openany]{book}
usepackage[a4paper, inner=4cm, outer=3cm, top=4cm, bottom=3cm]{geometry}
usepackage{longtable}
usepackage{lipsum}
usepackage{pdflscape}
renewcommand{arraystretch}{2.0}
usepackage{enumitem}
begin{document}
chapter{BOO}
lipsum[1-2]
newpage
thispagestyle{plain}
begin{landscape}
section{My Table}
begin{table}[h!]
centering
caption{This is a table}
begin{tabular}{|p{3cm}| p{3cm} |p{3cm}|p{3.2cm}|p{2.5cm}|p{2.5cm}|p{3cm}|}
hline
multicolumn{1}{|c|}{textbf{Whatever}}
& multicolumn{1}{c|}{parbox[H]{3cm}{centering textbf{Random Text}}}
& multicolumn{1}{c|}{textbf{Whatever}}
& multicolumn{1}{c|}{textbf{Whatever}}
& multicolumn{1}{c|}{parbox[H]{2cm}{centering textbf{Random Text}}}
& multicolumn{1}{c|}{parbox[H]{3cm}{centering textbf{Random Text}}}
& multicolumn{1}{c|}{parbox[H]{3cm}{centering textbf{Random Text}}}
hline
lipsum[2][1]
& begin{enumerate}[left= 0pt, label=arabic*), noitemsep, topsep= 0pt]
item lipsum[1][1]
item lipsum[1][1]
end{enumerate}
& begin{enumerate}[left= 0pt, label=arabic*), noitemsep, topsep= 0pt]
item lipsum[1][1]
item lipsum[1][1]
end{enumerate}
&begin{enumerate}[left= 0pt, label=arabic*), noitemsep, topsep= 0pt]
item lipsum[1][1]
item lipsum[1][1]
end{enumerate}
&begin{enumerate}[left= 0pt, label=arabic*), noitemsep, topsep= 0pt]
item lipsum[1][1]
end{enumerate}
&lipsum[2][4]
& lipsum[2][1]
hline
end{tabular}
end{table}
end{landscape}
end{document}
Help me please. Thanks!
To fix the first issue, I suggest you load the makecell
package and use makecell{...}
directives instead of multicolumn{1}{c|}{parbox[H]{3cm}{centering ...}}
wrappers.
To fix the second issue, I suggest you make use of some of the enumitem
package's machinery -- specifically, its newlist
and setlist
directives -- to create a bespoke enumerate
-like list environment (called ColEnum
in the example code below) that encases the list's contents in a minipage
. Doing so will strip off the vertical whitespace.
I would also like to suggest that you use RaggedRight
directives in the narrow columns, to switch from full justification to ragged-right.
documentclass[a4paper,12pt,oneside,openany]{book}
usepackage[inner=4cm, outer=3cm, top=4cm, bottom=3cm]{geometry}
usepackage{lipsum,pdflscape}
% new:
usepackage{makecell} % for 'makecell' macro
usepackage{ragged2e} % for 'RaggedRight' macro
usepackage{enumitem} % for 'newlist' and 'setlist' macros
newlist{ColEnum}{enumerate}{1}
setlist[ColEnum,1]{label = arabic*), left = 0pt, nosep,
before= {begin{minipage}[t]{hsize}RaggedRight},
after = {end{minipage}}}
begin{document}
setcounter{chapter}{2} % just for this example
thispagestyle{plain}
begin{landscape}
section{A section header, followed by a table}
begin{table}[h!]
centering
caption{This is a tablestrut}
begin{tabular}{|p{3cm} | p{3cm} | p{3cm} |
p{3.2cm} | p{2.5cm} | p{2.5cm} | p{3cm}|}
hline
bfseriesmakecell{Whatever} &
bfseriesmakecell{Random Text} &
bfseriesmakecell{Whatever} &
bfseriesmakecell{Whatever} &
bfseriesmakecell{Random Text} &
bfseriesmakecell{Random Text} &
bfseriesmakecell{Random Text}
hline
RaggedRightlipsum[2][1] &
begin{ColEnum}
item lipsum[1][1]
item lipsum[1][1]
end{ColEnum} &
begin{ColEnum}
item lipsum[1][1]
item lipsum[1][1]
end{ColEnum} &
begin{ColEnum}
item lipsum[1][1]
item lipsum[1][1]
end{ColEnum} &
begin{ColEnum}
item lipsum[1][1]
end{ColEnum} &
RaggedRightlipsum[2][4] &
RaggedRightlipsum[2][1]
hline
end{tabular}
end{table}
end{landscape}
end{document}
Correct answer by Mico on December 22, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP