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

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


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.