# Why isn't there any command to start a paragraph with \vbox?

\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:

\hbox{A}
\end

\noindent A
\end


The following two examples also produce identical output:

\vbox{\hrule width 1em}
\end

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


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?

\leavevmode\hbox{A}
\end

\catcode\@=11
\unvbox\voidb@x\hbox{A}
\end


(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 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.

\catcode@=11
\def\leavehmode{\unvbox\voidb@x}
\catcode@=12

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

abc\leavehmode def

\bye


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);
vmode+letter,vmode+other_char,vmode+char_num,vmode+char_given,
vmode+math_shift,vmode+un_hbox,vmode+vrule,
vmode+accent,vmode+discretionary,vmode+hskip,vmode+valign,
vmode+ex_space,vmode+no_boundary:@t@>@;@/
begin back_input; new_graf(true);
end;


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 at 21:00