TransWikia.com

How to vertically align rotated text and images in a tabular?

TeX - LaTeX Asked on November 28, 2020

Consider following MWE :

documentclass{report}
usepackage{tabularx}
usepackage{graphicx}
begin{document}
begin{tabular}{|c|c|}
hline a & b  hline
rotatebox[origin=c]{90}{Hello} & d  hline
e & f  hline
end{tabular}
vspace{1cm}
begin{tabular}{|c|c|}
hline a & b  hline
rotatebox[origin=c]{90}{There} & includegraphics[height=2cm]{dummy.png}  hline
e & f  hline
end{tabular}
end{document}

enter image description here

  • In the second line of the first table, the rotated text ("Hello") is vertically aligned with the text ("d") of its adjacent cell.

  • In the second table, there is a problem with the vertical alignment : the text seems to be aligned at the bottom [or left before rotation], and there is a whitespace below the figure. How can one obtain vertical alignment in this case?

I found this related question but it seems my problem is caused by the fact of adding an image in the adjacent cell.

One Answer

For the second table with image:

documentclass{report}
usepackage{tabularx}
usepackage[export]{adjustbox}

begin{document}
begin{tabular}{|c|c|}
hline a & b  hline
rotatebox[origin=c]{90}{There} 
         & includegraphics[height=2cm,valign=c,
                            margin= 0pt 3pt 0pt 3pt]{example-image-duck} 
         hline
e       & f  
        hline
end{tabular}
end{document}

enter image description here

Answered by Zarko on November 28, 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