44

I am looking for an alternate to the \pm symbol, and wondering if I am the only one bothered by it as I see that this has not been asked yet.

I have attempted to define one using my standard overkill solution using tikz. The one on the left is the standard \pm, and the one on the right is my version where there is a slight separation between the minus and the plus:

enter image description here

So, is there a better solution than that one I have. Or is there some typesetting standard that states that those two symbols are supposed to touch?

References:

Code:

\documentclass{article}
\usepackage{tikz}

\newcommand{\Mypm}{\mathbin{\tikz [x=1.4ex,y=1.4ex,line width=.1ex] \draw (0.0,0) -- (1.0,0) (0.5,0.08) -- (0.5,0.92) (0.0,0.5) -- (1.0,0.5);}}%

\begin{document} [ x \pm f \Mypm y ] \end{document}

Peter Grill
  • 223,288

4 Answers4

16

I wouldn't use rules (either tikz or primitive TeX ones) to fake characters unless absolutely desperate: it's impossible to make them look like font glyphs at all sizes due to the different way the renderer will snap rules and hinted fonts to pixel boundaries.

So I would strongly recommend going with a font whose glyph you prefer, or failing that, shifting a - and + from the font into appropriate positions.

The stix fonts do seem to have a small gap as you'd want. Currently it would be easier to access them from xetex, although standard tex support or then has long been promised.

David Carlisle
  • 757,742
16
\documentclass{article}
\makeatletter
\newcommand{\mypm}{\mathbin{\mathpalette\@mypm\relax}}
\newcommand{\@mypm}[2]{\ooalign{%
  \raisebox{.1\height}{$#1+$}\cr
  \smash{\raisebox{-.6\height}{$#1-$}}\cr}}
\makeatother
\begin{document}
$a+b\mypm c X_{\mypm_{\mypm}}(\mypm)$
\end{document}

I'd never recommend this, however. There's a reason why the \pm symbol sits on the baseline, rather than be centered to the axis, which makes it difficult to split the two parts. In any case, use "plus or minus" very sparingly other than for denoting error intervals, as it's generally very ambiguous.

enter image description here

egreg
  • 1,121,712
12

After smashing and declaring as a binary operator the following seems to be convenient:

\documentclass{article}
\usepackage{amsmath,lipsum}
\newcommand{\mypm}{\mathbin{\smash{%
\raisebox{0.35ex}{%
            $\underset{\raisebox{0.5ex}{$\smash -$}}{\smash+}$%
            }%
        }%
    }%
}
\begin{document}
Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna.  
$A\mypm B$ \lipsum[3]
\[
A\mypm B \mypm B \mypm x \mypm f \mypm 0.001\%
\]
\end{document}

It might still need tweaking in terms of scaling and vertical positioning.

enter image description here

percusse
  • 157,807
  • the toop of the plus really shouldn't be higher than the height of the tallest letter or punctuation symbol. try this between parentheses, and you'll see the problem. – barbara beeton Apr 05 '12 at 13:41
  • This solution won't scale when used in a subscript, say, for example \[\lim_{x\ti\mypm0}\]. A solution should involve \mathpalette or \mathchoice somehow, I guess. – cgnieder Apr 05 '12 at 13:49
  • @barbarabeeton you are right and it needs further tweaks. But I actually feel that PeterGrill is better at these things than me also I am counting on the answer of David in this one. If I have time I'll try to update it but if you have a fix please post it as an answer or just feel free to edit mine. – percusse Apr 05 '12 at 14:10
  • @cgnieder You are right too and please refer to the answer of David in the link on my previous comment to barbara. – percusse Apr 05 '12 at 14:11
5

With regards to typographic "standards": you can browse fonts (say at myfonts.com) and enter "±" as your sample text (use unicode). Scanning popular and top fonts seems to indicate that the majority separate the two components. Every one of the bestsellers that defines the glyph appropriately has a separation for example (4 April 2012). Unfortunately, many of the math fonts don't have this glyph at the unicode code-point, so a more relevant comparison is difficult (but possible by exploring the glyph-browser).

Still, looking through all my fonts, and browsing the font databases shows that it is certainly not a typographic standard to attach the two operators: the opposite appears to be much more common.

mforbes
  • 5,571
  • 8
    The problem with "normal" fonts is that symbols like ± or ≤ are not designed at all to be used in formulas, but only with numbers, which means the design constrains are different: see for example Microsoft's Math Symbols Design Standards. A real math font must have its symbols aligned on the math axis and Knuth wanted the ± to sit on the baseline (which is not the case of ≤). As the + sign must not be too small (or else the readability of formulas suffer), having a separation on the ± would mean the + would be too high. – Philippe Goutet Apr 05 '12 at 05:00