Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
3  
Welcome to TeX.SX! Could you give an approximate graphic representation of what you're looking for? –  egreg Jul 12 at 17:52
    
Thanks! I added a link to an example. –  user59001 Jul 12 at 18:02
1  
Which package are you using to produce the indices for the tensor? –  Gonzalo Medina Jul 12 at 18:11
    
Please provide a little example! Like this we know what documentclass you are using and we do not have to type the formula. –  LaRiFaRi Jul 12 at 18:11

1 Answer 1

up vote 9 down vote accepted

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}
share|improve this answer
    
Thanks this is exactly what I'm looking for. However, when I try to use your example, I get the error message: ! I can't find file tikzlibrarytikzmark.code.tex'. <argument> ...nput tikzlibrary\pgf@temp .code.tex \catcode \@ =\csname tikz... l.14 \usetikzlibrary{tikzmark} Please type another input file name: –  user59001 Jul 12 at 19:02
1  
@user59001 You're welcome! In order for my code to work you need an updated LaTeX system. In the meantime, I can provide a modified version in some minutes, not requiring the library. –  Gonzalo Medina Jul 12 at 19:09
1  
@user59001 please see my updated answer. The second version of the code should work even with outdated versions of PGF/TikZ. –  Gonzalo Medina Jul 12 at 19:11
    
It works! Thanks so much for your help! –  user59001 Jul 12 at 19:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.