TeX - LaTeX Asked on January 1, 2021
I was on Tug.org reading about some of TeX’s primitives. I came across this example usage of vadjust.
1. defstrutA#1#2{vrule height#1 depth#2 width0pt}
2. defta#1%
3. {%
4. strutA{8.5pt}{3.5pt}%
5. vadjust
6. {
7. vbox to 0pt
8. {
9. kern-1baselineskip
10. moveleft0.5inhbox to 0.5in
11. {
12. strutA{8.5pt}{3.5pt}%
13. hfil#1kern1em
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 kern2emhfill Fyodor Dostoyevsky, {it The Brothers
27. Karamazov}par
I was having trouble understanding the code, so I ran it and then fiddled around with some of the values. It seems to me that the values used to align the margin vbox vertically with the main text (or a given line in it), are a bit contrived. I’m wondering if there’s a way to ask TeX for the line height of the line that the vadjust occurs in and use that to set the position of the vbox.
No. The height and depth of the line depends on what is on the line, and what is on the line is decided after the vadjust material is typeset.
The example uses a strut to make most cases have known height and depth. You don't need strutA with explicit values for height and depth -- an ordinary strut would work fine, as long as there is nothing bigger on the line. To elaborate, the box from vadjust is added to the vertical list without any baseline skip. The height and depth of the struts add up to baselineskip so, as long as there is no text taller or deeper than the strut, one can align the baselines by kerning up by baselineskip. Other lengths could be used, as long as
upwards kern = depth of strut in text + height of vadjust box
Large dimensions could give less ideal page breaks.
The way to make it work more generally, no matter the depth of the text on the line, is to force a page break, have the output routine collect the boxes (using lastbox), and record the height and depth of the boxes. But once you use the output routine, you wouldn't have to measure heights and depths because the boxes can be combined into one box.
Answered by Donald Arseneau on January 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP