probsoln:如何将问题与其解决方案联系起来?

probsoln:如何将问题与其解决方案联系起来?

我简化了第 13 和 14 页上的示例probsoln 包装文档提出以下问题:我如何将问题与解决方案联系起来?(解决方案已经与相应问题相关联。)

MWE(2 个文件!)

衍生品.tex

\begin{defproblem}{cosxsqsinx}%
\begin{onlyproblem}%
$y = \cos(x^2)\sin x$.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}

主文本

\documentclass{report}

\usepackage{probsoln}
\usepackage[colorlinks,linkcolor=blue]{hyperref}

\begin{document}

\hideanswers

\chapter{Differentiation}
% randomly select 25 problems from derivatives.tex and add to
% the data set called 'deriv'
\loadrandomproblems[deriv]{1}{derivatives}
% Display the problems
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
\begin{enumerate}
\foreachproblem[deriv]{\item\label{prob:\thisproblemlabel}\thisproblem}
\end{enumerate}
% You may need to change \theenumi back here

\appendix
\chapter{Solutions}
\showanswers
\begin{itemize}
\foreachdataset{\thisdataset}{%
\foreachproblem[\thisdataset]{\item[\ref{prob:\thisproblemlabel}]\thisproblem}
}
\end{itemize}

\end{document}

截屏

我想要第 1 页上的“1.1”链接到解决方案......

在此处输入图片描述

...在第 2 页。例如第 2 页上的“1.1”链接到第 1 页上的练习。

在此处输入图片描述

答案1

\documentclass{report}

\usepackage{probsoln}
\usepackage[colorlinks,linkcolor=blue]{hyperref}

\begin{document}

\hideanswers

\chapter{Differentiation}
% randomly select 25 problems from derivatives.tex and add to
% the data set called 'deriv'
\loadrandomproblems[deriv]{1}{derivatives}
% Display the problems
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
\begin{enumerate}
\foreachproblem[deriv]{%
 \item[{\refstepcounter{enumi}\label{prob:\thisproblemlabel}%
        \hyperref[sol:\thisproblemlabel]{\theenumi}}]
       \thisproblem}
\end{enumerate}
% You may need to change \theenumi back here

\appendix
\chapter{Solutions}
\showanswers
\begin{itemize}
\foreachdataset{\thisdataset}{%
\foreachproblem[\thisdataset]{%
 \item[\ref{prob:\thisproblemlabel}\phantomsection\label{sol:\thisproblemlabel}]\thisproblem}
}
\end{itemize}

\end{document}

相关内容