ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Myway on using mathalign
@ 2006-04-02 17:21 Aditya Mahajan
  2006-04-03  7:42 ` Taco Hoekwater
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2006-04-02 17:21 UTC (permalink / raw)


Hi,
  I have written some examples on how to use startalign. Patrick has 
placed it on the garden. It can be downloaded from

http://dl.contextgarden.net/myway/mathalign.pdf

In case someone is interested, the source is available at

http://dl.contextgarden.net/myway/mathalign.tex

This is how I understand math alignment. Let me know if there is a 
mistake somewhere.

Thanks,
Aditya

-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-02 17:21 Myway on using mathalign Aditya Mahajan
@ 2006-04-03  7:42 ` Taco Hoekwater
  2006-04-03  8:28   ` Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Taco Hoekwater @ 2006-04-03  7:42 UTC (permalink / raw)




Aditya Mahajan wrote:
> Hi,
>   I have written some examples on how to use startalign. Patrick has 
> placed it on the garden. It can be downloaded from
> 
> http://dl.contextgarden.net/myway/mathalign.pdf

Excellent document! Can we persuade you to write similar texts
for the other math environments? And you can remove the actual
code for the intertext, it will be included in the core for
the upcoming release.

Cheers, Taco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-03  7:42 ` Taco Hoekwater
@ 2006-04-03  8:28   ` Hans Hagen
  2006-04-04  2:42     ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2006-04-03  8:28 UTC (permalink / raw)


Taco Hoekwater wrote:
> Aditya Mahajan wrote:
>   
>> Hi,
>>   I have written some examples on how to use startalign. Patrick has 
>> placed it on the garden. It can be downloaded from
>>
>> http://dl.contextgarden.net/myway/mathalign.pdf
>>     
>
> Excellent document! Can we persuade you to write similar texts
>   
indeed
> for the other math environments? And you can remove the actual
> code for the intertext, it will be included in the core for
> the upcoming release.
>   
watch the header line (esp last two pages)

never use \setupheadertexts this way (in page stream) since you get a sync problem then 

at the top of your document say: 

\setupheadertexts[section]

or 

\setupheadertexts[{\getmarking[section][both]}]

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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-03  8:28   ` Hans Hagen
@ 2006-04-04  2:42     ` Aditya Mahajan
  0 siblings, 0 replies; 8+ messages in thread
From: Aditya Mahajan @ 2006-04-04  2:42 UTC (permalink / raw)


On Mon, 3 Apr 2006, Hans Hagen wrote:

> Taco Hoekwater wrote:
>> Aditya Mahajan wrote:
>>
>>> Hi,
>>>   I have written some examples on how to use startalign. Patrick has
>>> placed it on the garden. It can be downloaded from
>>>
>>> http://dl.contextgarden.net/myway/mathalign.pdf
>>>
>>
>> Excellent document!
>>
> indeed

Thank you for the encouragement.

>> Can we persuade you to write similar texts for the other math 
>> environments?

The only other math environments that I understand are matrix and 
cases. I will try to include matrix, esp how to emulate amsmath's 
aligned family of environments using context's matrix.

>> And you can remove the actual code for the intertext, it will be 
>> included in the core for the upcoming release.

I will change this once I do an update at my end. I can not install 
the beta right now, as I have some deadlines and do not want to break 
anything.


> watch the header line (esp last two pages)

Thanks for catching this.

> never use \setupheadertexts this way (in page stream) since you get a sync problem then

I see that now.

> at the top of your document say:
>
> \setupheadertexts[section]
>
> or
>
> \setupheadertexts[{\getmarking[section][both]}]

Done that to my local copy. Will make a new version with some clean up 
and additions later this month.

Aditya

-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-06  0:17   ` WN
@ 2006-04-06  5:17     ` Aditya Mahajan
  0 siblings, 0 replies; 8+ messages in thread
From: Aditya Mahajan @ 2006-04-06  5:17 UTC (permalink / raw)
  Cc: mailing list for ConTeXt users

On Thu, 6 Apr 2006, WN wrote:

> adityam@umich.edu wrote:
>> On Wed, 5 Apr 2006, WN wrote:
>>> One thing I want to do with a set of subformula's is
>>> to reference the main formula but still subnumbering the equations
>>> like
>> 
>> Try this. Warning: I do not know everything that is happening here. There 
>> may be some unexpected side effects.
>> 
>> \unprotect
>> \def\placesubformulawithnumber{%
>>   \dodoubleempty\doplacesubformulawithnumber}
>> 
>> \def\doplacesubformulawithnumber[#1][#2]%#2 gobbles spaces
>>   {\iffirstargument
>>     \incrementnumber[\v!formula]
>>     \makesectionnumber[\v!formula]
>>     \rawreference{\s!for}{#1}{\composedsectionnumber}
>>   \else
>>     \incrementnumber[\v!formula]
>>   \fi\placesubformula}
>> \protect
>> 
>> 
>>> \starttext
>> %% > \incrementnumber[formula]
>> %% > \placesubformula
>> \placesubformulawithnumber[eqn1] %I need to think of a smaller name
>>> \startformula
>>> \startalign
>>> \NC div  \vec{E} \NC =  \epsilon_{0}^{-1} \rho  \NR[eqn1:A][a]
>>> \NC rot  \vec{E} \NC =  0 \NR
>>> \NC div  \vec{B} \NC =  0 \NR[eqn1:B][b]
>>> \NC rot  \vec{B} \NC =  \mu_{0} \vec{j} \NR
>>> \stopalign
>>> \stopformula
>>> See *\in[eqn1] *for the static Maxwell equations, where we are going to 
>>> examine \in[eqn1:A] a bit further ....
>>> \stoptext
>>> 
>> 
>> Also, note that div and rot should be in text font. You should probably do
>> \startmathcollection[default]
>>   \definemathcommand [div]      [nolop] {\mfunction{div}}
>>   \definemathcommand [rot]      [nolop] {\mfunction{rot}}
>> \stopmathcollection
>> 
>> and use \div \rot etc.
>> 
> Hi Aditya,
> I tested your solution and it works great. I cannot see any problems 
> in my output. I wish I had your Tex programming skills, I am trying 
> to learn the language myself from the TexBook (D.Knuth) but I still 
> have a long way to go.

Well, I do not understand Tex. What I usually do is look at the 
context source, which is much easier to read than latex internals, and 
then copy from there, play around a bit, and sometimes things 
work.

> Another test to check that the formula numbers work as expected
> \placeformula[kem-chapter-eqn11]
> \startformula
> \cases{
> \eqalign{
> \widehat{\vec{x}} &= - \vec{x} \cr
> \widehat{t} & = t \cr
> }}
> \quad \text{resp.} \quad
> \cases{\eqalign{
> \widehat{\vec{x}} &=  \vec{x} \cr
> \widehat{t} & = -t \cr
> }}
> \stopformula

How about

\definemathmatrix
   [group]
   [left={\left\{\,},right={\right.}]

\startformula
   \startgroup
     \NC \widehat{\vec{x}} \NC= - \vec x \NR
     \NC \widehat t        \NC= t        \NR
   \stopgroup
   \quad \text{resp} \quad
   \startgroup
     \NC \widehat{\vec{x}} \NC= \vec x \NR
     \NC \widehat t        \NC= -t     \NR
   \stopgroup
\stopformula

There is also startstop cases, but that does not give the correct 
spacing in this case. May be useful otherwise.

\startformula
   \startcases
     \NC \widehat{\vec{x}} \MC= - \vec x \NR
     \NC \widehat t        \MC= t        \NR
   \stopcases
% Read MC as Math Column, there is also the usual NC
% which gives a text column
   \quad \text{resp} \quad
   \startcases
     \NC \widehat{\vec{x}} \MC= \vec x \NR
     \NC \widehat t        \MC= -t     \NR
   \stopcases
\stopformula


HTH,
Aditya

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-05  6:51 ` Aditya Mahajan
@ 2006-04-06  0:17   ` WN
  2006-04-06  5:17     ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: WN @ 2006-04-06  0:17 UTC (permalink / raw)
  Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

adityam@umich.edu wrote:
> On Wed, 5 Apr 2006, WN wrote:
>> One thing I want to do with a set of subformula's is
>> to reference the main formula but still subnumbering the equations
>> like
>
> Try this. Warning: I do not know everything that is happening here. 
> There may be some unexpected side effects.
>
> \unprotect
> \def\placesubformulawithnumber{%
>   \dodoubleempty\doplacesubformulawithnumber}
>
> \def\doplacesubformulawithnumber[#1][#2]%#2 gobbles spaces
>   {\iffirstargument
>     \incrementnumber[\v!formula]
>     \makesectionnumber[\v!formula]
>     \rawreference{\s!for}{#1}{\composedsectionnumber}
>   \else
>     \incrementnumber[\v!formula]
>   \fi\placesubformula}
> \protect
>
>
>> \starttext
> %% > \incrementnumber[formula]
> %% > \placesubformula
> \placesubformulawithnumber[eqn1] %I need to think of a smaller name
>> \startformula
>> \startalign
>> \NC div  \vec{E} \NC =  \epsilon_{0}^{-1} \rho  \NR[eqn1:A][a]
>> \NC rot  \vec{E} \NC =  0 \NR
>> \NC div  \vec{B} \NC =  0 \NR[eqn1:B][b]
>> \NC rot  \vec{B} \NC =  \mu_{0} \vec{j} \NR
>> \stopalign
>> \stopformula
>> See *\in[eqn1] *for the static Maxwell equations, where we are going 
>> to examine \in[eqn1:A] a bit further ....
>> \stoptext
>>
>
> Also, note that div and rot should be in text font. You should 
> probably do
> \startmathcollection[default]
>   \definemathcommand [div]      [nolop] {\mfunction{div}}
>   \definemathcommand [rot]      [nolop] {\mfunction{rot}}
> \stopmathcollection
>
> and use \div \rot etc.
>
> HTH,
> Aditya
>
>
Hi Aditya,
I tested your solution and it works great. I cannot see any problems in 
my output.
I wish I had your Tex programming skills, I am trying to learn the 
language myself from
the TexBook (D.Knuth) but I still have a long way to go.

BTW

Thanks for your comment on the div, rot.
I indeed defined the div and rot in text font, it is defined in one of 
my environment settings.
Attached my small Context script to confirm your solution

Again thanks for your help,
Kind regards
Wim


[-- Attachment #2: testformula.tex --]
[-- Type: text/plain, Size: 1675 bytes --]

\unprotect

% ========= Aditya code ============
\def\placesubformulawithnumber{%
  \dodoubleempty\doplacesubformulawithnumber}

\def\doplacesubformulawithnumber[#1][#2]%#2 gobbles spaces
  {\iffirstargument
    \incrementnumber[\v!formula]
    \makesectionnumber[\v!formula]
    \rawreference{\s!for}{#1}{\composedsectionnumber}
  \else
    \incrementnumber[\v!formula]
  \fi\placesubformula}

\startmathcollection[default]
  \definemathcommand [div]      [nolop] {\mfunction{div}}
  \definemathcommand [rot]      [nolop] {\mfunction{rot}}
\stopmathcollection 
% =================================
\definereferenceformat [informula] 
    [left=(, right=), text=]

\protect 

\starttext
Some math tests, use of formula/subformula numbering.
\placesubformulawithnumber[kem-chapter1-eqn1]
\startformula
\startalign
\NC \div  \vec{E} \NC =  \frac{\rho}{\epsilon_{0}}\NR[kem-chapter1-eqn1:A][a]
\NC \rot  \vec{B}  \NC =  \mu_{0}  \:\vec{j}          \NR[kem-chapter1-eqn1:B][b]
\NC \div  \vec{B} \NC =  0                        \NR[kem-chapter1-eqn1:C][c]
\NC \rot  \vec{E} + \frac{\partial \vec{B} }{\partial t} \NC = 0  \NR[kem-chapter1-eqn1:D][d]
\stopalign
\stopformula
See \informula[kem-chapter1-eqn1] or alternatively
\informula[kem-chapter1-eqn1:A], \informula[kem-chapter1-eqn1:B],\informula[kem-chapter1-eqn1:C] or
\informula[kem-chapter1-eqn1:D].
\blank
Another test to check that the formula numbers work as expected
\placeformula[kem-chapter-eqn11]
\startformula
\cases{
\eqalign{
\widehat{\vec{x}} &= - \vec{x} \cr
\widehat{t} & = t \cr
}}
\quad \text{resp.} \quad
\cases{\eqalign{
\widehat{\vec{x}} &=  \vec{x} \cr
\widehat{t} & = -t \cr
}}
\stopformula

\stoptext


[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Myway on using mathalign
  2006-04-05  1:15 WN
@ 2006-04-05  6:51 ` Aditya Mahajan
  2006-04-06  0:17   ` WN
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2006-04-05  6:51 UTC (permalink / raw)
  Cc: mailing list for ConTeXt users

On Wed, 5 Apr 2006, WN wrote:
> One thing I want to do with a set of subformula's is
> to reference the main formula but still subnumbering the equations
> like

Try this. Warning: I do not know everything that is happening here. 
There may be some unexpected side effects.

\unprotect
\def\placesubformulawithnumber{%
   \dodoubleempty\doplacesubformulawithnumber}

\def\doplacesubformulawithnumber[#1][#2]%#2 gobbles spaces
   {\iffirstargument
     \incrementnumber[\v!formula]
     \makesectionnumber[\v!formula]
     \rawreference{\s!for}{#1}{\composedsectionnumber}
   \else
     \incrementnumber[\v!formula]
   \fi\placesubformula}
\protect


> \starttext
%% > \incrementnumber[formula]
%% > \placesubformula
\placesubformulawithnumber[eqn1] %I need to think of a smaller name
> \startformula
> \startalign
> \NC div  \vec{E} \NC =  \epsilon_{0}^{-1} \rho  \NR[eqn1:A][a]
> \NC rot  \vec{E} \NC =  0 \NR
> \NC div  \vec{B} \NC =  0 \NR[eqn1:B][b]
> \NC rot  \vec{B} \NC =  \mu_{0} \vec{j} \NR
> \stopalign
> \stopformula
> See *\in[eqn1] *for the static Maxwell equations, where we are going to 
> examine \in[eqn1:A] a bit further ....
> \stoptext
>

Also, note that div and rot should be in text font. You should 
probably do
\startmathcollection[default]
   \definemathcommand [div]      [nolop] {\mfunction{div}}
   \definemathcommand [rot]      [nolop] {\mfunction{rot}}
\stopmathcollection

and use \div \rot etc.

HTH,
Aditya


-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Myway on using mathalign
@ 2006-04-05  1:15 WN
  2006-04-05  6:51 ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: WN @ 2006-04-05  1:15 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 733 bytes --]

Hi Aditya,

I read you MyWay document on using \startalign and I was
interested in section 4.2 numbering subformula's
Everything works fine as stated in your nice document.

One thing I want to do with a set of subformula's is
to reference the main formula but still subnumbering the equations
like
\starttext
\incrementnumber[formula]
\placesubformula
\startformula
\startalign
\NC div  \vec{E} \NC =  \epsilon_{0}^{-1} \rho  \NR[eqn1:A][a]
\NC rot  \vec{E} \NC =  0 \NR
\NC div  \vec{B} \NC =  0 \NR[eqn1:B][b]
\NC rot  \vec{B} \NC =  \mu_{0} \vec{j} \NR
\stopalign
\stopformula
See *\in[eqn1] *for the static Maxwell equations, where we are going to 
examine \in[eqn1:A] a bit further ....
\stoptext

Hope you can help
Thanks
Wim

[-- Attachment #1.2: Type: text/html, Size: 1104 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-04-06  5:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-02 17:21 Myway on using mathalign Aditya Mahajan
2006-04-03  7:42 ` Taco Hoekwater
2006-04-03  8:28   ` Hans Hagen
2006-04-04  2:42     ` Aditya Mahajan
2006-04-05  1:15 WN
2006-04-05  6:51 ` Aditya Mahajan
2006-04-06  0:17   ` WN
2006-04-06  5:17     ` Aditya Mahajan

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).