Beamer 和 longtable

Beamer 和 longtable

我试图在 beamer 中突出显示一行,但整行并没有被突出显示(即每列之间都有空白)。有没有办法仍然使用长表来突出显示整行?还请注意,还有许多其他幻灯片,因此我不得不使用许多可能看起来不相关的包。以下是我目前所拥有的:

\documentclass[table,slidestop,compress,mathserif, 10pt]{beamer}
\usetheme{Frankfurt}
\usecolortheme{seahorse}
\usepackage{booktabs, longtable}
\newcommand\mcc[1]{\multicolumn{1}{c}{#1}}
\usepackage{bbm}
\usepackage{array, booktabs, tabularx}
\usepackage{siunitx}

\usepackage[orientation=landscape,size=custom,width=16,height=9,scale=0.5,debug]{beamerposter} 


% The main document
\begin{document}






\setcounter{subsection}{1}
\begin{frame}{Regression}
\vspace{-0.50cm}
\begin{table}[htb]
\footnotesize   

  \begin{tabularx}{\linewidth}{l*{6}{Y}}

     \toprule 
    & \mcc{(I)} & \mcc{(II)} & \mcc{(III)} & \mcc{(IV)} & \mcc{(V)}& \mcc{(VI)}   \\\hline 
\rowcolor{blue!20} $\mathbbm{1}$(Hosp$_{i})\times\mathbbm{1}$(Doc$_{t}$)  & 3.333***&6.333***& 7.333*** & 7.334***& 6.353*** & 6.333*** \\
\rowcolor{blue!10}  & (0.111) &(0.112)& (0.112) & (0.113) & (0.173)& (0.178) \\\addlinespace
\midrule
\textbf{Health Variables}  
      &        &     &          & {X}       & {X}    & {X}    \\ 

 \midrule

\textbf{Other Effects} \\
Time 
    &           & {X}       &     &    &  {X}            \\
Location
    &           &           &      {X}    & &  & {X}            \\
\midrule
Number  & {11,210} & {11,210} & {11,210} & {10,504} &{10,504} &{10,504}  \\
 K-Number  & {63.11} & {61.33}  & {58.33}  & {56.01}  & {50.93} & {53.77}  \\ 
 \hline
    \bottomrule
  \end{tabularx}
\end{table}
\end{frame}



\end{document} 

答案1

我快速搜索了一下,发现似乎存在一个大难题colortbl,涉及使表格填满整个页面的技巧,以及使用列的功能Ssiunitx尤其是与 beamer 搭配使用时。我们的版主可能可以从以下位置配对解决方案这个帖子带有fragile框架(我没有尝试过,没有fragile它显然不会起作用)。但我遇到了一些来自这个网站的经验丰富的用户的声明,他们说这colortbl永远不会完美,人们可能会使用tikz,你似乎已经加载了。因此,解决方案是使用tikzpagenodestikzmark库在本地切换这些颜色的背景。为此,需要table从中删除选项\documentclass[table,slidestop,compress,mathserif, 10pt]{beamer},并在后续帧中重置背景。

\documentclass[slidestop,compress,mathserif, 10pt]{beamer}
\usepackage{array}
\usetheme{Frankfurt}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{dsfont}
\newcommand\mcc[1]{\multicolumn{1}{c}{#1}}

\usepackage[orientation=landscape,size=custom,width=16,height=9,scale=0.5,debug]{beamerposter} 

% Custom numbering for the footline
\setbeamertemplate{footline}{%
  \raisebox{5pt}{%
    \makebox[\paperwidth]{%
      \hfill\makebox[7pt]{%
        \tiny\insertframenumber
      }
    }
  }
}
\definecolor{dgreen}{rgb}{0.,0.6,0.}
\definecolor{dblue}{rgb}{0.,0.,0.6}
\definecolor{dred}{rgb}{0.6,0.,0.}

\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark}
\usepackage{eso-pic}



\begin{document}

\begin{frame}[t]
\frametitle{Test}

\end{frame}


\setbeamertemplate{background}{\begin{tikzpicture}[overlay,remember picture]
 \fill[blue!20] (current page text area.west|-row1.south)
 rectangle (current page text area.east|-row1.north);
 \fill[blue!10] (current page text area.west|-row2.south)
 rectangle (current page text area.east|-row2.north);
\end{tikzpicture}}

\setcounter{subsection}{9}
\begin{frame}{Regression}

\begingroup
\footnotesize
\sisetup{table-format=1.4,
         table-space-text-pre=(,
         table-space-text-post=***,
         table-align-text-post=false,
         input-symbols=(),
         table-alignment=right
         }
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{0pt}
 \vspace*{-0.53cm}
    \begin{longtable}{@{\extracolsep{\fill}} l
                                           *{6}{S}}
     \toprule  
\multicolumn{1}{c}{}
    & \mcc{(I)} & \mcc{(II)} & \mcc{(III)} & \mcc{(IV)} & \mcc{(V)} & \mcc{(VI)}  \\
    \midrule
\endhead
    \bottomrule
\endlastfoot 
\tikzmarknode{row1}{\strut} $\mathds{1}$(Hospital$_{i})\times\mathds{1}$(Doctor$_{t}$)  & 3.333***&6.333***& 7.333*** & 7.334***& 6.353*** & 6.333*** \\
\tikzmarknode{row2}{\strut} & (0.111) &(0.112)& (0.112) & (0.113) & (0.173)& (0.178) \\\addlinespace


 \midrule
\textbf{Health Variables}  
      &        &     &          & {X}       & {X}    & {X}    \\ 

 \midrule

\textbf{Other Effects} \\
Time 
    &           & {X}       &     &    &  {X}            \\
Location
    &           &           &      {X}    & &  & {X}            \\
\midrule
Number  & {11,210} & {11,210} & {11,210} & {10,504} &{10,504} &{10,504}  \\
 K-Number  & {63.11} & {61.33}  & {58.33}  & {56.01}  & {50.93} & {53.77}  \\ 
 \hline
\end{longtable}
\endgroup

\end{frame}


\setbeamertemplate{background}{}

\begin{frame}[t]
\frametitle{Another test}

\end{frame}    
\end{document}

在此处输入图片描述

我还用 替换了mathbbm因为mathds它的字形非常相似但没有像素化,等等。不过,我并没有完全调整这个答案。

相关内容