I am using the exercise package, as illustrated in the following example:


I can put a reference to this problem by doing something like:

In \ref{modernOpticsLecture2:pr2} we show that

which shows up with a 2.2 hyperlink:

In 2.2 we show that

but would prefer the reference include a bit more text (i.e. prefixed by exercise) like so:

In Exercise 2.2 we show that

For now I've just prefixed by \ref with the text 'Exercise', but noticed that in my .aux file I have something like:

\newlabel{modernOpticsLecture2:pr2}{{2.2}{38}{Problems\relax }{Exercise.2.2}{}}

which seems to imply that there's probably a way to directly reference this by the Exercise.2.2 name that's tucked away in the .aux file encoded using this \newlabel command.

I was wondering how that would be done?

  • I've updated my answer showing how to use cleveref together with the exercise package. – Gonzalo Medina Oct 8 '12 at 3:47

The cleveref package automatically generate this kind of format for cross-references. Instead of using \ref, you now use \cref (or \Cref at the beginning of a sentence.)

You have to make cleveref aware of the Exercise environment from the exercise package; this can be done using the \crefname (for \cref) and \Crefname (for \Cref) commands:


A little example:




The reader is asked to demonstrate this fact in~\cref{modernOpticsLecture2:pr2}.
title={Some exercise},
Test exercise


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.