lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

Aligning text vertically with `\rotatebox` #436

Closed Aljumaily closed 10 months ago

Aljumaily commented 10 months ago

The following example is expected to centre the text vertically. However, since \rotatebox{...}{...} is used, the text is aligned with b alignment.

image
\documentclass[border=1cm]{standalone}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}
  \begin{tblr}{hlines, vlines, cell{1}{2-Z}={8em, halign=c, valign=m, azure9}}
    \rotatebox{90}{Some text} & Alpha & Gamma & Delta \\
  \end{tblr}
\end{document}
muzimuzhi commented 10 months ago

Well, the (non-spanning, see https://github.com/lvjr/tabularray/issues/434#issuecomment-1686778391) cells are still vertically centered. It's just the \rotatebox (from graphicx package that rotating loads) that made the the baseline height of \rotatedbox{90}{Some text} at its bottom, not half-height.

Setting rotation origin to the center (of box to be rotated) solves the problem. See user manual Packages in the ‘graphics’ bundle (2021-03-05, can be opened by texdoc graphicx or texdoc grfguide), sec. 4.2 "Rotation" for more info about key-values that \rotatebox accepts as optional argument.

\documentclass[border=1cm]{standalone}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}
  \begin{tblr}{hlines, vlines, cell{1}{2-Z}={8em, halign=c, valign=m, azure9}}
    \rotatebox[origin=c]{90}{Some text} & Alpha & Gamma & Delta \\
  \end{tblr}
\end{document}

image