# What is the internal LaTeX working logic for \left and \right with delimiters?

I am reading about latex and in several books is written that to be able to size the delimiter to the vertical size of formula I need to use \left and \right. I understand that part. But I am interested what is the internal LaTeX working logic for \left and \right with delimiters? What \left and \right are doing at the software level?

• The exact algorithm for sizing and the parameters it uses is explained in appendix G of the TeXBook (it is controlled by the underlying TeX engine, not by LaTeX) Sep 1, 2018 at 14:15

When TeX encounters material in math mode, it creates a math list. A math list is a list of nodes (they are called noad here), sometimes containing sublists, representing all the things written in math mode.

If you write

$f\left( stuff \right)$


the block with the delimiters is put into a sublist with math class inner, as if you wrote

$f\mathinner{\left( stuff \right)}$


Then TeX converts the \mathinner part without \left( and \right) into a horizontal list to determine it's height and depth. Then TeX tries to add delimiters with height+depth equal to 2*max(height,depth) from this inner material.

How does TeX create this delimiters? The \delcode of the delimiter points to a character in a font, if this is big enough, TeX inserts it. Otherwise the character might contain a next field indicating the codepoint of the next larger variant. Then TeX tries again with the bigger one. This repeats until TeX found a delimiter large enough or an extensible delimiter. Extensible delimiters have multiple parts which can be stacked on top of each other and repeated to form arbitrary large delimiters. They are always big enough, but they have to consist mostly of vertical segments.

The last part can be customized with the just released new version of LuaTeX.

For further details, it is best to read The TeXbook, Appendix G, Rule 19 (see also p. 152).

• +1, great answer, maybe Moriambar should have made a post about that in his "appendix G question series". Sep 1, 2018 at 14:31
• To be fussy, the field that points to the next larger character is labeled NEXTLARGER in the output of the tftopl program. (I wouldn’t have remarked this if you hadn’t written next within backticks… ;-)
– GuM
Sep 1, 2018 at 23:48
• @GuM I recently worked a lot with the LuaTeX font table, so I used the name from there and expected it to be the "standard" name. But you're right, tftopl might be a better reference. Feel free to edit it in. Sep 1, 2018 at 23:59
• I think that it is more than enough to have the name used by tftopl cited in the comments! :-) Added: Rather, I’m going to improve the reference to Appendix G.
– GuM
Sep 2, 2018 at 0:03

This is not quite an answer, but in a comment, the formatting is lost. Let's start with line 22328 and following of tex.web:

@ We have dealt with all constructions of math mode except \.{\\left}' and
\.{\\right}', so the picture is completed by the following sections of
the program.

@<Put each...@>=
@!@:left_}{\.{\\left} primitive@>

And finally, we have |left_noad| and |right_noad| types, to implement