From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/27303 Path: news.gmane.org!not-for-mail From: Sanjoy Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: using headnumber Date: Thu, 20 Apr 2006 17:54:09 +0100 Message-ID: References: <4447A561.1020102@gmx.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1145552071 16537 80.91.229.2 (20 Apr 2006 16:54:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2006 16:54:31 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Apr 20 18:54:28 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org 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 1FWcQ7-0004fz-Ed for gctc-ntg-context-518@m.gmane.org; Thu, 20 Apr 2006 18:54:19 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2D975127AA; Thu, 20 Apr 2006 18:54:19 +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 32624-03-4; Thu, 20 Apr 2006 18:54:13 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id B2D34127BB; Thu, 20 Apr 2006 18:54:13 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 788FA127BB for ; Thu, 20 Apr 2006 18:54:12 +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 32624-03-3 for ; Thu, 20 Apr 2006 18:54:11 +0200 (CEST) Original-Received: from mraos.ra.phy.cam.ac.uk (mraos.ra.phy.cam.ac.uk [131.111.48.8]) by ronja.ntg.nl (Postfix) with SMTP id 57B8C127AA for ; Thu, 20 Apr 2006 18:54:10 +0200 (CEST) Original-Received: from skye.ra.phy.cam.ac.uk ([131.111.48.158] ident=mail) by mraos.ra.phy.cam.ac.uk with esmtp (Exim 4.43) id 1FWcPx-0005Os-PE; Thu, 20 Apr 2006 17:54:09 +0100 Original-Received: from sanjoy by skye.ra.phy.cam.ac.uk with local (Exim 3.36 #1) id 1FWcPx-0000G2-00; Thu, 20 Apr 2006 17:54:09 +0100 Original-To: mailing list for ConTeXt users In-Reply-To: Your message of "Thu, 20 Apr 2006 17:14:41 +0200." <4447A561.1020102@gmx.net> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:27303 Archived-At: > \determineheadnumber[section] Thanks for mentioning that command, which I'd been looking for. I couldn't quite get it to work, but reading the code near its definition helped me solve another problem. Each chapter has a section for exercises, and each exercise is a subsection with a short title (a few words). e.g. \exercise{Batteries} What is the cost of energy from a 9V battery? From a wall socket (the mains)? I want the exercises to be numbered just by the exercise number (e.g. 7), not for example 1.6.7 (if the exercises are the 6th section in chapter 1). Hence this setup: \definehead[exercise][subsection] \def\choptwo#1.#2.{} \def\processtwo#1{\expandafter\choptwo#1\relax} \setuphead[exercise][style=italic, numbercommand={\processtwo{\currentheadnumber} \gobbleoneargument}] If there's an easier way using \determineheadnumber, I'll be happy to use it instead but the above probably fragile hack works for me. The more obvious try \def\choptwo#1.#2.{} \setuphead[subsection][numbercommand={\expandafter\choptwo}] produced 200 lines of complaint, starting with: ERROR: Argument of \choptwo has an extra }. In the following minimal example of my attempt to use determineheadnumber, the subsection numbers are missing (instead of being the chapter number): \setuphead[subsection] [numbercommand={\determineheadnumber[chapter] \gobbleoneargument}] \starttext \chapter{One} \section{A1} hi \subsection{B1} hi \subsection{B2} hi \stoptext >> >> \setuphead[section] >> [command={{{\determineheadnumber[section]} ^^^^ > one opening brace too much That's why I want the editor to insert } for me automatically when I type { (in the earlier thread about AUCTeX/Emacs). -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.