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 頁。

在此輸入影像描述

答案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}

相關內容