Tuesday, March 8, 2011

Rotating a Single Page in Latex

It seems common (and absolutely, positively, completely asinine) that dissertations and theses require that rotated figures appear on rotated pages. I mean that the page (headers, footers, page number, etc) are rotated with the figure so that the whole page is in landscape and not just the figure. Apparently they (whoever "they" are...I suspect a primitive race of subhumans that haven't developed advanced logic...or liberal arts majors) think that in this digital world landscape figures should appear vertically in the electronic document by rotating the whole page so all the text appears vertically. This is dumb because it forces a different formatting of fancy header/footer positions but most importantly because the hard copy version (THE REAL DOCUMENT THAT SOMEONE HOLDS IN THEIR ACTUAL HAND) has to be rotated to read the running header. That is not how a document flows even if the document has to be rotated to read an ELEMENT (table, fig., etc.). The ELEMENT should not dictate the PAGE SETUP. It should be the other way around! Documents with running headers use that information to track the location in the document even if the table is not useful. Hence, the document should not be rotated to continue tracking the location. Anyway, since my tiny brain can't compete with that of the clearly more intelligent liberal arts mind, I have to format MY dissertation in this stupid way!

Whew...breathe Josh...

Problem: My document contains a long table that fits in landscape but not portrait view. The entire page needs to be rotated including headers and footers.

Solution: What solution!? They can shove it up their... Sorry... got excited again. Thanks to Alan Munn we have a reasonably sophisticated answer. I saw some other ones (simpler ones) that worked too, but this seems to be the most correct within the context of programming in Latex. He posted it here. I took what he had and edited it for the UTK Latex Template. This is the exact code for one of my long tables

\documentclass[letterpaper,12pt]{report}

\usepackage[vcentering,dvips]{geometry} % help with margins
\usepackage[absolute]{textpos}
\usepackage{booktabs}
\usepackage{pdflscape}

\geometry{
letterpaper,
left=1.0in,
top=1.5in,
right=1.0in,
bottom=1.5in,
paperheight=11in,
paperwidth=8.5in,
dvips,
pdftex
}

\pagestyle{fancy}
\fancyhead{} % clear all header fields
%\fancyhead[LE,RO]{\slshape \rightmark}
%\fancyhead[LO,RE]{\slshape \leftmark}
\fancyfoot{} % clear all footer fields
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{lscape}{%

\fancyhf{} % clear all header and footer fields
\fancyfoot[LE]{% Left field on EVEN pages
\begin{textblock}{20}(1,5){\rotatebox{90}{}}\end{textblock} % This is for running header info \leftmark or \rightmark
\begin{textblock}{1}(13,10.5){\rotatebox{90}{\thepage}}\end{textblock}}
\fancyfoot[LO] {% Left field on ODD pages
\begin{textblock}{1}(18.75,3.5){\rotatebox{90}{\thepage}}\end{textblock} % this positions the page number
\begin{textblock}{20}(1,13.25){\rotatebox{90}{}}\end{textblock}}% This is for running header info \leftmark or \rightmark

\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}
}

\begin{document}
\newpage
\thispagestyle{lscape}
\begin{landscape}

% EXPERIMENTAL MANTLE LOCATIONS
%===============================================================================================
%\begin{sidewaystable}
\begin{table}
\addtolength{\tabcolsep}{-2.0pt}
\centering % ensure it centers on the page. modify this if centering is not wanted
\caption{Comparison of experimental and computational mantle locations with the complex-lamellar (\text{CL}) and Beltramian (\text{BEL}) models}

\label{Ch:Vortex Sec:MULT Comparison Experimental mantle locations} % this is the label for cross-referencing
%\begin{tabular*}{6.5in}{@{\extracolsep{\fill}} lllllccclcc }
\begin{tabular}{lllllccclcc}
\\
\toprule
& & & & \multicolumn{3}{c}{Experimental} & & \multicolumn{3}{c}{Computational} \\ \cmidrule(){5-7} \cmidrule(){9-11}
$n$ & $\beta_{2,n}^{({\rm CL})}$ & $\beta_{2,n}^{({\rm BEL})}$ & & $\beta_{2,n}^{({\rm EXP})}$ & $\left |\beta_{2,n}^{({\rm CL})}-\beta_{2,n}^{({\rm EXP})} \right |$ & $\left |\beta_{2,n}^{({\rm BEL})}-\beta_{2,n}^{({\rm EXP})} \right |$ & & $\beta_{2,n}^{({\rm CFD})}$ & $\left |\beta_{2,n}^{({\rm CL})}-\beta_{2,n}^{({\rm CFD})} \right |$ & $\left |\beta_{2,n}^{({\rm BEL})}-\beta_{2,n}^{({\rm CFD})} \right | $ \\

\hline
\\[-2.0ex]
0 & 0.408 & 0.236 & & 0.296 & 0.112 & 0.060 & & 0.305 & 0.103 & 0.069 \\

1 & 0.707 & 0.543 & & 0.594 & 0.113 & 0.051 & & 0.385 & 0.322 & 0.158 \\

2 & 0.913 & 0.851 & & 0.803 & 0.110 & 0.048 & & 0.787 & 0.126 & 0.064 \\

\bottomrule
\end{tabular}
\end{table}
%===============================================================================================
\end{landscape}
\end{document}

2 comments:

Unknown said...

Hi!
your example seems to be missing a

\usepackage{fancyhdr}

in the header. Also, are the \rmCL and \rmEXP and so on necessary?

Unknown said...

Hi!

your example seems to be missing a

\usepackage{fancyhdr}

in the preamble. Also, are all the \rmEXP, etc., really necessary?