How to produce symbol with arrow under

My goal is to create a symbol with an arrow and a variable length argument under it.

The top line in the picture shows how I want the symbol to look, generated using \underset{\quad \ \rightarrow k+1}{r}, however the spacing I have to introduce to the underset creates an unwanted space between this and A. Additionally, this spacing must be tuned to match the length of the variable length argument.

The second option uses \underrightarrow{r}_{k+1}, which removes the unwanted space, but uses an uglier arrow and places the subscript too high.

Can anyone think of a more elegant solution for me?

• A similar way with these solutions: tex.stackexchange.com/questions/395603/… may help – koleygr Oct 20 '17 at 12:24
• You will meet a lot of nice people showing you how to typeset this weird thing, but are you required to use such a construction? It is very hard to read—the letter r is just too thin to support some kind of "limits" like \lim or \sum do. – jknappen Oct 20 '17 at 14:37

\documentclass[a4paper, 11pt]{article}
\usepackage{amsmath}

\begin{document}

text

\fbox{$A\underset{\overset{\rightarrow}{}}{r}_{\overset{k+1}{}}$}

\fbox{$A\underset{\rightarrow}{r}_{k+1}$}

text
\end{document}


Like this, with the lapping commands from stackengine?

\documentclass{article}

\usepackage{stackengine}

\newcommand\isom{\mathrel{\stackon[-0.1ex]{\makebox*{\scalebox{1.08}{\AC}}{=\hfill\llap{=}}}{{\AC}}}}
\newcommand\nvisom{\rotatebox[origin=cc] {-90}{$\isom$}}
\newcommand\visom{\rotatebox[origin=cc] {90} {$\isom$}}

\begin{document}

$A \stackMath\brlap[1.4ex]{\scriptstyle\rightarrow k+1}r = B$%

\end{document}


With an array:

\documentclass{article}

\newcommand{\subarrow}[2]{%
\mathord{% ensure math mode and grouping
\renewcommand{\arraystretch}{0}%
\begin{array}[t]{@{}c@{}l@{}}
#1\\
\scriptstyle\rightarrow&\scriptstyle#2
\end{array}
\kern\scriptspace
}%
}

\begin{document}

$A\subarrow{r}{k+1}B$

\end{document}


Here is the solution I came to based on koleygr's comment

\usepackage{stackengine}
\stackengine{1pt}{$\, r$}{$\scriptstyle \rightarrow k+1$}{U}{l}{F}{F}{S}


and here is this wrapped with an xparse command of the form \fut{r}_{k+1}^T with optional subscript and superscript

\NewDocumentCommand \fut
{m E{\_\^}{{}{}}}
{
\stackengine{1pt}
{$\, {#1}^{#3}$}
{$\scriptstyle \rightarrow {#2}$}
{U}{l}{F}{F}{S}
}


• nice... Remember to come back and accept your answer next time – koleygr Oct 20 '17 at 12:47

if I understood the question correctly.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$A_{\overset{r}{\rightarrow}k+1}$
\end{document}