Consider these statements

Exercise 1. $\phi(n)$ is multiplicative.

Exercise 2. By Exercise 1 we have $\phi(n)=\prod_{p|n}(1-1/p)$.

Suppose I want to cross refer Exercise 2 to Exercise 1 what command should I give??

I looked at various example on this site, but I am unable to understand anything. I tried

  • Exercise 1. \label{1} $\phi(n)$ is multiplicative

  • Exercise 2. By \ref{1} we have ..... but this doesn't work.

Kindly help.

  • To use the TeX/LaTeX \label-\ref cross-referencing system, you generally need a counter variable that's incremented automatically (usually via a \refstepcounter directive). Please tell us how the exercise list is constructed and how the counter is incremented. – Mico Jul 2 '16 at 8:15
  • @Mico Em. Exercise list is constructed using the \textbf{Exercise 1 } command, there is no listing as such :( – crskhr Jul 2 '16 at 8:19
  • 2
    If you set the number by hand, how is the computer program supposed to know that there even is a number to be referred to. You have to define an environment along with a suitable counter. And when labeling stuff, don't use numerical labels. It is the worst you can do. Do something like label{multiplicativePhi}. – Johannes_B Jul 2 '16 at 8:22
  • 2
    I looked at your profile, you are a member for four years and have asked 23 questions. Why don't you use proper marup for your questions and comments? – Johannes_B Jul 2 '16 at 8:23
  • 1
    @Mico: Both interpretations are correct, in my point of view -- if it's the same file \label is sufficient, of course! – user31729 Jul 2 '16 at 9:23

It looks to me like you should set up a semi-customized enumerated list environment. One way to do this is with the facilities of the enumitem package. In the following example, a new enumerated list called "exlist" is defined and its formatting, labeling, and cross-referencing properties are specified. That way, items in the list can be cross-referenced using the standard \label-\ref mechanism.

enter image description here


\usepackage{enumitem} % for customized lists
         label = \textbullet\ \bfseries Exercise \arabic*.,
         ref   = Exercise \arabic*}

\item \label{ex:mult} $\phi(n)$ is multiplicative. 
\item By \ref{ex:mult} we have $\phi(n)=\prod_{p|n}(1-1/p)$.

  • 1
    ...nice than mine! +1 (well, missing the Heinlein reference, but well...) – Rmano Jul 2 '16 at 9:12

I think the problem here is that you do not grok the concept of label-reference in LaTeX ☺.

You should have an automatic numbered thing to use the automatic referencing one --- otherwise it has no sense (if you fix the exercise to "1", you can use "1", no?). For example:

Bla bla bla
\item \label{ex:simple} first exercise here 
\item \label{ex:complex} let's build on exercise~\ref{ex:simple}...

If you solved the exercises~\ref{ex:simple} and~\ref{ex:complex}, then \dots


(This is just to give an idea, probably the theorems environments are better for this, or tcolorbox to have fancy ones. Even this should be adjusted to remove the "dot" on the references, which surely can be done...).

This will compile to:

enter image description here

and if you add a intermediate item as \item Hi, I though an intermediate here:

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.