# How to change default for spacing around binary relations?

In TeX and LaTeX, the math binary relations (like =, \parallel, <, \le ...) have a default (rubber-length) spacing to either side, which is too large for my liking. How can reduce it?

## migrated from stackoverflow.comMay 12 '12 at 11:30

This question came from our site for professional and enthusiast programmers.

• @Werner thanks for your answer! Now I know what to do (of course setting these skips to 0em is not what I want either). – Walter May 13 '12 at 16:31

This answer doesn't encourage modifying the spaces, since TeX does a great job already. It merely discusses the concepts of spacing around math elements.

Spacing around math operators are discussed in the mathmode documentation (section 11 Space, p 28). Here's an example: \documentclass{article}
\newcommand{\func}{f(x) = x^2 + 3x_0 \cdot \sin x}% Function
\begin{document}
$\renewcommand{\arraystretch}{1.5} \begin{array}{rl} \mbox{default} & \func \\ \verb|\thinmuskip=0mu| & \setlength{\thinmuskip}{0mu} \func \\ \verb|\medmuskip=0mu| & \setlength{\medmuskip}{0mu} \func \\ \verb|\thickmuskip=0mu| & \setlength{\thickmuskip}{0mu} \func \\ \mbox{all set to zero} & \setlength{\thinmuskip}{0mu}\setlength{\medmuskip}{0mu} \setlength{\thickmuskip}{0mu} \func \end{array}$
\end{document}


To manually adjust the amount of space around a symbol, you can change it to an ordinal symbol by wrapping it in braces - for example {=} - and then add the space your want around it: \,{=}\,. Here's another example: \documentclass{article}
\begin{document}
$\begin{array}{rc} \mbox{default} & x = x \\ \verb|\mathbin| & x \mathbin{=} x \\ \verb|\mathrel| & x \mathrel{=} x \\ \verb|\mathord| & x \mathord{=} x \\ \verb|{ }| & x {=} x \\ \verb|\,{ }\,| & x\,{=}\,x \\ \verb|\;{ }\;| & x\;{=}\;x \\ \verb|\:{ }\:| & x\:{=}\:x \end{array}$
\end{document}


Negative spaces, although not shown is obtainable via \!. Of course, you can also use other spacing macros like \hspace.

Also see What is the difference between \mathbin vs. \mathrel? for a discussion between the difference in spacing around binary and relational operators.

Werner already explained that you have to change \thickmuskip if you want to change the default. However, I don't quite agree with Werner that TeX does a great job already; I also think that sometimes the spacing to either side is too large. The default \thickmuskip is

5mu plus 5mu


so it can stretch from 5mu up to as much as 10mu. (This stretching will only happen for inline math, not in displayed math.) While I like the 5mu, I think the added stretch is too much, and I think a little shrink is OK, too. So my preamble usually contains

\thickmuskip=5mu plus 3mu minus 1mu


Thus, I don't change the "standard" 5mu, but the space can only stretch to 8mu, and I allow it to shrink to 4mu. (If you wonder what a mu is: it's one 18th of an em from family 2, the symbols family.)

For comparison, the following picture shows in the first line how it looks with the defaults, and in the second line how it looks with my modifications It's not much of a difference, but I like the second line better. Note that the default \medmuskip (used around binary operations) is

4mu plus 2mu minus 4mu


i.e., it can shrink to zero. Personally, I don't like that either, so I have

\medmuskip=4mu plus 2mu minus 3mu


in my preamble – see the difference in the picture, too!

• Yes, yes, and yes! I wholeheartedly agree with you, good sir. It might be nice to add that 1 \fam2 em is 18mu (or maybe putting it the other way around)? – morbusg Jun 5 '12 at 13:46
• @morbusg: Is it OK like I did? – Hendrik Vogt Jun 5 '12 at 13:55
• Yes, that's actually much nicer way to put it. :-) – morbusg Jun 5 '12 at 14:11
• @HendrikVogt: Very good disagreement! – Werner Jun 8 '12 at 17:53
• @Werner: Thanks for the edit! (So, you still disagree? :-)) – Hendrik Vogt Jun 8 '12 at 18:00