2

I have the following table where I compare OLS and quantile regressions. I would like to use the onslide command to have the last three columns to appear in a second moment (hopefully keeping the heading fixed, so that only the coefficients show up in a second moment).

\documentclass[10pt,english,xcolor={usenames,dvipsnames}]{beamer}

\usepackage{amsmath}

\begin{document}
\begin{table}[ht]
    \begin{center}
        \begin{tabular}{l*{4}{r @{} l}}
            \hline
            &  (I)  &        &  (II)&        &  (III)&        &  (IV)&         \\
            &    OLS    &        &    Q1&        &    Q2&        &    Q3&         \\
            \hline
A&        xxx&$^{**}$       &      xxx&$^{***}$             &        xxx&$^{**}$                &        xxx&$^{***}$\\
                &      (yyy)&        &     (yyy)&           &      (yyy)&        &      (yyy)&        \\
B&        xxx&          &       xxx&$^{**}$             &        xxx&$^{***}$               &        xxx&$^{**}$\\
                &      (yyy)&        &      (yyy)&        &      (yyy)&        &      (yyy)&        \\
\hline
\end{tabular}
\end{center}
\end{table}
\end{document}

This thread provides a close solution using the <\onslide> command How to uncover a table column wise in Latex beamer. However, with this approach the headings would show up at the same time as the coefficients.

Also, I would like to keep the command \begin{tabular}{l*{4}{r @{} l}} and not \begin{tabular}{l rl rl rl rl} as the former provides a nicer output with the stars closer to the left border.

Andrew
  • 291
  • 1
    why you use document class article if you like to have solotion possible only in beamer? – Zarko Apr 08 '18 at 18:29
  • Oh sorry! you're right I corrected it! – Andrew Apr 08 '18 at 18:37
  • 1
    @Andrew: Your MWE still deos not contain a frame. Please also note, that using a floating environment like table is not necessary if you don't want to add a caption. Generally, nesting a tabular insde a center environment is not advisable, as it adds additional vertical space. You can use \centering instead. – leandriis Apr 08 '18 at 18:48
  • @Andrew Actually you can simply drop the center environment, as beamer centres tables by default (as long as the table environment is used, which is not a float in beamer) – samcarter_is_at_topanswers.xyz Apr 08 '18 at 18:56
  • I know, I just copied the table from an article, and I forgot to modify it – Andrew Apr 08 '18 at 23:49

1 Answers1

5

I'd suggest the following solution, that shows the first column, as well as the other column's headings and all horizontal lines on the first slide and adds the remaining data on a second slide:

\documentclass{beamer}
\usepackage{array}
\usepackage{amsmath}

\begin{document}
\begin{frame}
\centering
        \begin{tabular}{>{\onslide<1->}l >{\onslide<1->}r @{} >{\onslide<1->}l *3{>{\onslide<2->}r @{} >{\onslide<2->}l}}
            \hline
            &  (I)  &        & \onslide<1-> (II)&        & \onslide<1-> (III)&        &  \onslide<1->(IV)&         \\
            &    OLS    &        &   \onslide<1-> Q1&        &   \onslide<1-> Q2&        &   \onslide<1-> Q3&         \onslide<1->\\
           \hline
A&        xxx&$^{**}$       &      xxx&$^{***}$             &        xxx&$^{**}$                &        xxx&$^{***}$\\
                &      (yyy)&        &     (yyy)&           &      (yyy)&        &      (yyy)&        \\
B&        xxx&          &       xxx&$^{**}$             &        xxx&$^{***}$               &        xxx&$^{**}$\\
                &      (yyy)&        &      (yyy)&        &      (yyy)&        &      (yyy)&       \onslide<1-> \\
\hline
\end{tabular}
\end{frame}
\end{document}

enter image description here

leandriis
  • 62,593