Automate uncovering of lines of an align in beamer

alignbeameroverlays

The answer at https://tex.stackexchange.com/a/60692/12212 explains how to uncover lines of a tagged align in Beamer by wrapping the lines in onslide commands. It would be nice to have that done automatically without having to manually enter the onslide commands for each line of each align. How can I achieve the same result as the following example but without having to manually enter the onslide commands each time?

\documentclass{beamer}

\begin{document}

\begin{frame}

\begin{align}
\onslide<1->{abc & = def\\}
\onslide<2->{ & = ghi\\}
\onslide<3->{ & = 0.\\}
\notag
\end{align}
\vskip-1.5em
\end{frame}

\end{document}

Best Answer

I will give a solution with LaTeX3 Programming Layer:

\documentclass{beamer}

\ExplSyntaxOn
\NewDocumentEnvironment{myalign}{+b}
  {
    \tl_set:Nn \l_tmpa_tl { \begin{align} }
    \seq_set_split:Nnn \l_tmpa_seq { \\ } {#1}
    \seq_map_inline:Nn \l_tmpa_seq
      {
        \tl_if_empty:nF { ##1 }
          {
            \tl_put_right:Nn \l_tmpa_tl { \onslide<+->{ ##1 \\ } }
          }
      }
    \tl_put_right:Nn \l_tmpa_tl { \notag \end{align} \vskip-1.5em }
    \l_tmpa_tl
  } { }
\ExplSyntaxOff

\begin{document}

\begin{frame}
\begin{myalign}
abc & = def \\
    & = ghi \\
    & = jkl \\
    & = 0.  \\
\end{myalign}
\end{frame}

\end{document}

enter image description here

Related Question