# How to rotate landscape table page in PDF?

Currently I am using

\usepackage{rotating}

\begin{sidewaystable}
\begin{tabular}...\end{tabular}
\end{sidewaystable}


to typeset landscape tables, which works great.

But I want to rotate that page in the resulting pdf (generated by pdflatex) for more convenient screen reading.

I found the landscape environment which is also mentioned in another question. I tried it like this:

\usepackage{pdflscape}

\begin{landscape}
\begin{table}
\begin{tabular}...\end{tabular}
\end{table}
\end{landscape}


This kind of works, except the original table does not fit anymore on the page, i.e. sidewaystable makes better use of the available space.

Thus my question: Is it somehow possible to just use sidewaystable and instruct pdflatex to rotate it?

Or instruct pdflatex to mark it as rotated such that the PDF viewer knows what to do?

• The question is hard to answer without a concrete example of a table that fits with sidewaystable but not with pdflscape. – frabjous Oct 8 '10 at 21:37
• Hi, I'm new here and I'm spanish, so please excuse my english. I'm using landscape, but i can't quit the blank page before all \begin{landscape}, instead of that, landscape is great, have you resolved that problem? I don't know if I should ask this ina new question =S – DaniTeba Jul 18 '12 at 17:45
• @Daniteba, no, I did not resolve the problem. Since the question is not really about blank page issues just go ahead and ask a new question - of course, you can link this question because it is related. – maxschlepzig Jul 22 '12 at 8:29
• This might work for you: You can just temporarily rotate the view some pdf viewers (command+R in MAC OSX's preview, or ctrl+shift+plus/minus in acrobat). – user33430 Jul 9 '13 at 17:30
• What I read from the question is that the OP want the viewer to recognize this rotation automatically, rather than a manual/temporary rotation. – Werner Jul 9 '13 at 17:56

To make the table fit your landscape, put this in your preamble:

\usepackage{geometry}
\usepackage{pdflscape}


And for your landscape page, do this:

\newgeometry{margin=1cm} % modify this if you need even more space
\begin{landscape}

\end{landscape}
\restoregeometry


If you are working in a document that makes use of fancyhdr, you might want to put \thispagestyle{empty} on your landscape page so that you can make use of the space normally occupied by the header/footer. (and it looks cleaner in my opinion)

• While this flips the page to landscape, it doesn't actually change the page layout if you view if via showframe. Becuase of that you can't use things like \resizebox{\textwidth}{!}{} because it shrinks it to the portrait text width. It sticks the page numbers vertically on the left. Ideally the page numbering and footers would be on the bottom of the landscape page. Is there a way to do that? – Lloyd Christmas Sep 28 '18 at 14:28

I found it to be hard to accommodate both good landscape when viewing on the computer screen, as well as printing everything "right". My problem was with PStricks figure, which looked fine in the sidewaysfig, but was "clipped" when I rotate the page.

To "fix" the issue I have used the good old:

\vspace{-1cm}
\hspace{-1cm}


I know, this is "bad" but hey it worked for me =) I does mess with your head since in a rotated-sidewaysfig page vspace controls horizontal position and hspace - vertical one.

You can use sidewaystable and rotate these pages using the following script:

\batchmode
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{tikz}
\usepackage{xstring}

\newcommand{\ifassoc}[4]{%
\edef\dotheloop{%
\noexpand\foreach \noexpand\a/\noexpand\b in {#2} {%
\noexpand\IfEq{\noexpand\a}{#1}{%
\noexpand\gdef\noexpand\memberresult{true}%
\noexpand\xdef\noexpand\assocresult{\noexpand\b}%
\noexpand\breakforeach%
}{}%
}%
}%
\xdef\assocresult{}%
\xdef\memberresult{false}
\dotheloop%
\IfEq{\memberresult}{true}{#3}{#4}%
}%

% Theses file
\def\malfile{main.pdf}
\pdfximage{\malfile}

\begin{document}
\newcount\malcount \malcount=0 % This is a page counter...
\newbox\malbox % This is a virtual box...

\loop % Let's test all the pages one by one...

% The pages that you would like to rotate (Landscape)
\ifassoc{\the\malcount}{107,108,109,110,112,113,114}{
%Landscape
\includepdf[pages={\the\malcount}, fitpaper, angle=270]{\malfile}
}{
% Portrait
\includepdf[pages={\the\malcount}, fitpaper, angle=0]{\malfile}
}

\ifnum\malcount<\pdflastximagepages\repeat

\end{document}