練習包中答案的鏈接

練習包中答案的鏈接

我正在使用練習包創建練習簿。

我知道我可以向問題添加標籤以將答案連結到特定問題。

但是,我想在問題下方添加一個答案的連結。所以它看起來像:

目前文字來源:

\usepackage[answerdelayed]{exercise}
\begin{Exercise}
What is the value of 2+5?
\end{Exercise}
\begin{Answer}
7
\end{Answer}
<rest of the document>
\shipoutaAnswer

電流輸出:

Exercise 1: What is the value of 2 + 5?

<rest of the document>

Solution 1: 7

期望的輸出:

Exercise 1: What is the value of 2 + 5?
<Link to Solution at the end of the document>

<rest of the document>

Solution 1: 7

答案1

exercise有特定的方式來管理標籤。

請參閱包文件第 2.4 款。

\documentclass{article}
\usepackage{hyperref}% you must load it before the exercise package
\usepackage[answerdelayed]{exercise}

\begin{document}
    \begin{Exercise}[label={mylabel}]
        What is the value of 2+5? (To see the answer click here: \refAnswer{\ExerciseLabel})
    \end{Exercise}
    \begin{Answer}[ref=\ExerciseLabel]
        7
    \end{Answer}

    rest of the document
    \newpage % I've added a new page only to clearly show the hyperlink. Of course, you don't need it in your document.

    \shipoutAnswer
\end{document}

在此輸入影像描述

在此輸入影像描述

答案2

像這樣:

\documentclass{article}
\usepackage{exercise}
\usepackage{hyperref}
\begin{document}
\begin{Exercise}
    Some introductory text.
    \Question The first question
\end{Exercise}

See the answer \hyperref[one]{here}.
\newpage
\begin{Answer}[ref=first]
    The answer to question~\ref{first}.\label{one}
\end{Answer}
\end{document}

相關內容