What's the difference between \mspace and \hspace in math mode?
Once having made clear that
\mspace
can only be used in math mode (and requiresamsmath
),\mspace
only accepts a length expressed inmu
units (but theplus
andminus
components also acceptfil[ll]
units) or in terms of amu
based parameter (\thinmuskip
,\medmuskip
and\thickmuskip
),\hspace
doesn't acceptmu
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
orex
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
).
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.