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

2
  • 1
    I guess that the math spaces \quad or ` \!` or others are rubber spaces. Try to use \mbox{\ensuremath{M\!\!\:D}}.
    – Sigur
    Commented Apr 4, 2013 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
    Commented Apr 5, 2013 at 12:11

2 Answers 2

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.

7
  • How to use those last commands on your code?
    – Sigur
    Commented Apr 4, 2013 at 16:41
  • 1
    @Sigur I have now explained this in my answer. Commented Apr 4, 2013 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
    Commented Apr 4, 2013 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. Commented Apr 4, 2013 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
    Commented Apr 4, 2013 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
  • 1
    if there's a reason to use the cmmi letters rather than \textit the \kern could be expressed instead as \mkern-2mu. Commented Apr 4, 2013 at 17:09

You must log in to answer this question.

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