3

I'm trying to wrap the text in table column headings in the turn environment (from the package -rotating-). Is there a way to perform this using turn or do have to embed a minipage (e.g., ...& \begin{turn}{60}\begin{minipage}[t]{3cm}\textbf{Returned Surveys}\end{mini page}... )? Other ideas?
(note: I'm using a statistical program to generate/weave the code into the latex document and putting the minipage code within the turn environment causes other problems with string length -- I'd rather use an alternative to turn or an option in turn to fix the issue). Thanks for any advice!

EXAMPLE:

\documentclass{article}
\usepackage{booktabs,rotating,tabularx}
\begin{document}

\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{p{7cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}rrrrr}
\textbf{OTP Name} & \begin{turn}{60}\textbf{Initial Email Sent}\end{turn} & \begin{turn}{60}\begin{minipage}[t]{3cm}\textbf{Returned Surveys}\end{minipage}\end{turn} & \begin{turn}{60}\textbf{Survey Reminder Sent}\end{turn} & \begin{turn}{60}\textbf{Response Received from Reminder}\end{turn} & \begin{turn}{60}\textbf{Returned Surveys}\end{turn} \\
\midrule
UAMS Psychiatric Research Institute & x & & x & & x \\
Valley Alliance Treatment Services & x & & x & x & \\
\ldots &&&&&&&\\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%

\end{document}
2
  • 1
    You should try the examples in Rotated Column Titles in Tabular. Does that help?
    – Werner
    Jan 6, 2012 at 17:45
  • Kind of - I did miss this SE thread in my search, thanks. The answer by Gonzalo Medina is the only one in that thread that allows for wrapping, and it is just a new command (P) with minipage inside turn that still has to go into a multicolumn command. This is slightly shorter, but still hits my string limit when some of the labels are really long. I'm still hoping for other ideas/solutions. Jan 6, 2012 at 18:02

1 Answer 1

5

Here is something that might be an option for you. It modifies my solution in Rotated Column Titles in Tabular to accommodate your situation:

Rotating column headings in tabular

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{varwidth}% http://ctan.org/pkg/varwidth

\newcommand{\turn}[3][10em]{% \turn[<width>]{<angle>}{<stuff>}
  \rlap{\rotatebox{#2}{\begin{varwidth}[t]{#1}\bfseries#3\end{varwidth}}}%
}
\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
  \begin{tabular}{p{7cm}*{5}{p{1cm}}}
    \textbf{OTP Name} & 
      \turn{60}{Initial Email Sent} & 
      \turn[3cm]{60}{Returned Surveys} & 
      \turn{60}{Survey Reminder Sent} & 
      \turn{60}{Response Received from Reminder} & 
      \turn{60}{Returned Surveys} \\
    \midrule
    UAMS Psychiatric Research Institute & x & & x & & x \\
    Valley Alliance Treatment Services & x & & x & x & \\
    \ldots & & & & & \\
    \bottomrule
  \end{tabular}
  \label{tab:addlabel}
\end{table}
\end{document}​

varwidth provides a similar interface to what the minipage environment allows, but with a default "natural" width if the width is longer than its contents. Wrapping occurs as in minipage if the length is shorter. graphicx allows for rotation by an angle in degrees.

In the above example, the command \turn[<width>]{<angle>}{<stuff>} rotates <stuff> at angle <angle>, wrapped at a length/width of <width> (default is 10em; change to suit your needs). It also sets <stuff> in bold by default due to \bfseries, and puts it in a zero-width box (thanks to \rlap) so that you don't receive. For extremely long and wrapped headers, this may not be optimal. But then you should ask yourself whether the structure should be modified anyway.

Also note the use of an abbreviated notation for repetitive column specification. Using *{<num>}{<colspec>} repeats <colspec> as-is <num> times. It's useful and avoid having to count whether you have exactly (say) 11 r-columns in rrrrrrrrrrr.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .