在一个演示文稿中使用 \tikzmarkin 和 \tikzmarkend 两次会中断其中一个表格的突出显示

在一个演示文稿中使用 \tikzmarkin 和 \tikzmarkend 两次会中断其中一个表格的突出显示

在下面的代码中,如果注释掉第二个表,则突出显示对第一个表有效,但当第二个表的代码未注释掉时,突出显示就会中断。总是代码中的第一个表会中断。有什么想法出了什么问题吗?

\documentclass[notes,11pt, aspectratio=169]{beamer}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{tabularx}
\usepackage{beamerthemesplit}
\usepackage{amsmath,amssymb}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usetheme{Warsaw}
\definecolor{UFblue}{rgb}{0, 0.33, 1.65}
\definecolor{UForange}{rgb}{2.5, 0.70, 0.22}
\beamertemplatenavigationsymbolsempty
\setbeamercolor{palette primary}{bg=UFblue,fg=white}
\setbeamercolor{palette secondary}{bg=UFblue,fg=white}
\setbeamercolor{palette tertiary}{bg=UFblue,fg=white}
\setbeamercolor{palette quaternary}{bg=UFblue,fg=white}
\setbeamercolor{structure}{fg=UFblue} % itemize, enumerate, etc
\setbeamercolor{section in toc}{fg=UFblue} % TOC sections
\expandafter\def\expandafter\insertshorttitle\expandafter{%
    \insertshorttitle\hfill%
    \insertframenumber\,/\,\inserttotalframenumber}
\setbeamercolor{subsection in head/foot}{bg=UForange,fg=white}
\useoutertheme[subsection=false]{smoothbars}
\tikzset{hl/.style={
        set fill color=orange!25,
        set border color=orange,
    },
}
\setbeamertemplate{frametitle}[default][colsep=-4bp,rounded=false,shadow=false]
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=false,shadow=false]
\usepackage{booktabs,colortbl}

\begin{document}
        \frame{\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{tabular}{lccccc}
                            \toprule
                            First       & \multicolumn{2}{c}{Signs} \\ \cmidrule(lr){2-3}
                            derivatives & Status quo & Mean outcome \\ \hline
                            \tikzmarkin<2>[hl]{a}$\frac{ \partial U}{ \partial  \sigma}$                    & $<0$          &  $\lessgtr0$  \tikzmarkend{a}\\
                            \addlinespace
                            \tikzmarkin<3>[hl]{b}$\frac{ \partial U}{ \partial \lambda }$                   & $<0$          &  $>0$         \tikzmarkend{b}\\
                            \addlinespace 
                            \tikzmarkin<4>[hl]{c}$\frac{ \partial U}{ \partial q^-}$                        & $<0$          &  $<0$         \tikzmarkend{c}\\
                            \addlinespace
                            \tikzmarkin<5>[hl]{d}$\frac{ \partial U}{ \partial q^+}$                        & $>0$          &  $>0$         \tikzmarkend{d}\\
                            \addlinespace
                            \tikzmarkin<6>[hl]{e}$\frac{ \partial U}{ \partial\eta}$                        & $<0$          &  $<0$         \tikzmarkend{e} \\
                            \hline
                        \end{tabular}
                }}
            \end{table}
        }
        \frame{\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{tabular}{lccccc}
                            \toprule
                            &(1)                &(2)            &(3)        &Predicted  &Predicted \\
                            &                   &               &           & sign, SQ  & sign, MO \\
                            \midrule
                            \tikzmarkin<2>[hl]{a}$\sigma$       &   2258.0         &    832.9       &   -324.9 & $<0$ & $\lessgtr 0$\\
                            & (2446.0)         & (1859.7)       & (3143.5) &        &\phantom{$\lessgtr 0$}\tikzmarkend{a}\\
                            \addlinespace
                            \tikzmarkin<3>[hl]{b}$\lambda$      &   -721.4\textsuperscript{**} &   -488.8\textsuperscript{**} &   -183.4   & $<0$ & $>0$\\
                            &  (305.7)                     &  (228.3)                     &  (349.4)   &      &\phantom{$>0$}\tikzmarkend{b}\\
                            \addlinespace 
                            
                            $\alpha$        &   2333.3         &   2305.5         &   2278.0   & &       \\
                            & (3266.5)         & (3471.3)         & (3492.5)   & &      \\
                            \addlinespace
                            \tikzmarkin<4>[hl]{c}HBR        &                  &  -4036.0\textsuperscript{*}&  -2458.3 & $<0$   & $<0$ \\
                            &                  & (1961.5)                   & (2194.7) &        &\phantom{$<0$}\tikzmarkend{c}\\
                            \addlinespace
                            
                            \tikzmarkin<5>[hl]{d}HBR x $\sigma$ &                  &                  &   1877.4 & $>0$ & $>0$ \\
                            &                  &                  & (3845.9) &      & \phantom{$>0$}\tikzmarkend{d}\\
                            \addlinespace
                            \tikzmarkin<6>[hl]{e}HBR x $\lambda$    &                  &                  &   -526.0 & $<0$ & $<0$  \\
                            &                  &                  &  (423.7) &      &\phantom{$<0$}\tikzmarkend{e} \\
                            
                            \midrule
                            Observations            &     1,666        &     1,666       &     1,666  & &      \\
                            R-squared               &    0.474         &    0.445        &    0.446   & &      \\
                            \bottomrule
                        \end{tabular}
                }}
            \end{table}
}



