Beamer 注释表

Beamer 注释表

我正在尝试在表格中的数字周围添加一些方框。我使用的方法与以下问题的答案中描述的方法完全相同:

Beamer,使用 Tikzmark 注释表格

问题是,框所包围区域的第一个单元格会获得额外的空间(如果您看到上面的示例,就会看到这一点)。这很烦人。为什么会发生这种情况?如何解决?

答案1

包中的宏定义未能在所有必要位置注释行尾。由于 TeX 将这些解释为空格,因此会插入空格。

的定义\tikzmarkin涉及许多嵌套的条件子句。在这里,我只是试图挑选一个与你相关的子句并重新定义它。

修复方法是在加载后将其添加到序言中高频-tikz

\RenewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
  \IfNoValueTF{#2}{%true-val
    \only<#1>{\tikz[remember picture,overlay]
      \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
      (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
      ;}%
  }{%false-val
    \only<#1>{\tikz[remember picture,overlay]
      \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#2]
      (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
      ;}}%
}

请注意,我的修复方法是在行尾添加两个%符号。显然,这应该针对所有情况进行修复,而不仅仅是 Beamer-rounded-corners-fill-etc.-etc. 的情况,但这确实是其维护者在包中做得最好的。

结果如下:

幻灯片 1

幻灯片 2

完整代码例如:

\documentclass{beamer}
\mode<presentation>
{
\usetheme{CambridgeUS}
\usecolortheme{dolphin}
\setbeamercovered{transparent}
}
\usepackage{colortbl}
\usepackage{amsmath,amssymb,amsthm} %%% INCLUDE
\usepackage{multirow,booktabs,dcolumn}
\usepackage[beamer,customcolors]{hf-tikz}
\usetikzlibrary{calc}
\tikzset{hl/.style={%
    set fill color=red!80!black!40,
    set border color=red!80!black,
  },
}
\RenewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
  \IfNoValueTF{#2}{%true-val
    \only<#1>{\tikz[remember picture,overlay]
      \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
      (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
      ;}%
  }{%false-val
    \only<#1>{\tikz[remember picture,overlay]
      \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#2]
      (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
      ;}}%
}
\begin{document}

\begin{frame}{Regression Results}{Participation}

\begin{table}
\resizebox{0.86\textwidth}{0.4\textheight}{
\begin{tabular}{lcccccc} \hline
& \multicolumn{3}{c}{Dependent Variable:} &  \multicolumn{3}{c}{Dependent Variable:} \\
& \multicolumn{3}{c}{Effort>0} &  \multicolumn{3}{c}{Effort>5} \\
\cline{2-4} \cline{5-7}
Variables & (1) & (2) & (3) & (4) & (5) & (6) \\
\hline
 &  &  &  &  &  &  \\
\tikzmarkin<2>[hl]{H1}Slider & -0.019 & -0.031 & -0.038 & -0.037 & -0.051 & -0.055 \\
 & (0.069) & (0.068) & (0.068) & (0.068) & (0.067) & (0.066)\tikzmarkend{H1}\\
Early Departure  & -0.143** & -0.160** & -0.147** & -0.204*** & -0.222*** & -0.209*** \\
 & (0.070) & (0.070) & (0.070) & (0.069) & (0.068) & (0.069) \\
Pause  & -0.427*** & -0.430*** & -0.425*** & -0.694*** & -0.697*** & -0.691*** \\
 & (0.068) & (0.068) & (0.067) & (0.067) & (0.066) & (0.066) \\
20-Minute  & -0.036 & -0.040 & -0.037 & -0.035 & -0.040 & -0.036 \\
 & (0.069) & (0.068) & (0.068) & (0.067) & (0.066) & (0.066) \\
Threshold  & -0.284*** & -0.282*** & -0.272*** & -0.266*** & -0.263*** & -0.254*** \\
 & (0.068) & (0.068) & (0.067) & (0.067) & (0.066) & (0.066) \\
Flat Wage  & 0.037 & 0.020 & 0.031 & 0.056 & 0.038 & 0.041 \\
 & (0.069) & (0.069) & (0.069) & (0.068) & (0.067) & (0.067) \\
Effort Choice & -0.606*** & -0.608*** & -0.601*** & -0.766*** & -0.769*** & -0.759*** \\
 & (0.068) & (0.068) & (0.068) & (0.067) & (0.066) & (0.066) \\
Constant & 0.963*** & 1.111*** & 0.989*** & 0.944*** & 1.102*** & 1.051*** \\
 & (0.049) & (0.064) & (0.159) & (0.048) & (0.062) & (0.155) \\
 &  &  &  &  &  &  \\
Observations & 434 & 434 & 434 & 434 & 434 & 434 \\
R-squared & 0.277 & 0.298 & 0.316 & 0.429 & 0.448 & 0.463 \\
\% invested in Risk Task & N & Y & Y & N & Y & Y \\
Controls & N & N & Y & N & N & Y \\
\hline
\multicolumn{7}{c}{ Standard errors in parentheses} \\
\multicolumn{7}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.10} \\
\end{tabular}
\begin{tikzpicture}[remember picture,overlay]
\node<2>[left=-3pt,anchor=west,yshift=1.5ex,font=\small] at (pic cs:H1) {Comment};
\end{tikzpicture}
}
\end{table}

\end{frame}

\end{document}

相关内容