Enhancements to core-des for theorems
Hi Hans, I am attaching my enhancements for core-des. This takes care of most of the needs for theorems with ConTeXt. I hope that I have not broken anything. I have tested this with a 40 page documents, while Oliver, Olaf, and Dalyoung have tested this with bigger documents. The test files show different features. It takes care of a few bugs in enumerations, (and introduces new ones... there is a suprious space somewhere which I can not find) Basically, more enhanced support for titles, and end of proof markers, and makes sure that conversion=whatever works correctly. If you want a "title" for the theorem, say \defineenumeration[theorem] \defineenumeration[theorem][title=yes] titledistance, titlestyle, titlecolor, titleleft, and titleright control the appearance of the title. To use a title, say \starttheorem[label]{title} both the label and the title are optional, so you can have \starttheorem[label] This is a theorem with no title \stoptheorem and \starttheorem {title} this is a theorem with no label \stoptheorem \starttheorem this is a theorem with neither a title nor a label \stoptheorem For end of proof markers, say \definetheorem[theorem][endmarker=\math{\square}] or whatever symbol you want. Then a end of proof marker with will be placed at the \stoptheorem. Sometimes, for example after an itemize, the end of thoerem marker may appear on a line of its own. Then say \placenedmarker just before \stopitemize To couple two enumerations \defineenumeration[theorem] \defineenumeration[proposition][theorem] To couple just the numbers \defineenumeration[theorem] \defineenumeration[proposition][usenumer=theorem] I cannot use number=theorem because number=yes|no is to enable disable numbering. Maybe a better choice will be numbering=yes|no, and number=counter. But that will break backward compatibility :( The main thing that needs to be done is to get end of proof markers to work with formulas, but that is a bit difficult, so I have left it for the future. Aditya
Aditya Mahajan wrote:
Hi Hans,
I am attaching my enhancements for core-des. This takes care of most of the needs for theorems with ConTeXt. I hope that I have not broken anything. I have tested this with a 40 page documents, while Oliver, Olaf, and Dalyoung have tested this with bigger documents. The test files show different features.
It takes care of a few bugs in enumerations, (and introduces new ones... there is a suprious space somewhere which I can not find) Basically, more enhanced support for titles, and end of proof markers, and makes sure that conversion=whatever works correctly. \descriptionparameter\c!right% }} <======= here is your space \doifnot{#1}{-}{\rawreference\s!num{#1}{}}%
\strut\doshowdnnumber% \showdntitle{#2} <======= here is another space %AM: Remaining part of \domakednnumbed \descriptionparameter\c!left \showdntitle{#2} <======= here is another space \descriptionparameter\c!stopper most of the %'s you added are not needed, e.g. never after a \macroname
For end of proof markers, say
\def\placeendmarker {\@EA\ifcase \csname dnendmarker\currentdescription\endcsname \global\@EA\chardef\csname dnendmarker\currentdescription\endcsname\plusone \doifsomething{\descriptionparameter\c!endmarker} % {\pushright{\descriptionparameter\c!endmarker}}\fi} {\wordright{\descriptionparameter\c!endmarker}}\fi} this is what wordright was made for; maybe it can be improved but thsi qed stuff looks too complex to me (may also interfere with other things)
\definetheorem[theorem][endmarker=\math{\square}] or whatever symbol you want.
Then a end of proof marker with will be placed at the \stoptheorem. Sometimes, for example after an itemize, the end of thoerem marker may appear on a line of its own. Then say \placenedmarker just before \stopitemize
To couple two enumerations
\defineenumeration[theorem] \defineenumeration[proposition][theorem]
To couple just the numbers
\defineenumeration[theorem] \defineenumeration[proposition][usenumer=theorem]
I cannot use number=theorem because number=yes|no is to enable disable numbering. Maybe a better choice will be numbering=yes|no, and number=counter. But that will break backward compatibility :( \defineenumeration[proposition][theorem]
will inherit and then you can set up proposition independently
The main thing that needs to be done is to get end of proof markers to work with formulas, but that is a bit difficult, so I have left it for the future.
i need to give this some thought ... endmark -> endsymbol (we use symbol for other things; mark is too much related to marks) usenumber -> have to think of it, cloning happens more (\c!coupling is used low level) There is some code i made for David Antos: \doif{\descriptionparameter\c!title}\v!yes % new, for david antos {\doattributes{\??dd\currentdescription}\c!titlestyle\c!titlecolor {\hskip\descriptionparameter\c!titledistance\begstrut#2\endstrut}}% did you check if his usage still works? (at least we need to tell David what to use now) Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On Sat, 2 Jun 2007, Hans Hagen wrote:
Aditya Mahajan wrote:
Hi Hans,
I am attaching my enhancements for core-des. This takes care of most of the needs for theorems with ConTeXt. I hope that I have not broken anything. I have tested this with a 40 page documents, while Oliver, Olaf, and Dalyoung have tested this with bigger documents. The test files show different features.
It takes care of a few bugs in enumerations, (and introduces new ones... there is a suprious space somewhere which I can not find) Basically, more enhanced support for titles, and end of proof markers, and makes sure that conversion=whatever works correctly. \descriptionparameter\c!right% }} <======= here is your space \doifnot{#1}{-}{\rawreference\s!num{#1}{}}%
\strut\doshowdnnumber% \showdntitle{#2} <======= here is another space %AM: Remaining part of \domakednnumbed
\descriptionparameter\c!left \showdntitle{#2} <======= here is another space \descriptionparameter\c!stopper
most of the %'s you added are not needed, e.g. never after a \macroname
Thanks, I am still learning this space % stuff.
For end of proof markers, say
\def\placeendmarker {\@EA\ifcase \csname dnendmarker\currentdescription\endcsname \global\@EA\chardef\csname dnendmarker\currentdescription\endcsname\plusone \doifsomething{\descriptionparameter\c!endmarker} % {\pushright{\descriptionparameter\c!endmarker}}\fi} {\wordright{\descriptionparameter\c!endmarker}}\fi}
this is what wordright was made for; maybe it can be improved but thsi qed stuff looks too complex to me (may also interfere with other things)
I had a look at \wordright. The trouble is that \wordright makes no attempt to prevent a page break if it is on a line of its own. It it can be enhanced to take that into account, that is fine with me. The placed of endofproof symbol is complicated. amsthm, does something similar to qed.sty, while ntheorem goes into a two pass mechansim to get the placement right.
\definetheorem[theorem][endmarker=\math{\square}] or whatever symbol you want.
Then a end of proof marker with will be placed at the \stoptheorem. Sometimes, for example after an itemize, the end of thoerem marker may appear on a line of its own. Then say \placenedmarker just before \stopitemize
To couple two enumerations
\defineenumeration[theorem] \defineenumeration[proposition][theorem]
To couple just the numbers
\defineenumeration[theorem] \defineenumeration[proposition][usenumer=theorem]
I cannot use number=theorem because number=yes|no is to enable disable numbering. Maybe a better choice will be numbering=yes|no, and number=counter. But that will break backward compatibility :( \defineenumeration[proposition][theorem]
will inherit and then you can set up proposition independently
Yes, but that is doing a lot of work simply to inherit the number.
The main thing that needs to be done is to get end of proof markers to work with formulas, but that is a bit difficult, so I have left it for the future. i need to give this some thought ...
endmark -> endsymbol (we use symbol for other things; mark is too much related to marks)
Ok.
usenumber -> have to think of it, cloning happens more (\c!coupling is used low level)
There is some code i made for David Antos:
\doif{\descriptionparameter\c!title}\v!yes % new, for david antos {\doattributes{\??dd\currentdescription}\c!titlestyle\c!titlecolor {\hskip\descriptionparameter\c!titledistance\begstrut#2\endstrut}}%
did you check if his usage still works? (at least we need to tell David what to use now)
I think that the old code will still work. There may a change in the default behaviour of stopper. If I remember correctly, earlier we had, <enumeration><left><number><right><stopper><title> and now I have <enumeration><left><number><right><title><stopper> which seems to be more common. Aditya
On Sat, 2 Jun 2007, Aditya Mahajan wrote:
this is what wordright was made for; maybe it can be improved but thsi qed stuff looks too complex to me (may also interfere with other things)
I had a look at \wordright. The trouble is that \wordright makes no attempt to prevent a page break if it is on a line of its own. It it can be enhanced to take that into account, that is fine with me. The placed of endofproof symbol is complicated. amsthm, does something similar to qed.sty, while ntheorem goes into a two pass mechansim to get the placement right.
Actually, the only part of qed.sty that I use is this: \def\parag@pushright#1{{% set up \parfillskip=0pt % so \par doesnt push \square to left \widowpenalty=10000 % so we dont break the page before \square \displaywidowpenalty=10000 % ditto \finalhyphendemerits=0 % TeXbook exercise 14.32 % % horizontal %\leavevmode % not needed since we now only use it in hmode \hbox@pushright % this used to be incorporated #1% % the end-of-proof mark (or whatever) % % vertical \par}}% % build paragraph with the above parameters \def\hbox@pushright{% horizontal \unskip % remove previous space or glue \nobreak % don't break lines \hfil % ragged right if we spill over \penalty50 % discouragement to do so \hskip.2em % ensure some space \null % anchor the following \hfill \hfill % push \square to right }% Compare with \wordright \def\dowordright[#1]% {% don't change \groupedcommand {\removeunwantedspaces \hfill \allowbreak % changed back from \hskip\zeropoint \strut \hfill \quad % decent spacing \hbox} {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}% \parfillskip\zeropoint \par}} And there is also \signed from the texbook \def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50 \hskip2em\hbox{}\nobreak\hfil\sl#1\/ \rm(#2) \parfillskip=0pt \finalhyphendemerits=0 \par}} What was the motivation for \wordright? I thought it was same as \signed in the TeXbook (pg 106). But \signed uses \nobreak (\penality1000) and \penality50, \wordright uses allowbreak (\penality0). And then there is \finalhypendemerits=0 which is "missing". And if you are relooking this macro, it will be nice to have the \hfill configurable (dotfill or something fancier) Aditya
Aditya Mahajan wrote:
I had a look at \wordright. The trouble is that \wordright makes no attempt to prevent a page break if it is on a line of its own. It it can be enhanced to take that into account, that is fine with me. The placed of endofproof symbol is complicated. amsthm, does something similar to qed.sty, while ntheorem goes into a two pass mechansim to get the placement right.
i never tested it but in pdftex we can add a "\vadjust pre {\nobreak}" ; the problem with tricks is that it will break other things; the only work in controlled situations
Yes, but that is doing a lot of work simply to inherit the number. well, as long as tex is doing the work ... the advantage is that other number related things also inherit
Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On Sun, 3 Jun 2007, Hans Hagen wrote:
Aditya Mahajan wrote:
I had a look at \wordright. The trouble is that \wordright makes no attempt to prevent a page break if it is on a line of its own. It it can be enhanced to take that into account, that is fine with me. The placed of endofproof symbol is complicated. amsthm, does something similar to qed.sty, while ntheorem goes into a two pass mechansim to get the placement right.
i never tested it but in pdftex we can add a "\vadjust pre {\nobreak}" ; the problem with tricks is that it will break other things; the only work in controlled situations
Maybe then also add an option for \endsymbolcommand. Let the core implement the safest way to do things; the adventurous user (or a module) can change the placement mechanism to whatever he/she wants.
Yes, but that is doing a lot of work simply to inherit the number. well, as long as tex is doing the work ... the advantage is that other number related things also inherit
That is true. I had not thought about conversion, numberstyle, and such things. There is another thing, which is more important from a style writer's point of view, rather than the user's. Suppose I am writing a module for IEEE journals, and they want their theorms in a particular style. Suppose there are two styles, one for theorems and propositions (say stlyeA), and one for definitions and remarks (say styleB). In the module I can define four enumerations, with appropriate styles. \defineenumeration[theorem] \defineenumeration[proposition] \setupenumerations[theorem,proposition][settings for styleA] and similar for styleB. Now suppose a user wants to have a new enumeration, called lemma, in styleA. How does he do that? The options are: 1. Looks into the IEEE module and copies settings for styleA. 2. does something like \definenumber[lemma] \defineenumeration[lemma][theorem][number=lemma] An alternative approach is to define a new object called enumerationalternative. So that things can be \defineenumerationalternative[styleA][settings for styleA] \defineenumeration[theorem][alternative=styleA], etc. This is roughly what LaTeX does, and most math users have come to expect something like this. This should not be too difficult to implement. \defineenumerationalterative can simply do \getvariables[\??dd\c!alternative#1] and \defineenumeration can see if alternative is something and copy parameters from \??dd\c!alternative. Do you think it makes sense to add this in the core? Aditya
Aditya Mahajan wrote:
\definenumber[lemma] \defineenumeration[lemma][theorem][number=lemma]
Do you think it makes sense to add this in the core? well, it's basically there so i'll give it a try
Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
participants (2)
-
Aditya Mahajan
-
Hans Hagen