35

I assume that, to guard against strange errors, you should use \vspace rather than \vskip whenever possible in a LaTeX document. But are there any situations in which you must use \vskip?

I'm wondering the same thing about \hspace vs. \hskip.

  • 4
    This one is easy: never. ;-) – egreg Jul 31 '13 at 13:19
  • 1
    IMO if you use LaTeX semantically (for writing a document, as opposed to designing it), you should use neither skips nor spaces. – marczellm Jul 31 '13 at 13:35
37

The answer is easy: you should never use \vskip in a LaTeX document. The only precaution to be taken is adding a blank line before \vspace when the vertical space is meant to appear between paragraphs, which usually is the case.

However, \vspace can also appear in a paragraph and the vertical spacing will be applied below the text line where the command finally happens to fall: think of it as an invisible “word” that extends below the baseline (but this space will disappear at a page break anyway).

There are several reasons for not using \vskip (except, maybe, in basic LaTeX programming):

  1. it's easy to add a * where needed;
  2. it's easy to change \vspace into \addvspace (when two consecutive \addvspace commands, that are usually issued by macros rather than directly, only the largest one prevails);
  3. the syntax conforms to the traditional LaTeX one and a \relax is placed by default behind the scenes, thus avoiding some possible problems that, by Murphy's law, will show as very weird errors.

Similarly, never use \hskip in a LaTeX document, but prefer \hspace which avoids head scratching in cases such as

text\hskip 1pt plus other text

Try it. ;-) Then you'll switch to

text\hspace{1pt}plus other text

Notice that \hspace{...} should not be preceded nor followed by a space, because we're overriding TeX's rules at that point and we probably don't want other spaces to begin with.

  • Just to be clear, are you saying it's okay to use \vskip in macros or in a package? – Geoff Pointer Sep 15 '17 at 0:20
  • 2
    @GeoffPointer If the author knows what they're doing, yes, why not? \vskip and \vspace have quite distinctive features (the former adds \par if not in vertical mode). – egreg Sep 15 '17 at 8:09
  • There's no why not. I just wanted to be sure the distinction was being made. – Geoff Pointer Sep 16 '17 at 12:55
5

If you are an author of the text, you should never use \vspace nor \vskip because you should use only logical markup of the document. And typographical issue is responsibility of used macros.

If you are macro programmer then you like TeX primitives like \vskip, \vadjust, \hskip because you understand well what they are doing. And you needn't to use a complicated macros like \vspace in your macros.

The result: there is no need to use \vspace.

Moreover, \vspace is a big source of user confusions, because its default behaviour is something like \vadjust{\vskip...} so, it breaks line grid in the current paragraph but it doesn't end the paragraph.

  • I respect your optimism, but usually we are both the author of the text and responsible for its typography. ;) – Olivier Feb 17 '20 at 20:09
3

One difference that appears strange to me is, that \hspace does not eat following spaces:

Test\hskip0.1\textwidth\relax Test

Test\hspace{0.1\textwidth} Test

Test\hspace{0.1\textwidth}Test

Thus, in many low level cases \hskip is preferred. This appeared to me when implementing something similar to another question.

  • 8
    There is no following space to be eaten up in the first case: a space after a control sequence is always ignored during tokenization, so it simply doesn't enter in TeX processing. A better example could be Test\hskip 1pt test where a space is actually eaten up, but just because a space token is always ignored after a unit of measure (when a length is required by the syntax rules). – egreg Jan 10 '14 at 16:54

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.