# How to switch between horizontal and vertical modes?

I've got some complex code giving me an error: ! You can't use '\vadjust' in vertical mode.

So I presume I need to switch to the horizontal mode. I've found this question, "What are vertical and horizontal modes?", but nothing explaining how to switch between them.

I've looked at the TeXbook, but nothing seems to answer this question.

How do switch between the two?

-
You don't want to switch to horizontal mode in order to use \vadjust; just say \ifvmode<...>\else\vadjust{<...>}\fi. –  egreg Jul 26 '13 at 14:02
@egreg If I do the \ifvmode it ends up skipping the code which is supposed to typeset some numbers properly vertically spaced. –  McGafter Jul 26 '13 at 14:06
Sorry, but without seeing the code it's impossible to say more. But \vadjust is for adding vertical material when we're in horizontal mode, so I can't understand why you need to use it in the first place. However, the way to ensure being in horizontal mode (which starts a paragraph, if issued in vertical mode) is \leavevmode. –  egreg Jul 26 '13 at 14:09
@egreg That answers the question. Thanks –  McGafter Jul 26 '13 at 14:19

The command \vadjust can be issued only in horizontal or inline math mode. Its purpose is to insert vertical material (for instance a vertical space) after the line where the command eventually ends up.

An example of \vadjust in LaTeX is given by \vspace that does (in the normal variant)

\ifvmode
\vskip#1\vskip\z@skip
\else
\@bsphack
\@esphack
\fi


Thus it just does a \vskip if already in vertical mode or it inserts a \vadjust item.

Sometimes \vadjust is used for “cheating”; an example is to add something to the left or right of a line without resorting to \marginpar. In this cases, horizontal mode must be ensured, which is obtained by issuing

\leavevmode


before \vadjust.

-