4

I have a document (article class) in which sections of text are interrupted by sideways tables. In order to be able to view the document properly I am using

\newpage
\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}

and

\newpage
\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}

to turn the pages in the viewer.

The turning works well however I cannot use \newpage after a text section and then rotate using pdfpageattr without inserting text inbetween. If I do that all the tables disappear. Here an example of this:

\newpage
text I dont Want But Need To But There For Tables to show up!
%************************************************************
% FS Tables
%************************************************************

\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}

%%% Table I: Loan Amount
\begin{sidewaystable}
       \centering
       \caption{Loan Amount - Closest-Saathi to Client km}
       \input{reg_fs_e_sewaloan_amount_iv1}
\end{sidewaystable}

I would usually include a minimalist document here but in this case it seems rather complicated because I am importing tables etc. Perhaps we can answer the question this way.

3
  • Does \clearpage after sidewaystable helps? Sep 13 '12 at 14:29
  • It does. Thank you! What's the logic behind that?
    – Max
    Sep 13 '12 at 14:35
  • Have a look at the pdflscape package.
    – egreg
    Sep 13 '12 at 14:48
4

The problem is that sidewaystable can float. Since you probably want to allow it to continue to float, here is an outline of how to deal with it, using the fact that fancyhdr can treat float-only pages differently.

\documentclass{article}
\usepackage{rotating}
\usepackage{lipsum} % For generating dummy text
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[C]{\thepage
    \iffloatpage{\global\pdfpageattr{/Rotate 90}}%
    {\global\pdfpageattr{/Rotate 0}}}
\begin{document}
  \lipsum[1-3]

  \begin{sidewaystable}
    \caption{here is the caption}
    here is a fake table
  \end{sidewaystable}

\lipsum[4-30]
\end{document}

Notes:

  1. This assumes that \pdfpageattr is normally empty. It would be easy to change the code in order to maintain a constant token list in \pdfpageattr. The way you redefined \pdfpageattr in the question, by appending to it each time, means that \pdfpageattr gets longer with each rotation;
  2. This will cause all full-page floats to be rotated, so you'll have to do something more sophisticated if you have a mixture of rotated and non-rotated full-page floats.
0
3

Environment sidewaystable is similar to table a floating environment. LaTeX stores these floating objects some time until it finds a place where it can put them. \clearpage forces the pending floating objects to be put on the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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