What is the internal LaTeX working logic for left and right with delimiters?
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
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?
tex-core delimiters
add a comment |Â
up vote
6
down vote
favorite
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?
tex-core delimiters
1
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)
– David Carlisle
Sep 1 at 14:15
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
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?
tex-core 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?
tex-core delimiters
edited Sep 1 at 19:50
asked Sep 1 at 13:49
vasili111
1547
1547
1
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)
– David Carlisle
Sep 1 at 14:15
add a comment |Â
1
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)
– David Carlisle
Sep 1 at 14:15
1
1
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)
– David Carlisle
Sep 1 at 14:15
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)
– David Carlisle
Sep 1 at 14:15
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
13
down vote
accepted
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
$fleft( stuff right)$
the block with the delimiters is put into a sublist with math class inner
, as if you wrote
$fmathinnerleft( 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".
– TeXnician
Sep 1 at 14:31
To be fussy, the field that points to the next larger character is labeledNEXTLARGER
in the output of thetftopl
program. (I wouldn’t have remarked this if you hadn’t writtennext
within backticks… ;-)
– GuM
Sep 1 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.
– Marcel Krüger
Sep 1 at 23:59
I think that it is more than enough to have the name used bytftopl
cited in the comments! :-) Added: Rather, I’m going to improve the reference to Appendix G.
– GuM
Sep 2 at 0:03
add a comment |Â
up vote
3
down vote
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...@>=
primitive("left",left_right,left_noad);
@!@:left_}.\left primitive@>
primitive("right",left_right,right_noad);
@!@:right_left_noad.\left primitive@>
primitive("right",left_right,right_noad);
@!@:right_left_noad.\left primitive@>
primitive("right",left_right,right_noad);
@!@:right_Â
up vote
3
down vote
up vote
3
down vote
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...@>=
primitive("left",left_right,left_noad);
@!@:left_.\left primitive@>
primitive("right",left_right,right_noad);
@!@:right_left_noad.\left primitive@>
primitive("right",left_right,right_noad);
@!@:right_{.\right primitive@>
So what does this say? This has nothing to do with LaTeX, they are TeX primitives. And basically, this says you should read the TeX book (as David Carlisle already commented the important part for this is appendix G) to understand what's going on here.
Alternatively, you may dig into the source code which is documented (see link above). So you could simply look up the missing references and you would, for instance, go on with line 13514:
And finally, we have |left_noad| and |right_noad| types, to implement
TeX's .\left and .\right.
But as it would take quite some time to find all the corresponding source code, I come back to my recommendation to read the TeX book.
answered Sep 1 at 14:21


TeXnician
20.5k52880
20.5k52880
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f448846%2fwhat-is-the-internal-latex-working-logic-for-left-and-right-with-delimiters%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
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)
– David Carlisle
Sep 1 at 14:15