Reading through tex.web, I note that there is a difference between grouping levels and semantic nesting (i.e., the nesting of math, horizontal, and vertical modes). I can think of commands which increase the grouping level without changing modes: \begingroup, \bgroup. Are there commands which nest modes without affecting the grouping level, and is it possible to reach the overflow "semantic nest size" exceeded seen in the procedure push_nest:

@p procedure push_nest; {enter a new semantic level, save the old}
begin if nest_ptr>max_nest_stack then
  begin max_nest_stack:=nest_ptr;
  if nest_ptr=nest_size then overflow("semantic nest size",nest_size);
@:TeX capacity exceeded semantic nest size}{\quad semantic nest size@>
nest[nest_ptr]:=cur_list; {stack the record}
incr(nest_ptr); head:=get_avail; tail:=head; prev_graf:=0; mode_line:=line;

A naive

~ % 256 times \hbox\bgroup

leads to TeX's capacity being exceeded because of the number of grouping levels.

  • By accident I achieved to get this error via \newcommand\foo{\mathnormal{\foo}} (note the recursion). I know too little TeX to judge whether it fulfills what you asked for (i.e., does not affect grouping level), hence I leave it as a comment.
    – ComFreek
    Jul 7 at 11:47

The first way that comes to my mind is to start a paragraph in vertical mode, which sets TeX in horizontal mode without grouping.


This produces

! TeX capacity exceeded, sorry [semantic nest size=500].
<to be read again>
~...x\vbox \bgroup x\vbox \bgroup x\vbox \bgroup x
                                                  \vbox \bgroup x\vbox \bgro...
  • Here you get two mode nests per group. Can this be beaten? If not, then it is maybe silly to have any limit, since increasing it to 512 (513?) would make the error unreachable. Jul 8 '13 at 23:34
  • @BrunoLeFloch I'm thinking about it.
    – egreg
    Jul 8 '13 at 23:46
  • @BrunoLeFloch The suspended lists might be huge, so the limit to the semantic nest size is set rather low in order to avoid filling the memory.
    – egreg
    Jul 9 '13 at 9:21

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.