[Tex/LaTex] How to horizontally merge two symbols

symbols

This is a very short question and hopefully there's a short answer. I know I can use \stackrel{top}{bot} to vertically merge two symbols into one with top on top and bot on the bottom. Is there something similar for left-right merging? I ask because I want to make a += symbol (for an additive update step in code). If there's already a symbol for that, that would be OK too.

Best Answer

For this problem the solution is quite simple:

\mathrel{+}=

so that the combination will be treated as a relation, since = is a relation and TeX never puts space between two relation symbols. So

$a \mathrel{+}= b$

will be rendered as

enter image description here

You might want to define a shorthand

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

and input the formula above as

$a \pluseq b$
Related Question