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 have a simple table where I would like to add arrows pointing from certain cells to other cells. In the example below, I would like to add one vertical arrow going from Start1 to Finish1 and one horizontal arrow going from Start2 to Finish2. What is the best way to do this?

\documentclass{article}
\usepackage{setspace}
    \doublespacing
\begin{document}
\begin{tabular}{l l}
Word & Start1\\
Word & Finish1\\
Finish2 & Start2\\
\end{tabular}
\end{document}
share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Simple

Just an idea: Use an extra row and an extra column.

The following example does not change the placement of text in the tabular.

Code

\documentclass{article}
\usepackage{setspace,calc}
\doublespacing
\begin{document}
\begin{tabular}{l c l}
    Word    &              & Start1                                       \\
            &              & \makebox[\widthof{Start1}][c]{$\downarrow$} \\
    Word    &              & Finish1                                      \\
    Finish2 & $\leftarrow$ & Start2                                       \\
\end{tabular}
\end{document}

Output

enter image description here

TikZ

You could also use TikZ with all its possibilities.

tabular + remember picture/overlay

Code

\documentclass{article}
\usepackage{setspace,tikz}
\newcommand*{\tn}[2]{\tikz[baseline,remember picture]\node[inner sep=0pt,anchor=base] (#1) {#2};}
\doublespacing
\begin{document}
\begin{tabular}{l l}
    Word             & \tn{s1}{Start1}  \\
    Word             & \tn{f1}{Finish1} \\
    \tn{f2}{Finish2} & \tn{s2}{Start2}  \\
\end{tabular}
\tikz[remember picture,overlay,shorten >=.3333em,shorten <=.3333em]
    \path[->] (s1.south) edge (f1.north -| s1.south) (s2) edge (f2);

\end{document}

Output

enter image description here

\matrix (without tabular)

Code

\documentclass{article}
\usepackage{setspace,tikz}
\usetikzlibrary{matrix}
\doublespacing
\begin{document}
\begin{tikzpicture}
\matrix[name=m,nodes={anchor=base west},matrix of nodes,row sep={2em,between origins},column sep=\tabcolsep]{
    Word & Start 1 \\
    Word & Finish1 \\
    Finish2 & Start 2 \\
};
\path[->] (m-1-2.south) edge (m-2-2.north -| m-1-2.south) (m-3-2) edge (m-3-1);
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
I went with the tikz remember picture/overlay option, but slightly simplified some of the options (looking in the pgf manual and doing some trial and error). But I wouldn't have gotten anywhere if I weren't equipped with your solution from the start. –  Sverre Feb 15 '13 at 21:04
add comment

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.