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

Reply via email to