9

I want to rotate a large table with the caption. However, I can not rotate the caption for the table. Do you have any ideas how to rotate the caption for this layout? Thanks a lot.

Here my text code is below

\rotatebox{90}{
% \caption{Comparison} I cannot use this function like that
\begin{tabular}{l*{6}{c}r}
\hline
Names  & A & B & C & D \\
\hline
\hline
Jobs   & A & B & C & D \\
\hline
Types   & A & B & C & D \\
\hline
\end{tabular}    
}

3 Answers3

12

I tried this:

\documentclass{article}
\usepackage{rotating}

\begin{document}

\begin{sidewaystable}
\centering
\caption{Comparison}
\begin{tabular}{l*{6}{c}r}
\hline
Names  & A & B & C & D \\
\hline
\hline
Jobs   & A & B & C & D \\
\hline
Types   & A & B & C & D \\
\hline
\end{tabular}    

\end{sidewaystable}

\end{document}

enter image description here

it8
  • 1,210
7

While iacopo's answer is the way I'd choose, here is a different solution:

\documentclass[]{scrartcl}

\usepackage{rotating}

\begin{document}

\rotatebox{90}{
\vbox{
    \centering
    \captionaboveof{table}{Comparison}
    \begin{tabular}{l*{6}{c}r}
    \hline
    Names  & A & B & C & D \\
    \hline
    \hline
    Jobs   & A & B & C & D \\
    \hline
    Types   & A & B & C & D \\
    \hline
    \end{tabular}    
}
}
\end{document}

If you don't use a KOMA-class you can use the package caption and replace \captionaboveof with \captionof.

Skillmon
  • 60,462
5

As an alternative option to the previous two, for really large tables I prefer to rotate the whole page instead:

\documentclass{article}

\usepackage{pdflscape}
\usepackage{afterpage}

\begin{document}

\afterpage{%
\clearpage% Flush earlier floats (otherwise order might not be correct)
\begin{landscape}% Landscape page
\begin{table}
\centering
\caption{Comparison}
\begin{tabular}{l*{6}{c}r}
\hline
Names  & A & B & C & D \\
\hline
\hline
Jobs   & A & B & C & D \\
\hline
Types   & A & B & C & D \\
\hline
\end{tabular}    
\end{table}
\end{landscape}
\clearpage% Flush page
}
\end{document}

This has the advantage that the page displays correctly in software and prints like normal with headers and footers in normal orientation. It really depends on your requirements.

enter image description here

(credit to Martin Scharrer for this answer)

zelanix
  • 525