Tug.org 上的 \vadjust 示例

Tug.org 上的 \vadjust 示例

我在 Tug.org 上阅读了一些有关 TeX 基本函数的内容。我偶然发现了这个 \vadjust 的示例用法。

1. \def\strutA#1#2{\vrule height#1 depth#2 width0pt}
2. \def\ta#1%
3. {%
4.      \strutA{8.5pt}{3.5pt}%
5.      \vadjust
6.      {
7.           \vbox to 0pt
8.           {
9.                \kern-1\baselineskip
10.                \moveleft0.5in\hbox to 0.5in
11.                {
12.                     \strutA{8.5pt}{3.5pt}%
13.                     \hfil#1\kern1em
14.                }
15.                \vss
16.           }%
17.      }%
18. }
19. \hsize=4.75in
20. There are cries, sobs, confusion among the people, and at that moment
21. the cardinal himself, the Grand Inquisitor, passes by the cathedral.
22. He is an old man, almost ninety, tall and erect,\ta{100} with a
23. withered face and sunken eyes, in which there is still a gleam of
24. light. He is not dressed in his brilliant cardinal's robes, as he was
25. the day before, when he was burning the enemies of the Roman
26. Church~\char144 \kern2em\hfill Fyodor Dostoyevsky, {\it The Brothers
27. Karamazov}\par 

我无法理解代码,所以我运行了它,然后调整了一些值。在我看来,用于将边距 vbox 与主文本(或其中的给定行)垂直对齐的值有点做作。我想知道是否有办法让 TeX 获得 \vadjust 所在行的行高,并使用它来设置 vbox 的位置。

答案1

不是,线的高度和深度取决于线上的内容,而线上的内容是在 \vadjust 素材排版后决定的。

该示例使用支柱使大多数情况下具有已知的高度和深度。您不需要具有明确高度和深度值的 \strutA —— 普通的 \strut 就可以正常工作,只要线上没有比它更大的东西。详细地说,来自 \vadjust 的框被添加到垂直列表中,没有任何基线跳过。支柱的高度和深度加起来等于 \baselineskip,因此,只要没有比支柱更高或更深的文本,就可以通过 \baselineskip 向上调整字距来对齐基线。可以使用其他长度,只要

upwards kern = depth of strut in text + height of vadjust box

尺寸过大可能会导致分页效果不太理想。

无论行内文本的深度如何,让它更普遍地发挥作用的方法是强制分页,让输出例程收集框(使用 \lastbox),并记录框的高度和深度。但是一旦您使用输出例程,您就不必测量高度和深度,因为这些框可以组合成一个框。

相关内容