0

I am trying to perform the following:

\setcounter{cnt}{1}

\begin{description}

\item[A\value{cnt} label{A1}{(A\value{cnt})}].......

---increment {cnt} by 1

\item[A\value{cnt} label{A2}{(A\value{cnt})}].......

\end{description}

\ref{A1} should give A1 and \ref{A2} should give A2 and so on.

Basically I want to add a sequence of numbers to the item description and add a label to each of those items and when I refer using that label, the number assigned to that label should show.

  • 1
    Is there a reason you want to use description and not enumerate? – TeXnician May 19 '17 at 6:22
  • I have no specific reason to use description, because a lot of my lists have custom item descriptions, I ended up using description out of habit. The answer below does exactly what I needed. Thank you for the clarification. – Adi May 19 '17 at 6:48
2

As TeXnician says, the enumerate environment is better for this. I highly recommend the enumitem package because it gives an easy interface for customising labels and the layout of list environments, such as enumerate, itemize, description, ....

The following code uses enumitem to do what (I think) you want:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

  \begin{enumerate}[label=A\arabic*]
    \item\label{A1}.......
    \item\label{A2}.......
  \end{enumerate}

Look at \ref{A1} and \ref{A2}.

\end{document}

Here is the output:

enter image description here

  • This is a very nice and simple answer and does exactly as I need. Thanks for the help. – Adi May 19 '17 at 6:47
  • 1
    You could have automated the labels too... – TeXnician May 19 '17 at 7:07

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.