Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been struggling to appropriately align rotated text using longtable, array and rotating packages. I basically want column headers to be aligned at the bottom, however, LaTeX centres them even after issuing an explicit ragged directives.

\documentclass[a4paper,10pt]{report}

\usepackage{longtable}
\usepackage{multirow}
\usepackage{array}
\usepackage{rotating}

\begin{document}

\begin{longtable}{
>{\centering\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.60\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}}

\caption{Minimal Example Table}
\label{tab:minimal-example:the-table} \\
 \cline{3-9}
 \multicolumn{1}{c}{} &
 \multicolumn{1}{c|}{} &
 \begin{sideways}\textbf{Column 1}\end{sideways} &
 \begin{sideways}\textbf{Column 2}\end{sideways} &
 \begin{sideways}\textbf{Column 3}\end{sideways} &
 \begin{sideways}\textbf{Column 4}\end{sideways} &
 \begin{sideways}\textbf{Long Column 1}\end{sideways} &
 \begin{sideways}\textbf{Column 5}\end{sideways} &
 \begin{sideways}\textbf{Column 6}\end{sideways}\\
 \cline{1-9}
 \endfirsthead
 \caption[]{(continued)}\\
 \cline{3-9}
 \multicolumn{1}{c}{} &
 \multicolumn{1}{c|}{} &
 \begin{sideways}\textbf{Column 1}\end{sideways} &
 \begin{sideways}\textbf{Column 2}\end{sideways} &
 \begin{sideways}\textbf{Column 3}\end{sideways} &
 \begin{sideways}\textbf{Column 4}\end{sideways} &
 \begin{sideways}\textbf{Long Column 1}\end{sideways} &
 \begin{sideways}\textbf{Column 5}\end{sideways} &
 \begin{sideways}\textbf{Column 6}\end{sideways}\\
 \cline{1-9}
 \endhead

 % Page footer
 \cline{1-9}
 \multicolumn{9}{c}{(Continued on next page)} \\
 \endfoot

 % Last page footer
 %\bottomrule
 \endlastfoot

 \multirow{3}{*}{\begin{sideways}\textbf{R1}\end{sideways}} &
 {Place holder text....}&
 {}&
 {}&
 {}&
 {}&
 {X}&
 {}&
 {}\\

 \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

 \cline{1-9}

 \multirow{3}{*}{\begin{sideways}\textbf{R2}\end{sideways}} &
 {Place holder text....}&
 {}&
 {}&
 {}&
 {}&
 {X}&
 {}&
 {}\\

 \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

  \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

 \cline{1-9}

\end{longtable}

\end{document}
share|improve this question
2  
Is tex.stackexchange.com/q/98388/19384 of any help? –  Peter Jansson Feb 17 '13 at 16:36
    
@PeterJansson, indeed it does; but only after I stop using \array package for those columns --by replacing >{\arraybackslash}m{0.010\linewidth} with a c. However, I was rather hoping I could have control over the width of those columns. –  phiri Feb 17 '13 at 16:59
    
It's a bit clunky but you could always simply put each column label into a fixed-size \hbox, like this: \hbox to 1.2in{\bf Column 1\hss}. –  Thruston Feb 17 '13 at 17:56

1 Answer 1

up vote 3 down vote accepted

You have impossibly narrow columns widths specified, and the rotated text was centred because of the m column specifier.

I would use something like the following although I note you added a comment saying you need to specify columns so you could switch c back to >{\centering\arraybackslash}p{...} for some width.

also rotating package is mainly for compatibility with a latex2.09 package of the same name it is just a wrapper around the standard latex rotation functions, so it is simpler just to use that.

enter image description here

\documentclass[a4paper,10pt]{report}

\usepackage{longtable}
\usepackage{multirow}
\usepackage{array}
\usepackage{rotating}

\begin{document}
\setlength\extrarowheight{3pt}
\begin{longtable}{
c|l|
*{7}{c|}}
\caption{Minimal Example Table}
\label{tab:minimal-example:the-table} \\
 \cline{3-9}
 \multicolumn{1}{c}{} &
 \multicolumn{1}{c|}{} &
 \rotatebox{90}{\textbf{Column 1 }} &
 \rotatebox{90}{\textbf{Column 2 }} &
 \rotatebox{90}{\textbf{Column 3 }} &
 \rotatebox{90}{\textbf{Column 4 }} &
 \rotatebox{90}{\textbf{Long Column 1 }} &
 \rotatebox{90}{\textbf{Column 5 }} &
 \rotatebox{90}{\textbf{Column 6 }}\\
 \cline{1-9}
 \endfirsthead
 \caption[]{(continued)}\\
 \cline{3-9}
 \multicolumn{1}{c}{} &
 \multicolumn{1}{c|}{} &
 \rotatebox{90}{\textbf{Column 1}} &
 \rotatebox{90}{\textbf{Column 2}} &
 \rotatebox{90}{\textbf{Column 3}} &
 \rotatebox{90}{\textbf{Column 4}} &
 \rotatebox{90}{\textbf{Long Column 1}} &
 \rotatebox{90}{\textbf{Column 5}} &
 \rotatebox{90}{\textbf{Column 6}}\\
 \cline{1-9}
 \endhead

 % Page footer
 \cline{1-9}
 \multicolumn{9}{c}{(Continued on next page)} \\
 \endfoot

 % Last page footer
 %\bottomrule
 \endlastfoot

 \multirow{3}{*}{\rotatebox{90}{\textbf{R1}}} &
 {Place holder text....}&
 {}&
 {}&
 {}&
 {}&
 {X}&
 {}&
 {}\\

 \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

 \cline{1-9}

 \multirow{3}{*}{\rotatebox{90}{\textbf{R2}}} &
 {Place holder text....}&
 {}&
 {}&
 {}&
 {}&
 {X}&
 {}&
 {}\\

 \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

  \cline{2-9}

 {}&
 {Place holder text....}&
 {}&
 {X}&
 {X}&
 {}&
 {X}&
 {X}&
 {X}\\

 \cline{1-9}

\end{longtable}

\end{document}
share|improve this answer
    
Thank you for this @DavidCarlisle –  phiri Feb 17 '13 at 18:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.