[Tex/LaTex] What’s the difference between \mspace and \hspace in math mode

amsmathmath-modespacing

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!

Best Answer

Once having made clear that

  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$

enter image description here

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