\end{document}

答案1

我不知道你的评论是什么意思。

请注意,当对 {a}、{b} 等使用所有唯一字母时,会出现同样的问题。

您确实需要使用唯一的名称。以下代码编译成功:

\documentclass[notes,11pt, aspectratio=169]{beamer}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{tabularx}
\usepackage{beamerthemesplit}
\usepackage{amsmath,amssymb}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usetheme{Warsaw}
\definecolor{UFblue}{rgb}{0, 0.33, 1.65}
\definecolor{UForange}{rgb}{2.5, 0.70, 0.22}
\beamertemplatenavigationsymbolsempty
\setbeamercolor{palette primary}{bg=UFblue,fg=white}
\setbeamercolor{palette secondary}{bg=UFblue,fg=white}
\setbeamercolor{palette tertiary}{bg=UFblue,fg=white}
\setbeamercolor{palette quaternary}{bg=UFblue,fg=white}
\setbeamercolor{structure}{fg=UFblue} % itemize, enumerate, etc
\setbeamercolor{section in toc}{fg=UFblue} % TOC sections
\expandafter\def\expandafter\insertshorttitle\expandafter{%
    \insertshorttitle\hfill%
    \insertframenumber\,/\,\inserttotalframenumber}
\setbeamercolor{subsection in head/foot}{bg=UForange,fg=white}
\useoutertheme[subsection=false]{smoothbars}
\tikzset{hl/.style={
        set fill color=orange!25,
        set border color=orange,
    },
}
\setbeamertemplate{frametitle}[default][colsep=-4bp,rounded=false,shadow=false]
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=false,shadow=false]
\usepackage{booktabs,colortbl}

