我想将横向模式的表格和图形与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}