From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/21784 Path: news.gmane.org!not-for-mail From: Brooks Moses Newsgroups: gmane.comp.tex.context Subject: Re: enumerated lists Date: Thu, 04 Aug 2005 11:14:22 -0700 Message-ID: <4.3.1.2.20050804011251.01c63008@cits1.stanford.edu> References: <427530A1.4050108@online-resourcen.de> <427530A1.4050108@online-resourcen.de> <42CCDA63.8000204@online-resourcen.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Trace: sea.gmane.org 1123179375 8165 80.91.229.2 (4 Aug 2005 18:16:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 Aug 2005 18:16:15 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 04 20:16:14 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1E0kEy-0000yJ-RZ for gctc-ntg-context-518@m.gmane.org; Thu, 04 Aug 2005 20:14:48 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 5A1EB127E6; Thu, 4 Aug 2005 20:14:48 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25857-01; Thu, 4 Aug 2005 20:14:42 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DBFEF127E2; Thu, 4 Aug 2005 20:14:42 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 25EE2127E2 for ; Thu, 4 Aug 2005 20:14:42 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25583-07-3 for ; Thu, 4 Aug 2005 20:14:40 +0200 (CEST) Original-Received: from smtp2.Stanford.EDU (smtp2.Stanford.EDU [171.67.16.125]) by ronja.ntg.nl (Postfix) with ESMTP id 9C48A127DE for ; Thu, 4 Aug 2005 20:14:39 +0200 (CEST) Original-Received: from mindolluin.stanford.edu (DNab42a43d.Stanford.EDU [171.66.164.61]) by smtp2.Stanford.EDU (8.12.11/8.12.11) with ESMTP id j74IEYi1000465 for ; Thu, 4 Aug 2005 11:14:36 -0700 X-Sender: brooks@cits1.stanford.edu X-Mailer: QUALCOMM Windows Eudora Version 4.3.1 Original-To: mailing list for ConTeXt users In-Reply-To: <42CCDA63.8000204@online-resourcen.de> Original-References: <427530A1.4050108@online-resourcen.de> <427530A1.4050108@online-resourcen.de> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:21784 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:21784 At 12:31 AM 7/7/2005, Frank Grieshaber wrote: >Hello all (esp. the ConTeXt-Developers), > >some time ago I sent the following email to this list and got no reply so >I'm resending it. >>Dear all, >>I have a manuscript with long nested numbered enumerations and I want the >>numbers of all levels to be printed automatically like: >>1. one >>1.1 one-one >>1.2 one-two >>2. two >>2.1 two-one >>2.2.1 two-two-one >>... >>Using the following prints only the current level's number, not all levels: >>\startitemize[n,packed] >>\item >>\item >> \startitemize[m,packed] >> \item >> \item >> \stopitemize >>\item >>\item >>\stopitemize >> >>For Latex there is the package paralist.sty for doing the desired >>numbering, how can this be done with ConTeXt? (I wrote this before I noticed that Hans had already replied, but I'm sending this anyway in case someone finds it useful.) I just accidentally solved this problem, in some of the LaTeX-compatibility stuff that I've been working on. Have a look at t-ltenum.tex for the kernel code that does it, and latextest.tex for an example of how to use it for something akin to that effect. It's fairly self-contained; you should be able to use t-ltenum.tex, t-ltcnts (which does counters) and t-ltbase.tex to get the "LaTeX-style enumerations" working, without needing any of the other bits. All my current files are in this repository: http://dpdx.net/context/latex-compat/ That's sort of the long way around to doing what you're looking for, though, and you can get the same effect without the LaTeX-compatibility overhead. Here's the trick.... First, you create a set of "conversions" for each level of the list -- see the Wiki page linked off "Enumerations" for how to do that. The conversion for level one will look something like this: \def\listconversioni{% \edef\listheadi{\numbers{#1}.}% \numbers{#1}} \defineconversion[listconvi][\listconversioni] That returns the list-counter in number form, but it also stores it (with a "." after it) in a "header". (I don't know whether that should be \edef or just \def, but I _think_ \edef is right.) Then, the conversion for level two looks something like this: \def\listconversionii{% \edef\listheadii{\listheadi\numbers{#1}.}% \listheadi\numbers{#1}} \defineconversion[listconvii][\listconversionii] That does the same thing, but now it's prefixing it with \listheadi. This then continues down the list as deep as you want to go. You then do a \defineitemgroup and some \setupitemgroup commands (again, see the Wiki's "Enumerations" page) to set it so that each one of those is associated with the appropriate level, and off you go; it's all automatic from there. Depending on whether \startitemize / \stopitemize includes grouping or not (and on exactly where that grouping is placed), it may be possible to do this in a more general form -- have \startitemize execute some code to set \parentlisthead to the current \listhead (which comes from the next level up), and then have one conversion for all levels which uses \parentlisthead and defines a new \listhead to be used on any child itemizations. The trick here is that \stopitemize will (hopefully) contain a \endgroup or \egroup, so that after it the \listhead value will revert to what it was before the corresponding \startitemize. This has the advantage of being able to go arbitrarily deep, but you can't do things like "1.a" where the levels are enumerated differently. There are, of course, variations on all of these, but that general idea should be enough to get you going. And I'll second the recommendation that something like this ought go in the kernel; I'm actually rather surprised that it's not already in there! Actually, what I would specifically suggest is that the \item code should place the converted item counter -- the result of calling \doconversion -- into something like \currentitemlabel, and then \startitemize should move that to \parentitemlabel, all automatically, so one can simply define conversions with \parentitemlabel in them without having to implement the machinery oneself. Or ... ah, wait; I see that Hans already replied to this shortly after you posted, and I missed it. Oh, well; I'll send this anyway. :) - Brooks