Text Formatting ⇒ Set current reference string in list environment
-
- Posts: 5
- Joined: Thu May 21, 2009 11:13 pm
Set current reference string in list environment
I'm relatively new to LaTeX... and I'm trying to define a list environment which will generate cross-reference labels automatically as per the code below:
%% Environment for numbered display items
%% The argument is used to define a label allowing later reference to the number
\newcounter{ndictr}%
\newenvironment{ndi}[1]%
{% open environment ndi
\newcommand{\ndil}{(\thendictr)}
\begin{list}{}%
{% declarations
\settowidth{\labelwidth}{\makelabel{(999)}}%
\setlength{\leftmargin}{\labelwidth+\labelsep}%
\addtocounter{ndictr}{1}%
}%
\item [\ndil] \mbox{}\outl{\thendictr}\label{ndi#1key}%
\ignorespaces%
}%
{% close environment ndi
\unskip%
\end{list}%
}% end of environment ndi
The label is generated as expected, but later uses of \ref{key} fail because, as expected, the current reference string is not being set.
Can someone tell me what to do in order to get that set?
Thanks!
K
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
-
- Posts: 5
- Joined: Thu May 21, 2009 11:13 pm
Re: Set current reference string in list environment
K
-
- Posts: 5
- Joined: Thu May 21, 2009 11:13 pm
Re: Set current reference string in list environment
I read through the code of the cjoutl package, which does something similar to enumerate, and by sheer process of elimination discovered the \refstepcounter command: this increments the counter and sets the \ref value as well.
See A Document Preparation System: LaTeX--User's Guide and Reference Manual, p. 195.
Seems to work

Thanks
K