(I'm sorry for my bad english) I created an accountant to do an enumeration of questions for an exercise list. Eventually I would like to make a reference to a given exercise. But the \label and \ref commands are not working for me. Could someone help me?


\newcommand{\eq}{{\noindent {\bf{\arabic{eq}}}} \addtocounter{eq}{1}{\hspace{-0.1cm{{.}}}} }
\newcommand{\eqz}{{\setcounter{eq}{1}} {{\arabic{eq}}} \addtocounter{eq}{1}\hspace{-0.1cm{{.}}}}

\pagestyle{myheadings} \thispagestyle{empty}

\eq \label{eq1} Let $X$ be such that....

\eq \label{eq2}In this exercise consider $Y=2$ ...

\eq \label{eq3} Consider, in exercise \ref{eq1} (I would like to see the issue number 1)

\eq Here, consider in exercise \ref{eq2} (I would like to see the issue number 2) $Y=3$...

\eq Here, consider in exercise \ref{eq3} (I would like to see the issue number 3) $Y=5$...

  • 4
    Please, do not use \bf which has been obsolete for at least 12-15 years, and try \textbf{text} or {\bfseries text} – Moriambar May 19 '17 at 20:24
  • 2
    I see, but try and stop using it since it has some drawbacks (other than not being supported) e.g., wrong spacing – Moriambar May 19 '17 at 20:43
  • 3
    Don't use pdfsync: it's invasive and very obsolete. – egreg May 19 '17 at 20:53
  • 3
    \addtocounter{eq}{1} does what you want. But what you really want is \refstepcounter{eq}. – Johannes_B May 20 '17 at 5:32
  • 2
    @Moura if I 1) remove \refstepcounter{eq} from your example 2) replace \addtocounter{eq}{1} with \refstepcounter{eq} in the definition of \eq I get working references. What exactly doesn't work for you? – cgnieder May 22 '17 at 17:53

All you need is to create the counter, set it, set a reference name and then you can start to reference it.

Let me elaborate with a short example.


\usepackage{environ, hyperref, cleveref}

  \begin{tikzpicture} %\pbox[pos][height][inner-pos]{max-width}{text}
        \pbox{#1\linewidth}{\BODY \label{quot:#3}}};
                \node[inner sep=1pt,very thin,anchor=east,pink,font=\bfseries\fontsize{48}{48}\selectfont,yshift=-5pt]at(box.north west){``};
                 \node[inner sep=1pt,very thin,pink,anchor=west,font=\bfseries\fontsize{48}{48}\selectfont,yshift=-8pt,xshift=-2pt]at(box.south east){''};
                \node[inner sep=1pt,very thin,anchor=north west,gray,font=\small\sffamily]at(box.south west){\begin{minipage}[t][1cm][t]{0.8\linewidth}
                \ {#2}\end{minipage}};


 \begin{hsquote}{Antoine de Saint-Exupéry}{adesigner}
 A designer knows that has has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.

 \Cref{quot:designer} is a quote on design used in the tufte-book.

  • 3
    The key point here is \refstepcounter -- that's not mentioned at all -- no \refstepcounter, no working cross-referencing (unless knowing internals about \@currentlabel – user31729 May 19 '17 at 20:32

There are already packages, so you might want to go with this:









References: \cref{ex:foo}, \cref{ex:bar} and \Cref{ex:foo}. 

References: \cref{noex:foo}, \cref{noex:bar} and \Cref{noex:foo}. 


Here are some manuals: http://www.ctan.org/pkg/cleveref, http://www.ctan.org/pkg/ntheorem. Here is an alternative: http://www.ctan.org/pkg/theorem.

enter image description here

  • Thanks for your help, but I do not like the word exercise to appear, only number. – Moura May 19 '17 at 20:44
  • @Moura: Please see my edits. – CampanIgnis May 19 '17 at 20:48
  • I saw. Maybe I did not understand. I would not like to have exercise 1, exercise 2. Only 1, 2, – Moura May 19 '17 at 20:53
  • 1
    @Moura: The recent change introduced the environments "nonum", and they only show the number, not "exercise". – CampanIgnis May 19 '17 at 20:55

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.