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

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}


• 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.

• to see why you get the layout you show draw in the baseline for the second table row, it passes through the centre of There (as you used origin=c) and along the bottom of the image, so space has to be added under the image to allow both to sit on the baseline. – David Carlisle Sep 9 '20 at 18:35
• It should be noted that in many cases the baseline is slightly below the center. One can ishow the location of the baseline using \llap{\rule{1in}{0.5pt}} AFTER the text. – John Kormylo Sep 10 '20 at 15:04

For the second table with image:

\documentclass{report}
\usepackage{tabularx}

\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}


• How to choose the margins? Do they depend on the chosen height of the image? – Karlo Sep 10 '20 at 13:09
• @Karlo, margin size is determined absolutely, it is independent from image size. it is defined as margin= <left> <above> <below> <right>.sinceon the left and tight size of image are already space \tabcolspace (6pt), You only need add space above and below of image. If you like to have the same space above/below as is left/right, than margin= 0pt 6pt 0pt 6pt. For details see documentation for adjustbox package. – Zarko Sep 10 '20 at 13:29