7

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?

enter image description here

1 Answer 1

8

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}

enter image description here

BTW, what is the intention of using ensuremath and \xspace here? It is better not to use them.

4
  • cool, thanks! what does the two braces do?
    – Gabriel
    Commented Aug 27, 2015 at 15:57
  • 2
    @Gabriel The extra pair of braces converts the relational nature of arrow (\mathrel so adding space) in to ordinary symbol (\mathord) which doesn't have spaces around.
    – user11232
    Commented Aug 27, 2015 at 16:47
  • 1
    As usual: \ensuremath and \xspace are redundant and should disappear.
    – egreg
    Commented Aug 27, 2015 at 16:49
  • @egreg: I forgot \ensuremath :). Added a note now.
    – user11232
    Commented Aug 27, 2015 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .