4

Consider the following examples:

example1.tex

%\input vadjust_hook
\def\marginalstar{\strut\vadjust{\kern-\dp\strutbox\specialstar}}
\def\specialstar{\vtop to \dp\strutbox{
    \baselineskip\dp\strutbox
    \vss\llap{* }\null}}
\input template

The output of example1.tex

\hbox(6.94444+1.94444)x57.81621, glue set 1.173 []
\penalty 150
\glue(\baselineskip) 1.55556
\hbox(8.5+3.5)x57.81621, glue set 0.10767 []
\kern -3.5
\vbox(0.0+3.5)x0.0, glue set - 7.5fil []
\penalty 150
\glue(\baselineskip) 1.55556
\hbox(6.94444+1.94444)x57.81621, glue set 11.09389fil []

example1

example2.tex

%\input vadjust_hook
\def\marginalstar{\strut\vadjust{\vskip-\dp\strutbox\specialstar}}
\def\specialstar{\vtop to 1pt{
    \baselineskip=1pt
    \vss\llap{* }\null}}
\input template

The output of example2.tex

\hbox(6.94444+1.94444)x57.81621, glue set 1.173 []
\penalty 150
\glue(\baselineskip) 1.55556
\hbox(8.5+3.5)x57.81621, glue set 0.10767 []
\glue -3.5
\vbox(0.0+1.0)x0.0, glue set - 7.5fil []
\penalty 150
\glue(\baselineskip) 1.55556
\hbox(6.94444+1.94444)x57.81621, glue set 11.09389fil []

example2

Here are the files to \input:

vadjust_hook.tex

\let\oldvadjust\vadjust
\def\vadjust{%
  \begingroup\def\par{\endgraf\showboxdepth0\showboxbreadth\maxdimen\showlists\endgroup}%
  \oldvadjust
}

template.tex

\nopagenumbers
\hsize0.8in
\noindent
Quick brown fox eats a
\marginalstar
fat big
mouse.
\bye

By comparing the traces of the examples we can see that depth of vbox does not influence the calculations of interline glue. Why? And if interline glue is the same, why the resulting documents differ?

  • 2
    The TeXbook, page 105, second doubly dangerous paragraph after exercise 14.27: “Inserted vertical material does not influence the interline glue.” – egreg Sep 6 '15 at 23:12
7

You can create vertical material from \vadjust{parameter} by macro expansion in its parameter. But this is processed immediately in horizontal mode and macro programmer is unable to measure the depth of the previous line because such line doesn't exist at this time. And the result of \vadjust is a fixed vertical list which cannot be modified later after lines of paragraph are known. (There is one exception: you can do re-box the whole paragraph after \par using \lastbox, \unskip, \unpenalty but there are many limitations for such processing, unfortunately.)

There is one assurance when \vadjust is used: if the resulting vertical list has zero height plus depth then interline grid in the paragraph will be kept, because interline glue is calculated from previous line to next line, no matter if there is inserted vertical material from \vadjust or not.

Your question "why" can be answerwed: because of the assurance mentioned above.

The problem is that the relative position of such \vadjust material (with zero height plus depth) to the line grid varies dependent on the depth of the previous line. If you need to fix it to the line grid then you must use \strut in the paragraph text and you must be betting that this \strut does not break the interline glue.

In your first example: the \vadjust material has zero height plus depth, exactly \kern-\dp\strutbox \vtop to\dp\strutbox{...\vss\null} but in your second example the height plus depth of the material is -\dp\strutbox+1pt and it is typically negative. This is the reason why your examples differ.

  • Everything is clear now. I would add the following after the third paragraph on page 78 of TeXbook: "Vertical list is always increased by natural height-plus-depth of \vadjust box, in addition to what is described here." – Igor Liferenko Sep 8 '15 at 10:46
  • Moreover, I think that \vadjust was devised not with marginal notes in mind in the first place, i.e., it is simply inappropriate for this task. (\strut is not general enough to be considered as a universal solution.) – Igor Liferenko Sep 8 '15 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.