3

I got the following situation: I would like to place all tables in my document at the end. I found out that endfloat is usually used for this purpose.

endfloat puts a short reference at the position of each table location, something like "Table 1 about here..." for Table 1, etc. But it can lead to problems. For example I am also using longtable in my document. When I include a longtable somewhere, the positioning/table ordering at the end is always wrong. I am using the following code to accept longtables as floats:

\DeclareDelayedFloatFlavour*{longtable}{table}

The problem is that I got many tables and the longtable is placed at the beginning instead of where it should be, that is rather at the end. So it seems to mess up the order of tables (The labelling is correct though, just the order is affected). Is there any way to fix this in Latex? Or are there any alternatives to endfloat? Maybe people do this manually instead? Thanks for any hints. I cannot make a working example because that would include a ton of tables. edit: someone else had this problem, but it was not solved: http://latex.org/forum/viewtopic.php?t=5554

edit: Here is the requested MWE. The problem only occurs if you also use sidewaystable.

\documentclass[paper=a4,fontsize=10pt, doublespacing, numbers=noenddot]{scrartcl} 
\usepackage[paper=letterpaper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}           
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[nolists, tablesfirst]{endfloat}
\renewcommand{\efloatseparator}{\vspace{\floatsep}}
\DeclareDelayedFloatFlavor{sidewaystable}{table}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{landscape}{table}       
\DeclareDelayedFloatFlavour*{longtable}{table}


\begin{document}

\section{Introduction}

\begin{table}[!htbp]
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\section{Main part}

\begin{table}[!htbp]
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{table}[!htbp]
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{table}[!htbp]
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{sidewaystable}
\centering
\begin{tabular}{|l|}
\hline
A \\
\hline
a \\
\hline
\end{tabular}
\caption{Table 1}
\end{sidewaystable}

\begin{table}[!htbp]
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{longtable}{|c|c|c|c|}
\caption{A simple longtable example}\\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}

\end{document}
  • 1
    You are mixing up landscape and longtable. – Ulrike Fischer Jan 30 '18 at 10:53
  • There is still a landscape in the text. And make a minimal example -- there is no need for "tons of tables". Three should be enough to demonstrate the problem. – Ulrike Fischer Jan 30 '18 at 11:02
  • @X7248724X: Did you try including \DeclareDelayedFloatFlavour*{longtable}{table} in your preamble as described in section '8.2. Environments based on figures and tables' (page 9) of the endfloat package manual? – leandriis Jan 30 '18 at 13:02
  • 1
    As I already wrote: Make an example. Without code one can only guess around. – Ulrike Fischer Jan 30 '18 at 13:03
  • I added the MWE – X7248724X Jan 30 '18 at 15:16
2

Usually one adds a \clearpage before longtable to flush queued floats, so I did. Of course, the \clearpage has to be inside the environment in order to wind up in the ttt file.

The original [h!tbp] options work fine. I just didn't bother to restore them. Also, the ! is pointless since h is attempted first anyway.

\documentclass[paper=a4,fontsize=10pt, doublespacing, numbers=noenddot]{scrartcl} 
\usepackage[paper=letterpaper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}           
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[nolists, tablesfirst]{endfloat}
\renewcommand{\efloatseparator}{\vspace{\floatsep}}
\DeclareDelayedFloatFlavor{sidewaystable}{table}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{landscape}{table}       

\let\normallongtable=\longtable
\renewcommand{\longtable}{\clearpage\normallongtable}

\DeclareDelayedFloatFlavour*{longtable}{table}

\begin{document}

\section{Introduction}

\begin{table}
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\section{Main part}

\begin{table}
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{table}
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{table}
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{sidewaystable}
\centering
\begin{tabular}{|l|}
\hline
A \\
\hline
a \\
\hline
\end{tabular}
\caption{Table 1}
\end{sidewaystable}

\begin{table}
\centering
\caption{Caption XY}
\begin{tabular}{lcr}
1 & 2 & 3 \\
\end{tabular}
\end{table}

\begin{longtable}{|c|c|c|c|}
\caption{A simple longtable example}\\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}

\end{document}
| improve this answer | |

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.