[Tex/LaTex] How to redefine the “plus” symbol

equationsmacrossymbols

Let's say I don't like the way the + symbol is printed inside equation: is there a way to change its appearance without defining a new command?

More generally, is it possible to create a command without the initial backslash?

Best Answer

Yes, of course.

\documentclass{article}

\begingroup
\catcode`+=\active
\gdef+{\mathbin{\mathrm{blurb}}}
\endgroup
\AtBeginDocument{\mathcode`+="8000 }

\begin{document}
$x+y$
\end{document}

enter image description here

Of course you can think to better definition for the “math active” +. ;-)


A more general approach where you can also use an equivalent of the character being “redefined”.

\documentclass{article}

\makeatletter
\newcommand{\mathactivedef}[3][]{%
  \begingroup\lccode`~=`#2\lowercase{\endgroup\def~}{#3}%
  \if\relax\detokenize{#1}\relax
  \else
    \@ifdefinable{#1}{\mathchardef#1=\mathcode`#2\relax}%
  \fi
  \AtBeginDocument{\mathcode`#2="8000 }%
}
\@onlypreamble{\mathactivedef}
\makeatother

\mathactivedef[\keptplus]{+}{\mathbin{(\mkern-2mu\keptplus\mkern-2mu)}}

\begin{document}

$x+y$

\end{document}

In the optional argument to \mathactivedef you set the equivalent name that you can use in the body of the redefinition.

enter image description here

The previous “blurb” (without keeping the meaning of +) would be

\mathactivedef{+}{\mathbin{blurb}}