# Drawing Arrows in Tables

What is the best way to draw a diagonal line through the following table?

\begin{center}
\begin{tabular}{*{9}{c}}
$e_{1}$ & = & $0$ & $.$ & $d_{1}^{1}$ & $d_{1}^{2}$ & $d_{1}^{3}$ & $d_{1}^{4}$ & $...$ \\
\\
$e_{2}$ & = & $0$ & $.$ & $d_{2}^{1}$ & $d_{2}^{2}$ & $d_{2}^{3}$ & $d_{2}^{4}$ & $...$ \\
\\
$e_{3}$ & = & $0$ & $.$ & $d_{3}^{1}$ & $d_{3}^{2}$ & $d_{3}^{3}$ & $d_{3}^{4}$ & $...$ \\
\\
$e_{4}$ & = & $0$ & $.$ & $d_{4}^{1}$ & $d_{4}^{2}$ & $d_{4}^{3}$ & $d_{4}^{4}$ & $...$ \\
$...$ \\
\end{tabular}
\end{center}


I want the arrow to hit $d_{1}^{1}$, $d_{2}^{2}$, etc.

-
A tip: If you select the entire code block and hit Ctrl + K (or click the {} button above the text field), the code will be marked as such. This also works for inline code. – Torbjørn T. Dec 9 '11 at 18:07

Here's a TikZ variant (\tikzmark was borrowed from one of Andrew Stacey's answers):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}

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

\begin{document}
$\begin{array}{*{9}{c}} e_{1} & = & 0 & . & \tikzmark{a}d_{1}^{1} & d_{1}^{2} & d_{1}^{3} & d_{1}^{4} & ... \\ \\ e_{2} & = & 0 & . & d_{2}^{1} & d_{2}^{2} & d_{2}^{3} & d_{2}^{4} & ... \\ \\ e_{3} & = & 0 & . & d_{3}^{1} & d_{3}^{2} & d_{3}^{3} & d_{3}^{4} & ... \\ \\ e_{4} & = & 0 & . & d_{4}^{1} & d_{4}^{2} & d_{4}^{3} & d_{4}^{4}\tikzmark{b} & ... \\ ... \\ \end{array}$
\tikz[overlay,remember picture] \draw[-triangle 45] ($(a.north east)+(-0.2,0.2)$) -- ($(b.south west)+(0.3,-0.2)$);

\end{document}


For other different predefined arrow tips, refer to Section 23 Arrow Tip Library of the pgf manual.

-
Is there any way to increase the size of the arrowhead in this solution? – jamaicanworm Dec 9 '11 at 19:22
Also, is there any way to fix the result so that $d_{1}^{1}$ and $d_{4}^{4}$ are not oddly lowered beneath the other symbols? – jamaicanworm Dec 9 '11 at 19:24
@jamaicanworm:please see my updated answer. – Gonzalo Medina Dec 9 '11 at 21:45

You can use pst-node and a latex -> dvips -> ps2pdf (or xelatex) compile sequence to produce the following:

\documentclass{article}
\usepackage{pst-node}% http://ctan.org/pkg/pst-node
\begin{document}
$\begin{array}{*{9}{c}} e_{1} & = & 0 & . & \rnode{A}{d_{1}^{1}} & d_{1}^{2} & d_{1}^{3} & d_{1}^{4} & ... \\ \\ e_{2} & = & 0 & . & d_{2}^{1} & d_{2}^{2} & d_{2}^{3} & d_{2}^{4} & ... \\ \\ e_{3} & = & 0 & . & d_{3}^{1} & d_{3}^{2} & d_{3}^{3} & d_{3}^{4} & ... \\ \\ e_{4} & = & 0 & . & d_{4}^{1} & d_{4}^{2} & d_{4}^{3} & \rnode{B}{d_{4}^{4}} & ... \\ ... \\ \end{array}$
\ncline[nodesep=-1.2\baselineskip,linewidth=.4pt]{->}{A}{B}% Draw line
\end{document}


\rnode{<node>}{<stuff>} makes one able to reference <stuff> via <node>. \ncline is used to draw the node connection lines between the specified nodes. Since this draws on the rich pstricks library, you can modify the colour, width, presentation and style of the line as needed.

Note that I've changed your "entirely mathematical tabular" to an array environment, which is its intended use. Additionally, instead of centering it (via the center environment), I've place the entire array in a display math environment (using $ and $).

More pronounced arrow definitions is possible via some of the basic pstricks arrow head modifications. One could use the options (key-value) arrowsize=<dim> <num>, arrowlength=<dim>, arrowinset=<num> or arrowscale=<factor>. Here is some detail from the pstricks documentation (p 28, section 15 Arrowheads and such):

For example, try

\ncline[nodesep=-1.2\baselineskip,linewidth=.4pt,arrowsize=3pt 2]{->}{A}{B}% Draw line

-
Thanks! How can I fix the arrow so that the arrowhead is more pronounced? – jamaicanworm Dec 9 '11 at 18:35
@jamaicanworm: I've added some detail to modify that. Try my last suggestion. – Werner Dec 9 '11 at 18:42
@jamaicanworm: use arrowscale=2 – Herbert Dec 9 '11 at 19:28
@Herbert: Thanks; forgot about that one! – Werner Dec 9 '11 at 19:30
Thanks! I think the TikZ variant is easier for my setup, but I would like to know how to get the arrow bigger for that one as well. – jamaicanworm Dec 9 '11 at 19:56