[Tex/LaTex] How to place a table on a new page with landscape orientation without clearing the current page

floatslandscapepositioning

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!

Best Answer

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}