Re: [NTG-context] New math feature requests
Wolfgang Schuster wrote: On Sat, 26 Aug 2006 12:37:56 -0400 (EDT) Aditya Mahajan [EMAIL PROTECTED] wrote: On Fri, 25 Aug 2006, Aditya Mahajan wrote: On Tue, 8 Aug 2006, Aditya Mahajan wrote: [ A long list of feature requests ] Here is something that was not in my original list: subformula numbering. [...] I was thinking of a better (rather more familar) way of treating subformulas by imitating the \begin{subequations} \end{subeqations} environment of latex. I propose a \startsubformula \stopsubformula environment, so that inside it, I will get subformula numbers rather than formula numbers. Having discovered conversions (see my previous mail on tagged formulas), I tried to implement it using conversions. The following straightforward approach works fine. This is just a stop gap code, I do not take care of inherting the right settings for formulas, but it conveys the idea. Hans and Taco, can something like this be added to the core? If so, I will try to make this macro more robust (correct inheritence, etc.) Here is a more robust version. I use \??sf as a namespace for subformulas. I do not think that this is used anywhere else. I found nothing where \??sf is used in the ConText core, but it is defined as systemvariable in mult-sys line 552. -- \definesystemvariable {sf} % SpeciFics You should ask Hans if he need it. core-env.tex : 6 : {\long\setvalue{\??sf#1}{#2}} core-env.tex : 12 : \getvalue{\??sf#1}\relax core-env.tex : 15 : \getvalue{\??sf#1}\relax on my machine 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Mon, 28 Aug 2006, Hans Hagen wrote: Wolfgang Schuster wrote: On Sat, 26 Aug 2006 12:37:56 -0400 (EDT) Aditya Mahajan [EMAIL PROTECTED] wrote: Here is a more robust version. I use \??sf as a namespace for subformulas. I do not think that this is used anywhere else. I found nothing where \??sf is used in the ConText core, but it is defined as systemvariable in mult-sys line 552. -- \definesystemvariable {sf} % SpeciFics You should ask Hans if he need it. core-env.tex : 6 : {\long\setvalue{\??sf#1}{#2}} core-env.tex : 12 : \getvalue{\??sf#1}\relax core-env.tex : 15 : \getvalue{\??sf#1}\relax on my machine Alright, how about if I add a new variable \definesystemvariable {subfm} % subForMulas or do I need to stick to two letter acronyms? Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
Aditya Mahajan wrote: \definesystemvariable {subfm} % subForMulas or do I need to stick to two letter acronyms? in this case i'd go for a double one: you can take \definesystemvariable {fn} i didn't look into your code yet (but you're improving it anyway) 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Fri, 25 Aug 2006, Aditya Mahajan wrote: On Tue, 8 Aug 2006, Aditya Mahajan wrote: [ A long list of feature requests ] Here is something that was not in my original list: subformula numbering. [...] I was thinking of a better (rather more familar) way of treating subformulas by imitating the \begin{subequations} \end{subeqations} environment of latex. I propose a \startsubformula \stopsubformula environment, so that inside it, I will get subformula numbers rather than formula numbers. Having discovered conversions (see my previous mail on tagged formulas), I tried to implement it using conversions. The following straightforward approach works fine. This is just a stop gap code, I do not take care of inherting the right settings for formulas, but it conveys the idea. Hans and Taco, can something like this be added to the core? If so, I will try to make this macro more robust (correct inheritence, etc.) Here is a more robust version. I use \??sf as a namespace for subformulas. I do not think that this is used anywhere else. Aditya \unprotect %D \macros{setupsubformulas} \def\setupsubformulas {\dodoubleargument\getparameters[\??sf]} \definenumber [parentformula] [\c!text=parentformula, \c!way=\@@fmway] \def\subformulaconversion#1% {\getnumber[parentformula]% \@@sfseparator% \convertnumber{\@@sfconversion}{#1}} \defineconversion[subformulaconversion][\subformulaconversion] %D \macros{startsubformulas} \def\startsubformulas% {\bgroup \incrementnumber[\v!formula] \expanded{\setupnumber[parentformula][start={\rawnumber[\v!formula]}]} \savenumber[\v!formula] \setupformulas[conversion=subformulaconversion,way=\@@sfway] \resetnumber[\v!formula]} \def\stopsubformulas% {\restorenumber[\v!formula] \resetlastlinewidth \nonoindentation \dochecknextindentation{\??sf}% \egroup \dorechecknextindentation} % here ? % I have just copied the indentation checking from \stopformulas. I am not % sure on how this works. \setupsubformulas [\c!way=\v!by\v!text, \c!sectionnumber=\v!no, \c!conversion=\v!character, \c!separator=\@@fmseparator, \c!indentnext=\@@fmindentnext] \protect %D The test cases \startbuffer \placeformula \startformula a^2 + b^2 = c^2 \stopformula \stopbuffer \startsetups[test] \dorecurse{3}{\getbuffer} Lets start subformulas \startsubformulas \dorecurse{3}{\getbuffer} \stopsubformulas Also works inside alignments \startsubformulas \placeformula \startformula \startalign \NC A \EQ B + C \NR[first] \NC D \EQ E + F \NR[+] \stopalign \stopformula \stopsubformulas Notice that in \in formula[first] we get the correct reference. \dorecurse{3}{\getbuffer} \stopsetups \starttext \section{Default} \setups[test]\page \section{Section} \setupformulas[way=bysection] \setups[test]\page \section{Roman} \setupsubformulas[conversion=romannumerals] \setups[test]\page \section{Separator} \setupsubformulas[separator=-] \setups[test]\page \stoptext ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Tue, 8 Aug 2006, Aditya Mahajan wrote: 3. Formula tagging amsmath allows formulas to be tagged. I will explain amsmath's behaviour and hope that Hans can come up with the context way of doing such things. Occasionally, one wants to tag a formula, e.g. \placefomrula[a] \startformula a x = b \stopformula \placetaggedformula[b]{*} \startformula x = \frac {b}{a} \stopformula should come out as a x = b (1) x = b/a (*) Notice that ( and ) correspond to left and right in setupformulas. It should also be possible to place a tag without these brackets, so \placetaggedformulawithoutbrackets[c]{**} \startformula b = ax \stopformula should come out as b = ax ** --- no brackets here Maybe, instead of placetaggedformulawithout brackets, one can simply have \placetaggedformula[c][left=,right=]{**} but in such cases it is easy to get confused with the reference and options. I am not sure what is a good way to do this. It should also be possible to refer to these tagged formulas. So \in{formula}[b] should give * and \in{formula}[c] should give **. The tag should be set in text mode, so that one can say \placetagformula {Answer} and the Answer will come out in text mode. I got an idea of using conversion for formula tagging. For single line formulas, the idea is pretty simple. I define a dummyconversion which always maps to the tag and set the formula conversion to dummyconversion. Then, I save the formula number, let startformula, work as normal and refine stopformula to restore formula number. The internal macros take care of referencing. This is my first attempt %8-- \def\placeformulatag% {\dosingleempty\doplaceformulatag} \def\doplaceformulatag[#1]#2% {\let\normalstopformula\stopformula \def\stopformula% {\normalstopformula \restorenumber[formula] \egroup \let\stopformula\normalstopformula} \bgroup \savenumber[formula] \def\dummyconversion##1{#2} \defineconversion[dummyconversion][\dummyconversion] \setupformulas[conversion=dummyconversion] \placeformula[#1]} \starttext \placeformulatag[tag]{test} \startformula E = mc^2 \stopformula See \in formula[tag] for a tagged formula \stoptext %8- This one places (test) with the brackets in place of the formula number. It is easy to get rid of the brackets by using \setupformulas[left=,right=]. However, I do not know what will be a good interface for this. In Latex, \tag{whatever} give (whatever) and \tag*{whatever} gives whatever without the brackets. But context does not use starred form of commands, and I do not want to introduce them here. One way is \placeformulatag[ref][left=,right=] {my tag} Is this fine? We can also have tagleft=... and tagright=... as part of setupformulas, or, if that is too confusion, have \setupformulatagging[left=...,right=...]. However, this idea does not work inside \startmathalignment as the conversion can not be changed inside a formula. \placeformula \startformula \startalign \NC a \NC = b \NR[+] \setupformulas[conversion=set 1] \NC c \NC = d \NR[+] \stopalign \stopformula Is there some better way to achieve the same effect inside a mathalignment? Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Tue, 8 Aug 2006, Aditya Mahajan wrote: [ A long list of feature requests ] Here is something that was not in my original list: subformula numbering. Context allows one to number subformulas by specifying the subnumber. Thus, if I want (1a) (1b) and (1c), I need to do \placesubformula[+]{a} \placesubformula[+]{b} \placesubformula[+]{c} Basically, do the numbering by hand. This is fine if there are only a few formulas, but there are some drawbacks of this approach. Firstly, if at a later stage you decide to move the equations around, you need to retype the formula numbers. Also, you need to remember to increment the formula numbers at the right time. I was thinking of a better (rather more familar) way of treating subformulas by imitating the \begin{subequations} \end{subeqations} environment of latex. I propose a \startsubformula \stopsubformula environment, so that inside it, I will get subformula numbers rather than formula numbers. Having discovered conversions (see my previous mail on tagged formulas), I tried to implement it using conversions. The following straightforward approach works fine. This is just a stop gap code, I do not take care of inherting the right settings for formulas, but it conveys the idea. %--8 \definenumber[tempformula] \def\subformulaconversion#1{\getnumber[tempformula]\character{#1}} % character should be modifiable using \setupsubformulas \defineconversion[subformulaconversion][\subformulaconversion] \def\startsubformulas% {\incrementnumber[formula] \expanded{\setupnumber[tempformula][start={\rawnumber[formula]}]} \savenumber[formula] \setupformulas[conversion=subformulaconversion] % way should be set to bytext \resetnumber[formula] } \def\stopsubformulas% {\setupformulas[conversion=numbers] % conversion should be inherited from setupformulas % way should be restored to whatever it was earlier \restorenumber[formula]} \startbuffer \placeformula \startformula a^2 + b^2 = c^2 \stopformula \stopbuffer \starttext \dorecurse{3}{\getbuffer} Lets start subformulas \startsubformulas \dorecurse{3}{\getbuffer} \stopsubformulas Also works inside alignments \startsubformulas \placeformula \startformula \startalign \NC A \EQ B + C \NR[first] \NC D \EQ E + F \NR[+] \stopalign \stopformula \stopsubformulas Notice that in \in formula[first] we get the correct reference. \dorecurse{3}{\getbuffer} \stoptext %8--- Hans and Taco, can something like this be added to the core? If so, I will try to make this macro more robust (correct inheritence, etc.) Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Tue, 8 Aug 2006, Aditya Mahajan wrote: Hi Hans and Taco, I am back with some more math request Forgot a small request: Can this be added to core-mat.tex \def\intertext#1{\startintertext#1\stopintertext} Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
Aditya Mahajan wrote: On Tue, 8 Aug 2006, Aditya Mahajan wrote: Hi Hans and Taco, I am back with some more math request Forgot a small request: Can this be added to core-mat.tex \def\intertext#1{\startintertext#1\stopintertext} sure, but as: \def\intertext#1% {\noalign{\dointertext{#1}}} (more efficient) 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
Aditya Mahajan wrote: 2. In amsmath, most of alignment constructs exist in two forms: outer and inner. The mathalignment implemented in core-mat.tex corresponds to outer alignment. The inner alignment is same as outer alignment, but is only as wide as necessay. The most common amsmath inner alignment constructs are aligned and gathered. It is easiest to explain by means of an example. Suppose I want to type a x + b y = c `\ } (simultaneous equations) d x + e y = f / , I want to be able to do \defineinnermathalignment[aligned][n=2,left={\left.},right={\right\}}] This sounds very close to \definemathmatrix, yes? Taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] New math feature requests
On Tue, 8 Aug 2006, Taco Hoekwater wrote: Aditya Mahajan wrote: 2. In amsmath, most of alignment constructs exist in two forms: outer and inner. The mathalignment implemented in core-mat.tex corresponds to outer alignment. The inner alignment is same as outer alignment, but is only as wide as necessay. The most common amsmath inner alignment constructs are aligned and gathered. It is easiest to explain by means of an example. Suppose I want to type a x + b y = c `\ } (simultaneous equations) d x + e y = f / , I want to be able to do \defineinnermathalignment[aligned][n=2,left={\left.},right={\right\}}] This sounds very close to \definemathmatrix, yes? It is, and my first thought was that this can be achieved using \definematrix (that is why the previous requests for location= and style=). However, all my attempts to use a matrix failed because: 1. Matrix does not see beyond the \NCs as align. Comapre the output of \startformula \startalign[n=2] \NC a \NC = bx + c \NR \NC \NC + ey \NR \stopalign \stopformula with \startformula \startmatrix[n=2,distance=0pt, style=\displaystyle] \NC a \NC = bx + c \NR \NC \NC + ey \NR \stopmatrix \stopformula The '+' in the second line comes out as a unary operator rather than a binary operator. This can be corrected by using \NC{}+ but should the user really know the ugly implementation details? 2. Matrix does not correct interline space. Compare \startformula \startalign[n=2] \NC f(x) \NC = \int_{-\infty}^{\infty} \phi(y-x) dy \NR \NC \NC = \sum_{i=-\infty}^{\infty} \hat phi(i-x) \NR \stopalign \stopformula with \startformula \startmatrix[n=2,distance=0pt, style=\displaystyle] \NC f(x) \NC = \int_{-\infty}^{\infty} \phi(y-x) dy \NR \NC \NC = \sum_{i=-\infty}^{\infty} \hat phi(i-x) \NR \stopmatrix \stopformula The two lines are too close. I thought that it might be easier to simply wrap the whole align around a hbox as these inner alignments need not break across pages. If matrix can be enhanced to take care of the above two requirements then matrix is fine. However, if I just want a matrix, then both above behaviours of the matrix are correct. I am not sure what kind of interface matrix should have to behave in both ways (the current matrix behaviour and the requested aligned behaviour). Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context