[Tex/LaTex] Plus-minus sign in a circle

symbolstikz-pgf

I’m using \oplus and \ominus in a manuscript and I need an “\oplusminus”, that is, a ± in a big circle. Whatever I use will probably end up being published (though maybe only four times in the whole book), so I’m anxious for it to look elegant and natural, not hacked or unclear.

Stealing some code from egreg and Alain Matthes I've come up with the code below. It's fairly similar in proportions to \oplus and \ominus, but the match could be a bit better: I've had to shrink the \pm sign to footnotesize and then stick it into a \raisebox, yet the thickness doesn’t quite match that of \oplus and \ominus.

Does anyone have suggestions for improvement?

enter image description here

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix}
\usepackage{amssymb, amsmath, mathptmx}

\newcommand{\opm}{ 
  \mathbin{
    \mathchoice
      {\buildcirclepm{\displaystyle}}
      {\buildcirclepm{\textstyle}}
      {\buildcirclepm{\scriptstyle}}
      {\buildcirclepm{\scriptscriptstyle}}
  } 
}

\newcommand\buildcirclepm[1]{%
  \begin{tikzpicture}[baseline=(X.base), inner sep=-.8, outer sep=-.65]
    \node[draw,circle] (X)  {\footnotesize\raisebox{.1ex}{$#1\pm$}};
  \end{tikzpicture}%
}

\begin{document}

$\ominus \opm \oplus$

\end{document}

Best Answer

You just need to tweak more parameters, namely use \scalebox or similar, and fine-tune all the numbers for all four sizes:

enter image description here

\documentclass[12pt]{report}

\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix}
\usepackage{amssymb, amsmath, mathptmx}

\newcommand{\opm}{ 
  \mathbin{
    \mathchoice
      {\buildcirclepm{\displaystyle     }{0.14ex}{0.95}{0.05ex}{.7}}
      {\buildcirclepm{\textstyle        }{0.14ex}{0.95}{0.05ex}{.7}}
      {\buildcirclepm{\scriptstyle      }{0.13ex}{0.955}{0.04ex}{.55}}
      {\buildcirclepm{\scriptscriptstyle}{0.08ex}{0.95}{0.03ex}{.45}}
  } 
}

\newcommand\buildcirclepm[5]{%
  \begin{tikzpicture}[baseline=(X.base), inner sep=-#5, outer sep=-.65]
    \node[draw,circle,line width=#4] (X)  {\footnotesize\raisebox{#2}{\scalebox{#3}{$#1\pm$}}};
  \end{tikzpicture}%
}

\begin{document}

\[
\ominus \opm \oplus
\]

\centerline{\(
{\ominus \opm \oplus}_{{\ominus \opm \oplus}_{\ominus \opm \oplus}}
\)}

\end{document}