[Tuglist] Please help with \ref

David Kastrup tuglist@tug.org.in
24 May 2002 09:38:19 +0200


[Quoting rearranged.  It helps to place material you refer to first,
or after a few followups the order of communication is beyond
recognition.]

"Dr. Dinesh Karia" <dineshjk@earth.planet.net.in> writes:

> From: "Manoj K N" <knm@india.ti.com>
> To: <tuglist@tug.org.in>
> Sent: Tuesday, May 21, 2002 6:47 PM
> Subject: Re: [Tuglist] Please help with \ref
> 
> > On Tue, May 21, 2002 at 05:56:13PM +0530, Dr. Dinesh Karia wrote:
> >
> > > \begin{defn}
> > > Some text here.
> > > \renewcommand{\labelenumi}{{(\roman{enumi})}}
> > > \begin{enumerate}
> > > \item \label{P:first}({\em positive definiteness}) descriptio here.
> > > \item \label{P:second}({\em subadditivity})descriptio here.
> > > \item \label{P:third}({\em homogeneity}) descriptio here.
> > > \end{enumerate}
> > > Then some text here.
> > >
> > > \begin{rems}\label{R:first} $ $ \\

> > I fail to understand what the environments defn and rems do here.
> > If what you need is a roman counter inside parentheses for the enumerate
> > environment, put the following line in your file.
> >
> > \renewcommand{\theenumi}{(\roman{enumi})}

>     Thanks for your reply. But you are making another question and
> it does not solve my problem.

I have not seen this "other question", and I would think that the
above advice should lead to some results.

> Well, I need to change the numbering scheme in my document. I prefer
> (a) (b) .... at some places and (1) (2) ..... at other.  So, I have
> to change this environment. But my question still stands. When in
> dvi file an item is listed as (i) (ii).. etc how is it that its
> reference appears as (1) (2) etc....? This is what is happening in
> my sample listed in my mail.

There are two different macros involved here.  The \theenumi macro
defines the proper name of the label and so is what is used when one
uses \ref, whereas the \labelenumi defines the way it is formatted
when actually making a list item in the text.

Thus, \labelenumi will most commonly include \theenumi in its
definition.

If we take a look at the definitions in the article class, we see the
equivalent of
\newcommand\labelenumi{\theenumi .}
\newcommand\theenumi{\arabic{enumi}}

So while the actual label is formatted with a period behind it, the
reference text does not include this markup.

Since you redefine only \labelenumi, references to the label are not
affected, only the formatting of the label itself in the actual list
is changed.

You will probably want to have something like
\renewcommand\theenumi{\roman{enumi}}
\renewcommand\labelenumi{(\theenumi)}
since the parentheses are not really a part of the label numbering
scheme, but rather of the formatting.

I recommend taking a look at the paralist package: this package makes
it very easy to make lists with custom label formatting.

Its documentation can be accessed with
texdoc paralist
if you are using a teTeX-based system.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de