[Tex/LaTex] How to lower an \xrightarrow

arrowskerningmath-modespacing

I'm referring to a previous post where I asked how to handle lines that are too tall due to stacked mathematical symbols. In particular, the problem occurs in my texts when using \xrightarrow like in the following picture.

enter image description here

One solution mentioned was to lower the arrow produced by \xrightarrow.

I tried this using the \raisebox command but was not successfull. My solution

\newcommand{\myrightarrow}[1]{\ensuremath{\raisebox{-2pt}{$\xrightarrow{#1}$}}}

lowers the arrow correcly but completely ruins the kerning before and after the arrow, i.e., there is no space between the arrow and the preceeding and following symbols. The problem seems to be that \raisebox does not work in math mode and, hence, breaks the kerning.

Does anyone know a way around this?

A minimum working example is

\documentclass{article}
\usepackage{amsmath}
\newcommand{\myrightarrow}[1]{\ensuremath{\raisebox{-2pt}{$\xrightarrow{#1}$}}}
\begin{document}
$a\myrightarrow{b}c$ vs.\ $a\xrightarrow{b}c$
\end{document}

which produces enter image description here

Best Answer

your approach is almost there.

\newcommand{\myrightarrow}[1]{\ensuremath{\raisebox{-2pt}{$\xrightarrow{#1}$}}}   

if instead of \ensuremath you use \mathrel, like this,

\newcommand{\myrightarrow}[1]{\mathrel{\raisebox{-2pt}{$\xrightarrow{#1}$}}}

that will treat the "adjusted" symbol as a relation, which in turn will add the proper spacing around it. you don't need \ensuremath anyway, since it's highly unlikely that you will ever use it outside of a math expression.