Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

ReferToEnumeratedItem

Categories: Numbering
<< | Page list | >>

Example of how you can refer to a specific enumerated item

This example is copied almost verbatim from this post to the user's list -- Christian (who haven't tested this himself).

Rudi van der Linde asks:

> I have got an enumerated list e.g.
> 
> 1. Item 1
> 2. Item 2
> 3. [Label1]Item 3
> 4. Item 4
> 
> Where [Label1] is a label to an item of interest.
> 
> What I want to do is have another enumerated list after the first one
> which contains one item only, such that the item in the list has the
> same number as the one with [Label1] in the first list e.g.
> 
> 3. Item 5
> 
> The solution I need must not affect the numbering for any other
> enumerated lists.

where Paul A. Rubin answered:

The only way I know to do this requires Evil Red Text. It's a bit clunky, because LyX automatically issues the first \item command as soon as you start an enumeration.

In your document preamble, add the line \newcounter{myCounter} (feel free to customize the name myCounter).

Precede the text of item 3 (after the 3. that LyX displays) with the following ERT:

\setcounter{myCounter}{\value{enumi}}\addtocounter{myCounter}{-1}

Note that you can avoid the \addtocounter command if you put the \setcounter ERT in item *2* (the item preceding the one you want to reference), so pick your poison.

Now when you're ready to add item 5, use a standard environment (not enumerate), precede the text of item 5 with an ERT box containing

\begin{enumerate}\setcounter{enumi}{\value{myCounter}}\item 

and follow item 5 with an ERT box containing ERT%\end{enumerate}

If you need to refer back to more than one enumerated item, you'll need to define separate counters for each.

Two things pertaining to the enumeration counter. I used "enumi" here on the assumption that you're referring back to items at the outermost enumeration level; if not, you'll need to change the counter name. As far as screwing up other enumerations, each time you start an enumeration list in LyX, I'm pretty sure the counter gets reset to 1.
-- Paul

There are also packages that provide another way of accomplishing this without any ERT. Check out Covington.

Numbering

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2006-08-29 18:52 UTC