0

I asked a question before, howerver it was marked as a duplicate and closed down. Unfortunately the provided solution did not answer the problem, so I am reposting it.

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.

SUGGESTED SOLUTION THAT DOES NOT WORK:

Following a suggestion by @NBur who pointed me 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?

2

1 Answer 1

1

An alternative solution with tblr environment of tabularray package, using head and foot alignmnet types:

\documentclass{article}    

\usepackage{tabularray}

\begin{document}

\begin{tblr}{|h{2cm}|m{2cm}|f{2cm}|} 
short 1 & long text spanning more than one row & short 2 \\
\end{tblr}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.