\begin{document}
        \frame{\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{tabular}{lccccc}
                            \toprule
                            First       & \multicolumn{2}{c}{Signs} \\ \cmidrule(lr){2-3}
                            derivatives & Status quo & Mean outcome \\ \hline
                            \tikzmarkin<2>[hl]{a}$\frac{ \partial U}{ \partial  \sigma}$                    & $<0$          &  $\lessgtr0$  \tikzmarkend{a}\\
                            \addlinespace
                            \tikzmarkin<3>[hl]{b}$\frac{ \partial U}{ \partial \lambda }$                   & $<0$          &  $>0$         \tikzmarkend{b}\\
                            \addlinespace 
                            \tikzmarkin<4>[hl]{c}$\frac{ \partial U}{ \partial q^-}$                        & $<0$          &  $<0$         \tikzmarkend{c}\\
                            \addlinespace
                            \tikzmarkin<5>[hl]{d}$\frac{ \partial U}{ \partial q^+}$                        & $>0$          &  $>0$         \tikzmarkend{d}\\
                            \addlinespace
                            \tikzmarkin<6>[hl]{e}$\frac{ \partial U}{ \partial\eta}$                        & $<0$          &  $<0$         \tikzmarkend{e} \\
                            \hline
                        \end{tabular}
                }}
            \end{table}
        }
        \frame{\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{tabular}{lccccc}
                            \toprule
                            &(1)                &(2)            &(3)        &Predicted  &Predicted \\
                            &                   &               &           & sign, SQ  & sign, MO \\
                            \midrule
                            \tikzmarkin<2>[hl]{f}$\sigma$       &   2258.0         &    832.9       &   -324.9 & $<0$ & $\lessgtr 0$\\
                            & (2446.0)         & (1859.7)       & (3143.5) &        &\phantom{$\lessgtr 0$}\tikzmarkend{f}\\
                            \addlinespace
                            \tikzmarkin<3>[hl]{g}$\lambda$      &   -721.4\textsuperscript{**} &   -488.8\textsuperscript{**} &   -183.4   & $<0$ & $>0$\\
                            &  (305.7)                     &  (228.3)                     &  (349.4)   &      &\phantom{$>0$}\tikzmarkend{g}\\
                            \addlinespace 
                            
                            $\alpha$        &   2333.3         &   2305.5         &   2278.0   & &       \\
                            & (3266.5)         & (3471.3)         & (3492.5)   & &      \\
                            \addlinespace
                            \tikzmarkin<4>[hl]{h}HBR        &                  &  -4036.0\textsuperscript{*}&  -2458.3 & $<0$   & $<0$ \\
                            &                  & (1961.5)                   & (2194.7) &        &\phantom{$<0$}\tikzmarkend{h}\\
                            \addlinespace
                            
                            \tikzmarkin<5>[hl]{i}HBR x $\sigma$ &                  &                  &   1877.4 & $>0$ & $>0$ \\
                            &                  &                  & (3845.9) &      & \phantom{$>0$}\tikzmarkend{i}\\
                            \addlinespace
                            \tikzmarkin<6>[hl]{j}HBR x $\lambda$    &                  &                  &   -526.0 & $<0$ & $<0$  \\
                            &                  &                  &  (423.7) &      &\phantom{$<0$}\tikzmarkend{j} \\
                            
                            \midrule
                            Observations            &     1,666        &     1,666       &     1,666  & &      \\
                            R-squared               &    0.474         &    0.445        &    0.446   & &      \\
                            \bottomrule
                        \end{tabular}
                }}
            \end{table}
}

\end{document}

答案2

供参考,以下是您可以使用 执行{NiceTabular}的操作nicematrix

\documentclass[notes,11pt, aspectratio=169]{beamer}

\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{tabularx}
\usepackage{beamerthemesplit}
\usepackage{amsmath,amssymb}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usetheme{Warsaw}
\definecolor{UFblue}{rgb}{0, 0.33, 1.65}
\definecolor{UForange}{rgb}{2.5, 0.70, 0.22}
\beamertemplatenavigationsymbolsempty
\setbeamercolor{palette primary}{bg=UFblue,fg=white}
\setbeamercolor{palette secondary}{bg=UFblue,fg=white}
\setbeamercolor{palette tertiary}{bg=UFblue,fg=white}
\setbeamercolor{palette quaternary}{bg=UFblue,fg=white}
\setbeamercolor{structure}{fg=UFblue} % itemize, enumerate, etc
\setbeamercolor{section in toc}{fg=UFblue} % TOC sections
\expandafter\def\expandafter\insertshorttitle\expandafter{%
    \insertshorttitle\hfill%
    \insertframenumber\,/\,\inserttotalframenumber}
