Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
2  
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

1 Answer 1

up vote 6 down vote accepted

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
  \vadjust{\@restorepar\vskip#1\vskip\z@skip}%
  \@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.

share|improve this answer

Your Answer

 
discard

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.