假设在一本超过 500 页的巨著中,您经常用图形排版长注释(或其他类似定理的环境)。您希望图形尽可能靠近声明的位置,并且如果图形浮动,它会在逻辑上包含它的注释内浮动,即在“注释⟨注释编号⟩⟨(可能是括号中的注释标题)⟩”和终止注释的 ■ 之间。您还希望浮动和非浮动图形一起在输出中保持与输入中相同的总顺序。我们可以用 固定注释的最后一个图形,[H]
并\FloatBarrier
在其前面放置一个(这会使图形不浮动),或者让最后一个图形浮动,但 halmos 太低:
\documentclass{svmono}% V5.10 from https://resource-cms.springernature.com/springer-cms/rest/v1/content/20566/data/monographs . For testing purposes, I hope, book would do as well.
\usepackage[latin,USenglish]{babel}%%% solely because lipsum is Latin
\usepackage{amssymb}
% \usepackage{float,afterpage}% also see \flushhere from http://tex.stackexchange.com/a/246315
\usepackage{placeins}
\usepackage{lipsum}
\makeatletter
% typesetting halmos:
\newlength\lastSkipOfEndCenter
\newcommand*{\halmosEndingNonProofAfterCenter}{\setlength\lastSkipOfEndCenter{\lastskip}\removelastskip\nopagebreak\par\nopagebreak\vspace{\dimexpr-\baselineskip-\parskip\relax}\nopagebreak{\unskip\nobreak\hfil\penalty50\hskip1em\null\nobreak\hfil\(\blacksquare\)\parfillskip=\z@\finalhyphendemerits=0\endgraf}\vskip\lastSkipOfEndCenter}
\makeatother
\begin{document}
\chapter{Chapter}
\newcommand{\figureheight}{19ex}% With ≤17ex, the halmos appears way too low below the figure. With 18 ex, the halmos appears of the next page. With ≥19 ex, Fig. 3 goes to the next page and the halmos appears way too low.
\lipsum[1]
\begin{figure}[htbp]\centering
\rule{10em}{\figureheight}
\caption{1}
\end{figure}
\lipsum[1]
\FloatBarrier
\begin{note}% Note 1
\lipsum[1]
\begin{figure}[htbp]\centering
\rule{10em}{\figureheight}
\caption{2}
\end{figure}
\lipsum[1]
%\FloatBarrier
\begin{figure}[htbp]\centering%%% We don't wish to simply use [H] for this figure and [h] elsewhere in the chapter because then the Figures might hypohetically come out in the wrong order. Otherwise, and with \FloatBarrier right before, [H] seems to do the job. Using [H] everywhere in the chapter is not an option because outside this environment, LaTeX does a good automatic job of placing the environment, and a manual placement everywhere would have to be reviewed too often.
\rule{10em}{\figureheight}
\caption{3}
\end{figure}%
\FloatBarrier
\halmosEndingNonProofAfterCenter
\end{note}
\lipsum[1]
\begin{figure}[htbp]\centering
\rule{10em}{\figureheight}
\caption{4}
\end{figure}
\lipsum[1]
\end{document}
两种解决方案中的任何一种都可能保留顺序(尽管,正如 Skillmons 在https://tex.stackexchange.com/a/654613,\FloatBarrier
不是万能药);如果我错了,请随时纠正我。有没有办法让注释的最后一幅图(在我们的示例中,图 3)浮动(在我们的示例中,仅在 ■ 上方),以便 halmos 正确地放置在注释的最后一行,无论是文本还是标题(在我们的示例中,图 3)?有没有其他方法可以避免在 halmos 之前分页(进行测试,设置\figureheight
为 18ex)?
答案1
在这里,您的数字在逻辑上是注释的一部分,并且您不希望它们浮动,因此我认为最干净的解决方案可能是[H]
在注释中使用非浮动数字,并\Floatbarrier
在定义中使用\begin{note}
,以便数字始终按顺序设置。
会发生的最“糟糕”的事情是,如果待处理的浮动字被清除,则注释会被迫开始新的一页,并且由于注释中没有浮动字,因此您知道最后的视觉线是来自普通文本还是标题,因此可以适当地放置 halmos qed。