TeX - LaTeX Asked by TylerD007 on December 19, 2020
I’m trying to create a pretty straightforward table with tabularx that should look like this:
A1 A2 A3 MULTIROW
B1 B2 B3
C1 C2 C3
My problem is that I can’t make the text in the multirow cell fit inside the page margin (the text is printed in one single line and does not respect the cell width). Also, I want the text top aligned and not centered. Here is my code:
begin{flushleft}
begingroup
defarraystretch{1.5}
begin{tabularx}{textwidth}{c l l X}
A1 & A2 & A3 & multirow{3}{*}{multirow text}
B1 & B2 & B3
C1 & C2 & C3
end{tabularx}
endgroup
end{flushleft}
From your description, I guess you are interested in
t
option to top align the contents of the multirow
: multirow[t]{3}...
in combination with
=
instead of *
to make sure the width if the multirow cell adapts to the width of the column it is used inside of instead of adapting to the width of its contents: multirow[t]{3}{=}...
Combined into a MWE, this could look like the following:
documentclass{article}
usepackage{tabularx}
usepackage{multirow}
begin{document}
noindent
{defarraystretch{1.5}%
begin{tabularx}{textwidth}{c l l X}
A1 & A2 & A3 & multirow[t]{3}{=}{multirow text multirow text multirow text multirow text multirow text multirow text multirow text}
B1 & B2 & B3 &
C1 & C2 & C3 &
end{tabularx}
}
end{document}
With a nested tabular
instead of multirow
:
documentclass{article}
usepackage{tabularx}
usepackage{lipsum}
begin{document}
noindent
{defarraystretch{1.5}%
begin{tabularx}{textwidth}{l X}
begin{tabular}[t]{@{}c l l@{}} A1 & A2 & A3
B1 & B2 & B3
C1 & C2 & C3
end{tabular} & lipsum[1][1-4]
end{tabularx}
}
end{document}
Correct answer by leandriis on December 19, 2020
It is not clear what is your problem, Probably you looking for something like this:
documentclass{article}
usepackage{lipsum} % for text filler
usepackage{multirow,
tabularx}
begin{document}
begingroup
flushleft
renewcommandmultirowsetup{}
defarraystretch{1.5}
begin{tabularx}{textwidth}{c l l X}
A1 & A2 & A3 & multirow[t]{3}{=}{lipsum[1][1-3]}
B1 & B2 & B3
C1 & C2 & C3
end{tabularx}
endgroup
end{document}
Note:
begin{tabularx}{textwidth}{|c | l | l | X|}
multirow
cells contain longer text, it can be automatic split into more lines, if you use (relatively new) specification multirow[t]{3}{=}{...}
as it already mention @leandriis in his comment.Edit:
raggedright
multirowsetup
, see edited MWE below(red lines show text borders)
Answered by Zarko on December 19, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP