6

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

  • 1
    I guess that the math spaces \quad or ` \!` or others are rubber spaces. Try to use \mbox{\ensuremath{M\!\!\:D}}. – Sigur Apr 4 '13 at 16:30
  • @Sigur Thanks for the alternative approach. Just for the record, I had experimented a bit and \! does not actually appear to be a rubber space, only \: is. – Christian Apr 5 '13 at 12:11
7

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.

  • How to use those last commands on your code? – Sigur Apr 4 '13 at 16:41
  • 1
    @Sigur I have now explained this in my answer. – Andrew Swann Apr 4 '13 at 16:46
  • OK. It works. I can see the code on the log file. But I don't know why my TeXstudio returns error when I compile it. Thanks. – Sigur Apr 4 '13 at 16:51
  • It is the \show command that is causing TeXstudio to think there is an error. When you run tex interactively, \show will stop the processing at that point, display its output, and prompt for a command. Texstudio, and other systems, run tex in nonstopmode, carrying on past such prompts. – Andrew Swann Apr 4 '13 at 16:59
  • 1
    Ok, so 1mu is 1/18 quad, right? \mkern is exactly the command I needed. Just for the record, for -2/18 quad I need a kerning of -2mu, not -9. Thanks! – Christian Apr 4 '13 at 17:39
3

Just tell TeX to add -2/18 of an em. If the command is to be used in text, do

\newcommand{\md}{\textit{M\kern-0.11111em D}}

A kern will never be stretched or shrinked.

Load also amsmath to use it both in text and math:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\md}{\textit{M\kern-0.11111em D}}

\begin{document}
a a a a a a \md{} a a a a a

a a a a a a $\md$ a a a a a

\end{document}

The little difference is due to the fact that the italic correction is applied in text mode, but not in math mode.

enter image description here

  • 1
    if there's a reason to use the cmmi letters rather than \textit the \kern could be expressed instead as \mkern-2mu. – barbara beeton Apr 4 '13 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.