# 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

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}


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