4

While trying to duplicate TeX dimension computations, I noticed that the delimiters placed with \left…\right are slightly bigger than the box around which they wrap. How much bigger, how is that computed, and where is that specified?

To be explicit, with amsmath the command $\begin{pmatrix}1\\2\end{pmatrix}$ (which internally does \left(…\right)) produces the following boxes:

.\mathon
.\hbox(14.5001+9.50012)x19.7223
..\hbox(0.39998+23.60025)x7.36115, shifted -14.10013
...\OMX/cmex/m/n/10 ^^R
..\glue -5.0
..\vbox(14.5+9.5)x15.00002
...\hbox(8.39996+3.60004)x15.00002
....\glue(\tabskip) 0.0
....\hbox(8.39996+3.60004)x15.00002
.....\rule(8.39996+3.60004)x0.0
.....\glue 5.0
.....\glue 0.0 plus 1.0fil
.....\mathon
.....\OT1/cmr/m/n/10 1
.....\mathoff
.....\mathon
.....\hbox(0.0+0.0)x0.0
.....\mathoff
.....\glue 0.0 plus 1.0fil
.....\glue 5.0
....\glue(\tabskip) 0.0
...\glue(\lineskip) 0.0
...\hbox(8.39996+3.60004)x15.00002
....\glue(\tabskip) 0.0
....\hbox(8.39996+3.60004)x15.00002
.....\rule(8.39996+3.60004)x0.0
.....\glue 5.0
.....\glue 0.0 plus 1.0fil
.....\mathon
.....\OT1/cmr/m/n/10 2
.....\mathoff
.....\glue 0.0 plus 1.0fil
.....\glue 5.0
....\glue(\tabskip) 0.0
..\glue -5.0
..\hbox(0.39998+23.60025)x7.36115, shifted -14.10013
...\OMX/cmex/m/n/10 ^^S
.\mathoff

Now the size of the delimiters is 0.39998+23.60025=24.00023, and the size of the overall box is 14.5001+9.50012=24.00022, and both of this is bigger than the inner vbox with 14.5+9.5=24.0. Where does that size come from?

1 Answer 1

5

The formulas are in Appendix G "Generating Boxes from Formulas", item 19 in "The TeXbook" of Donald E. Knuth:

h = maximum height of the material inside
d = maximum depth of the material inside
a = height of math axis (σ22 = font dimen parameter 22 of symbol font, family 2)

Then the inside material is made symmetrical around the axis and the total height is calculated:

δ = max(h - a, d + a)

Then this size is adjusted according to

f = \delimiterfactor (default = 901)
l = \delimitershortfall (default = 5 pt)

The first one shrinks the size to 90.1 %, the second reduces the size by 5 pt in the default setting. Then the final minimum size is the maximum of both values:

result = max(⌊δ/500⌋ f, 2δ - l)

Then it depends on the font, which size is actually taken.

With numbers from the example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \showboxdepth=\maxdimen
  \showboxbreadth=\maxdimen
  \tracingonline=1
  \nonstopmode
  \sbox0{$\begin{pmatrix}1\\2\end{pmatrix}$}
  \showbox0

  % math axis, indirect way
  \sbox0{$\vcenter{}$}% show math axis, variable a
  \showbox0

  % math axis, direct way
  \showthe\fontdimen22\textfont2

  \showthe\delimiterfactor
  \showthe\delimitershortfall
\end{document}
\hbox(14.5001+9.50012)x19.7223
.\mathon
.\hbox(14.5001+9.50012)x19.7223
..\hbox(0.39998+23.60025)x7.36115, shifted -14.10013 % => size delimiter
...\OMX/cmex/m/n/10 ^^R
[...]
..\vbox(14.5+9.5)x15.00002 % => inner material
[...]
> \box0=
\hbox(2.5+0.0)x0.0 % => math axis, variable a
.\mathon
.\vbox(2.5+-2.5)x0.0
.\mathoff
[...]
> 2.5pt.
l.18 \showthe\fontdimen22\textfont2
[...]
> 901.
l.18   \showthe\delimiterfactor

> 5.0pt.
l.19   \showthe\delimitershortfall

h = 14.5 pt
d = 9.5 pt
a = 2.5 pt
δ = max(h - a, d + a) = max(12 pt, 12 pt) = 12 pt
f = 901
l = 5 pt
result = max(⌊δ/500⌋ f, 2δ - l)

Let TeX do the math for ⌊δ/500⌋:

\dimen0=12pt
\divide\dimen0 by 500 % division including floor (smallest unit is 1 sp)
\showthe\dimen0
> 0.02399pt.

result = max(0.02399 pt ⋅ 901, 24 pt - 5pt) = max(21.61499 pt, 19 pt) = 21.61499 pt

This is the minimum size for the delimiter. The font stuff is more complicate. The font can provide several fixed sizes and construct the delimiter for larger sizes. In this case, the size of the delimiter is the same as for \bigg, the smaller size would be \Big:

\setbox0=\hbox{$\Big($}
\showbox0

\setbox0=\hbox{$\bigg($}
\showbox0

This gives (^^Q and ^^S are the right parentheses):

...\hbox(0.39998+17.60019)x5.97223, shifted -11.1001
....\OMX/cmex/m/n/10 ^^P

...\hbox(0.39998+23.60025)x7.36115, shifted -14.10013
....\OMX/cmex/m/n/10 ^^R

^^P has total height of 18.00017 pt and ^^R has 24.00023 pt. Requested minimum size is 21.61499 pt. Therefore, the former is too small, thus the latter is used.

2
  • Now that you quote it, I remember reading it at some point. The formula still doesn't explain why the delimiters are larger, since both terms are smaller than 2δ. (When I first read this, I had concentrated on 901>500 and completely missed that 901<2*500. Reading this as 90.1% helped!) But I believe that if I combine this with the fact that delimiter sizes are quantized by a whole number of extension character repetitions, then things start to make sense and I can reproduce TeX behavior.
    – MvG
    Commented Jun 14, 2015 at 6:04
  • it may help to know that in the "basic" (10pt) computer modern extension font, the extension characters have a height of 6pt. (calculations are in scaled points, and there is some small roundoff error.) Commented Jun 14, 2015 at 14:53

You must log in to answer this question.

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