# \xrightarrow not changing size with \scriptstyle and \scriptscriptstyle

Consider the following MWE.

\documentclass[fontsize=12pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\begin{document}
\begin{align*}
\scriptstyle v\xrightarrow{e}w &\quad \scriptstyle v\overset{e}\rightarrow w \\
\scriptscriptstyle v\xrightarrow{e}w &\quad \scriptscriptstyle v\overset{e}\rightarrow w
\end{align*}
\end{document}


The result looks like this:

While \rightarrow is changing in size when using \scriptstyle or \scriptscriptstyle, \xrightarrow is not and produces arrows of wrong size and hence height, as well as too little spacing.

Is there a way to fix \xrightarrow?

• You might want to reduce the MWE even further and removing the libertine stuff as well – daleif Sep 8 '17 at 9:13

According to its definition, \xrightarrow only provides normal size and it won't scale in subscripts.

You can define a (less efficient) variant:

\documentclass[fontsize=12pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
%\usepackage{libertine}
%\usepackage[libertine]{newtxmath}

\newcommand{\sxrightarrow}[2][]{%
\mathrel{\text{$\xrightarrow[#1]{#2}$}}%
}

\begin{document}

\begin{align*}