1

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.

2
  • 1
    Is there a reason you want to use description and not enumerate?
    – TeXnician
    May 19, 2017 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, 2017 at 6:48

1 Answer 1

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

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

You must log in to answer this question.

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