TransWikia.com

vertical alignment in tabularx environment

TeX - LaTeX Asked by jopeto on April 5, 2021

I am using tabularx environment and in the MWE I have three columns. The first column contains short text, the second column contains long text and the third column contains short text again.

documentclass{article}    
usepackage{tabularx}

begin{document}

begin{tabularx}{6cm}{|p{2cm}|b{2cm}|p{2cm}|} 
short 1 & long text spanning more than one row & short 2 
end{tabularx}

end{document}

As expected, the result is that both short 1 and short 2 align to the bottom.

enter image description here

If I change the setting on middle column from b{2cm} to p{cm}, as expected both short 1 and short 2 align to the top.

I would like to make short 1 align to the top and short 2 align to the bottom. How can I achieve that?

Thanks in advance.

EDIT:

Following the suggestion by @NBur who pointed me out to this post, I’ve implemented the following changes:

documentclass{article}    
usepackage{tabularx}

newcolumntype{C}{b{2cm}<{vfill}}

begin{document}


begin{tabularx}{6cm}{|C|b{2cm}|p{2cm}|} 
short 1 & long text spanning more than one row & short 2 
end{tabularx}

end{document}

Unfortunately this code brings up the text only by one line and not all the way up to the top of the cell, so it does not work.

enter image description here

Are there any other suggestions?

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