How can I remove the space between this
\newcommand{\deref}{\ensuremath{\rightarrowtriangle}\xspace}
$b\deref\mathbf{r}_S$
such that the arrow is as closest to the two surounding characters as possible?
Put one extra pair of braces around the arrow.
\documentclass{article}
\usepackage{stmaryrd,xspace}
\newcommand{\deref}{\ensuremath{{\rightarrowtriangle}}\xspace}
\begin{document}
$b\deref\mathbf{r}_S$
\end{document}
BTW, what is the intention of using ensuremath
and \xspace
here? It is better not to use them.
\mathrel
so adding space) in to ordinary symbol (\mathord
) which doesn't have spaces around.
\ensuremath
and \xspace
are redundant and should disappear.
\ensuremath
:). Added a note now.