我最初的回答尝试是错误的

我最初的回答尝试是错误的

我正在开发一个允许包含多个子图的软件包,这些子图可以跨多页显示。到目前为止,我的人物系列包在大多数情况下都能正常工作,但有时我会收到“Float(s) lost”错误,我不明白为什么。整个情况相当复杂,而我的 LaTeX 水平还不够好,无法理解。

到目前为止,它们仅出现在双列文档(IEEEtran 和 sig-alternate)中。在我的包中,我用它\afterpage来“模拟”多页浮动。在双列文档中,我在图形系列之后切换到\onecolumn并返回\twocolumns\afterpage如果我在第一列中,我也使用两个嵌套来到达第二列。

可以使用以下 MWE 重现该错误,其中我使用 lorem ipsums 作为填充文本并调整字母大小而不是图形。

\documentclass{IEEEtran}%
\RequirePackage{lipsum}%
\RequirePackage{graphicx}%
\RequirePackage{figureSeries}%
%
\begin{document}%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.12\textheight}{o}%
\caption{Interdum primis ultrices augue.}%
\end{figure*}
%
\lipsum[1-7]%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.15\textheight}{j}%
\caption{Inceptos eget varius curae;.}%
\end{figure*}%
%
\figureSeriesFloat{Urna massa sollicitudin curae;.}{%
\figureSeriesRow{%
\figureSeriesElement{Vulputate exercitation faucibus fusce.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
\figureSeriesRow{%
\figureSeriesElement{Nec per sodales aliquyam.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.13\textheight}{o}%
\caption{Sodales condimentum nascetur tempus?}%
\end{figure}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.15\textheight}{j}%
\caption{Soluta autem nascetur litora.}%
\end{figure}%
%
\lipsum[14]%
%
\end{document}%

我的人物系列包中有以下代码,你可以在GitHub 存储库。那里的文档 PDF 还包括多个示例和一个讨论,说明为什么拥有这样的包figureSeries会很有用。

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{figureSeries}
    [2015/02/13 v0.9.2 Provides a floating, figure*-like construct that can break over multiple pages]
\newif\if@figSer@captionCompatibilityFalse%
\@figSer@captionCompatibilityFalsefalse%
\ifx\spnewtheorem\@undefined%
\else%
\@figSer@captionCompatibilityFalsetrue%
\fi%
\if@figSer@captionCompatibilityFalse%
\RequirePackage[compatibility=false]{caption}%
\else%
\RequirePackage{caption}%
\fi%
\RequirePackage{subcaption}%
\DeclareCaptionSubType*[arabic]{figure}%
\RequirePackage{afterpage}%
\long\gdef\figureSeriesElement#1#2{%
\strut\hfill\strut%
\edef\@captype{figure}%
\subcaptionbox{#1}{#2}%
\strut\hfill\strut%%
}%
\long\gdef\figureSeriesRow#1{%
\begin{center}%
\ifx\@figSer@delayedCaption\@empty%
\vspace\abovecaptionskip%
\strut#1\strut%
\else%
\parbox[b]{\textwidth}{%
\@figSer@delayedCaption%
\xdef\@figSer@delayedCaption{}%
\vspace\abovecaptionskip%
\strut#1\strut%
}%
\fi%
\end{center}%
}%
\long\def\figureSeriesHere#1#2{%
\@figSer@detectColumns%
\if@figSer@isTwoColumns%
\@figSer@hereTwoCol{#1}{#2}%
\else%
\@figSer@hereOneCol{#1}{#2}%
\fi%
}%
\long\gdef\figureSeriesFloat#1#2{%
\@figSer@detectColumns%
\if@figSer@isTwoColumns%
\@figSer@floatTwoCol{#1}{#2}%
\else%
\@figSer@floatOneCol{#1}{#2}%
\fi%
}%
\newif\if@figSer@isTwoColumns%
\@figSer@isTwoColumnsfalse%%
\def\@figSer@detectColumns{%
\@figSer@isTwoColumnsfalse%
\ifx\multicols\@undefined%
\else%
\ifnum\col@number>\@ne%
\@figSer@isTwoColumnstrue%
\fi%
\fi%
\if@twocolumn%
\@figSer@isTwoColumnstrue%
\fi%
}%
\edef\@figSer@delayedCaption{}%
\long\def\@figSer@hereOneCol#1#2{%
\def\@figSer@delayedCaption{%
\noindent\parbox{\textwidth}{%
\captionof{figure}{#1}%
\global\advance\c@figure by 0%
}%
\par}%
\begin{center}%
#2%
\end{center}%
\medskip%
}%
\long\def\@figSer@floatOneCol#1#2{%
\afterpage{\@figSer@hereOneCol{#1}{#2}}%
}%
\xdef\@figSer@floatingBody{}%
\gdef\@figSer@afterPage{%
\@figSer@longTwoColumnMain[\@figSer@floatingBody]%
\xdef\@figSer@floatingBody{}%
}%
\long\def\@figSer@floatTwoCol#1#2{%
\ifx\@figSer@floatingBody\@empty%
\gdef\@figSer@floatingBody{\@figSer@hereOneCol{#1}{#2}}%
\if@firstcolumn%
\afterpage{\afterpage{\@figSer@afterPage}}%
\else%
\afterpage{\@figSer@afterPage}%
\fi%
\else%
\g@addto@macro{\@figSer@floatingBody}{\@figSer@hereOneCol{#1}{#2}}%
\fi%
}%
\let\@figSer@hereTwoCol\@figSer@floatTwoCol%
\newsavebox\@figSer@box%
\def\@figSer@breakBodyRepeat@Orig{%
\@figSer@longTwoColumn[{\@twocolumnfalse%
\ifdim\ht\@figSer@box>1.00\textheight%
\begingroup%
\vbadness10000%
\setbox0\vsplit\@figSer@box to 1.00\textheight%
\setbox1\vbox{\unvbox\@figSer@box}%
\global\setbox\@figSer@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0%
}%
\ht2=0.9\textheight%
\box2%
\endgroup%
\else%
\ifdim\ht\@figSer@box>0.84\textheight%
\global\let\@figSer@breakBodyRepeat\clearpage%
\else%
\global\let\@figSer@breakBodyRepeat\relax%
\fi%
\unvbox\@figSer@box%
\vspace{15pt plus 15pt}%
\fi%
}]%
\@figSer@breakBodyRepeat%
}%
\long\def\@figSer@longTwoColumnMain[#1]{%
\let\@figSer@breakBodyRepeat\@figSer@breakBodyRepeat@Orig%
\begingroup%
\let\@figSer@longTwoColumn\twocolumn%
\@figSer@longTwoColumn[{\@twocolumnfalse%
\global\setbox\@figSer@box\vbox{#1}%
\ifdim\ht\@figSer@box>\textheight%
\begingroup%
\vbadness10000%
\setbox0\vsplit\@figSer@box to 1.00\textheight%
\setbox1\vbox{\unvbox\@figSer@box}%
\global\setbox\@figSer@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0%
}%
\ht2=0.9\textheight%
\box2%
\endgroup%
\else%
\ifdim\ht\@figSer@box>0.87\textheight%
\global\let\@figSer@breakBodyRepeat\clearpage%
\else%
\global\let\@figSer@breakBodyRepeat\relax%
\fi%
\unvbox\@figSer@box%
\fi%
}]%
\@figSer@breakBodyRepeat%
\endgroup%
}%
\endinput

如果有人能帮助我解决这个问题,我将非常感激。

答案1

我没有尝试跟踪您的代码在做什么,但 figureseries 浮点代码正在丢失此时待处理的现有双列浮点。如果您用 清除它们,则\clearpage不会丢失任何浮点。

\documentclass{IEEEtran}%
\RequirePackage{lipsum}%
\RequirePackage{graphicx}%
\RequirePackage{figureSeries}%
%
\begin{document}%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.12\textheight}{o}%
\caption{Interdum primis ultrices augue.}%
\end{figure*}
%
\lipsum[1-7]%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.15\textheight}{j}%
\caption{Inceptos eget varius curae;.}%
\end{figure*}%
%
\clearpage
\figureSeriesFloat{Urna massa sollicitudin curae;.}{%
\figureSeriesRow{%
\figureSeriesElement{Vulputate exercitation faucibus fusce.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
\figureSeriesRow{%
\figureSeriesElement{Nec per sodales aliquyam.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.13\textheight}{o}%
\caption{Sodales condimentum nascetur tempus?}%
\end{figure}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.15\textheight}{j}%
\caption{Soluta autem nascetur litora.}%
\end{figure}%
%
\lipsum[14]%
%
\end{document}%

答案2

我最初的回答尝试是错误的

它解决了我的最小示例和其他一些情况下的问题,但现在错误出现在以前没有出现过的文档中。:-(

我现在使用软件包placeinseverypage来做另一个 hack:当我开始一个浮动图形系列时,我发出一个,这似乎可以消除编译器错误。这不是一个好的解决方案,但至少我上面的错误示例可以解决这个问题。我用这个“修复”\AddThispageHook{\FloatBarrier}更新了我的包figureSeries发布 0.9.3

事实证明,罪魁祸首是\if@firstcolumn我用来判断是否需要执行\afterpage一次或两次的。然而,\if@firstcolumn这并不可靠。经过几次尝试修复我的包后,我发现可爱包裹strip环境可以完成我需要的布局。但是,现在我面临另一个问题:`strip` 环境在空文档中不起作用/与 `\afterpage` 交互

相关内容