79

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
  • 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. May 25, 2011 at 13:06
  • 1
    Related question: How to wrap text around landscape page. May 25, 2011 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.) May 25, 2011 at 13:21

3 Answers 3

82

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}
14
  • @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, 2014 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. Sep 3, 2014 at 14:02
  • 2
    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! Nov 2, 2016 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 Mar 24, 2017 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, 2017 at 15:35
32

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}
7
  • 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, 2011 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? May 25, 2011 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, 2014 at 9:51
  • It looks likt this: imgur.com/a/eOiAg Sep 21, 2017 at 13:29
  • 1
    @GonzaloMedina It works, but the page has been placed at the end of the document after my bibliography. What to do ? Apr 29, 2018 at 6:57
1
\documentclass{article}

\usepackage{lscape}

\begin{document}

% An extra wide table 
\begin{landscape}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}\hline

Object & Apple & Banana & Stone & Cake & Tree & Flower & House & Door & Car & Plane & Chair \\ \hline 

Quantity in Thousands & 35  &  25  & 23 & 33 & 43  & 52 & 64 & 75 & 86  & 94  & 122  \\ \hline 

\end{tabular}
\end{landscape}
\end{document}

%To this end, everything will be displayed in portrait format.\\
1
  • I have added the caption but its not working May 2, 2022 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .