\vbox does not switch modes and \hbox does not switch modes, as demonstrated by the following two groups of examples.

The following two examples produce identical output:

\noindent A

The following two examples also produce identical output:

\vbox{\hrule width 1em}
\noindent\vbox{\hrule width 1em}

Also, empty content switches mode from vertical to horizontal, as in \unhbox\voidb@x. That same empty content may be obtained via \unvbox\voidb@x. But using this does not switch mode from vertical to horizontal (see following two examples). Why?


(Here in the first example indentation is added, and in the second not.)

\vbox may be inside paragraph, like \hbox. What control sequence may be used to create a \vbox in the middle as well as in the beginning of paragraph?

  • I'm not sure what the final question is about. Do you mean something like this: \def\parvbox{\ifvmode\leavevmode\fi\vbox}? That way a \parvbox can start a paragraph if needed. – Henri Menke Dec 3 '19 at 5:58

The command for starting horizontal mode with a \vbox is \leavevmode. Why would you need something else?

Your assumption is wrong, I'm afraid: it's not “empty contents” that triggers mode change. It is precisely \unhbox that does.

Differently from \box and \copy, \unhbox is a horizontal command, so it triggers horizontal mode if TeX is in vertical mode. The macro \leavevmode uses \voidb@x so that nothing is appended to the horizontal list (after possibly having started it).

The analog command \unvbox is a vertical command and ends a paragraph.


\everypar{PAR}% to show a paragraph has started

abc\leavehmode def


enter image description here


I don't know whether this is clear or not, but let's state it explicitly (from the TeXbook):

|\leavevmode| is an abbreviation for `|\unhbox\voidbox|',
where |\voidbox| is a permanently empty box register.

Now what does \unhbox\voidbox actually do? Let's take a look in tex.web:

@ @<Cases of |main_control| that build...@>=
vmode+start_par: new_graf(cur_chr>0);
  begin back_input; new_graf(true);

As you can see any of those combinations of mode and something else start a paragraph, but vmode+un_vbox is not among them.

On a personal note, I find it interesting that Knuth did not let vmode+<*>vbox start a paragraph but vmode+valign does.

  • It's in the same order as vmode+<*>hbox does start a paragraph but vmode+halign doesn't. – touhami Dec 3 '19 at 21:00

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.