i am creating an exercise book using the exercise package.

i understand that i can add a label to a question to link an answer to a specific question.

however, i'd like to add a link to the answer under the question. so it looks something like:

Current tex source:

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


Current output:

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

<rest of the document>

Solution 1: 7


Desired output:

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


The exercise package has a specific way to manage the label.

See the package documentation subsection 2.4.

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

\begin{document}
\begin{Exercise}[label={mylabel}]
\end{Exercise}
7

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.

\end{document}


• thanks a lot @CarLaTeX :) Is there a way to achieve this if I don't want to label each exercise manually. – gaurav gupta Jul 11 '17 at 0:27
• can someone help me with the follow-up question posted at the following link, please? tex.stackexchange.com/questions/380095/… – gaurav gupta Jul 11 '17 at 4:53
• @gauravgupta Thank you for accepting my answer! I'll try to help you with your new question, too. – CarLaTeX Jul 11 '17 at 5:03
• @gauravgupta I've already got an answer, Troy's been faster than me :) – CarLaTeX Jul 11 '17 at 6:18
• yupp - saw Troy's answer. You two are fantastic! Thanks :) – gaurav gupta Jul 11 '17 at 10:13

Like this:

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