[Tex/LaTex] Inline math spacing and varying interword spacing

inline()math-modespacing

Say I want to reduce the space between two letters in math mode by 2/18 quad. Going all Die Hard 3, I put together 2 -3/18 quad \! and add 4/18 quad with \:. The problem is, though, that apparently the positive space gets squashed according to the current line's interword spacing while the negative space does not. So in extreme cases I get -6/18 quad which looks less than satisfying in my MWE and in the real world:

screenshot

\documentclass[a5paper]{article}
\newcommand{\md}{\ensuremath{M\!\!\:D}}
\begin{document}
a a a a a a a a a a a a a a a a a a a a a a $\md$ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a

aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa $\md$ aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaa
\end{document}

So why is inline math subjected to normal interword spacing adjustments and how can I switch it off? (I can imagine this leading to problematic results in many formulae, even when not doing such strange spacing arithmetic as I did.)

Best Answer

There is some glue in \:, but not in \!: the first uses \medmuskip which is 4.0mu plus 2.0mu minus 4.0mu, the second \thinmuskip which is 3.0mu. To avoid the glue use only \! or, simpler, just \mkern:

Sample output

Second sample

\documentclass[a5paper]{article}
\newcommand{\md}{\ensuremath{M\mkern-9mu D}}
\begin{document}
a a a a a a a a a a a a a a a a a a a a a a $\md$ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a

aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa $\md$ aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
aaaaaaaa

\clearpage
\hbox{aa aa $\md$ aa aa}

\hbox spread 10pt{aa aa $\md$ aa aa}

\hbox spread 20pt{aa aa $\md$ aa aa}

\end{document}

As 18mu = 1em this is much closer spacing than you ask for, use -2mu instead.

The numbers in my statements above come from:

\documentclass{article}
\begin{document}
\( \show\!\show\: \)
\showthe\thinmuskip
\showthe\medmuskip
\end{document}

which prints the following infomation in the log file:

> \!=macro:
->\mskip -\thinmuskip .
l.10 \( \show\!
               \show\: \)
> \:=macro:
->\mskip \medmuskip .
l.10 \( \show\!\show\:
                       \)
> 3.0mu.
l.11 \showthe\thinmuskip

> 4.0mu plus 2.0mu minus 4.0mu.
l.12 \showthe\medmuskip

As far as I can see, in standard latex, the glued skips \medmuskip and \thickmuskip, are only used around binary and relation symbols, and in the definition of \bmod.

Related Question