I'm a beginner to LaTeX. I want to add a curved arrow pointing from one row to another. And I also want to add a { on the other side of the table to mark several rows.

 \begin{tabular}{ | l | l |}
   letter & number \\ \hline
   A &  1 \\ \hline
   A &  2 \\ \hline
   A &  1 \\ \hline
   B &  1 \\ \hline
   B &  2 \\ \hline

So my idea is to add a curved arrow outside the table to mark the first line and the third line as "duplicated" on the right and add two { to mark the first 3 rows as "A" and the last 2 rows as "B" on the left.

Any suggestion on how can I do it?


As percusse said in his comment, the most convenient way to go is to exploit the tikzmark macro (just one reference: Adding a large brace next to a body of text).

This solution allows to draw both braces and arrows through:

  1. \drawbrace command;
  2. \drawcurvedarrow command,

as well as to put some annotations via \annote and it exploits a variant of tikzmark macro in which it is possible to customize a bit the position of the marker via shifts.

The code:


\newcommand{\tikzmark}[2][-3pt]{\tikz[remember picture, overlay, baseline=-0.5ex]\node[#1](#2){};}

\tikzset{brace/.style={decorate, decoration={brace}},
 brace mirrored/.style={decorate, decoration={brace,mirror}},

 \tikz[remember picture, overlay]\draw[#1] (#2.center)--(#3.center)node[pos=0.5, name=brace-\thebrace]{};

 \tikz[remember picture, overlay]\draw (#2.center)edge[#1]node[coordinate,pos=0.5, name=arrow-\thearrow]{}(#3.center);

% #1 options, #2 position, #3 text 
 \tikz[remember picture, overlay]\node[#1] at (#2) {#3};


 \begin{tabular}{ | l | l |}
   letter & number \\ \hline
   \tikzmark[xshift=-8pt,yshift=1ex]{x}A &  1\tikzmark[xshift=3.5em]{a} \\ \hline
   A &  2 \\ \hline
   \tikzmark[xshift=-8pt,yshift=-1ex]{y}A &  1\tikzmark[xshift=3.5em]{b} \\ \hline
   \tikzmark[xshift=-8pt,yshift=1ex]{w}B &  1 \\ \hline
   \tikzmark[xshift=-8pt,yshift=-1ex]{z}B &  2 \\ \hline
\drawcurvedarrow[bend left=60,-stealth]{a}{b}
\drawbrace[brace mirrored, thick]{x}{y}
\drawbrace[brace mirrored, thick]{w}{z}

The result:

enter image description here

Remember to compile at least twice to get the result and to put annotations refer to the order in which braces or arrows have been deployed to identify their position (i.e. second brace: brace-2, fourth arrow: arrow-4).

  • 2
    Minor comment: If I understand the OP correctly, he wants the braces left, and the arrow right. Should be a trivial fix though.
    – jmc
    Jun 6 '13 at 9:04
  • Can I add text for the arrow and the braces? "Duplicated" for the arrow and "A" and "B" for the braces.
    – Mike Shaw
    Jun 6 '13 at 9:05
  • @MikeShaw: please see my updated answer. :) Jun 6 '13 at 9:41
  • 1
    @MikeShaw: you're welcome! Jun 6 '13 at 14:48

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.