From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/29182 Path: news.gmane.org!not-for-mail From: Ulf Martin Newsgroups: gmane.comp.tex.context Subject: Re: Numbering Date: Fri, 07 Jul 2006 10:55:44 +0200 Message-ID: <44AE2190.6050206@web.de> References: <2DDE0779-E922-4C59-8C55-F4798844EC58@cox.net> Reply-To: ulfmartin@web.de, 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 1152262634 27677 80.91.229.2 (7 Jul 2006 08:57:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 7 Jul 2006 08:57:14 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Fri Jul 07 10:57:12 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 1Fym94-0005nC-1S for gctc-ntg-context-518@m.gmane.org; Fri, 07 Jul 2006 10:57:07 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0240312788; Fri, 7 Jul 2006 10:57:06 +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 17084-04; Fri, 7 Jul 2006 10:57:00 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 12BF8127BA; Fri, 7 Jul 2006 10:56:58 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 73855127BA for ; Fri, 7 Jul 2006 10:56:53 +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 16677-08 for ; Fri, 7 Jul 2006 10:56:43 +0200 (CEST) Original-Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221]) by ronja.ntg.nl (Postfix) with SMTP id 971BD12788 for ; Fri, 7 Jul 2006 10:56:41 +0200 (CEST) Original-Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate01.web.de (Postfix) with ESMTP id 018326E435B for ; Fri, 7 Jul 2006 10:55:46 +0200 (CEST) Original-Received: from [212.202.36.37] (helo=[212.202.36.37]) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.107 #114) id 1Fym7l-0002lk-00 for ntg-context@ntg.nl; Fri, 07 Jul 2006 10:55:45 +0200 User-Agent: Thunderbird 1.5.0.4 (Macintosh/20060530) Original-To: mailing list for ConTeXt users In-Reply-To: <2DDE0779-E922-4C59-8C55-F4798844EC58@cox.net> X-Sender: ulfmartin@web.de 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:29182 Archived-At: Hi David Arnold schrieb: > All, > > Let's say I have some enumerations that are numbered, for > definitions, examples, theorems, etc. Let's say I want everything in > a section numbered consecutively, except figures. So, numbering would > proceed like this: Here is a possible solution. Idea: - Define own counters - Use section type with "ownnumber" option - Wrap them suitably Lets call "Definition"s, "Example"s etc by the name "Topic" and assume you want to reset the topic number with each section. Here is the code: %%% \newcount\SectionNum \def\resetSection{\SectionNum=0} \def\stepSection{\advance\SectionNum by 1 \resetTopic} \def\theSection{\the\SectionNum} \resetSection \newcount\TopicNum \def\resetTopic{\TopicNum=0} \def\stepTopic{\advance\TopicNum by 1} \def\theTopic{\theSection.\the\TopicNum} \resetTopic \definehead[TopicHead][section=section-7] \setuphead[TopicHead] [ownnumber=yes, % use own counter TopicNum % more setup ] \def\Topic{\dotripleempty\doTopic} % Usage: \Topic[topic type][topic text][label] \def\doTopic[#1][#2][#3]{ \stepTopic \ifthirdargument \TopicHead[#3]{#1~\theTopic}{ #2}% \else \ifsecondargument \TopicHead{#1~\theTopic}{ #2}% \else \iffirstargument \TopicHead{#1~\theTopic}{}% \else \TopicHead{\theTopic}{}% \fi \fi \fi} %% Example for a convenient abbreviation: %% \Def[...][...] instead of \Topic[Definition][...][...] \def\Def{\dodoubleempty\doDef} % Usage: \Def[title text][label] \def\doDef[#1][#2]{ \ifsecondargument \Topic[Definition][#1][#2] \else\iffirstargument \Topic[Definition][#1] \else \Topic[Definition] \fi\fi} %% I don't know if one can access section counters directly %% So we need a wrapper for the section level that resets the %% topic counter. \setuphead[section] [ownnumber=yes, % more setup ] \def\Section{\dosingleempty\doSection} % Usage: \Section[label]{title text} \def\doSection[#1]#2{ \stepSection \iffirstargument \section[#1]{\theSection}{#2} \else \section{\theSection}{#2} \fi} %%% %%% Example \starttext \Section{Things Going Wrong} \Def[(Murphy's Law)][law:murphy] Everything that can go wrong will go wrong sometime. \Topic[Example][(Bread of Butter)] An example for \in[law:murphy] is that a bread of butter falling off a table universally lands with the buttered side on the carpet. \Section{Motion} \Def[(Silly Walk)][def:sillywalk] Silly walking is a kind of walking made up of motions that do not necessarily contribute to the advancement of the walker. \Topic[Corollary][][cor:goosestep] Goose-step is a type of silly walking as defined in \in[def:sillywalk]. \Topic[Remark] Prussians and Bolshewists may not agree with \in[cor:goosestep]. \stoptext (I had a similar problem: I wanted a type of sections with a numbering only affected by specified other structural elements.) The solution is probably not the most ConTeXt-like -- I am still on my way from LaTeX... Question to TeX experts: in the context of the above, how would one properly define a command like \ProvideTopicType[Definition]{Def} after which \Def[(Murphy's Law)] produces something like Definition 1.2 (Murphy's Law) Cheers! Ulf