# Auto-generate label and index for description environment

\begin{description}
\item [\textsc{abandon}\label{abandon}\index{abandon}] \textit{verb} desert, leave behind
\end{description


Is it possible to automate the above process in such a way that the label and index entry for the description item will be automatically generated.

• Are your index entries just one word? Or do you refer to sub entries as well? \label isn't really useful here, since description does not use a counter! – user31729 Mar 8 '16 at 9:57
• @Christian Yes, my index entries are one word. If description does not use a counter, how can I reference to other words. (E.g. while discussing a certain word, I want reader to able to jump to a description of another word.) – blackened Mar 8 '16 at 10:03
• IMHO, you can refer to myname by writing myname. – touhami Mar 8 '16 at 10:10

Something like this ? ( a preliminary version only)

Since description does not use a counter, the \label item is effectively useless, unless a fake counter is introduced.

Since \item[...] is applied, I can't use \xapptocmd without much efforts, so I put \refstepcounter{...} before \item, but this is not really nice. I'll try to improve.

\documentclass{article}
\usepackage{imakeidx}

\usepackage{xpatch}

\newcounter{itemcntr}

\usepackage{hyperref}

\AtBeginEnvironment{description}{%
\setcounter{itemcntr}{0}%
\xpretocmd{\item}{\refstepcounter{itemcntr}}{}{}%
}
\makeindex

\newcommand{\descitem}[1]{%
\textsc{#1}%
\label{#1}%
\index{#1}%
}
\begin{document}

\begin{description}
\item [\descitem{abandon}] \textit{verb} desert, leave behind
\item [\descitem{upvote}] \textit{verb} appreciate answers on TeX.SX!
\end{description}

\clearpage

The term \nameref{upvote} is very important ;-)

\printindex

\end{document}

• refname, really does nothing here. – touhami Mar 8 '16 at 10:14
• @touhami: I don't understand. refname? Do you mean \nameref? – user31729 Mar 8 '16 at 10:18
• yes that is, but don't take it very serious. – touhami Mar 8 '16 at 10:21