为什么某些段落的垂直(行)间距会挤压?

为什么某些段落的垂直(行)间距会挤压?

我正在写一系列笔记,我开始发现某些段落的垂直(行)间距与其他段落相比大幅减小。我附上了一张照片来描述我的意思。紧随其后的文本Exercise 6.12和星星比环境之后的段落中的文本更加拥挤verbatim。有人知道为什么,我该如何防止这种情况发生?请注意,该exercise命令只接收一个数字、章节标识符和要使用的文本。

在此处输入图片描述

\newcommand{\exercise}[3]
{\noindent\textbf{Exercise {~\ref{#2}}.\theexcounter.} (\repeatstar{#1}) \\
{#3} \stepcounter{excounter}}
...
\exercise{3}{chapter-advanced-oop}{This exercise involves the interpreter we wrote in the chapter.}
Data structures are a core and fundamental feature of programming languages. A language without them, or at least one to build others on top of, suffers severely in terms of usability. We will implement a \textit{cons}-like data structure for our interpreter. In functional programming, we often use three operations to act on data structures akin to linked lists: \textit{cons}, \textit{first}, and \textit{rest}, to construct a new list, retrieve the first element, and retrieve the rest of the list respectively. We can inductively define a cons list as follows:
\begin{footnotesize}
\begin{verbatim}
A ConsList is one of:
 - new ConsList()
 - new ConsList(x, ConsList)
\end{verbatim}
\end{footnotesize}
Implement the cons data structure into your interpreter. This should involve designing the \ttt{ConsNode} class that conforms to the aforementioned data definition. Moreover, you will need to update \ttt{PrimNode} to account for the \ttt{first} and \ttt{rest} primitive operations, as well as an \ttt{empty?} predicate, which returns whether or not the cons list is empty. Finally, update the \ttt{Lvalue} class to print a stringified representation of a \ttt{ConsNode}, which amounts to printing each element, separated by spaces, inside of brackets, e.g., \ttt{[$l_0, l_1, ..., l_{n-1}]$}.

答案1

(La)TeX 在段落结束时“冻结”段落的几个特征。其中之一就是基线分离。

在 中开始新的文本块时,您尚未结束上一个段落footnotesize,并且段落以较小的尺寸结束。因此整个段落的基线距离适合该字体大小。

正如@DavidCarlisle 所指出的,footnotesize这不是一个环境;但是,它的行为就像环境一样,并且由于环境通常以内置的段落分隔符结束,较小的基线也结束于此。

您可以通过修改来挽救这个示例,以使用\par{\footnotesize \begin{verbatim} ... \end{verbatim}}

相关内容