67

I'd like to place a table on a new page with landscape orientation. To do so, I use

\usepackage{pdflscape}
...
\pagestyle{empty}
\begin{landscape}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{llll}
...
\end{tabular}
\end{center}
\end{table} 
\end{landscape}
\pagestyle{plain}

However, this clears the current page, places the table on the next page with landscape orientation, and restarts typesetting in a new page with portrait orientation.

Question I'd like to place the table on a new page (as it is currently done) but to avoid to clear the current page. Is that possible?

Thanks!

  • 3
    Do not use center inside table but \centering instead. DO NOT USE FORMATTING environments AROUND floating environments like table or figure. EVERYTHING for it must be placed inside the floating environment. – Martin Scharrer May 25 '11 at 13:06
  • 1
    Related question: How to wrap text around landscape page. – Martin Scharrer May 25 '11 at 13:09
  • @Macro: I adapted my linked answer to this specific case. The my answer below. (Also note that you need to write @username not #username, but this might just be a typo.) – Martin Scharrer May 25 '11 at 13:21
66

Similar like my answer to How to wrap text around landscape page I would use \afterpage from the afterpage package to place the table at the next page of where it was declared. Here a non-floating replacement of table is used instead, e.g. the \captionof{table}{...} is used (capt-of or caption) package.

One issue are potential other tables which should be flushed beforehand. Otherwise the non-floating table replacement might appear earlier.

\documentclass{article}

\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package

\usepackage{lipsum}% dummy text
\begin{document}
\lipsum % Text before
\afterpage{%
    \clearpage% Flush earlier floats (otherwise order might not be correct)
    \thispagestyle{empty}% empty page style (?)
    \begin{landscape}% Landscape page
        \centering % Center table
        \begin{tabular}{llll}
            A & B & C & D \\
        \end{tabular}
        \captionof{table}{Table caption}% Add 'table' caption
    \end{landscape}
    \clearpage% Flush page
}
\lipsum % Text after
\end{document}
  • @MartinScharrer, what do you mean by "flushing potential tables beforehand"? I guess, in my case your solution doesn't work exactly because of that, but I am not expert enough to be sure about... – Py-ser Sep 3 '14 at 6:45
  • @Py-ser: I mean to flush the float buffer, e.g. place all processed but not yet placed tables or figures. You can force that using \clearpage. However, this creates a page break, so \afterpage{\clearpage} would be better. This forces the placement of any yet unplaced floats after the next normal page break. Not that this will lead to top placement (like the [t] optional argument of {table} would do) or a full float page (like [p]) if there are more or larger floats to be placed. As you can see, my code above uses \clearpage as the first command in \afterpage to do exactly that. – Martin Scharrer Sep 3 '14 at 14:02
  • 1
    So using this: \newgeometry{left=0.1cm,right=0.1cm,bottom=0.1cm,top=0.1cm} just before \begin{landscape} and \restoregeometry just after \end{landscape} worked! – travelingbones Nov 2 '16 at 18:12
  • 1
    @LShaver this worked: \usepackage[pass]{geometry} \newgeometry{left=3cm,right=3cm,bottom=3cm,top=3cm} %% set the margins \begin{landscape}% Landscape page \centering \begin{table} ... \end{table} \end{landscape} \restoregeometry %% put margins back to default – travelingbones Mar 24 '17 at 20:55
  • 1
    @travelingbones that worked, with two caveats: the [pass] option threw an error, and wasn't necessary. Also, left/right and top/bottom follow the rest of the document, not the landscape orientation. – LShaver May 29 '17 at 15:35
23

You could use the sidewaystable environment from the rotating package; a little example:

\documentclass{article}
\usepackage{rotating}

\begin{document}
text text text text
\begin{sidewaystable}
  \centering
  \rule{3cm}{4cm}% to simulate a table
  \caption{A rotated table}
  \label{tab:test}
\end{sidewaystable}
text text text
\end{document}
  • I have tried it but it produces the same result as with pdflscape. However, afterpage makes it work, as suggested in the link provided by Martin Scharrer. Thank you very much for your answer! – Marco May 25 '11 at 13:14
  • 1
    @Marco: sidewaystable and sidewaysfigure let the text flow. I'd be really interested in seeing an example in which the text doesn't flow. Could you please provide such a minimal example? – Gonzalo Medina May 25 '11 at 18:07
  • @GonzaloMedina, how can I let the table take one whole page and centered in that page, within the sidewaystable context? – Py-ser Sep 4 '14 at 9:51
  • It looks likt this: imgur.com/a/eOiAg – Martin Thoma Sep 21 '17 at 13:29
  • @GonzaloMedina It works, but the page has been placed at the end of the document after my bibliography. What to do ? – Duchamp Gérard H. E. Apr 29 '18 at 6:57

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.