22

Plain Tex defines \quad so:

\def\quad{\hskip1em\relax}

Why is the \relax there? It's usually used as a token that can't be expanded, serving as a "do nothing" operation after macro expansion is finished. But that use seems redundant, because it follows a command, namely \hskip.

The macro is defined alongside \enskip and \qquad in plain.tex, and in Latex in ltspace.dtx.

An idle question, but I guess the reason for it will be worth knowing.

1 Answer 1

26

So that \quad doesn't eat following text while assembling the argument of \hskip:

\documentclass{article}
\begin{document}

\def\quad{\hskip1em\relax}

\quad plus 1em text

\def\quad{\hskip1em}

\quad plus 1em text
\end{document}
3
  • 1
    This is a general feature of TeX skips: see also how LaTeX defines a number of wrappers so that 'escape' does not take place.
    – Joseph Wright
    Sep 14, 2010 at 13:10
  • Thank you. I guess this highlights the risks associated with designing robust macros. Sep 14, 2010 at 13:28
  • 1
    Fischer's explanation above can also be seen on the dangerous bend in pg. 71 of Knuth's The TeXbook.
    – Mafra
    Dec 2, 2012 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .