TransWikia.com

Vertical Alignment & Text Wrapping using Multirow

TeX - LaTeX Asked by Qureshi on December 24, 2020

I am facing issues in vertically aligning (and wrapping of) the text in a multirow table. I would accordingly appreciate some help in this regard from the estmeed community. Please see below:

begin{table}
caption{Story of Humpty Dumpty}
centering
begin{tabular}{c|c|c}
hline
multirow{3}{*}{Humpty Dumpty Sat} & on & begin{tabular}[c]{@{}c@{}}the wall\ and had a great fall  end{tabular}\ cline{2-3} 
& begin{tabular}[c]{@{}c@{}} onend{tabular} & begin{tabular}[c]{@{}c@{}}the wall\ and had a great fall end{tabular}\ cline{2-3} & begin{tabular}[c]{@{}c@{}}on\ end{tabular} & begin{tabular}[c]{@{}c@{}}the wall\ and had a great fallend{tabular} \ hline
end{tabular}
end{table}

I am looking to achieve the following:

enter image description here

2 Answers

vertical alignment

enter image description here

 multirow{5}{*}{Humpty Dumpty Sat} & on & begin{tabular}[c]{@{}c@{}}the wall\ and had a great fall  end{tabular}\ cline{2-3} 

additionally to wrap the text in multirow

enter image description here

multirow{5}{0.2textwidth}{centering Humpty Dumpty Sat} 

Correct answer by js bibra on December 24, 2020

Alternatively, with shorter code which employ m type of columns and center setting for `multirow cells:

documentclass{article}
usepackage{array, multirow}

begin{document}
    begin{table}
caption{Story of Humpty Dumpty}
centering
renewcommandmultirowsetup{centering} % <---
renewcommandarraystretch{1.3}
begin{tabular}{p{6em}|c|>{centeringarraybackslash}m{8em}} <---
    hline
multirow{4.5}{=}{Humpty Dumpty Sat} % 4.5=6 spanned lines-2 lines text + 0.5 line for gaps in rows
    & on    & the wall and had a great fall \ cline{2-3}
    & on    & the wall and had a great fall \ cline{2-3} 
    & on    & the wall and had a great fall \ 
    hline
end{tabular}
    end{table}
end{document}

enter image description here

Answered by Zarko on December 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP