[Tex/LaTex] Arrow pointing to subscript in equation

arrowsequationslabelstikz-arrows

I'm writing an equation for the components of a contracted tensor. I want to label one of the lower (covariant) indices with the text "rth positon," and have an arrow pointing to it from below. Any way to do this easily?

Something like this:

enter image description here

I'd also like to be able to do something like this from above so I can label upper (contravariant) indices.

Best Answer

Here's an example using the tikzmark library for TikZ; there was no information in the question regarding how the formula was typeset, but the idea will still apply: place marks using \tikzmark and then use the marks to draw the arrows and place the accompanying texts:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\[
A_{1\ldots\tikzmark{a}p\ldots\tikzmark{b}q\ldots4}
\]

\begin{tikzpicture}[remember picture,overlay]
\draw[<-] 
  ([shift={(2pt,-2pt)}]pic cs:a) |- ([shift={(-10pt,-10pt)}]pic cs:a) 
  node[anchor=east] {$\scriptstyle a\text{th position}$}; 
\draw[<-] 
  ([shift={(2pt,-2pt)}]pic cs:b) |- ([shift={(14pt,-10pt)}]pic cs:b) 
  node[anchor=west] {$\scriptstyle b\text{th position}$}; 
\end{tikzpicture}

\end{document}

enter image description here

If, for some reason, the tikzmark library is not available, then one can use:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand\tikzmark[1]{\tikz[remember picture,overlay]\coordinate (#1);}

\begin{document}

\[
A_{1\ldots\tikzmark{a}p\ldots\tikzmark{b}q\ldots4}
\]

\begin{tikzpicture}[remember picture,overlay]
\draw[<-] 
  ([shift={(2pt,-2pt)}]a) |- ([shift={(-10pt,-10pt)}]a) 
  node[anchor=east] {$\scriptstyle a\text{th position}$}; 
\draw[<-] 
  ([shift={(2pt,-2pt)}]b) |- ([shift={(14pt,-10pt)}]b) 
  node[anchor=west] {$\scriptstyle b\text{th position}$}; 
\end{tikzpicture}

\end{document}