[Tex/LaTex] How to change default for spacing around binary relations

math-modespacing

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?

Best Answer

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:

enter image description here

\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:

enter image description here

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

Related Question