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.

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:

share|improve this question
4  
Yes, that's the point. I don't think there's much more to say. –  egreg Mar 4 at 8:26

1 Answer 1

up vote 10 down vote accepted

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'.

share|improve this answer
    
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)". –  Lover of Structure Mar 5 at 3:22

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.