1

I found the very helpful question on how to add colors in a table using dcolumn here Colored text with dcolumn, but I would like to do the same thing using overlay such that the color only appears on the second slide. Does anyone have any ideas on how to do this? Thank you so much for your help. This is the MWE, which does not have overlay:

\documentclass[xcolor=table]{beamer}
\usepackage{amsmath}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{caption}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\makeatletter
\def\DC@endright{$\hfil\egroup\@dcolcolor\box\z@\box\tw@\dcolreset}
\def\dcolcolor#1{\gdef\@dcolcolor{\color{#1}}}
\def\dcolreset{\dcolcolor{black}}
\dcolcolor{black}
\makeatother

\begin{document}
\begin{frame}
\caption{Cycle: seasonally adjusted regional unemployment rate}
\scriptsize
\setlength\tabcolsep{3pt}
\begin{tabular}{l  d{2.4}  d{2.6} d{2.6} d{2.6} d{2.5} d{2.6} d{2.4}}
\toprule
\toprule
            &\multicolumn{1}{c}{\text{(1)}}&\multicolumn{1}{c}    {\text{(2)}}&\multicolumn{1}{c}{\text{(3)}}&\multicolumn{1}{c}{\text{(4)}}&\multicolumn{1}{c}{\text{(5)}}&\multicolumn{1}{c}{\text{(6)}}&\multicolumn{1}{c}{\text{(7)}}\\
        &\multicolumn{1}{c}{\text{growth-rate}}&\multicolumn{1}{c}{\text{hire-rate}}&\multicolumn{1}{c}{\text{sep-rate}}&\multicolumn{1}{c}{\text{hire-e-rate}}&\multicolumn{1}{c}{\text{hire-n-rate}}&\multicolumn{1}{c}{\text{sep-e-rate}}&\multicolumn{1}{c}{\text{sep-n-rate}}\\
\midrule
\beta_{1}&      0.1122         &     -0.1687         &     -0.2809^{\ast}  &     -0.0567         &     -0.1120         &     -0.1765^{\ast\ast} &     -0.1044         \\
            &    (0.0554)         &    (0.0846)         &    (0.0867)         &    (0.0262)         &    (0.0666)         &    (0.0374)         &    (0.0590)         \\
[1em]
\beta_{2}&     -0.0148         &     -0.2478^{\ast\ast} &     -0.2330^{\ast}  &     \dcolor{red}-0.0848^{\ast}  &     -0.1630^{\ast\ast} &     -0.1271^{\ast}  &     -0.1058         \\
            &    (0.0394)         &    (0.0697)         &    (0.0909)         &    (0.0359)         &    (0.0408)         &    (0.0419)         &    (0.0531)         \\
\hline
\(R^{2}\)   &      0.066         &   \dcolcolor{red}   0.288         &       0.352         &       0.195         &       0.283         &       0.332         &       0.325         \\
Wald p & 0.0026 & 0.9198 & 0.0012 & 0.9766 &  0.9062 & 0.0007& 0.0137 \\
\bottomrule
\multicolumn{8}{l}{\scriptsize N = 136012, Standard errors in parentheses}\\
\multicolumn{8}{l}{\scriptsize ^{\ast} p<0.05, ^{\ast\ast} p<0.01, ^{\ast\ast\ast} p<0.001}\\
\end{tabular}
\end{frame}

And I was hoping something like this works, but it doesn't:

\documentclass[xcolor=table]{beamer}
\usepackage{amsmath}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{caption}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\makeatletter
\def\DC@endright{$\hfil\egroup\@dcolcolor\box\z@\box\tw@\dcolreset}
\def\dcolcolor#1{\gdef\@dcolcolor{\color{#1}}}
\def\dcolreset{\dcolcolor{black}}
\dcolcolor{black}
\makeatother

\begin{frame}
\caption{Cycle: seasonally adjusted regional unemployment rate}
\scriptsize
\setlength\tabcolsep{3pt}
\begin{tabular}{l  d{2.4}  d{2.6} d{2.6} d{2.6} d{2.5} d{2.6} d{2.4}}
\toprule
\toprule
            &\multicolumn{1}{c}{\text{(1)}}&\multicolumn{1}{c}    {\text{(2)}}&\multicolumn{1}{c}{\text{(3)}}&\multicolumn{1}{c}{\text{(4)}}&\multicolumn{1}{c}{\text{(5)}}&\multicolumn{1}{c}{\text{(6)}}&\multicolumn{1}{c}{\text{(7)}}\\
        &\multicolumn{1}{c}{\text{growth-rate}}&\multicolumn{1}{c}{\text{hire-rate}}&\multicolumn{1}{c}{\text{sep-rate}}&\multicolumn{1}{c}{\text{hire-e-rate}}&\multicolumn{1}{c}{\text{hire-n-rate}}&\multicolumn{1}{c}{\text{sep-e-rate}}&\multicolumn{1}{c}{\text{sep-n-rate}}\\
