0

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?

jopeto
  • 165

1 Answers1

1

It is very simple to achieve with the new package tabularray:

\documentclass{article}    
\usepackage{tabularray}
\begin{document}
\begin{tblr}{|Q[h,2cm]|Q[m,2cm]|Q[f,2cm]|}
short 1 & long text spanning more than one row & short 2 \\
\end{tblr}

\vspace{1cm} And if you like the second column be justified: \vspace{1cm}

\begin{tblr}{|Q[h,2cm]|Q[m,2cm,halign=j]|Q[f,2cm]|} short 1 & long text spanning more than one row & short 2 \ \end{tblr}

\end{document}

enter image description here

CarLaTeX
  • 62,716