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?

5
  • See Why is \[\] preferable to $$?
    – Werner
    Feb 1, 2016 at 23:20
  • 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. Feb 1, 2016 at 23:21
  • Thanks but that wouldn't change the spacing around the ``equals" sign, would it? That was the issue. Feb 2, 2016 at 0: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 Feb 2, 2016 at 0: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? Feb 2, 2016 at 0:55

1 Answer 1

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

3
  • I will give your first alternative a try. It seems to work well and is configurable with having to type ` \( ... \) ` . Thanks! Feb 2, 2016 at 4:05
  • of course, this affects the spacing around all relations in this class of symbols. Feb 2, 2016 at 22:33
  • @barbarabeeton Undoubtedly
    – egreg
    Feb 2, 2016 at 22:35

You must log in to answer this question.

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