[Tex/LaTex] Rotating a one-page float for pdf viewing

floatslandscapepdfrotating

I have a few long tables that should be rotated 90 degrees. These tables pretty much need to take up their own page. Rotating the table itself is not a problem, but I would also like to have an attribute set in the appropriate page that made pdf viewers view the page in landscape mode.

I have read this question and this question and there is plenty of information for doing what I want using the landscape environment from pdflscape. Except for one problem: the table produced in these ways is not really a float. The landscape environment is not itself a float, so my tables take up a whole page, and the page that precedes them is full of whitespace.

Is there any way to designate the page containing some float as landscape while letting the float continue to float? Can I make a landscape-float environment? I don't mind if such a thing necessarily has to take up a whole page. If I have to, I'll resort to using sidewaystable from the rotating package and post-processing the pdf on pages that need rotating, but it would be nice to not have to do that every time I need to recompile the final draft.

Best Answer

Since the rotated table will take up a full page anyway (not as complex to position as a partial-page float), you can use afterpage to avoid breaking up the text flow.

\documentclass{article}

\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{lipsum} % for filler text only

\begin{document}
\pagestyle{myheadings} % to show header behavior
\lipsum
\afterpage{%
  \begin{landscape}
    \begin{table}[p]
      \caption{Rotated table caption.}
      \lipsum[1]
    \end{table}
  \end{landscape}
}
\lipsum
\end{document}