3

Here is my situation: I am using \tikzmarkin to highlight relevant rows of a results table in my Beamer slide deck. I want to put annotations to the right of the row highlight, so that hypothesis tested in each row is labelled (H1, H2, H3 and so on...).

I used the solution here to highlight relevant rows: https://tex.stackexchange.com/a/132818/88794

What I want is to put a small text box next to each highlighted area. I tried tikzpicture but it aligns at the top of the text box (as seen in bH2)

Below is my beamer page.

\documentclass{beamer}

% for themes, etc.
\mode<presentation>
\usetheme{CambridgeUS} 
\usecolortheme{beaver}

%\usepackage{times}  % fonts are up to you
\usepackage{graphicx}
% The usual suspects
\usepackage{multirow, booktabs, dcolumn, color} % Tables
% The table highlighting for hypothesis discussion.
\usepackage[beamer,customcolors]{hf-tikz}
\usetikzlibrary{calc}

% To set the hypothesis highlighting boxes red.
\tikzset{hl/.style={
    set fill color=red!80!black!40,
    set border color=red!80!black,
  },
}

\begin{document}


\begin{frame}
\frametitle{Preliminary Results}

\resizebox{.99\linewidth}{!}{

\begin{tabular}{l D{)}{)}{14)3}@{} D{)}{)}{13)3}@{} D{)}{)}{13)3}@{} }
            & \multicolumn{1}{c}{Model 1} & \multicolumn{1}{c}{Model 2} & \multicolumn{1}{c}{Model 3} \\
\toprule
\midrule


~Control           & 0.392 \; (0.021)^{***}   & 0.198 \; (0.022)^{***}  & 0.198 \; (0.022)^{***}  \\
\tikzmarkin<3>[hl]{bH2}DevOwn           & 0.064 \; (0.003)^{***}   &                         &                         \\
~Frat            &                          & 0.051 \; (0.001)^{***}  &                         \\
~Serot           &                          &                         & 0.051 \; (0.001)^{***}  \tikzmarkend{bH2}\\
\tikzmarkin<2>[hl]{bH1}Frat x Serot     & -22.018 \; (1.474)^{***} & -8.747 \; (1.535)^{***} & -8.750 \; (1.535)^{***} \tikzmarkend{bH1} \\
\midrule
AIC              & 171986.112               & 140758.027              & 140762.308              \\
Num. events      & 11821                    & 11821                   & 11821                   \\
Num. obs.        & 601960                   & 601960                  & 601960                  \\

\bottomrule
\multicolumn{4}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
\end{tabular} 

}

\only{2}{
% Place the hypothesis number next to the highlighted area
\begin{tikzpicture}[remember picture,overlay]
\node[align=left, left] at ({pic cs:bH1}) {\small{H1}};
\end{tikzpicture}
}

\end{frame}

\end{document}

1 Answers1

4

You can take advantage of the fact that \node (and all path commands in TikZ) are overlay aware; using xshift=<length>, yshift=<length>, or shift={(<point>)} you can adjust the position for the labels:

\documentclass{beamer}

% for themes, etc.
\mode<presentation>
\usetheme{CambridgeUS} 
\usecolortheme{beaver}

%\usepackage{times}  % fonts are up to you
\usepackage{graphicx}
% The usual suspects
\usepackage{multirow, booktabs, dcolumn, color} % Tables
% The table highlighting for hypothesis discussion.
\usepackage[beamer,customcolors]{hf-tikz}
\usetikzlibrary{calc}

% To set the hypothesis highlighting boxes red.
\tikzset{hl/.style={
    set fill color=red!80!black!40,
    set border color=red!80!black,
  },
}

\begin{document}


\begin{frame}
\frametitle{Preliminary Results}

\resizebox{.98\linewidth}{!}{%
\begin{tabular}{l D{)}{)}{14)3}@{} D{)}{)}{13)3}@{} D{)}{)}{13)3}@{} }
            & \multicolumn{1}{c}{Model 1} & \multicolumn{1}{c}{Model 2} & \multicolumn{1}{c}{Model 3} \\
\toprule
\midrule


~Control           & 0.392 \; (0.021)^{***}   & 0.198 \; (0.022)^{***}  & 0.198 \; (0.022)^{***}  \\
\tikzmarkin<3>[hl]{bH2}DevOwn           & 0.064 \; (0.003)^{***}   &                         &                         \\
~Frat            &                          & 0.051 \; (0.001)^{***}  &                         \\
~Serot           &                          &                         & 0.051 \; (0.001)^{***}  \tikzmarkend{bH2}\\
\tikzmarkin<2>[hl]{bH1}Frat x Serot     & -22.018 \; (1.474)^{***} & -8.747 \; (1.535)^{***} & -8.750 \; (1.535)^{***} \tikzmarkend{bH1} \\
\midrule
AIC              & 171986.112               & 140758.027              & 140762.308              \\
Num. events      & 11821                    & 11821                   & 11821                   \\
Num. obs.        & 601960                   & 601960                  & 601960                  \\

\bottomrule
\multicolumn{4}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
\end{tabular}% 
}

\begin{tikzpicture}[remember picture,overlay]
\node<2>[left,font=\small] at ([yshift=0.5ex]{pic cs:bH1}) {H1};
\node<3>[left,font=\small] at ([yshift=3ex]{pic cs:bH2}) {H2};
\end{tikzpicture}

\end{frame}

\end{document}

An animation of the result (I commented out some spurious spaces in your code and reduced a tad the table width to accommodate the annotations):

enter image description here

Gonzalo Medina
  • 505,128
  • Thank you. I realized I placed the \tikzpictures out of the resize box and centering environment in my original code, so the problem was resolved. Your answer actually allowed me to make results look prettier. – PoorLifeChoicesMadeMeWhoIAm Sep 29 '15 at 20:39