groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] List labels in MM and three argument .ds


From: Peter Schaffter
Subject: Re: [Groff] List labels in MM and three argument .ds
Date: Sat, 1 Aug 2009 11:24:38 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Jul 31, 2009, Blake McBride wrote:
> I'd like to label nested lists with the enclosing list's number using MM
> like the following:
> 
> 1.  First item
>     1.1.  First sub-item of the first list
>     1.2.  Second sub-item of the first list
> 2.  Second item
>     2.1.  First sub-item of the second list
>     2.2.  Second sub-item of the second list
> 
> What I attempted to do was specify a label while accessing the internal
> counter information.  By accessing those registers I could create any label
> I wanted and still retain the auto-numbering.
> 
> Is this easy to do in MOM?

Mom doesn't do this natively, but defining a macro like the
following before invoking LIST does the trick.

.eo
.de SUBLIST
.   rr sublist-digit
.   nr headlist-digit \n[#ENUMERATOR\n[#DEPTH]]
.   nr sublist-digit -1 1
.   ds item-number \n[headlist-digit].\En+[sublist-digit].\"
.   LIST USER \*[item-number]
..
.ec

To reproduce your example, here's the usage:

.LIST DIGIT
.ITEM
First item
.SUBLIST
.ITEM
First sub-item of the first list
.ITEM
Second sub-item of the first list
.LIST back
.ITEM
Second item
.SUBLIST
.ITEM
First sub-item of the second list
.ITEM
Second sub-item of the second list
.QUIT_LISTS

Don't know if that's what you consider easy, but it's a solution. :)
Things would get a bit more complicated if you wanted deeper levels
of nesting that followed the same scheme.

-- 
Peter Schaffter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]