6

I am trying to create something like the following image in a presentation I am making in beamer using tikz

What I am trying to create

Now obviously creating the equation is easy using a node but I would like to know if there is some way to get access to the coordinates for individual letters/symbols in the node after creating it so that I can more easily draw the arrows and annotations seen here. I could always just do this through visual trial and error but I will be doing this type of thing frequently in the presentation and would like to avoid having to spend time guessing coordinates all the time if possible.

Here is a really simple mwe that provides the equation in a node.

\documentclass{beamer}


\usepackage{tikz}

\newcommand{\rvec}{\mathbf{r}}
\newcommand{\Cmat}{\mathbf{C}}
\newcommand{\trace}[1]{\text{Tr}\left[#1\right]}
\newcommand{\eigval}{\lambda}
\newcommand{\eigvec}{\mathbf{v}}
\newcommand{\rot}[2]{\mathbf{T}_{#1}^{#2}}
\newcommand{\Amat}{\mathbf{A}}

\begin{document}

\begin{frame}
    \centering
    \begin{tikzpicture}
        \coordinate (solution) at (0,0);

        \node (solu) at (solution) {$\rvec_I=-\text{sign}\left(v_3\right)\left[\frac{\trace{\Cmat}-\eigval\trace{\Amat}}{\eigval\left(\eigvec^T\Amat\Amat\eigvec\right)-\eigval\left(\eigvec^T\Amat\eigvec\right)\trace{\Amat}}\right]^{\frac{1}{2}}\rot{I}{C}\eigvec$};

    \end{tikzpicture}
\end{frame}

\end{document}
2
  • You say it is easy to make the equation using a node, then please provide a complete, minimal document which does that. There is no point in people helping you with what you already know. Better they help with the bit you don't yet know. I'd give an example if there was an MWE, but there's not so I can't do much more than recommend using the \subnode macro from the tikzmark library which will let you do what you want.
    – cfr
    Apr 3, 2016 at 20:12
  • @cfr I added the code for the equation in the node. What I was trying to say was that the equation itself wasn't really important because I want to be able to do this for a number of equations. It just happened to be the equation I was working on right now. I think that tikzmark is what I want so I will check that out.
    – Andrew
    Apr 3, 2016 at 20:29

2 Answers 2

8

You can use tikzmark's \subnode command although you have to be a little careful with maths. For example:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark,scopes,decorations.pathreplacing}
\newcommand{\rvec}{\mathbf{r}}
\newcommand{\Cmat}{\mathbf{C}}
\newcommand{\trace}[1]{\text{Tr}\left[#1\right]}
\newcommand{\eigval}{\lambda}
\newcommand{\eigvec}{\mathbf{v}}
\newcommand{\rot}[2]{\mathbf{T}_{#1}^{#2}}
\newcommand{\Amat}{\mathbf{A}}
\begin{document}
\begin{frame}
  \centering
  \begin{tikzpicture}[remember picture]
    \node (solu) {$\rvec_I=-\text{sign}\left(v_3\right)\subnode{r}{$\left[\frac{\trace{\Cmat}-\eigval\trace{\Amat}}{\eigval\left(\eigvec^T\Amat\Amat\eigvec\right)-\eigval\left(\eigvec^T\Amat\eigvec\right)\trace{\Amat}}\right]$}^{\frac{1}{2}}\subnode{T}{$\rot{I}{C}$}\subnode{v}{$\eigvec$}$};
    {[draw=blue, <-]
      \draw  (v.north) -- +(-5pt,25pt) node [anchor=east, align=right] {eigenvector:\\corresponds to eigenvalue of unique sign};
      \draw (T.south) -- +(-5pt,-20pt) node [anchor=north, align=center] {rotation:\\camera to inertial};
    }
    \draw [draw=blue, decorate, decoration={brace, mirror, amplitude=5pt}] ([xshift=5pt]r.south west) -- ([xshift=-5pt]r.south east) node [midway, below, anchor=north, yshift=-2.5pt] {range};
  \end{tikzpicture}
\end{frame}
\end{document}

marked equation

5

I do not have enough reputation to add a comment so I am adding this as an answer. As of May 2019, \subnode in tikzmark is math-aware. As a result, the above answer by cfr results in a compilation error as the (now) extra $ signs are interpreted as exiting and re-entering math mode. The following should suffice when using the most recent version of tikzmark:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark,scopes,decorations.pathreplacing}
\newcommand{\rvec}{\mathbf{r}}
\newcommand{\Cmat}{\mathbf{C}}
\newcommand{\trace}[1]{\text{Tr}\left[#1\right]}
\newcommand{\eigval}{\lambda}
\newcommand{\eigvec}{\mathbf{v}}
\newcommand{\rot}[2]{\mathbf{T}_{#1}^{#2}}
\newcommand{\Amat}{\mathbf{A}}
\begin{document}
\begin{frame}
  \centering
  \begin{tikzpicture}[remember picture]
    \node (solu) {$\rvec_I=-\text{sign}\left(v_3\right)\subnode{r}{\left[\frac{\trace{\Cmat}-\eigval\trace{\Amat}}{\eigval\left(\eigvec^T\Amat\Amat\eigvec\right)-\eigval\left(\eigvec^T\Amat\eigvec\right)\trace{\Amat}}\right]}^{\frac{1}{2}}\subnode{T}{\rot{I}{C}}\subnode{v}{\eigvec}$};
    {[draw=blue, <-]
      \draw  (v.north) -- +(-5pt,25pt) node [anchor=east, align=right] {eigenvector:\\corresponds to eigenvalue of unique sign};
      \draw (T.south) -- +(-5pt,-20pt) node [anchor=north, align=center] {rotation:\\camera to inertial};
    }
    \draw [draw=blue, decorate, decoration={brace, mirror, amplitude=5pt}] ([xshift=5pt]r.south west) -- ([xshift=-5pt]r.south east) node [midway, below, anchor=north, yshift=-2.5pt] {range};
  \end{tikzpicture}
\end{frame}
\end{document}

Tikzmark subnode example

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .