I'd like to uncover a table row-by-row in a NiceTabular
environment (provided by the nicematrix
package). My table has alternating row colors, and I'd like overlay to cover/uncover the row color and its content at the same time. I'd also like to stick to the nicematrix
package instead of using the conventional tabular
/array
environments.
I tried several ways that work in tabular
and similar environments, but not in NiceTabular
. These include:
MWE
\documentclass{beamer}
\usepackage{nicematrix,booktabs}
\begin{document}
\begin{frame}
\centering
\begin{NiceTabular}{m{.4\textwidth}m{.4\textwidth}}
\CodeBefore
\rowcolor{gray!50}{1} % heading
\rowcolors{2}{gray!25}{} % body
\Body
\toprule
\onslide<2->{Head 1 & Head 2} \\
\midrule
Row 1 Col 1 & Row 1 Col 2 \pause\\
Row 2 Col 1 & Row 2 Col 2 Row 2 Col 2 Row 2 Col 2 Row 2 Col 2 \\
\bottomrule
\end{NiceTabular}
Overlay in conventional \texttt{tabular} for comparison:
\begin{tabular}{m{.4\textwidth}m{.4\textwidth}}
\toprule
\onslide<2->{Head 1 & Head 2} \\
\midrule
Row 1 Col 1 & Row 1 Col 2 \pause\\
Row 2 Col 1 & Row 2 Col 2 Row 2 Col 2 Row 2 Col 2 Row 2 Col 2 \\
\bottomrule
\end{tabular}
\end{frame}
\end{document}
Best Answer
Here is what I would do.
As usual with
nicematrix
, you need several compilations.If you accept to write in white the text that must be hidden, you have also the following solution (with a centered vertical position of the tabular).