TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

TeX can be in 7 distinct modes:

  1. Vertical mode: this is the mode in which TeX starts, and build pages.
  2. Internal vertical mode: TeX is in this mode within \vbox{...}.
  3. Horizontal mode: when constructing paragraphs.
  4. Restricted horizontal mode: within an \hbox{...}.
  5. Display math mode: $$...$$ (and LaTeX's other display math environments).
  6. Math mode: $...$ for inline math.
  7. No mode: only within \write commands?

The existence of the no mode mode can be ascertained by running


(with the plain TeX format). The log contains

 \write->\iftrue \fi 
 {no mode: \iftrue: (level 1)}
 {\fi: \iftrue (level 1)}

 {vertical mode: blank space  }

As you can see, TeX writes down the mode for the first command run in that mode. In this snippet, we can see no mode and vertical mode.

So far, I noted that neither \message nor \special change the mode to no mode. Only \write seems to do it.

share|improve this question
up vote 25 down vote accepted

no mode in tex.web corresponds to the variable modehaving the value 0. This can be seen in the procedure print_mode (§211), i.e.,

else if m=0 then print("no")

Now the only place in TeX where this variable is set to zero is in §1371 which is the code that expands a \write statement.

So the answer to your question is: yes that is the only place.

share|improve this answer
Interestingly, tex.web states (about [16] The semantic nest) that The mode is temporarily set to zero while processing \.{\\write} texts in the |ship_out| routine. It doesn't mention \immediate\write, in which the mode is also set to zero. – Bruno Le Floch Feb 9 '12 at 11:37
@BrunoLeFloch well in the end you have to go by the code even though TeX is fairly well documented. You might earn $2.56 as docu bug fee one day if you report it but probably not be fore the next decade ;-). It is understandable that \immediate behaves like this too, but less so that \special doesn't. – Frank Mittelbach Feb 9 '12 at 12:02
It seems natural that \special{\ifvmode...\else...\fi} would let you access the mode in effect when the \special is triggered, since expansion happens immediately. On the other hand, \write-1{\ifvmode...\fi} gets expanded late, so there is no obvious notion of "current mode" (Can nodes migrate from hlist to vlist?). It would be most consistent if \immediate\write used the current mode, not "no mode". --- Are documentation fixes rewarded too? I thought my only hope for a Knuth cheque was \batchmode\def\foo#1#2#3#4#5#6#7#8#9#}{}\errorstopmode\show\foo. – Bruno Le Floch Feb 9 '12 at 12:27
@BrunoLeFloch -- yes, documentation bugs are rewarded too. if frank says this is worth reporting, please report it. you can get the e-mail address for reports from don knuth's web site. the schedule he lists there says that he will next look at reports in 2013, so submit it soon, because it has to be vetted by a designated bug-checker before it gets sent on. if it passes this vetting process, knuth will answer you with a clear explanation, even if he doesn't accept it for a reward. – barbara beeton Feb 9 '12 at 13:10
@BrunoLeFloch thinking about this you are right one could even argue that this is not just a documentation bug but a programming one and \immediateshould leave the mode alone. But for very good reasons I'm certain there will be no change here. But mentioning correctly how the program behaves is something that could be considered a doc bug. And if it talks about shipout then it certainly doesn't cover the \immediate case. – Frank Mittelbach Feb 9 '12 at 17:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.