LaTeX nerd LaTeX blog

Tikz brace annotation

An example of placing a brace notation in the document. The result can be found in page 35 of CO 255 notes.

BFS
$x=\begin{pmatrix}
0 & 4 & 0 & 0 & 5
\end{pmatrix}^T$ \tikzmark{right} \tikzmark{2nd}

Obj. value = 12.  \tikzmark{4th}

\begin{tikzpicture}[overlay, remember picture]
  \node[anchor=base] (a) at (pic cs:2nd) {\vphantom{h}}; % push the mark to the top of the line (ie including ascenders)
  \node[anchor=base] (b) at (pic cs:4th) {\vphantom{g}}; % push the mark to the bottom of the line (ie including descenders)
  \node(a')  [right=1.5 em of a] {};
  \node(b')  [right=1.5 em of b] {};
  \node[anchor=west, bpink] (c) at ($(a')!0.5!(b')$) {Optimal Solution};
  \draw [decoration={brace,amplitude=0.5em},decorate,ultra thick,bpink]
  (a.north -| {pic cs:right}) -- (b.south -| {pic cs:right});
\end{tikzpicture}