带有 endfloat 的 longtable

带有 endfloat 的 longtable

我遇到以下情况:我想将文档中的所有表格放在末尾。我发现endfloat通常用于此目的。

endfloat在每个表格位置的位置放置一个简短的引用,例如“表格 1 关于这里...”等。但这可能会导致问题。例如,我也在longtable我的文档中使用。当我在某处包含一个 longtable 时,末尾的定位/表格顺序总是错误的。我使用以下代码将 longtable 接受为浮点数:

\DeclareDelayedFloatFlavour*{longtable}{table}

问题是我有很多表格,而长表放在开头而不是它应该在的位置,而是在结尾。所以它似乎弄乱了表格的顺序(虽然标签是正确的,只是顺序受到影响)。有没有办法在 Latex 中解决这个问题?或者有没有其他替代方案endfloat?也许人们会手动完成?谢谢任何提示。我无法制作一个可行的示例,因为那将包含大量表格。编辑:其他人也遇到了这个问题,但没有解决: http://latex.org/forum/viewtopic.php?t=5554

编辑:这是请求的 MWE。仅当您还使用 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

通常,人们会添加一个\clearpagebeforelongtable来刷新排队的浮点数,所以我这样做了。当然,必须\clearpage里面环境以便结束在ttt文件中。

原始[h!tbp]选项工作正常。我只是懒得恢复它们。另外,这!是没有意义的,因为h无论如何都会先尝试。

\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}

相关内容