8

amsmath.sty defines \mspace as follows:

\newcommand{\mspace}[1]{\mskip#1\relax}

What is the purpose of this definition?

amsmath.pdf says that \mspace is the "equivalent of \hspace for math mode use".

I know that LaTeX has a philosophy of using braces around every argument. Is that the point? Or is it the idea that \mskip is a TeX-command and thus shouldn't be used in LaTeX? I assume that the purpose of the \relax is to safeguard against a following plus or minus (for stretchable/shrinkable lengths). Is this explicit safety the purpose of the command?

Related:

1
  • 4
    Yes, that's the point. I don't think there's much more to say.
    – egreg
    Commented Mar 4, 2014 at 8:26

1 Answer 1

11

The LaTeX approach is that all commands should share, as far as possible, a similar input syntax. In the case of the \hskip and similar primitives, the syntax is not 'LaTeX-like': they pick up a following number without braces in a way that is not predictable from the 'usual LaTeX rules'. At the same time, and as you observe, the primitive syntax allows an optional trailing stretch component (there is also an optional trailing space and shrink component). The inclusion of a \relax prevents this being accidentally parsed by TeX from 'some other content'.

The addition of \mspace by the AMS is entirely consistent with LaTeX syntax and addresses exactly the same point as \hspace does in relation to \hskip. Probably at the time LaTeX2e was released the use of an extra macro for this slightly more unusual use case couldn't be justified by the kernel team (there were very few 'spare' macros). Today, we'd probably imagine that such a command would be added 'out of the box'.

1
  • See my edit to my original question; probably best if you change your phrasing of "(there is also an optional trailing space and shrink component)". Commented Mar 5, 2014 at 3:22

You must log in to answer this question.

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