# Place long sidewaystable at the end of document(using endfloat with both sidewaystable/landscape and longtable)

I have the same problem as described in this post: Using endfloat with both sidewaystable and longtable

I would show a long table that goes over two pages and has a landscape orientation at the end of my paper.

To me it seems that - sidewaystable works well with endfloat - longtable works well within landscape - landscape does not work with endfloat - longtable does not work with sidewaystable.

Therefore, I am looking for a way how to combine endfloat, sidewaystable/landscape, and longtable.

Example code:

\documentclass{article}
\usepackage{longtable}
\usepackage[
tablesonly,
notablist,
]{endfloat}
\usepackage{rotating}
\usepackage{pdflscape}

\DeclareDelayedFloatFlavor{sidewaystable}{table}
\DeclareDelayedFloatFlavour*{longtable}{table}

\begin{document}
\section{First section}

\begin{table}
\centering
\caption{1st Table: Standard table}
normal table works with endfloat
\end{table}

\begin{longtable}{l}
\caption{2nd Table: Longtable}\\
longtable works with endfloat
1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\
\end{longtable}

\begin{sidewaystable}
\centering
\caption{3rd Table: Sideways table}
sidewaystable works with endfloat
\end{sidewaystable}

\begin{landscape}
\begin{table}
\centering
\caption{4th Table: Landscape}
Landscape does not work with endfloat\\
\end{table}
\end{landscape}

\begin{sidewaystable}
\centering
\begin{longtable}{l}
\caption{5th Table: sidewaystable and longtable } \\
sidewaystable and longtable do not work together
1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\
\end{longtable}
\end{sidewaystable}

\section{Last section}
\end{document}


The endfloat package works by copying specific environments in their entirety into a ttt file (for tables). So I create a new environment for a sideways longtable and added it to the list.

Note: pdflscape makes sideways text look rightside up, while sidewaystable does not.

\documentclass{article}
\usepackage{longtable}
\usepackage[
tablesonly,
notablist,
]{endfloat}
\usepackage{rotating}
\usepackage{pdflscape}

\newenvironment{longsidewaystable}[1]{\landscape\longtable{#1}}{\endlongtable\endlandscape}

\DeclareDelayedFloatFlavor{sidewaystable}{table}
\DeclareDelayedFloatFlavour*{longtable}{table}
\DeclareDelayedFloatFlavour*{longsidewaystable}{table}

\begin{document}
\section{First section}

\begin{table}
\centering
\caption{1st Table: Standard table}
normal table works with endfloat
\end{table}

\begin{longtable}{l}
\caption{2nd Table: Longtable}\\
longtable works with endfloat
1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\
\end{longtable}

\begin{sidewaystable}
\centering
\caption{3rd Table: Sideways table}
sidewaystable works with endfloat
\end{sidewaystable}

\begin{longsidewaystable}{l}
\caption{4th Table: Longtable}\\
longsidewaystable works with endfloat
1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\  1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\
\end{longsidewaystable}

\section{Last section}
\end{document}