How to rotate text in multirow table?
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]
).
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}