1

I am trying to highlight a row in beamer, but the whole row does not get hihglighted (i.e., there is white space between each column). Is there any way to highlight the entire row by still using the long table? Please also note that there are many other slides, so I had to use many packages that may not seem relevant here. Here is what I have of far:

\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} 
Job
  • 307
  • 1
    Please reduce your code to a minimal version. You load many unrelated packages, some of them even twice. –  Apr 15 '20 at 02:04
  • @Schrödinger'scat, just modified it and removed all irrelevant parts. – Job Apr 15 '20 at 02:42
  • @Schrödinger'scat, when I remove the other parts, the issue seems to disappear but if I remove them in the original document, things get really messy. I am not sure where the original error was in. – Job Apr 15 '20 at 02:49
  • I added back the other parts since I cannot construct the whole presentation otherwise.. – Job Apr 15 '20 at 02:54
  • 1
    The original error is this one, I think. There are, however, better fixes for your situation. More importantly, this site is not about you nor me, it is about everyone. If someone writes an answer keeping all these packages, this may serve you, perhaps, but no one else. Cooking it down to a minimal content will allow others to benefit from the thread, too. –  Apr 15 '20 at 03:01
  • Thanks, I will remove the packages that are not needed. I believe, I found the command that causes the error:

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

    However, once I delete this command, the format of the beamer gets messed up.

    – Job Apr 15 '20 at 03:09
  • 2
    I think that the problem is that \rowcolor is not trained to collaborate with @{\extracolsep{\fill}}. If you remove this, the problem disappears but the table does no longer fill the full page width. –  Apr 15 '20 at 03:11
  • Interesting. There is no way to get around this issue? By the way, I have removed all comments that are not needed. The errors disappeared this way. – Job Apr 15 '20 at 03:18
  • 1
    AFAIK there is no always working way, only partial solutions. One can marry the X column of a tabularx to S (you do not need a longrable here) but it seems that the cleanest solutions here do not want to collaborate with beamer / your document. BTW, I do not see how you got rid of unused packages and libraries, you do not use tikz here but load \usetikzlibrary{decorations.pathreplacing} \usetikzlibrary{decorations.pathmorphing} twice. –  Apr 15 '20 at 03:28
  • Following your suggestion, I completely changed the setting to the tabularx setting. However, there is one minor issue now. The highlighting does not span the entire row. There is a small non-highlighted area towards the end of the row. – Job Apr 15 '20 at 03:45

1 Answers1

1

I did a quick search and it seems that there is a big conundrum concerning colortbl, the trick you employ to make the table fill the full page, and using the features of the S column of siunitx, in particular when paired with beamer. One probably can pair the solutions by our moderators from this post with a fragile frame (I did not try, without fragile it obviously won't work). But I came across several statements by rather seasoned users from this site who say that colortbl is never perfect, one may use tikz instead, which you seem to already loading. So the solution is to use tikzpagenodes and the tikzmark library to locally switch on a background of these colors. For this it is necessary to drop the table option from \documentclass[table,slidestop,compress,mathserif, 10pt]{beamer}, and to reset the background in the subsequent frame.

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

enter image description here

I also replaced mathbbm by mathds because its glyphs are very similar but not pixelated, and so on. However, I did not completely tune this answer.

  • 1
    I hope that not the usual thing happens that someone comes, makes minor adjustments and sells it as their solution. There are many alternative ways of answering this question. –  Apr 15 '20 at 03:49
  • This is really helpful, many thanks!!! – Job Apr 15 '20 at 03:51