# Line break in rotatebox in table?

I use \rotatebox to create a table with vertical headers, like so:

\documentclass{article}

\usepackage{rotating}

\begin{document}

\begin{table}
\begin{tabular}{|l|l|l|}
\hline
\hline
Content & Content & Content\\
\hline
\end{tabular}
\end{table}

\end{document}


Now, I have a header that is awkwardly long (and cannot be abbreviated in a meaningful way). I would like to break the header into two lines. However, I can't seem to get this to work with \linebreak or \\, so apparently some trickery is needed.

Help?

-
Rotating the column headers isn't a great solution. Is spreading them out over two or more lines an acceptable solution? –  Marc van Dongen Jan 8 '12 at 21:12
@MarcvanDongen: I'm working on a book translation, with the original in a rather cramped layout (which I still want to conserve). The actual table has 27 columns. Rotated headers is about the only way to get this done, and the way the original book did it, too. Unfortunately, the German headers are quite a bit longer than the English ones, and with 77 rows I'm running out of vertical space. Hence, it's a line break in the vertical header, or spreading this sea of numbers over multiple pages, which wouldn't help the document any... –  DevSolar Jan 8 '12 at 21:17
Would you mind giving an example of one such table? –  Marc van Dongen Jan 8 '12 at 21:21
Have you thought of rotating the table? That would give you some extra space. –  Marc van Dongen Jan 8 '12 at 21:25
Duplicate: Wrapping table column headings in -turn- environment? (in terms of the answer). –  Werner Jan 8 '12 at 21:27

How about putting the "problematic" header into a \parbox and manually adding \\ (which works inside the box) where necessary?

\documentclass{article}

\usepackage{rotating}

\begin{document}

\begin{table}
\begin{tabular}{|l|l|l|}
\hline
\rotatebox{90}{\parbox{4cm}{An awkwardly long \\header that cannot be \\abbreviated in a \\meaningful way}}\\
\hline
Content & Content & Content\\
\hline
\end{tabular}
\end{table}

\end{document}


-
Excellent, that did it. –  DevSolar Jan 8 '12 at 21:33

You can use \adjustbox{minipage=<width>,rotate=<angle>}{some text\\with line break} from the adjustbox package to create rotated box with the given width which can have manual and automatic line breaks.

-

You can wrap the long header in a \parbox:

\documentclass{article}

\usepackage{rotating}

\begin{document}

\begin{table}
\begin{tabular}{|l|l|l|}
\hline