[Tex/LaTex] Defining a new binary operator

math-mode

I am trying to find a way to define the % symbol as a binary operator that behaves essentially like the + symbol. I have heard of the command DeclareMathOperator, but I was under the impression that this was for operators like the logarithm and sine functions. What is an appropriate command? An an example, I would like the following to lines to have similar spacing.

\begin{equation*}
a % b % c
\end{equation*}
\begin{equation*}
a + b + c
\end{equation*}

Best Answer

If using macros to represent the new symbol is fine, then you have a couple of options:

enter image description here

\documentclass{article}
\newcommand{\percA}{\mathbin{\%}}
\newcommand{\percB}{\mathbin{\ooalign{$\hidewidth\%\hidewidth$\cr$\phantom{+}$}}}
\begin{document}
\[\begin{array}{|@{}c@{}|}
  a \percA b \percA c \\[\jot] % Option A
  a \percB b \percB c \\[\jot] % Option B
  a + b + c % Control
\end{array}\]
\end{document}

Option A \percA inserts \% as a binary math symbol using \mathbin{\%}. However, \% is slightly wider than +. That's where option B provides \percB which oversets a zero-width \% with a \phantom{+}.

For the inner working behind \ooalign, see \subseteq + \circ as a single symbol (“open subset”).

Related Question