![](https://secure.gravatar.com/avatar/13a310a9e966d8e50f10029887c37493.jpg?s=120&d=mm&r=g)
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: Definition 1.1 Where the first number is the section number. Now, by "consecutive," I mean: Definition 1.1 f(x)=3x+2 (1.2) Example 1.3 Definition 1.4 Definition 1.5 f(x)=x^2 (1.6) Figure 1 Example 1.7 Example 1.8 Definition 1.9 Figure 2 etc. Hope this give the right idea. Question: What would be the "Context Way" to go about this?
![](https://secure.gravatar.com/avatar/b23e98325f2700d335e6cf87fe97288c.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/6114858d84b0f40cf715f12237ab67a1.jpg?s=120&d=mm&r=g)
On 7/7/06, David Arnold wrote:
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:
Grrr ... I have exactly the opposite problem: I need the definitions/examples/problems/... to be numbered independent of each other, but I cannot get rid of coupling between these numbers.
Definition 1.1
Where the first number is the section number.
Now, by "consecutive," I mean:
Definition 1.1
f(x)=3x+2 (1.2)
Example 1.3
Definition 1.4
Definition 1.5
f(x)=x^2 (1.6)
Figure 1
Example 1.7
Example 1.8
Definition 1.9
Figure 2
etc.
Hope this give the right idea.
Question: What would be the "Context Way" to go about this?
I didn't know how to automatically increase the subsection number after formulas, but the rest should be OK. \setuphead [subsection] [after={\incrementnumber[formula]}] \definehead [definition] [subsection] \definehead [example] [subsection] \setuplabeltext[en][definition=Definition ] \setuplabeltext[en][example=Example ] % or \setupfloat[figure][...] \setupfloats [way=bysection, location=top, align=right] \setupformulas [way=bysection] % after={\setupheadnumber[subsection][+1]}, \starttext \section{First section} \definition{} \placeformula \startformula f(x)=3x+2 \stopformula \setupheadnumber[subsection][+1] \example{} \definition{} \definition{} \placeformula \startformula f(x)=x^2 \stopformula \setupheadnumber[subsection][+1] \placefigure[here]{}{abc} \example{} \placefigure[here]{}{def} \example{} \definition{} \stoptext Mojca
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
Mojca Miklavec wrote:
On 7/7/06, David Arnold wrote:
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:
Grrr ... I have exactly the opposite problem: I need the definitions/examples/problems/... to be numbered independent of each other, but I cannot get rid of coupling between these numbers.
\defineenumeration [remark] [text=Remark] \defineenumeration [definition] [text=Definition] \setupenumerations [remark,definition] [location=serried, width=broad, headstyle=bold, inbetween=\blank, before=\blank, after=\blank, way=bysection] \starttext \startremark Foo \stopremark \startdefinition Foo \stopdefinition \startremark Foo \stopremark \startdefinition Foo \stopdefinition \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
David Arnold wrote:
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:
Definition 1.1
Where the first number is the section number.
Now, by "consecutive," I mean:
Definition 1.1
f(x)=3x+2 (1.2)
Example 1.3
Definition 1.4
Definition 1.5
f(x)=x^2 (1.6)
Figure 1
Example 1.7
Example 1.8
Definition 1.9
Figure 2
etc.
Hope this give the right idea.
Question: What would be the "Context Way" to go about this?
\defineenumeration [remark] [location=serried, width=broad, text=Remark, headstyle=bold, inbetween=\blank, before=\blank, after=\blank, way=bysection] \defineenumeration [definition] [remark] [text=Definition] \starttext \startremark Foo \stopremark \startdefinition Foo \stopdefinition \startremark Foo \stopremark \startdefinition Foo \stopdefinition \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/13a310a9e966d8e50f10029887c37493.jpg?s=120&d=mm&r=g)
OK, Now, how can we get \placeformula \startformula f(x)=x^2 \stopformula To use the same number scheme. On Jul 10, 2006, at 11:47 AM, Hans Hagen wrote:
David Arnold wrote:
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:
Definition 1.1
Where the first number is the section number.
Now, by "consecutive," I mean:
Definition 1.1
f(x)=3x+2 (1.2)
Example 1.3
Definition 1.4
Definition 1.5
f(x)=x^2 (1.6)
Figure 1
Example 1.7
Example 1.8
Definition 1.9
Figure 2
etc.
Hope this give the right idea.
Question: What would be the "Context Way" to go about this?
\defineenumeration [remark] [location=serried, width=broad, text=Remark, headstyle=bold, inbetween=\blank, before=\blank, after=\blank, way=bysection]
\defineenumeration [definition] [remark] [text=Definition]
\starttext \startremark Foo \stopremark \startdefinition Foo \stopdefinition \startremark Foo \stopremark \startdefinition Foo \stopdefinition \stoptext
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
participants (4)
-
David Arnold
-
Hans Hagen
-
Mojca Miklavec
-
Ulf Martin