Suppose I have the following code. I want to cross reference the numbers between the 2 lists. Basically, by clicking on number 1 in question section the document should automatically bring you to the number 1 of the answer section.

\documentclass[12pt, a4]{article}

\item \label{question-01} What colour was Napoleon's white horse?
\begin{enumerate}%[label= ...]
\item White

Tried with \label and \ref, but the reference creates another number 1, while I want the cross reference to be inside the number of the list.

Maybe I should work on the \label command after \begin{enumerate}.

Hope to have been enough clear.

  • 2
    Cross references are not the same as hyperlinks (things that you can click on). You need hyperref for that. Btw: loading the enumerate package is redundant here as it is overwritten by enumitem. Plus where are your refs in this doc?
    – daleif
    Oct 14, 2016 at 19:04

2 Answers 2


The following provides an automated way of numbering questions and have it hyperlinked to answers.

enter image description here



\newcounter{questions}% To keep track of the questions environment
\newcounter{answers}% To keep track of the answers environment

  {\stepcounter{questions}% New questions environment
   \renewcommand{\theHenumi}{q-\thequestions-\arabic{enumi}}% To make hyperref happy
   \section*{Questions}% Question title
  \refstepcounter{enumi}% Step enumeration counter
  \item[{\hyperref[a-\thequestions-\labelenumi]{\labelenumi}}]\label{q-\thequestions-\labelenumi}% Set \item and \label it

  {\stepcounter{answers}% New answers environment
   \renewcommand{\theHenumi}{a-\theanswers-\arabic{enumi}}% To make hyperref happy
   \section*{Answers}% Answer title
  \refstepcounter{enumi}% Step enumeration item
  \item[{\hyperref[q-\theanswers-\labelenumi]{\labelenumi}}]\label{a-\theanswers-\labelenumi}% Set \item and \label it


  \qitem What colour was Napoleon's white horse?

  \aitem White


The questions environment sets up questions, with each question enumerated using \qitem. This sets a label for the question as well as a hyperlink jump from the enumeration to the corresponding answer. An analygous answers environment provides hyperlinks in the opposite direction.

The above should work for multiple sets of Questions and Answers, each sequentially linked to the corresponding set.

  • Great! Is there a way to automatically let the link between Q-A also functioning in the opposite directions? I am reading the question and I want to directly go to the answer while reading the answer I want to have a look back to data contained in the question. Oct 14, 2016 at 19:45
  • 1
    @FrancescoBianchi: That's how it was built... you should try it. You can click on the question number and it jumps to the corresponding answer. Then, clicking on the answer number will jump you to the corresponding question.
    – Werner
    Oct 14, 2016 at 19:46
  • Exactly what I was looking for. Unfortunately, I am not yet able to produce my own code to satisfy my own ideas. Thanks a lot! Oct 14, 2016 at 19:58

To achieve your objective, you need to load the hyperref package; neither the enumitem nor the enumerate package is required. (Aside: do not load both packages simultaneously.) The hyperref package provides the commands hypertarget, to create a "target", and \hyperlink, to create a link to the "target" defined by \hypertarget.

Here's a simple MWE (mininum working example). Note that each \item -- in both enumerate environments -- is associated with both a \hypertarget and a \hyperlink instruction. The "link button" is just a \textbullet; obviously, you free to come up with something fancier. For the simple example at hand, I've chosen to leave the second argument of both \hypertarget directives empty.


What colour was Napoleon's white horse?

\clearpage  % just to make jumping between the links non-trivial



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.