[Tex/LaTex] is there a way to write −= as one symbol in formulas

math-operatorsrelation-symbols

In programming -=, += and other similar operators are quite popular. But I am unable to write such operator nicely in Latex equations.

For example when I use x += \frac{\partial C}{\partial x} I get the following formula:

enter image description here

The problem is that += are kind of too far apart. Is there any latex operator which allows to write them closer together?

Best Answer

You can use

\[
x \mathrel{+}= \frac{\partial C}{\partial x}
\]

that will add no space between the + and the = signs and treat the whole block as a single relation symbol.

Of course a definition will do better:

\newcommand{\pluseq}{\mathrel{+}=}
\newcommand{\minuseq}{\mathrel{-}=}

and

a \pluseq b \minuseq c

would print

enter image description here

Related Question