1

I want to create a subscript-labeled arrow over some text. At the moment this arrow is only over a single letter, but I'd like to find the general solution, provided one exists.

I want the result to look something like $\overrightarrow{t}$, but with say a subscript n beneath the arrow, to the right-ish of the t.

This is common enough that I know the answer should exist, but my searching doesn't return the answer.

1
  • If someone knows of a package with this functionality already present, I'd like to hear about it. Commented Mar 26, 2018 at 19:46

1 Answer 1

2

You could just copy the definition of \overrightarrow and modify it:

\documentclass{article}

\usepackage[T1]{fontenc}

\usepackage{mathtools}

\makeatletter
    \newcommand\iorarrow[2][n]{%
        \mathpalette{\overarrow@{\arrowfill@\relbar\relbar%
            {\rightarrow\mkern -2mu\smash{\mathrlap{_{#1}}}}%
        }}%
        {\,#2\,}%
        \mkern -2mu\hphantom{_{#1}}%
    }
\makeatother

\begin{document}

\(a \iorarrow{t} b\)

\(a \iorarrow[x]{tuv} b\)

\end{document}

output of the code above

  • The \mkern -2mu (after \rightarrow) puts the index closer to the arrow.

  • The \, (in {\,#2\,}) makes the arrow a bit wider if #2 is wide. (Otherwide the arrow tip would end over the right border of #2 and the index would look rather like an exponent.)

  • The last line of the definition just adds some horizontal space (of the width added by the index) in order to prevent the index from being placed over (or on top of) the following symbol. (If you think the b in the example is too close to the index, you can remove the \mkern here or alter the -2mu to your liking.)

4
  • Oooh, that’s sneaky work! Commented Mar 25, 2018 at 17:18
  • To your knowledge, is there not some package that has this feature already built-in? I'm so hesitant to reach for tools that look so low level, and beyond my ability to easily understand and modify and maintain, when I would imagine I'm not the first person to encounter this problem, and that it should already exist. Commented Mar 26, 2018 at 16:25
  • I do not know of any such package. That does not mean much, however the fact that nobody else has commented the suggestion to use an existing package indicates that there really is none. Regarding your aversion to using low level commands: Since we do not change any registers or even macros here, you really have nothing to worry about. In case I missed something, the worst that can happen is that your output doesn't look right. In that case, just come back and ask a question about it. ;-)
    – schtandard
    Commented Mar 26, 2018 at 17:21
  • Good enough for me, certainly in the meantime. Commented Mar 26, 2018 at 19:46

You must log in to answer this question.

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