8

I'm (foolishly) trying to understand what determines vertical spacing. I was trying to do this in LaTeX originally, but have temporarily switched to plain in an attempt to simplify things.

Code:

What is the question?
Beth yw'r cwestiwn?
What is the question?
Beth yw'r cwestiwn?
What is the question?
Beth yw'r cwestiwn?
   
\begingroup
W

\offinterlineskip

\setbox5=\hbox{\strut\vrule height 0pt depth 0.4pt width 0.1pt\kern0pt}
\setbox4=\vbox{\parindent=0pt\strut\vrule height 0pt depth 0.4pt width \hsize}

What is the question? \leaders \copy5  \hfill \kern0pt

\leaders \copy4  \vfill

\parindent=0pt

What is the question? \leaders \copy5  \hfill \kern0pt % why is the vertical space below larger?

\leaders \copy4  \vfill

What is the question? \leaders \copy5  \hfill \kern0pt % why is the vertical space below smaller?

\leaders \copy4  \vfill

What is the question? \leaders \copy5  \hfill \kern0pt % why is the vertical space below larger?

\leaders \copy4  \vfill

M

W

W % why does deleting this reduce the vertical space above M?

W\strut 

W\strut

W\strut

\line{\offinterlineskip\strut\leaders \vrule height 0pt depth 0.4pt width \hsize \hfill}
\line{\offinterlineskip\strut\leaders \vrule height 0pt depth 0.4pt width \hsize \hfill}
\line{\offinterlineskip\strut\leaders \vrule height 0pt depth 0.4pt width \hsize \hfill}

\endgroup

\par
\vfill    

% \showlists
% \showbox4
% \showbox5

\bye

I'm trying to make the vertical spacing of the rules consistent, but (1) I'm failing utterly and (2) I have no clue what is going on.

spacing variations

I included specific questions in the code, but I suspect I need to ask a different question yet don't know what that is.

1
  • maybe I'm missing something, but I don't see how that helps?
    – cfr
    Commented Jul 29 at 17:22

2 Answers 2

7

You can think of leaders as control sequences that take two arguments: \leaders<box><glue>. The box can contain anything! For testing is best to use something that is not dots! I use letters as I can see if something influences the depth! In the example note the ag!.

A simple demo to show the problem:

\parskip=1cm  
\begingroup
\parskip=0pt
\offinterlineskip

aa \leaders \hbox{ABI} \hfill \null\par
bb \leaders \hbox{ABI} \hfill \null\par

\vskip20pt

% Note the depth of ag and the illusion that \offinterlineskip is not working!
ag \leaders \hbox{ABI} \hfill \null\par
bb \leaders \hbox{ABI} \hfill \null\par

\endgroup

\bye

Edit vertical leaders as per request in expl3.

\def\fox{The fox jumped over the lazy dog!}

    \ExplSyntaxOn
    \DeclareDocumentCommand {\Vdotfill}{}
      {
        \par\tex_leaders:D \hbox:n {\(\cdot\)}\tex_vfill:D
      }
        
    \vbox_to_ht:nn {2cm} 
      {
        \fox
        \Vdotfill
        \fox
      } 
        
    \ExplSyntaxOff 

enter image description here Vertical leaders image:

enter image description here

5

Quoting the TeXbook, first dangerous bend on page 224, which refers to an example on page 223:

Notice that the dots in the two example lines appear exactly above each other. This is not a coincidence; it's a consequence of the fact that the \leaders operation acts something like a window that lets you see part of an infinite row of boxes. If the words ‘Alpha’ and ‘Omega’ are replaced by longer words, the number of dots might be different but the ones that you see will be in the same places as before. The infinitely replicated boxes are lined up so that they touch each other, and so that, if you could see them all, one of them would have the same reference point as the smallest enclosing box.

This explains why the spacing seems random. In other words, the position of \leaders is not predictable, even more if you try to set them with \vfill that depends on all the material on the page.

Compare with

\def\checkrule{\vrule\kern-0.4pt}

What is the question?
Beth yw'r cwestiwn?
What is the question?
Beth yw'r cwestiwn?
What is the question?
Beth yw'r cwestiwn?

\setbox2=\hbox{\strut\checkrule\vrule height 0pt depth 0.4pt width \hsize}

\noindent\checkrule
\strut What is the question? \leaders\hrule height0pt depth 0.4pt\hfill \kern0pt

\cleaders \copy2 \vskip 6\dimexpr\ht2+\dp2\relax

\bye

where exactly six rules are drawn, because \cleaders ignores the “infinite row of boxes” and packs as many boxes as fit, with possible excess space at either end. Since I state an exact multiple of the height plus depth of the box, six boxes fit and there's no gap as witnessed by the \checkrule.

output

10
  • are you saying that the vertical position of \leaders is fixed in the same way as the horizontal position? but I don't think that can be what you're saying?
    – cfr
    Commented Jul 29 at 17:41
  • @cfr Yes, that's it. There's no real difference between horizontal and vertical leaders (besides the obvious).
    – egreg
    Commented Jul 29 at 17:43
  • so what happens when you don't use dots? the baseline gets aligned with the baseline of the box which would contain the dots?
    – cfr
    Commented Jul 29 at 17:49
  • @cfr see my example!
    – yannisl
    Commented Jul 29 at 17:50
  • @cfr I can't understand. When you use (vertical) leaders, TeX pretends that there is a sequence of the boxes (stacked according to the rules) and lets you see only those that entirely fit in the available space.
    – egreg
    Commented Jul 29 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .