使用问题计数器对出现在文档末尾的解决方案中的方程式进行编号

使用问题计数器对出现在文档末尾的解决方案中的方程式进行编号

我用exsheets它来编写问题集。我想根据方程式所属的问题对方程式进行编号。所以我使用\numberwithin{equation}{question}

这对于问题本身中出现的方程式很有效,但不适用于解决方案(我最后打印出来)。

\documentclass{article}

\usepackage{amsmath}
\usepackage{exsheets}

\numberwithin{equation}{question}

\begin{document}

\begin{question}
First Question
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{question}
\begin{solution}
    \begin{equation}
        E = m c^2
    \end{equation}
\end{solution}

\begin{question}
Second Question
\end{question}

\section*{Answers}%
\printsolutions%

\end{document}

在此处输入图片描述

我期望“a^2+b^2=c^2”的编号为 1.2。

所有解法方程都以最后一个问题号作为其编号。如何在解法中使用适当的问题号?

答案1

一个简单的解决方法是添加标签;只要您使用,这就可以自动完成equation

\documentclass{article}

\usepackage{amsmath}
\usepackage{exsheets}

\numberwithin{equation}{question}
\NewDocumentCommand{\TAG}{m}{\label{#1}}

\begin{document}

\begin{question}
First Question
\begin{equation}
a^2 + b^2 = c^2 \TAG{A}
\end{equation}
\end{question}
\begin{solution}
    \begin{equation}
        E = m c^2 \TAG{A}
    \end{equation}
\end{solution}

\begin{question}
Second Question
\end{question}

\section*{Answers}
\RenewDocumentCommand{\TAG}{m}{\tag{\ref{#1}}}
\printsolutions

\end{document}

在此处输入图片描述

相关内容