TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
I've updated my answer showing how to use cleveref together with the exercise package. – Gonzalo Medina Oct 8 '12 at 3:47
up vote 4 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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