9

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.

  • 3
    Welcome to TeX.SX! Could you give an approximate graphic representation of what you're looking for? – egreg Jul 12 '14 at 17:52
  • 1
    Which package are you using to produce the indices for the tensor? – Gonzalo Medina Jul 12 '14 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 '14 at 18:11
13

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}
  • 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: – ಠ_ಠ Jul 12 '14 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 '14 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 '14 at 19:11
2

A simpler, yet not exactly identical, solution without using tikz is:

\documentclass{article}

\begin{document}

\[
\begin{array}{c}
    A_{1\ldots pq\ldots4}\\
    \;\;\swarrow\;\searrow\\
    a\mbox{th position}\qquad b\mbox{th position}
\end{array}
\]

\end{document}

enter image description here

2

Using stacks:

\documentclass{article}
\usepackage{amsmath,stackengine}
\stackMath
\begin{document}
\[
\sum_{p,q}g^{pq}A_{1\ldots 
\stackengine{2pt}
  {\scriptstyle p}
  {\scriptstyle\text{$a$th position}\rule[1pt]{2ex}{.5pt}\mkern-5mu\raisebox{1.1pt}
  {\stackon[-.1pt]{\rule{.5pt}{9.1pt}}{\uparrow}}}{U}{r}{F}{T}{S}
\ldots 
\stackengine{2pt}
  {\scriptstyle q}
  {\scriptstyle\raisebox{1.1pt}{\stackon[-.1pt]{\rule{.5pt}{9.1pt}}{\uparrow}}
  \mkern-5mu\rule[1pt]{2ex}{.5pt}\text{$b$th position}}{U}{l}{F}{T}{S}
\ldots4}^{i_1\ldots i_r}
\]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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