# What's the difference between \mspace and \hspace in math mode?

I know that amsmath package provides extra math spacing commands, like the followings \, for \thinspace, \: for \medspace and \; for \thickspace, there are corresponding negative space as well like \negthinspace, \negmedspace and \negthickspace. But from the package documentation, it says:

For the greatest possible control over math spacing, use \mspace and ‘math units’.

Besides I tested out that anywhere the \mspace command takes effect then the \hspace command takes effect as well. I was wondering what's the difference between these two commands when used in math mode? If there's no difference between them why would I bother using \mspace as \hspace is more often used.

Any hints or help on this will be greatly appreciated!

1. \mspace can only be used in math mode (and requires amsmath),
2. \mspace only accepts a length expressed in mu units (but the plus and minus components also accept fil[ll] units) or in terms of a mu based parameter (\thinmuskip, \medmuskip and \thickmuskip),
3. \hspace doesn't accept mu units,

we can describe the differences.

Both commands insert space that will not interfere with the automatic spacing between atoms. However,

• the value of the mu unit for \mspace depend on the current math style;
• the value of the em or ex unit for \hspace depends on the text font current at the time the formula began.

In particular, given that 18mu corresponds to the value of 1em in the symbol font (math group 2), the following two formulas will give quite different result

$\scriptscriptstyle a\mspace{18mu}b$

$\scriptscriptstyle a\hspace{1em}b$ This is because the former uses the em in \scriptscriptfont2 (default for 10pt size is cmsy5) whereas the latter uses the em in the standard text font (default cmr10).

• Thank you! I think I got your idea, they're font dependent commands, and they both work in math mode. – Jiapan Sep 18 '17 at 9:39
• @Jiapan yes but use hspace and em units is a font dependent command that depends on a font that is unrelated to the math, so it is almost always the wrong command to use. – David Carlisle Sep 18 '17 at 9:57
• @DavidCarlisle so it's better to use \mspace when in math environment. Gotcha, thanks a lot! – Jiapan Sep 18 '17 at 11:30

It is not clear what is meant by

I tested out that anywhere the \mspace command takes effect then the \hspace command takes effect as well

The \mspace is but a thin wrapper for use of TeX's \mskip which expects a <muglue> specification, i.e. something with mu unit which makes sense in math mode.

The \mspace macro can be used only in math mode.

The \hspace macro does not accept mu unit.

• thanks! I mean \mspace and \hspace both works in my projects. – Jiapan Sep 18 '17 at 9:34