\figure 创建垂直空间

\figure 创建垂直空间

我遇到了以下问题:假设我有三段文本,第二段和第三段之间有一个\figure命令。如果将图形浮动放在其他位置(例如,页面顶部),则第二段和第三段之间(即命令所在的位置)将有一个额外的垂直空间\figure

我不确定这是由 latex 本身引起的,还是由错误的类文件引起的,在这种情况下https://github.com/schnorr/iiufrgs/blob/master/inputs/iiufrgs.cls


编辑:根据与 David Carlisle 的讨论,我想出了以下示例。如果切换到报告,它会起作用(段落之间的间距相等)。事实上,对于 iiufrgs.cls 类,它会中断,但我不知道如何修复它...

%\documentclass[12pt]{report}
\documentclass[ppgc,tese,english]{iiufrgs}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}

\chapter{Introduction}

The includegraphics is not related to the problem (it never adds space). Presumably (since you mention images moving) it is a figure environment. If the figure floats there should be no extra space at the original point. If you think there is (and that space is not just stretching for other reasons) you need to post an example showing the problem.   

The referenced class is just a customisation of the standard report class so you should be able to make an example just using report and using rule{3cm}{5cm} (or whatever size is needed to show the problem) instead of an image, and add that to the question.

\begin{figure}[t!]
\begin{minipage}[b]{0.5\linewidth} % A minipage that covers half the page
\centering
      \rule{3cm}{1cm}
\end{minipage}
\begin{minipage}[b]{0.5\linewidth}
\centering
      \rule{3cm}{1cm}
\end{minipage}
\caption{Some caption.}
\label{fig:zkdisk}
\end{figure}

You're absolutely right, it's in fact an includegraphics command inside a minipage, which is inside a figure environment. I'll try to come up with a minimal working example. Also, the three paragraphs are in the same page; if I remove the figure, the paragraphs become evenly distributed vertically. So I'm positive that the graph is causing the problem.

\end{document}

答案1

有问题的部分iiufrgs.cls是第 142 至 146 行。

\vfuzz=30pt % prevent overfull \vbox while \output is active

% prevent underfull \vbox while \output is active:
\edef\orig@output{\the\output}
\output{\setbox\@cclv\vbox{\unvbox\@cclv\vspace{0pt plus 50pt}}\orig@output}

正如 David Carlisle 在他的评论中指出的那样,第一行不会阻止盒子装满,而是会抑制警告。我猜这个类的作者实际上想写一些类似的东西

% prevent "overfull \vbox while \output is active" warning

然后缩短评论:-)

导致问题的邪恶部分是对 的重新定义\output。我无法详细说明,因为我对它们了解不够多,但我认为删除该行不会导致任何问题。而将其保留在那里会导致您观察到的问题 [可能还有其他问题 :-)]。

相关内容