# Centering rotated text in a multirow cell in a table with images

the following code:

\documentclass{article}
\usepackage{mwe}
\usepackage{multirow,makecell}
\begin{document}
\begin{tabular}{c|c|c|c}
\multirow{3}{*}{\rotatebox[origin=c]{90}{Text}}
& ro1 1 & \includegraphics[align=c,scale=0.25]{example-image} & text\\
& row 2 & \includegraphics[align=c,scale=0.1]{example-image} & text\\
& row 3 & \includegraphics[align=c,scale=0.4]{example-image} & text\\
\end{tabular}

\vspace{1cm}

\begin{tabular}{c|c|c|c}
\multirow{3}{*}{\rotatebox[origin=c]{90}{Text}}
& row 1 & without example-image & text\\
& row 2 & without example-image & text\\
& row 3 & without example-image & text\\
\end{tabular}
\end{document}


gives me the following output:

Is it possible to center the rotated text?

• you are close -- all you need to do is change the following code --\multirow{10}{*}{\rotatebox[origin=c]{90}{Text}} the multirow option for number of lines can be arbitrary and even decimal for fine tuning of the centering -- in the second case change the code to \multirow{8}{*}{\rotatebox[origin=l]{90}{Text}}  --you can read the multirow and makecell documentation for even more options at -- mirrors.ibiblio.org/CTAN/macros/latex/contrib/makecell/… and at ctan.imsc.res.in/macros/latex/contrib/multirow/multirow.pdf Feb 18 '21 at 4:28
• Feb 18 '21 at 6:22

\documentclass{article}
%\usepackage{mwe}
\usepackage{multirow,makecell}
\begin{document}
\begin{tabular}{c|c|c|c}
\multirow{10}{*}{\rotatebox[origin=c]{90}{Text}}
& ro1 1 & \includegraphics[scale=0.25]{example-image} & text\\
& row 2 & \includegraphics[scale=0.1]{example-image} & text\\
& row 3 & \includegraphics[scale=0.4]{example-image} & text\\
\end{tabular}

\vspace{1cm}

\begin{tabular}{c|c|c|c}
\multirow{8}{*}{\rotatebox[origin=l]{90}{Text}}
& row 1 & \makecell[l]{without example-image  \\ without example-image \\ without example-image}& text\\
& row 2 & \makecell[l]{without example-image  \\ without example-image \\ without example-image}& text\\
& row 3 & \makecell[l]{without example-image  \\ without example-image \\ without example-image} & text\\
\end{tabular}
\end{document}

• Hello and thanks for your answer. I was able to get the desired result after tinkering with the multirow option for the number of lines (as you have suggested). Since the NiceTabular command don't work on my system (unfortunately) your solution is the one I will use.
– rogr
Feb 18 '21 at 12:17

Have a nice welcome here! :)

Some weeks ago, I had a very similar problem, according to this thread. A decent solution is to use a NiceTabular from the nicematrix package by F. Patigny (see documentation). That provides some block logic, thus you don't need multirow and makecell anymore.

\documentclass{article}
\usepackage{mwe}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{c|c|c|c}
\Block{*-1}{\rotate{Text}}
& row 1 & \includegraphics[align=c,scale=0.25]{example-image} & text\\
& row 2 & \includegraphics[align=c,scale=0.1]{example-image} & text\\
& row 3 & \includegraphics[align=c,scale=0.4]{example-image} & text\\
\end{NiceTabular}

\vspace{1cm}

\begin{NiceTabular}{c|c|c|c}
\Block{*-1}{\rotate{Text}}
& row 1 & without example-image & text\\
& row 2 & without example-image & text\\
& row 3 & without example-image & text\\
\end{NiceTabular}

\end{document}


(You probably have to compile the document twice.)

Result:

• Thanks for the answer. Your output is exactly what i asked for. Unfortunately my editor couldn’t compile the code due to an issue with the NiceTabular Environment i wasn’t able resolve ("undefinded Environment"). I don’t know how to troubleshoot package issues as I never see them, so it’s possible your code doesn’t work just on my system.
– rogr
Feb 18 '21 at 12:08
• @rogr: You have not the latest version of nicematrix. You should update your TeX installation. Feb 18 '21 at 12:40
• @F.Pantigny Yes, you were right. I use LaTeX primarily Ubuntu and updating the TeX packages is a whole nother issue for itself. After switching to Windows I updated all the installed TeX packages via MikTeX Console and the code provided by Max16hr worked. Thank you all.
– rogr
Feb 18 '21 at 21:20