Beamer – Point Arrow to Specific Position and Add Text

beamer

There is a similar question on this link: How to draw an arrow to a specified position in a frame and write some notes on the another end of arrow?, but I still have problems in applying it in my case.
What I want is to put color on part of the equation and then point out this part and indicate it to $\beta_0$ and $\beta_i$, which should look like as image

According to the solution of this link, I define a command \newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};} then put this syntax \tikzmark{t1} at the end of the part that I want to be selected and point to $\beta_0$, then start a new

\begin{itemize}[<+-| alert@+>]
        \item  \tikzmark{n1} $\beta_0$
    \end{itemize}

However, it does not work. It turns out to be, which is not what I want. I think my case is a little bit different with the question in the link, so I don't know how to successfully apply it to my case. Actually, I don't want to start with a new item, just add $\beta_0$ and $\beta_i$ at the end of the arrow. Could someone indicate me how realize it? Thank you.

 \documentclass{beamer}
     \usepackage{tabularx} 
     \usepackage[customcolors,norndcorners]{hf-tikz}
     \usetheme{Madrid}
     \newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};}

    \title{An empirical Bayes approach to predict
    radiation-induced toxicity using large-scale
    SNPs}

    \author[C.e]{Ch   \\ \vspace{5mm}}

    \institute[University]{\textbf {  University}}
    \date{11 September 2017}



    \subject{Theoretical Computer Science}



    % Let's get started
    \begin{document}

    \begin{frame}
      \titlepage 
    \end{frame}

    \section{Introduction}

    \subsection{The general problem}
    \begin{frame}{Modelling}
      \begin{itemize}
      \item {\textbf{SNP model}

      \begin{equation}\label{bernoulli}
    X_{ik}|Y \stackrel{iid}{\sim}
    \begin{cases} 
          \mathrm{Bernoulli}($\mathrm{p}_{i+}$) & \text{when} \hspace{4mm} Y= +1, \\
          \mathrm{Bernoulli}($\mathrm{p}_{i-}$) & \text{when} \hspace{4mm} Y =-1.
       \end{cases}
    \end{equation}


      }
      \item { \textbf{Prediction rule} 
         \scalebox{0.87}{
         \hfsetfillcolor{green!10}
      \hfsetbordercolor{green!10}
         \begin{equation}\label{predictionrule}
    \log \frac{\mathrm{P}(Y=+1|X)}{\mathrm{P}(Y=-1|X)}=\tikzmarkin{c}(0.05,-0.6)(-0.05,0.65) \log\frac{\mathrm{P}(Y=+1)}{\mathrm{P}(Y=-1)} +  \sum_{i=1}^{N}\left(\log\frac{1-\mathrm{p}_{i+} }{1-\mathrm{p}_{i-} } \right) \tikzmarkend{c}  \tikzmark{t1}

    + \tikzmarkin{a}(0.05,-0.6)(-0.05,0.65)\sum_{i=1}^{N}\left(\log\frac{\mathrm{p}_{i+} (1-\mathrm{p}_{i-}) }{\mathrm{p}_{i-} (1-\mathrm{p}_{i+} )}\right) \tikzmarkend{a} X_i.
    \end{equation}\\
      }}

      \end{itemize}

      \begin{itemize}[<+-| alert@+>]
        \item  \tikzmark{n1} $\beta_0$
    \end{itemize}
    \end{frame}
    \end{document}


  [1]: https://tex.stackexchange.com/questions/199218/how-to-draw-an-arrow-to-a-specified-position-in-a-frame-and-write-some-notes-on
  [2]: https://i.stack.imgur.com/mAYTJ.jpg

Best Answer

You had some errors in your code, e.g the dollar signs inside the cases environment. Not sure if you like it, but I suggest a different way of typesetting that last equation, that doesn't involve a scalebox.

There's no need to use a tikzmark for the betas as well, those can be added as part of the tikzpicture used to draw the arrows.

output of code

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{tabularx} 
\usepackage[customcolors,norndcorners]{hf-tikz}
\usetikzlibrary{calc} %% added
\usetheme{Madrid}

\begin{document}

\begin{frame}{Modelling}
\begin{itemize}
  \item \textbf{SNP model}

   \begin{equation}\label{bernoulli}
     X_{ik}|Y \stackrel{iid}{\sim}
     \begin{cases} 
      \mathrm{Bernoulli}(\mathrm{p}_{i+}) & \text{when }  Y= +1, \\
      \mathrm{Bernoulli}(\mathrm{p}_{i-}) & \text{when }  Y =-1.
     \end{cases}
   \end{equation}

  \item  \textbf{Prediction rule} 
     \hfsetfillcolor{green!10}
     \hfsetbordercolor{green!10}
     \begin{equation}\label{predictionrule}
        \log \frac{\mathrm{P}(Y=+1|X)}{\mathrm{P}(Y=-1|X)} =
        \begin{aligned}[t]
          \tikzmarkin{c}(0.05,-0.6)(-0.05,0.65)
          \log\frac{\mathrm{P}(Y=+1)}{\mathrm{P}(Y=-1)} +
          \sum_{i=1}^{N}\left(\log\frac{1-\mathrm{p}_{i+} }{1-\mathrm{p}_{i-} } \right)
          \tikzmarkend{c}   \\
          \qquad{}+ \tikzmarkin{a}(0.05,-0.6)(-0.05,0.65) 
          \sum_{i=1}^{N}\left(\log\frac{\mathrm{p}_{i+} (1-\mathrm{p}_{i-}) }{\mathrm{p}_{i-} (1-\mathrm{p}_{i+} )}\right)
          \tikzmarkend{a} X_i.
        \end{aligned}
     \end{equation}

\end{itemize}

% draw arrows
\begin{tikzpicture}[remember picture,overlay]
% define two coordinates at bottom of each highlight box
\coordinate (aa) at ($(c)+(5mm,-1.3cm)$);
\coordinate (bb) at ($(a)+(5mm,-1.3cm)$);
% draw arrow down and place node below
\draw [->] (bb) -- ++(0,-3mm) node[below] (bi) {$\beta_i$};
% place beta0 node at same height as betai node
\node (b0) at (bi-|aa) {$\beta_0$};
% draw arrow
\draw [->] (aa) -- (b0);
\end{tikzpicture}

\end{frame}
\end{document}
Related Question