\setbeamercolor{subsection in head/foot}{bg=UForange,fg=white}
\useoutertheme[subsection=false]{smoothbars}
\tikzset{hl/.style={
        set fill color=orange!25,
        set border color=orange,
    },
}
\setbeamertemplate{frametitle}[default][colsep=-4bp,rounded=false,shadow=false]
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=false,shadow=false]
\usepackage{booktabs,colortbl}

\usepackage{nicematrix}
\NewDocumentCommand{\HighlightRow}{}{\Block[fill=red!15,draw,rounded-corners]{1-*}{}}
\NiceMatrixOptions{cell-space-limits=3pt}

\begin{document}
        \begin{frame}\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{NiceTabular}{lcc}
                            \toprule
                            First       & \multicolumn{2}{c}{Signs} \\ \cmidrule(lr){2-3}
                            derivatives & Status quo & Mean outcome \\ \hline
                            \only<1>{\HighlightRow}%
                            $\frac{ \partial U}{ \partial  \sigma}$                    & $<0$          &  $\lessgtr0$  \\
                            \only<2>{\HighlightRow}%
                            $\frac{ \partial U}{ \partial \lambda }$                   & $<0$          &  $>0$   \\
                            \only<3>{\HighlightRow}%
                            $\frac{ \partial U}{ \partial q^-}$                        & $<0$          &  $<0$ \\
                            \only<4>{\HighlightRow}%
                            $\frac{ \partial U}{ \partial q^+}$                        & $>0$          &  $>0$ \\
                            \only<5>{\HighlightRow}%
                            $\frac{ \partial U}{ \partial \eta}$                        & $<0$          &  $<0$   \\
                            \hline
                        \end{NiceTabular}
                }}
            \end{table}
        \end{frame}
        \begin{frame}\frametitle{Results}
            \begin{table}\centering
                \makebox[0pt]{\resizebox{\textheight}{!}{           
                        \begin{NiceTabular}{lccccc}
                            \toprule
                            &(1)                &(2)            &(3)        &Predicted  &Predicted \\
                            &                   &               &           & sign, SQ  & sign, MO \\
                            \midrule
                            \only<1>{\HighlightRow}%
                            $\sigma$       &   2258.0         &    832.9       &   -324.9 & $<0$ & $\lessgtr 0$\\
                            & (2446.0)         & (1859.7)       & (3143.5) &        &\phantom{$\lessgtr 0$}\\
                            \only<1>{\HighlightRow}%
                            $\lambda$      &   -721.4\textsuperscript{**} &   -488.8\textsuperscript{**} &   -183.4   & $<0$ & $>0$\\
                            &  (305.7)                     &  (228.3)                     &  (349.4)   &      &\phantom{$>0$}\tikzmarkend{g}\\
                            \only<1>{\HighlightRow}%
                            $\alpha$        &   2333.3         &   2305.5         &   2278.0   & &       \\
                            & (3266.5)         & (3471.3)         & (3492.5)   & &      \\
                            \only<1>{\HighlightRow}%
                            HBR        &                  &  -4036.0\textsuperscript{*}&  -2458.3 & $<0$   & $<0$ \\
                            &                  & (1961.5)                   & (2194.7) &        &\phantom{$<0$}\\
                            \only<1>{\HighlightRow}%
                            HBR x $\sigma$ &                  &                  &   1877.4 & $>0$ & $>0$ \\
                            &                  &                  & (3845.9) &      & \phantom{$>0$}\\
                            \only<1>{\HighlightRow}%
                            HBR x $\lambda$    &                  &                  &   -526.0 & $<0$ & $<0$  \\
                            &                  &                  &  (423.7) &      &\phantom{$<0$} \\
                            \midrule
                            Observations            &     1,666        &     1,666       &     1,666  & &      \\
                            R-squared               &    0.474         &    0.445        &    0.446   & &      \\
                            \bottomrule
                        \end{NiceTabular}
                }}
           \end{table}
       \end{frame}
\end{document}

您需要多次编译(因为nicematrix在后台使用 PGF/Tikz 节点)。

上述代码的输出

相关内容