在 Beamer 中注释 Tikzmark 突出显示的表格行

在 Beamer 中注释 Tikzmark 突出显示的表格行

我的情况如下:我用它\tikzmarkin来突出显示 Beamer 幻灯片中结果表的相关行。我想将注释放在突出显示行的右侧,这样每行中测试的假设都会被标记(H1、H2、H3 等等...)。

我使用此处的解决方案来突出显示相关行:https://tex.stackexchange.com/a/132818/88794

我想要的是在每个突出显示区域旁边放置一个小文本框。我试过 tikzpicture,但它与文本框顶部对齐(如 bH2 中所示)

下面是我的投影仪页面。

\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

\node您可以利用(TikZ 中的所有路径命令) 都具有叠加感知的功能;使用xshift=<length>yshift=<length>或者shift={(<point>)}您可以调整标签的位置:

\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}

结果的动画(我注释掉了代码中的一些虚假空格,并稍微减少了表格宽度以适应注释):

在此处输入图片描述

相关内容