GeneralCenter Sideways Text in Table

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nick
Posts: 1
Joined: Fri Feb 22, 2008 2:54 pm

Center Sideways Text in Table

Post by nick »

Does anyone know how to center sideways text in a table?

Example:

\begin{tabular}{|c|c|c|}
\hline
& \begin{sideways}USERNAME\end{sideways}&
\begin{sideways}PASSW\end{sideways}\\
\hline
NAME1 & x & x \\
\hline
NAME2 & x & x \\
\hline
\end{tabular}

I wish to vertically center the sideways text 'USERNAME' and 'PAS' .
I would like to avoid using the \array package.

Many thanks in advance,
Nick

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Center Sideways Text in Table

Post by localghost »

Use the \rotatebox command from graphicx to rotate the LR-box in the third column of the head.

Code: Select all

\begin{tabular}{|*{3}{c|}} \cline{2-3}
  \multicolumn{1}{c|}{}&\rotatebox{90}{USERNAME}&\rotatebox{90}{\makebox[\widthof{USERNAME}]{PASSW}} \\ \hline
  NAME1 & x & x \\ \hline
  NAME2 & x & x \\ \hline
\end{tabular}
To get familiar with the syntax of the \makebox command, refer to basic LaTeX documentation.


Best regards
Thorsten¹
Post Reply