
我在 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
我在理解程式碼時遇到了困難,所以我運行了它,然後擺弄了一些值。在我看來,用於將邊距垂直框與主文本(或其中的給定行)垂直對齊的值有點做作。我想知道是否有一種方法可以向 TeX 詢問 \vadjust 所在行的行高,並使用它來設定 vbox 的位置。
答案1
不會。
此範例使用支柱使大多數箱子具有已知的高度和深度。您不需要 \strutA 具有明確的高度和深度值 - 只要沒有更大的東西,普通的 \strut 就可以正常工作。詳細地說,來自 \vadjust 的框被添加到垂直列表中,而沒有任何基線跳過。支柱的高度和深度加起來為 \baselineskip,因此,只要沒有比支柱更高或更深的文本,就可以透過調整 \baselineskip 來對齊基線。可以使用其他長度,只要
upwards kern = depth of strut in text + height of vadjust box
大尺寸可能會導致不太理想的分頁符號。
無論行上文字的深度如何,使其更普遍地工作的方法是強制分頁,讓輸出例程收集框(使用 \lastbox),並記錄框的高度和深度。但是,一旦使用輸出例程,您就不必測量高度和深度,因為這些盒子可以組合成一個盒子。