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?
[Tex/LaTex] How to change default for spacing around binary relations
math-modespacing
Related Solutions
Spacing around operators and relations in math mode are governed by specific skip lengths: \thinmuskip
(default is 3mu
), \medmuskip
(default is 4mu plus 2mu minus 4mu
) and \thickmuskip
(default is 5mu plus 5mu
). All are given in m
ath u
nits.
Here is an illustration of how a modification (setting them to 0mu
) to these lengths affect the output (I've removed the forced space after \times
):
\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\verb|Normal:| \par
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\bigskip
\begingroup
\verb|\thinmuskip=0mu:| \par
\setlength{\thinmuskip}{0mu}
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\endgroup
\bigskip
\begingroup
\verb|\medmuskip=0mu:| \par
\setlength{\medmuskip}{0mu}
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\endgroup
\bigskip
\begingroup
\verb|\thickmuskip=0mu:| \par
\setlength{\thickmuskip}{0mu}
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\endgroup
\end{document}
Grouping (\begingroup
...\endgroup
) localizes the effect of the length modification. \medmuskip
is used around binary operators (like \times
) and \thickmuskip
is used around binary relations (like =
). It's best to stick to the standard LaTeX spacing rather that insert your own.
A good source of reading material on this is Herbert Voss' mathmode document. In particular, section 11 Space (p 28 onward).
Inline math forms part of the regular text construction. That's why there is some stretch in \medmuskip
and \thickmuskip
, which allows spacing around math operators/operands to change depending on their location within the paragraph text. Removing this glue allows for a more consistent setting of inline expressions. See Keeping the distance between mathematical symbols consistent?
However, it can also have some problematic effects with regards to line breaking, as is shown below:
\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\verb|Normal:| \par
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\bigskip
\begingroup
\verb|Math glue removed:| \par
\setlength{\medmuskip}{1\medmuskip}
\setlength{\thickmuskip}{1\thickmuskip}
Here again, four different simulations are run on networks of size
$C^{G} = 25 \times 25 = 625$, $C^{G} = 50 \times 50 = 2500$,
$C^{G} = 250 \times 250 = 62500$, and $C^{G} = 500 \times 500 = 250000$. Next,
for each network, the weights of the idiothetic connections are collected and
plotted based on radial distance, finally, they are averaged out over all
neurons and shifted and set about the centre of the graph.
\endgroup
\end{document}
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: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: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.