不同文本大小的段落之间的垂直间距相同

不同文本大小的段落之间的垂直间距相同

我经常遇到的情况是,我改变了某些公式类材料的大小(在我的情况下,与伪代码接近但不完全相同),但结果却导致垂直段落间距不一致。以下是一个例子:

\documentclass{memoir}

\begin{document}

{
  \parindent0pt
  \addtolength{\parskip}{\baselineskip}

1. Setup: \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

2. Core steps: \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

3. Wrapping up: \\
{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}
\par}

4. Final steps: \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

}

\end{document}

\par(我在每个“段落”末尾使用的原因在 Gonzalo Medina 的回答中给出关于行距的这个问题

块 2 和 3 之间的间距比其他材料块之间的间距略小。我该如何最轻松地修复此问题?显而易见的替代方法是省略并在每个材料块的末尾\addtolength{\parskip}{\baselineskip}使用,这似乎会导致相同的垂直间距。\\

答案1

\par间距不统一的原因与您在退出该部分之前需要的原因完全相同\footnotesize:段落排版时只有一个基线跳过,即段落结束时生效的基线跳过。

如果省略\par,则在取消\par设置后,会在右括号后面的空行中看到\footnotesize。使用\par,第一行也会使用\footnotesize基线跳过进行排版。

有什么办法吗?使用\paralso 将第一行与其余行分开(并\nobreak避免分页):

\documentclass{memoir}

\begin{document}

{
  \parindent0pt
  \setlength{\parskip}{\baselineskip}

1. Setup:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

2. Core steps:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

3. Wrapping up:\par\nobreak\vspace{-\parskip}
{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}
\par}

4. Final steps:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

}

\end{document}

\vspace{-\parskip}由于设置的原因,这是必要的\parskip

如果没有“引言”怎么办?使用支柱外部组(它是一个不可见的,零宽度的对象,可以确保统一的空间。当发出大小改变命令时,会重新计算支柱,但将其放在组之外(或之前\footnotesize)将确保它是正常大小的支柱:

\documentclass{memoir}

\begin{document}

{
  \parindent0pt
  \setlength{\parskip}{\baselineskip}

\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

\strut{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}
\par}

\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

}

\end{document}

在第一种形式中,相同位置的A\strut可能需要也可能不需要;这取决于正常尺寸行和以下小字体尺寸之间的视觉交互。

请注意,我使用的\setlength是 而不是\addtolength,这样就不会对 的实际值做出假设\parskip。最好为其增加一些灵活性:

\setlength{\parskip}{1\baselineskip plus 2pt minus 1pt}

帮助 TeX 形成一个好的页面;块之间的空间将是相同的:所有块都将以相同的量拉伸或收缩。

不过,我更喜欢插入明确的空格,而不是依赖自动\parskip,也许使用一些宏或环境。

如果没有

\parindent0pt
\setlength{\parskip}{\baselineskip}

你可以做

\documentclass{memoir}

\begin{document}

\noindent 1. Setup:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

\bigskip

\noindent 2. Core steps:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

\bigskip

\noindent 3. Wrapping up:\par\nobreak\noindent
\strut{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}\par}

\bigskip

\noindent 4. Final steps:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}

\end{document}

注意\bigskip获取块之间的间距。我保留了“小型”块的初始支柱,以避免线条彼此太近。(如上所述,如果没有“介绍行”,支柱也是必要的。)

相关内容