Red line in the output is \baselineskip, the only length in question that I know of. The output image provided here is an edited image in which (red line representing \baselineskip is re-positioned to start at the bottom of the top x) blue lines show the lengths I need to know.

  \fboxsep 0pt
  \fboxrule 0.1pt
  {\color{red}\vrule height \baselineskip}


There is no way for TeX to know the exact size of the glyph, TeX only knows the box around them, so the small blue line at the f in the second row can't be determined by TeX alone. The other lengths are determinable, you can measure the size of any box you can typeset (the following is in plain TeX syntax):

height: \the\ht0\par
depth: \the\dp0\par
width: \the\wd0

With this you can determine the first blue line as:

distance between boxes: \the\dimexpr\baselineskip-\ht0-\dp0\relax

The blue lines above and below the x in the second row:

distance above the x: \the\dimexpr\ht1-\ht0\relax\par
distance below the x: \the\dimexpr\dp1-\dp0\relax

enter image description here


e-tex allows you to get the font dimens of each charcter without needing to box it, this shows x and y of the current font





making a log:

> 4.30554pt.
l.8 \showthe\fontcharht\font`x

> 0.0pt.
l.9 \showthe\fontchardp\font`x

> 5.2778pt.
l.10 \showthe\fontcharwd\font`x

> 4.30554pt.
l.14 \showthe\fontcharht\font`y

> 1.94444pt.
l.15 \showthe\fontchardp\font`y

> 5.2778pt.
l.16 \showthe\fontcharwd\font`y

  • oh, forgot about those three. You got your sources copied twice. – Skillmon Jun 9 '19 at 19:06

The two distances marked with blue lines depend on the items in both lines, except the blue line next to “f”, which obviously only depends on the letter.

So you can't “know” them in general.

TeX tries to achieve constant distance b between consecutive lines (the value is stored in the parameter \baselineskip). In order to achieve this goal, TeX measures a line (let's call it “line T”) and the next (call it “line B”, by determining the maximum depth d (how much a character extends below the baseline) in line T and the maximum height in line B.

Then TeX computes bdh. If this turns out to be positive, then TeX will insert a glob of vertical glue of this amount between the two lines.

Let's see an example:



\typeout{depth of y: \the\fontchardp\font`y}

\typeout{height of f: \the\fontcharht\font`h}




The relevant part of the log file is

depth of y: 1.94444pt
height of f: 6.94444pt
....\OT1/cmr/m/n/10 x
....\OT1/cmr/m/n/10 y
....\OT1/cmr/m/n/10 f
....\OT1/cmr/m/n/10 M
...\glue(\baselineskip) 3.11111
....\OT1/cmr/m/n/10 x
....\OT1/cmr/m/n/10 y
....\OT1/cmr/m/n/10 f

As you see, the depth of y is reflected in the depth of line T, namely \hbox(6.94444+1.94444)x22.77786; the height of f corresponds to the height of line B, namely \hbox(6.94444+1.94444)x13.61118.

If we try 1.94444+6.94444+3.11111 we get 11.99999, which to TeX is the same as 12pt; actually \typeout{\the\dimexpr1.94444pt+6.94444pt+3.11111pt} would print 12.0pt on the console.

However, if bdh is less than the value stored in \lineskiplimit (default is 0pt), instead of the computed glue, TeX inserts a fixed amount using the value stored in \lineskip (default 1pt), so that lines never overlap with each other (in the standard setup). By using suitable values of \lineskiplimit and \lineskip one can actually get lines that superimpose to each other, never filling a page (this is exploited in the \ooalign macro).

The usage of \hbox might seem unrealistic, but actually TeX makes \hboxes after splitting a paragraph into lines.

The amount by which a glyph extends outside its bounding box is unknown to TeX and irrelevant for its computations, which only use the bounding box, characterized by height, depth and width.

XeTeX has a primitive to do such measurements, namely \XeTeXglyphbounds; look for it in the XeTeX reference (texdoc xetex).

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.