\midrule
\beta_{1}&      \dcolor<2->{red}0.1122         &     -0.1687         &     -0.2809^{\ast}  &     -0.0567         &     -0.1120         &     -0.1765^{\ast\ast} &     -0.1044         \\
            &    (0.0554)         &    (0.0846)         &    (0.0867)         &    (0.0262)         &    (0.0666)         &    (0.0374)         &    (0.0590)         \\
[1em]
\beta_{2}&     -0.0148         &     -0.2478^{\ast\ast} &     -0.2330^{\ast}  &     -0.0848^{\ast}  &     -0.1630^{\ast\ast} &     -0.1271^{\ast}  &     -0.1058         \\
            &    (0.0394)         &    (0.0697)         &    (0.0909)         &    (0.0359)         &    (0.0408)         &    (0.0419)         &    (0.0531)         \\
\hline
\(R^{2}\)   &      0.066         &   \dcolcolor{red}   0.288         &       0.352         &       0.195         &       0.283         &       0.332         &       0.325         \\
Wald p & 0.0026 & 0.9198 & 0.0012 & 0.9766 &  0.9062 & 0.0007& 0.0137 \\
\bottomrule
\multicolumn{8}{l}{\scriptsize N = 136012, Standard errors in parentheses}\\
\multicolumn{8}{l}{\scriptsize ^{\ast} p<0.05, ^{\ast\ast} p<0.01, ^{\ast\ast\ast} p<0.001}\\
\end{tabular}
\end{frame}
\end{document}
1
  • What do you mean by "overlay"? Are you looking for a change of background color, text color, or both?
    – A Feldman
    Jun 19 '16 at 12:24
1

You had several unrelated errors in the table (mostly related to missing math markup and bad caption use). Once they are fixed the colour will just appear on the second layer if you use the normal beamer <2> syntax on the \color command.

enter image description here

\documentclass[xcolor=table]{beamer}
\usepackage{amsmath}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{caption}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\makeatletter
\def\DC@endright{$\hfil\egroup\@dcolcolor\box\z@\box\tw@\dcolreset}
\def\dcolcolor#1{\gdef\@dcolcolor{\color<2>{#1}}}
\def\dcolreset{\dcolcolor{black}}
\dcolcolor{black}
\makeatother

\begin{document}
\begin{frame}{Cycle: seasonally adjusted regional unemployment rate}
\scriptsize
\setlength\tabcolsep{3pt}
\begin{tabular}{>$l<$  d{2.4}  d{2.6} d{2.6} d{2.6} d{2.5} d{2.6} d{2.4}}
\toprule
            &\multicolumn{1}{c}{\text{(1)}}&\multicolumn{1}{c}    {\text{(2)}}&\multicolumn{1}{c}{\text{(3)}}&\multicolumn{1}{c}{\text{(4)}}&\multicolumn{1}{c}{\text{(5)}}&\multicolumn{1}{c}{\text{(6)}}&\multicolumn{1}{c}{\text{(7)}}\\
        &\multicolumn{1}{c}{\text{growth-rate}}&\multicolumn{1}{c}{\text{hire-rate}}&\multicolumn{1}{c}{\text{sep-rate}}&\multicolumn{1}{c}{\text{hire-e-rate}}&\multicolumn{1}{c}{\text{hire-n-rate}}&\multicolumn{1}{c}{\text{sep-e-rate}}&\multicolumn{1}{c}{\text{sep-n-rate}}\\
\midrule
\beta_{1}&      0.1122         &     -0.1687         &     -0.2809^{\ast}  &     -0.0567         &     -0.1120         &     -0.1765^{\ast\ast} &     -0.1044         \\
            &    (0.0554)         &    (0.0846)         &    (0.0867)         &    (0.0262)         &    (0.0666)         &    (0.0374)         &    (0.0590)         \\
[1em]
\beta_{2}&     -0.0148         &     -0.2478^{\ast\ast} &     -0.2330^{\ast}  &     \dcolcolor{red}-0.0848^{\ast}  &     -0.1630^{\ast\ast} &     -0.1271^{\ast}  &     -0.1058         \\
            &    (0.0394)         &    (0.0697)         &    (0.0909)         &    (0.0359)         &    (0.0408)         &    (0.0419)         &    (0.0531)         \\
\hline
R^{2}   &      0.066         &   \dcolcolor{red}   0.288         &       0.352         &       0.195         &       0.283         &       0.332         &       0.325         \\
\text{Wald p} & 0.0026 & 0.9198 & 0.0012 & 0.9766 &  0.9062 & 0.0007& 0.0137 \\
\bottomrule
\multicolumn{8}{l}{\scriptsize $N = 136012$, Standard errors in parentheses}\\
\multicolumn{8}{l}{\scriptsize $^{\ast} p<0.05$, $^{\ast\ast} p<0.01$, $^{\ast\ast\ast} p<0.001$}\\
\end{tabular}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.