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: <contextcode> %%%<Topic> \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} %%%</Topic> %%% 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 </contextcode> (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