# How to rotate text in multirow table?

I have a big table with a problem, when I want to rotate the text in a \multirow cell, the text is placed outside and is bigger than the dimensions of the cell, I took some advice from here, using\parbox, and then \rotatebox. But I don't get good results.

 \documentclass{article}
\usepackage{array,multirow,graphicx}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|l|r|r|r|r|}
\hline
& \multicolumn{1}{|c|}{Text} & \multicolumn{1}{|c|}{Text} & \multicolumn{1}{|c|}{Text} & \multicolumn{1}{|c|}{Text} & \multicolumn{1}{|c|}{text}\\
\hline
\rotatebox{90}{\parbox{2mm}{\multirow{3}{*}{rota}}} & text &&&&\\
& text &&&&\\
& text &&&&\\
\hline
\end{tabular}
\end{table}
\end{document}


Which results in:

Put \rotatebox inside like:

\parbox[t]{2mm}{\multirow{3}{*}{\rotatebox[origin=c]{90}{rota}}}


# Code:

 \documentclass{article}
\usepackage{array,multirow,graphicx}
\usepackage{float}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|l|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{text}\\
\hline
\parbox[t]{2mm}{\multirow{3}{*}{\rotatebox[origin=c]{90}{rota}}} & text &&&&\\
& text &&&&\\
& text &&&&\\
\hline
\end{tabular}
\end{table}
\end{document}


I have eliminated some spurious vertical lines in the title and introduced the origin for rotation. However, the idea of introducing a parbox did not get in to my head as this may not be needed for the present MWE. In case you have other uses in your actual code, you may use the alignment specifiers to parbox (Here [t]).

• If rota is instead rotatoata, it will be outside the table. Any idea of how to force it to increase the spacing of rows or something to avoid this? – Jorge Leitao Oct 15 '15 at 14:10
• @J.C.Leitão You can't. Only way is to increase the number of rows from 3 to 4 or more. – user11232 Oct 15 '15 at 14:14
• For posterity, an hacky solution is to decrease the text-size. – Jorge Leitao Oct 15 '15 at 14:15
• Note that with colors it is safer to use the last row to contain the multirow, see this blog – towi Sep 27 '16 at 21:06
• I can confirm that \parbox does not seem necessary – Johannes Nov 1 '19 at 9:25

A variant that doesn't require manual adjustment of width and automatically centers the rotated cell horizontally:

\documentclass{article}
\usepackage{array,multirow,graphicx}
\begin{document}

\newcommand{\STAB}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\begin{table}[!h]
\centering
\begin{tabular}{|c|l|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{text} \\ \hline
\multirow{3}{*}{\STAB{\rotatebox[origin=c]{90}{rota}}}
& text                      &                           &                           &                           &                           \\
& text                      &                           &                           &                           &                           \\
& text                      &                           &                           &                           &                           \\ \hline
\end{tabular}
\end{table}

\end{document}


• It seems to work without STAB too for me: \multirow{3}{*}{\rotatebox[origin=c]{90}{rota}}. Not sure what it is for. – Bora M. Alper Dec 8 '20 at 15:18

Improving Harish Kumar's answer on follow up question of placing longer word inside a cell, i.e., rota to rotatoata. It also uses \rotatebox and \parbox but the order is different.

And, if the intentions of using \multicolumn{1}{c|}{Text} is to center the text, then {\hfill Text\hfill} could be alternative solution.

# Code:

\documentclass{article}
\usepackage{array,multirow,graphicx}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|c|l|r|r|r|r|}\hline
~ & \multicolumn{1}{c|}{Text} & {\hfill Text\hfill} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} & \multicolumn{1}{c|}{Text} \\ \hline
\multirow{3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{\centering rotato-ata}}} & text &&&&\\
& text &testing A& testing B&&\\
& text &right aligned&&&\\ \hline
\end{tabular}
\end{table}
\end{document}


• Updated the package from graphics to graphicx and it works. Checked with Overleaf. – Seong Jan 1 '18 at 9:20

add \newcommand*\rot{\rotatebox{90}} before \begin{document}

and then just do \rot{Whatever you want to rotate}

Hope it helps..

Found here

With {NiceTabular} of nicematrix and its built-in command \Block, you have directly the expected output.

Morever, with that command \Block, you specify the number of logical rows and not the number of physical row (as with \multirow).

 \documentclass{article}
\usepackage{nicematrix}

\begin{document}
\begin{table}[!h]
\centering
\begin{NiceTabular}{|c|l|r|r|r|r|}
\hline
& Text & Text & Text & Text & text \\ \hline
\Block{3-1}<\rotate>{rota}
& text & & & & \\
& text & & & & \\
& text & & & & \\ \hline
\end{NiceTabular}
\end{table}
\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).