![横向模式下的表格和图形带有 endfloat](https://linux22.com/image/435583/%E6%A8%AA%E5%90%91%E6%A8%A1%E5%BC%8F%E4%B8%8B%E7%9A%84%E8%A1%A8%E6%A0%BC%E5%92%8C%E5%9B%BE%E5%BD%A2%E5%B8%A6%E6%9C%89%20endfloat.png)
我想将横向模式的表格和图形与endfloat
包结合起来。
问题是,据我所知,我只能将景观环境分配给 atable
或figure
via \DeclareDelayedFloatFlavour
。
因此,假设我将 endfloat 配置为首先显示图形,并将横向分配给表格,即\DeclareDelayedFloatFlavour{landscape}{table}
。然而,在文档中,横向模式下的表格位于横向模式下的图形之前。那么它将首先显示表格。
我怀疑有一个简单的解决方案,但我找不到。MWE 附在下面。
\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{pdflscape}
\usepackage[figuresfirst,nomarkers,nolists]{endfloat}
\DeclareDelayedFloatFlavour{landscape}{table}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\caption{This should be second}
\begin{tabular}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{table}
\end{landscape}
\begin{landscape}
\begin{figure}[h!]
\centering
\rule{1cm}{1cm}
\caption{This should be first}
\end{figure}
\end{landscape}
\end{document}
答案1
一个解决方案可能是为横向的表格和图形定义新的环境。
\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{pdflscape}
\usepackage[figuresfirst,nomarkers,nolists]{endfloat}
% new environment for landscape tables
\newenvironment{ltable}
{\begin{landscape}}
{\end{landscape}}
% new environment for landscape figures
\newenvironment{lfigure}
{\begin{landscape}}
{\end{landscape}}
% assignment
\DeclareDelayedFloatFlavour{ltable}{table}
\DeclareDelayedFloatFlavour{lfigure}{figure}
\begin{document}
\begin{ltable}
\begin{table}
\centering
\caption{This should be second}
\begin{tabular}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{table}
\end{ltable}
\begin{lfigure}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This should be first}
\end{figure}
\end{lfigure}
\end{document}