The situation
In the standard Computer Modern (and also in Latin Modern) the math-mode minus and plus symbols are, in some font sizes, not of the same width. This causes slight misalignments in formulas. I would like to redefine the math-mode -
to have the same width as +
, in any font size.
The example
\documentclass[12pt]{standalone}%
%
\begin{document}%
\newlength{\test}%
\begin{tabular}{rll}%
textstyle & \fbox{$-$} & \settowidth{\test}{$-$}\the\test\\
textstyle & \fbox{$+$} & \settowidth{\test}{$+$}\the\test\\
scriptstyle & \fbox{$\scriptstyle-$} & \settowidth{\test}{$\scriptstyle-$}\the\test\\
scriptstyle & \fbox{$\scriptstyle+$} & \settowidth{\test}{$\scriptstyle+$}\the\test\\
scriptscriptstyle & \fbox{$\scriptscriptstyle-$} & \settowidth{\test}{$\scriptscriptstyle-$}\the\test\\
scriptscriptstyle & \fbox{$\scriptscriptstyle+$} & \settowidth{\test}{$\scriptscriptstyle+$}\the\test\\
\end{tabular}%
\end{document}%
This shows that the minus is wider than the plus in both 12pt and 6pt math fonts, but has the same width in 8pt.
The solution?
I'll post one below, but I am not happy with it.
Best Answer
Note: I take a very different view of the original question in the following discussions and solutions. And, no, I do not like the idea of making
+
and/or-
active in math mode just for alignment purposes.This problem exists not only for Computer Modern/Latin Modern, and not only for the
+
and-
pairWith the default Computer Modern family (or the Latin Modern family), the width difference problem is barely visible. However, with other math fonts such as
newtxmath
,newpxmath
andmtpro2
, this problem is much more visible and it goes beyond the+
and-
pair. The following MWE illustrates this point:We may now conclude that the width differences are by design. More importantly, the behavior is unpredictable across different math fonts and across different design/optical sizes. Clearly, any solutions that involve active
+
,-
,=
and so on would be ineffective and dangerous.How can we get mono-width symbols?
Instead of making characters active (and possibly breaking other things), I propose two specially designed commands:
and
The names are inspired by “proportional versus tabular figures”. Each of the two commands essentially makes a box of fixed width according to some “standard symbol”, then it puts the actual symbol horizontally centered. Note that
\mathpalette
is needed to get the correct math style. Of course, this method of aligning tabular-like math can be applied to any math fonts.Here is a MWE:
Voilà!!!
For most “one-liner” equations, there are no need for mono-width symbols. However, when typing inside tabular-like environments, e.g., tables, arrays, cases, matrices, etc., horizontal alignment may be crucial.