答案是https://tex.stackexchange.com/a/60692/12212解释了如何通过将行包装在命令中来发现 Beamer 中标记对齐的行onslide
。如果可以自动完成此操作,而无需手动输入每个对齐的每一行的命令,那就太好了。如何才能实现与以下示例相同的结果,但不必每次都onslide
手动输入命令?onslide
\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}
答案1
我将使用 LaTeX3 编程层给出解决方案:
\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}
答案2
使用与https://tex.stackexchange.com/a/661242/36296,你可以使用该tabularray
包来模拟如下的样子align
:
\documentclass{beamer}
\usepackage{tabularray}
\UseTblrLibrary{counter}
\NewDocumentEnvironment{myalign}{+b}{
\begin{tblr}{
column{1}={co=1},
column{Z}={co=1},
column{odd}={halign=r},
column{even}={halign=l},
colsep = 0pt,
cells={mode=dmath},
cell{1-Z}{1}={cmd=\action<+->},
cell{1-Z}{2-Z}={cmd=\action<.->},
cell{1-Z}{Z}={appto={\hfill \refstepcounter{equation}(\theequation)}}
}
#1
\end{tblr}
}{}
\begin{document}
\begin{frame}
\begin{myalign}
abc & = def\\
& = ghi\\
& = 0.\\
\end{myalign}
\end{frame}
\end{document}