# Subtleties in typesetting radicals: explaining what TeX is actually doing

Following this and this, I decided to describe a little in detail what is happening when typesetting radicals, since these are kind of a wild beast.

What font characteristics are involved? What are the fine tuning mechanisms and typesetting rules applied?

As usual, I think that the stepwise process is the best.

Step 0 - Notation and definitions

Any symbol fonts (ie font family 2 in TeX language) must have at least 22 parameters in three different "styles" in order for TeX to typeset a formula. The "styles" roughly can be grouped as "text" for "display style", "text style" and their cramped version (see TeXBook), "script" for "script style" (cramped and standard) and "scriptscript" (cramped and standard). The TeXBook describes extensively how to determine which style to use and how to determine the correct style switch from main formula to super/subscripts.

Step 1 - First definitions

First of all the radicals are different with respect to the rest of math beasts, because they are set in their cramped style equivalent, (as described in step 0, this is described in the TeXBook, as also how calculate the cramped of any given styles). This has to be known, anyway in the rest of the answer, whenever I refer to the style I mean the original formula style and not the equivalent which will be effectively used to typeset the radicand.

Anyway, there are two main parameters:

1. r which is fontdimen8 of fontfamily number 3, and which represents the default rule height

2. s which is fontdimen5 of fontfamily number2, and which represents the x-height

Also useful are the box parameter for the radicand, ie its height h and depth d; we will refer to its box (remember, constructed in cramped style) as x

Step 2 - calculation of the font and style dependent parameter p

Simply:

• if the style is not Display or Display cramped p=0

• p=s otherwise

Step 3 - calculation of the tentative clearance k

Simply set k=r+(1/4)|p|

Step 4 - typesetting the delimiter first passage

A variable radical delimiter is set such as its height plus depth z: z≥h+d+r+k. Let's call H the height of this character and D its depth.

Step 5 - defining the rule

The rule height r is reset to r=H – usually the font designer specifies the rule thickness to be equal to the height of the radical character.

Step 6 - adjusting the clearance k

If D > h+d+k the clearance has to be increased (ie, the space over the radicand has to be increased to match the extra depth of the radical). This is done by setting k=(1/2)(k+D-h-d), that is k gets half of the excess.

Step 7 - building the radicand box

A vertical box is built (ie its description goes from top to bottom):

• kern of amount r

• rule of height r

• kern of amount k

• the x box

Step 8 - typeset the radical

The radical is substituted, then, by the box constructed by the delimiter (see step 4), raised by h+k, followed by the vertical box constructed in step 7. These two boxes are then converted into a single Ord atom.

Interconnections among parameters and other formula typesetting

Here I will briefly detail how the parameters are intertwined with the other formula typesetting calculations, in order to be able to use and adjust only the ones needed.

• fontdimen5 represents the "x-height" and is thus widely used:
1. (1/4) |(fontdimen 5)| also takes part into determining the up and downshift of super and subscripts
2. Also fontdimen8 of family 3 is used determining the rule thickness in overlines, underlines and fractions, as well as sub and superscripts