我试图将我使用 Beamer 制作的演示文稿中的所有方程式放入一个表中以进行总结。但它们位于\align
环境中的不同框架中。我该如何实现这一点?
答案1
您可以使用collect*
来自collect
包;一个简单的例子:
\documentclass{beamer}
\usepackage{collect}
\definecollection{equations}
\begin{document}
\begin{frame}
\frametitle{A frame with an equation}
\begin{collect*}{equations}{}{}{}{}
\begin{align*}
a &= b \\
&=c.
\end{align*}
\end{collect*}
\end{frame}
\begin{frame}
\frametitle{Another frame with an equation}
\begin{collect*}{equations}{}{}{}{}
\begin{align*}
x &= y \\
&=z.
\end{align*}
\end{collect*}
\end{frame}
\begin{frame}
\frametitle{List of Equations}
\includecollection{equations}
\end{frame}
\end{document}
答案2
以下是借鉴的解决方案将框的内容写入文件
我用过etoolbox
包裹align
和equation
环境
% surround the align environment with
% \begin{lrbox}{\mybox}
% \begin{minipage}{\linewidth}
%
% CONTENT
%
% \end{minipage}
% \end{lrbox}
将内容保存到盒子中\mybox
;内容当然会输出到屏幕上,但也会保存在盒子中以供以后使用\savedeqns
\documentclass{beamer}
\usepackage{amsmath}
\usepackage{etoolbox}
% to store the contents of a SINGLE equation
\newsavebox{\mybox}
% to store the contents of ALL of the equations
\newbox\savedqns
\setbox\savedqns\vbox{}
% surround the align environment with
% \begin{lrbox}{\mybox}
% \begin{minipage}{\linewidth}
%
% CONTENT
%
% \end{minipage}
% \end{lrbox}
\BeforeBeginEnvironment{align}{\begin{lrbox}{\mybox}\noindent\begin{minipage}{\linewidth}}
\AfterEndEnvironment{align}{%
\end{minipage}%
\end{lrbox}%
\vspace{\abovedisplayskip}%
\noindent\usebox{\mybox}%
% save the equations for later
\global\setbox\savedqns\vbox{%
\unvbox\savedqns
\bigskip
\filbreak
\noindent\usebox{\mybox}}%
}
% do the same for the equation environment
\BeforeBeginEnvironment{equation}{\begin{lrbox}{\mybox}\noindent\begin{minipage}{\linewidth}}
\AfterEndEnvironment{equation}{%
\end{minipage}%
\end{lrbox}%
\vspace{\abovedisplayskip}%
\noindent\usebox{\mybox}%
% save the equations for later
\global\setbox\savedqns\vbox{%
\unvbox\savedqns
\bigskip
\filbreak
\noindent\usebox{\mybox}}%
}
\begin{document}
\begin{frame}{An align environment...}
\begin{align}
y&=x^2+2\\
&=2+x^2
\end{align}
\end{frame}
\begin{frame}{An equation environment...}
\begin{equation}
y=mx+b
\end{equation}
\end{frame}
\begin{frame}{My very important equations- SUMMARY}
\unvbox\savedqns
\end{frame}
\end{document}