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?

Someone
  • 539
  • 1
    You can use \mkern, for example: https://www.tutorialspoint.com/tex_commands/mkern.htm – Sebastiano Oct 10 '20 at 22:21
  • 2
    Use \mkern x mu and choose the value of $x$ that fits your needs. – Bernard Oct 10 '20 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 – David Carlisle Oct 10 '20 at 22:22
  • 1
    \!\! is negative space of 2\thinmuskip \!\!\!\; is space of \thickmuskip-3\thinmuskip why would you use these amounts? – David Carlisle Oct 10 '20 at 22:25
  • Roughly speaking \! is -3 and \: is +4 and \; is +5. Thus \!\: is +1 and \!\; is +2 and \, is +3 ... and so on. Similarly, \!\!\; is -1 and \!\!\: is -2 ... – Symbol 1 Oct 10 '20 at 22:33
  • Not really, \: and \; are rubber glue lengths of variable size, but you can use the values directly no need to use weird combinations of the named lengths. Also one should try to avoid explicit spacing in almost all cases. – David Carlisle Oct 10 '20 at 22:35
  • 1
    @Sebastiano why \mkern ? that will lose the plus and minus components ? – David Carlisle Oct 10 '20 at 22:48
  • @DavidCarlisle With a lot of sincerity I use often \mkern and I have written this command. – Sebastiano Oct 11 '20 at 07:52
  • 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) ? – David Carlisle Oct 11 '20 at 08:46
  • @DavidCarlisle You're right. I have understood another information that I not knew. I have seen only your comment. – Sebastiano Oct 11 '20 at 08:53

1 Answers1

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.

David Carlisle
  • 757,742
  • Does fractional mu work too? – Someone Oct 11 '20 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} – David Carlisle Oct 11 '20 at 20:54
  • What's the point of using plus and minus in \mspace? – Someone Oct 21 '20 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) – David Carlisle Oct 21 '20 at 13:14