I would like to rotate text inside a table and align to the centre as shown. The next column has several other rows which are combined in the "standards" row. Something similar to the first picture(aligning with the vertical line) and not the second. I would appreciate suggestions on the best way to do this. Thanks
[Tex/LaTex] Rotate text inside table and align it to the centre of combined rows
horizontal alignmentrotatingtablesvertical alignment
Related Solutions
For this kind of stuff I find it best to use \tikzmark
:
I was not sure where you wanted the brace, so the brace below might not be where you want it. But do the table as you normally would and get the text in the correct spot. Include a \tikzmark{<nameA>}
and \tikzmark{<nameB>}
to mark the location of the two end points of the brace. Then provide the name of those two marks to \DrawVerticalBrace
to do the actual drawing.
Notes:
This does require two runs. First one to determine the locations, and the second to do the drawing.
The
\tikzmark
is from Adding a large brace next to a body of text.
Code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}
\newcommand{\tikzmark}[1]{%
\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {};}
\newcommand{\DrawVerticalBrace}[3][]{%
% [<draw options>]{<mark>}{<mark>}
\begin{tikzpicture}[overlay,remember picture]
\draw[decorate,decoration={brace,amplitude=1ex}, #1]
($(#3)+(0.0em,-0.5ex)$) to
($(#2)+(0.0em,+1.7ex)$);%
\end{tikzpicture}%
}
\begin{document}
\begin{tabular}{ l c r }
$T=0$ & $T=1$ & $T=2$ \\
$-1$ & \multicolumn{2}{l}{$
\begin{array}{l l}
\tikzmark{top}0 & R\\
\tikzmark{bot}1 & 0
\end{array} $}
\end{tabular}
\DrawVerticalBrace[red, thick]{top}{bot}%
\end{document}
You can do this with or without multirow
. Use graphicx
for the rotation via \rotatebox[<opts>]{<deg>}{<stuff>}
:
\documentclass{article}
\usepackage{graphicx,multirow}
\begin{document}
\begin{tabular}{ |c|c|c| }
\hline
\multirow{8}{*}{\rotatebox[origin=c]{90}{Text}} & row 1 & row 1 \\
& row 2 & row 2 \\
& row 3 & row 3 \\
& row 4 & row 4 \\
& row 5 & row 5 \\
& row 6 & row 6 \\
& row 7 & row 7 \\
& row 8 & row 8 \\
\hline
\end{tabular}
\begin{tabular}{ |c|c|c| }
\hline
& row 1 & row 1 \\
& row 2 & row 2 \\
& row 3 & row 3 \\
\raisebox{-.5\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{Text}} & row 4 & row 4 \\
& row 5 & row 5 \\
& row 6 & row 6 \\
& row 7 & row 7 \\
& row 8 & row 8 \\
\hline
\end{tabular}
\end{document}
With multirow
you don't need to worry about the placement, while without you need to place the text in the appropriate location, and perhaps lower/raise it into position. Also, you have to flatten the content (done by using the [0pt][0pt]
options to \raisebox
) so it doesn't impede in the row height - something that is naturally done by multirow
.
There might be a slight discrepancy between the two methods, but it is negligible.
Best Answer
You can use
\rotatebox
as follows: