ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: New math feature requests
Date: Fri, 25 Aug 2006 01:15:48 -0400 (EDT)	[thread overview]
Message-ID: <Pine.WNT.4.63.0608250057150.2420@nqvgln> (raw)
In-Reply-To: <Pine.WNT.4.63.0608080147040.3232@nqvgln>

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

  parent reply	other threads:[~2006-08-25  5:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08  5:49 Aditya Mahajan
2006-08-08  5:59 ` Aditya Mahajan
2006-08-08  8:14   ` Hans Hagen
2006-08-08 14:20 ` Taco Hoekwater
2006-08-08 15:38   ` Aditya Mahajan
2006-08-25  1:34 ` Aditya Mahajan
2006-08-25  5:15 ` Aditya Mahajan [this message]
2006-08-26 16:37   ` Aditya Mahajan
2006-08-28 15:12     ` Wolfgang Schuster
2006-08-28 15:21       ` Hans Hagen
2006-08-28 17:10         ` Aditya Mahajan
2006-08-28 21:55           ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.WNT.4.63.0608250057150.2420@nqvgln \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).