I am trying to make a table that shows how an element moves from location in the table to another. I would like to add a vector that starts at the first element and goes to the second element.

How do I do this?

I've tried putting the table in a picture but I get the error: Not in outer par mode.

\textbf{Something here} &  \\ \hline
A & F \\ 
B & A \\ 
C & G \\ 
D & H \\ 
E & I%

I want a vector pointing from A in left column to A in right column.

And I've tried putting the picture in a cell but the \vector commands don't show up in the PDF.

I have also searched Google but can't find how to do it.

Can anyone help?

  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. For example, where do you use \vector or what package defines this command? Also, does this \vector stretch in a straight line from one cell to the other? – Werner Mar 7 '12 at 18:30
  • Added MWE (which is misleading because it doesn't work) and yes it does stretch in a straight line from one cell to the other. Vector is a part of LaTeX and is not a part of any package that I know of. – Fred Mar 7 '12 at 18:48

You can use Andrew Stacey's tried and tested tikzmark idea, first posted here

Adding a large brace next to a body of text

and repeated in many examples since.

The idea is to set a node at each of the places in your table, and then connect the two nodes afterwards (using overlay and remember picture). You can tweak the placement of the connections using the calc tikz library.

enter image description here


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

    \textbf{Something here} &  \\ \hline
    A\tikzmark{firstmarker} & F \\ 
    B & A\tikzmark{secondmarker} \\ 
    C & G \\ 
    D & H \\ 
    E & I%

\tikz[overlay,remember picture]\draw[red,->] ($(firstmarker)+(.2em,0.5em)$)--($(secondmarker)+(-.6em,0.5em)$);
  • I haven't heard of tikzmark, but that is exactly what I want. Thanks! – Fred Mar 7 '12 at 19:12
  • @Fred you're welcome! Note that tikzmark is just the name of the newcommand- it's the tikz package that does the work. – cmhughes Mar 7 '12 at 19:23

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.