I want to print on the margin paragraph a \pageref to the hint of the current exercise.

This is a follow up to a previous question of mine which I rely on, but for some reason my code doesn't work.

I don't understand why I get the error

LaTeX Warning: Reference `hint:1' on page 1 undefined on input line XX.

although I do create a label for each hint, by using this line of code:


(copied from the linked answer). I expect this line of code to create a label hint:1 for exercise with ID 1, and label hint:2 for exercise with ID 2 etc.

The complete code is:

% !TEX TS-program = xelatex

  exercise/within = chapter,
  solution/template =myTemplate ,


\ForEachUsedExerciseByType{\GetExercisePropertyT{hint}{\label{hint:##2}}} %<<-- Apparently creates a label

\IfExercisePropertySetT{hint}{hint on page \pageref{hint:\ExerciseID}} %<<-- This label is undefined

\chapter{Euclidean Geometry}
Questions for this week:

Prove Pythagoras' theorem
\hint{The sum of the angles in a triangle is equal to 180 degrees.}
The theorem can be proved algebraically\ldots

\begin{exercise}[subtitle={Proof of Thales's Theorem}]
Prove Thales's theorem.
\hint{the base angles of an isosceles triangle are equal. }

Let $\alpha=\angle BAO$ and $\beta=\angle OBC$\ldots

Prove the angle bisector theorem.
% no hint for this exercise

Consider triangles $ABD$ and $ACD$\ldots

{\normalfont\bfseries Hint #3\par}

enter image description here

1 Answer 1


A label assigns to key the number of the current sectional unit, and no sectional unit is in the vicinity of your command where you expect to create a label.

You have to append the \label{hint:#1} into an item of a list environment such as description, as done in the answer you linked to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .