3

I have a math mode expression which requires a spacing that doesn't seem to be possible using just the spacing commands like \!, \;, etc. The closest appears to be \!\!, but it has too much space. Is there a way to customize spacing in math mode?

10
  • 1
    You can use \mkern, for example: tutorialspoint.com/tex_commands/mkern.htm
    – Sebastiano
    Commented Oct 10, 2020 at 22:21
  • 2
    Use \mkern x mu and choose the value of $x$ that fits your needs.
    – Bernard
    Commented Oct 10, 2020 at 22:22
  • 2
    without any example code impossible to guess your issue but you can use whatever space you like, no need for \!\! you can use \mspace{5mu} or whatever Commented Oct 10, 2020 at 22:22
  • 1
    \!\! is negative space of 2\thinmuskip \!\!\!\; is space of \thickmuskip-3\thinmuskip why would you use these amounts? Commented Oct 10, 2020 at 22:25
  • 3
    @Sebastiano yes but \mskip 2mu plus 1mu minus 2mu is half of \: \mkern 2mu plus 1mu minus 2mu is a kern of 2mu and then typesets plus 1mu minus 2mu as text, so why \mkern rather than \mskip (or the latex version, \mspace) ? Commented Oct 11, 2020 at 8:46

1 Answer 1

10

You don't give many clues but the default values are

\thinmuskip=3mu
\medmuskip=4mu plus 2mu minus 4mu
\thickmuskip=5mu plus 5mu

Although they may be changed by the document class or packages you are using.

so \!\! is -6mu and \!\!\!\; is a stretch length of -4mu plus 5mu (that is will be between -4mu and +1mu depending on the surrounding context).

It is not clear how you are using these values, but (with amsmath) you can use \mspace{..} with arbitrary mu values or (almost always preferable) you can adjust the values of the three mathskips to change the spacing in all cases without adding explicit spacing to each formula.

Note that the reason for the named space commands like \, is they match the space added by TeX's automatic spacing between atoms of different classes, so you can emulate or negate that spacing in some contexts.

x\,x

will always have the same space that Tex adds automatically to a construct such as

\log x

so whatever values a document class gives to \thinmuskip these constructs will change in a consistent way.

However a construct such as

x\!\!\;x

Gives no consistency at all: it might be a positive or negative space depending on the values set for \thinmuskip and \thickmuskip any formula using such a construct is fragile and probably would need editing if typeset with different fonts using different spacing defaults.

If you really need to add explicit space distinct from the named spaces, amsmath provides \mspace as a LaTeX syntax version of \mskip (cf \vspace and \hskip) so you can use

x\mspace{6mu plus 2mu}x

Or whatever space you need.

4
  • Does fractional mu work too?
    – Someone
    Commented Oct 11, 2020 at 20:50
  • @Someone yes, you could have just tried it:-) \documentclass{article}\usepackage{amsmath}\begin{document}\Huge zz\\$x\mspace{2mu}x$\\$x\mspace{.5mu}\mspace{1.5mu}\mspace{.5mu}x$\end{document} Commented Oct 11, 2020 at 20:54
  • What's the point of using plus and minus in \mspace?
    – Someone
    Commented Oct 21, 2020 at 12:19
  • @Someone the default values are stretchy not fixed so you may want to specify stretchy values 6mu plus 2mu has a natural length of 6mu and can stretch to 8mu on lines that need stretching (minus components are shrink amounts) Commented Oct 21, 2020 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .