[NTG-context] New math feature requests

Aditya Mahajan adityam at umich.edu
Sat Aug 26 18:37:56 CEST 2006


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

-------------- next part --------------
\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


More information about the ntg-context mailing list