我正在为我的学生写一本书,我希望在每一章的末尾对该章中所有重要的方程式进行总结(包括其方程式编号、实际公式和一些关于它的解释——有点像“克拉珀龙理想气体方程”)。
有没有简单的方法可以做到这一点?或者我需要疯狂地使用标签、复制粘贴等?
答案1
我介绍\retaineqn{...}
如何呈现但保存一个等式以供稍后重演,并\recalleqn
回忆起之前保存的下一个等式(重演阶段)。
\documentclass[12pt]{article}
\newcounter{retained}\setcounter{retained}{0}
\newcounter{shown}\setcounter{shown}{0}
\newcounter{saveequation}
\newcommand\retaineqn[1]{%
\addtocounter{retained}{1}%
\expandafter\edef\csname defeqnum\roman{retained}\endcsname{%
\arabic{equation}}%
\expandafter\gdef\csname defeq\roman{retained}\endcsname{#1}%
\csname defeq\roman{retained}\endcsname%
}
\newcommand\recalleqn{%
\addtocounter{shown}{1}%
\setcounter{saveequation}{\value{equation}}%
\setcounter{equation}{\csname defeqnum\roman{shown}\endcsname}%
\csname defeq\roman{shown}\endcsname%
\setcounter{equation}{\value{saveequation}}%
}
\begin{document}
\section{A Chapter}
In equation~\ref{eq:first}, we present and retain an important equation.
\retaineqn{%
\begin{equation}
\label{eq:first}
y = x
\end{equation}
}%
Then we use it in a not so important equation~\ref{eq:second}
\begin{equation}
\label{eq:second}
y = x^2
\end{equation}
Now for this next equation (equation~\ref{eq:third}), it is also important,
so we will retain it
\retaineqn{%
\begin{equation}
\label{eq:third}
y = x^3
\end{equation}
}%
and use it to prove this last unimportant equation
\begin{equation}
\label{eq:fourth}
y = x^4
\end{equation}
\subsection{Recapitulation}
Our first retained equation was
\recalleqn
Our next retained equation was
\recalleqn
\section{Next Section}
Did equation numbers pick up in the right place?
\begin{equation}
y = x^5
\end{equation}
\end{document}