3

I am using the most recent release of TexLive on my MacBook Air. I am using the packages amsmath, amssymb, scalefnt, graphicx,and subcaption in addition to a journal's package.

Like a previous query How to get less spacing in math mode, I want to reduce the white space in math mode but only when an equation occurs in text, as in $a=b.$ I don't want to automatically reduce the white space when in display-math mode, such as

$$a=b$$

or

\begin{align}
a&=b\\
c&=d
\end{align}

I know that I can do various things in individual equations such as $a{=}b$ or $ a \!=\! b,$ but I don't want to have to do it each time, and the journal might insist on changes in publication, or perhaps my co-author will want to do things differently for some other purpose.

I couldn't see how to use \newcommand or \stackrel in a way that makes such a distinction between equations in text and equations in displaymath, but it ought to be simple using {displaystyle} or something similar. I couldn't figure it out.

Help?

  • It's a rather strange request and no obvious way to easily support it if you use $ to enter math mode. If you use the standard latex alternative \(a=b\) then it is easy as you just need to redefine \( to change the spacing. – David Carlisle Feb 01 '16 at 23:21
  • Thanks but that wouldn't change the spacing around the ``equals" sign, would it? That was the issue. – MidwestGeek Feb 02 '16 at 00:19
  • @Werner @DavidCarlisle Actually, I have never seen anybody in my field (theoretical physics) ever use \( a=b \) instead of $ a=b $ . Why use 4 keystrokes when 2 will do? – MidwestGeek 20 mins ago – MidwestGeek Feb 02 '16 at 00:46
  • @Werner @DavidCarlisle Sorry. Don't know markdown language; another try. Actually, I have never seen anybody in my field (theoretical physics) ever use
    \( a=b \)
    instead of
    $ a=b $.
    Why use 4 keystrokes when 2 will do?
    – MidwestGeek Feb 02 '16 at 00:55

1 Answers1

2

Here's a possibility:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\everymath{\if@display\else\thickmuskip=2mu plus 2mu\fi}
\makeatother

\begin{document}

\begin{center}% just to show the effect
$a=b$
\end{center}
\[
a=b
\]

\end{document}

Alternatively (and preferably), but this requires using \(...\) for inline math:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xpatch}

\xpatchcmd{\(}{$}{$\thickmuskip=2mu plus 2mu }{}{}

\begin{document}

\begin{center}% just to show the effect
\(a=b\)
\end{center}
\[
a=b
\]

\end{document}

Note that $$...$$ will produce reduced spaces, if the first method is used. But this construction should never be used in LaTeX anyway.

enter image description here

egreg
  • 1,121,712