ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* do not understand \xmlindex
@ 2010-03-14 21:53 Hans van der Meer
  2010-03-14 22:01 ` alignment explanation Mehdi Omidali
  0 siblings, 1 reply; 7+ messages in thread
From: Hans van der Meer @ 2010-03-14 21:53 UTC (permalink / raw)
  To: NTG ConTeXt


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

I do not understand the behaviour of \xmlindex in the code below. The  
goal is to extract the contents of node <abc>-number 1. The strange  
things is that \xmltext returns the contents of both the <abc> nodes,  
but \xmlindex returns nothing.
The returns of the \writestatus calls:
 >>1>> ab-2        : ::
 >>2>> ab-2        : :ABC-1ABC-2:


\startxmlsetups xml:testsetups
	\xmlsetsetup{test}{test|ab|abc}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}

\startxmlsetups xml:test
	\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:ab
	\writestatus{>>1>> \xmltag{#1}-\xmlcount{#1}{/abc}}{:\xmlindex{#1}{/ 
abc}{1}:}
	\writestatus{>>2>> \xmltag{#1}-\xmlcount{#1}{/abc}}{:\xmltext{#1}{/ 
abc}:}
\stopxmlsetups

\starttext
\xmlprocessfile{test}{test.xml}{}
\stoptext

Input is:
<test>
	<ab>
		<abc>ABC-1</abc>
		<abc>ABC-2</abc>
	</ab>
</test>

Hans van der Meer





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

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* alignment explanation
  2010-03-14 21:53 do not understand \xmlindex Hans van der Meer
@ 2010-03-14 22:01 ` Mehdi Omidali
  2010-03-14 22:51   ` Aditya Mahajan
  0 siblings, 1 reply; 7+ messages in thread
From: Mehdi Omidali @ 2010-03-14 22:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,
Finally, after reading source code of math-ali.mkiv, I found the best 
way to typeset my multiline equation as follows

\starttext
\placeformula

\startformula

\startalign[n=3]

\NC x^2 + y^2 \NC = z^2 \NC \NR[eq:1]

\NC\NC = w^2 \NC + u^2\NC \text{(by \in{Equation}[eq:2])} \cr

\NC\NC + v^2 + r^2 \NR[eq:2]

\NC\NC\NC + v^2 + r^2 \NR[eq:3]

\NC\NC = v^2\NC + r^2 \NR[eq:4]

\stopalign

\stopformula
\stoptext


but I don't know what is going on here. Exactly, eq:2 and eq:3 has the 
same output but they can not be interchanged. Can someone explain this code?
MO


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: alignment explanation
  2010-03-14 22:01 ` alignment explanation Mehdi Omidali
@ 2010-03-14 22:51   ` Aditya Mahajan
  2010-03-15  8:32     ` Mehdi Omidali
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2010-03-14 22:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 15 Mar 2010, Mehdi Omidali wrote:

> Hi,
> Finally, after reading source code of math-ali.mkiv, I found the best way to 
> typeset my multiline equation as follows
>
> \starttext
> \placeformula
>
> \startformula
>
> \startalign[n=3]

This means that you must have three "columns" in each line


> \NC x^2 + y^2 \NC = z^2 \NC \NR[eq:1]
>
> \NC\NC = w^2 \NC + u^2\NC \text{(by \in{Equation}[eq:2])} \cr

This has 4 columns. You do not get an error message because you use \cr 
instead of \NR. That also messes up the alignment of the next equation.
>
> but I don't know what is going on here. Exactly, eq:2 and eq:3 has the same 
> output but they can not be interchanged. Can someone explain this code?

This is how I would do this.

\placeformula \startformula \startalign[n=3]
\NC x^2 + y^2 \NC = z^2             \NC                                 \NR[eq:1]
\NC           \NC = w^2 + u^2       \NC \text{(by \in{Equation}[eq:2])} \NR
\NC           \NC \quad + v^2 + r^2 \NC                                 \NR[eq:2]
\NC           \NC \quad + v^2 + r^2 \NC                                 \NR[eq:3]
\NC           \NC = v^2 + r^2       \NC                                 \NR[eq:4]
\stopalign \stopformula

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: alignment explanation
  2010-03-14 22:51   ` Aditya Mahajan
@ 2010-03-15  8:32     ` Mehdi Omidali
  2010-03-15 16:40       ` Aditya Mahajan
  0 siblings, 1 reply; 7+ messages in thread
From: Mehdi Omidali @ 2010-03-15  8:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/15/2010 2:21 AM, Aditya Mahajan wrote:
> On Mon, 15 Mar 2010, Mehdi Omidali wrote:
>
>    
>> Hi,
>> Finally, after reading source code of math-ali.mkiv, I found the best way to
>> typeset my multiline equation as follows
>>
>> \starttext
>> \placeformula
>>
>> \startformula
>>
>> \startalign[n=3]
>>      
> This means that you must have three "columns" in each line
>
>
>    
>> \NC x^2 + y^2 \NC = z^2 \NC \NR[eq:1]
>>
>> \NC\NC = w^2 \NC + u^2\NC \text{(by \in{Equation}[eq:2])} \cr
>>      
> This has 4 columns. You do not get an error message because you use \cr
> instead of \NR. That also messes up the alignment of the next equation.
>    
>> but I don't know what is going on here. Exactly, eq:2 and eq:3 has the same
>> output but they can not be interchanged. Can someone explain this code?
>>      
> This is how I would do this.
>
> \placeformula \startformula \startalign[n=3]
> \NC x^2 + y^2 \NC = z^2             \NC                                 \NR[eq:1]
> \NC           \NC = w^2 + u^2       \NC \text{(by \in{Equation}[eq:2])} \NR
> \NC           \NC \quad + v^2 + r^2 \NC                                 \NR[eq:2]
> \NC           \NC \quad + v^2 + r^2 \NC                                 \NR[eq:3]
> \NC           \NC = v^2 + r^2       \NC                                 \NR[eq:4]
> \stopalign \stopformula
>
> Aditya
>    
Thanks, but your output is not the same as mine. The comment "by 
Equation 2" must be right aligned exactly where formula number is. Also 
I don't like manual alignment like \quad. AMS-TEX provide commands for 
automatic alignment. It would be nice if context supports that too.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: alignment explanation
  2010-03-15  8:32     ` Mehdi Omidali
@ 2010-03-15 16:40       ` Aditya Mahajan
  2010-03-15 17:50         ` Mehdi Omidali
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2010-03-15 16:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 15 Mar 2010, Mehdi Omidali wrote:

> On 3/15/2010 2:21 AM, Aditya Mahajan wrote:
>> On Mon, 15 Mar 2010, Mehdi Omidali wrote:
>>
>> 
>>> Hi,
>>> Finally, after reading source code of math-ali.mkiv, I found the best way 
>>> to
>>> typeset my multiline equation as follows
>>> 
>>> \starttext
>>> \placeformula
>>> 
>>> \startformula
>>> 
>>> \startalign[n=3]
>>> 
>> This means that you must have three "columns" in each line
>> 
>>
>> 
>>> \NC x^2 + y^2 \NC = z^2 \NC \NR[eq:1]
>>> 
>>> \NC\NC = w^2 \NC + u^2\NC \text{(by \in{Equation}[eq:2])} \cr
>>> 
>> This has 4 columns. You do not get an error message because you use \cr
>> instead of \NR. That also messes up the alignment of the next equation.
>> 
>>> but I don't know what is going on here. Exactly, eq:2 and eq:3 has the 
>>> same
>>> output but they can not be interchanged. Can someone explain this code?
>>> 
>> This is how I would do this.
>> 
>> \placeformula \startformula \startalign[n=3]
>> \NC x^2 + y^2 \NC = z^2             \NC 
>> \NR[eq:1]
>> \NC           \NC = w^2 + u^2       \NC \text{(by \in{Equation}[eq:2])} \NR
>> \NC           \NC \quad + v^2 + r^2 \NC 
>> \NR[eq:2]
>> \NC           \NC \quad + v^2 + r^2 \NC 
>> \NR[eq:3]
>> \NC           \NC = v^2 + r^2       \NC 
>> \NR[eq:4]
>> \stopalign \stopformula
>> 
>> Aditya
>> 
> Thanks, but your output is not the same as mine. The comment "by Equation 2" 
> must be right aligned exactly where formula number is.

ConTeXt does not support that directly, but you can fake it.

\def\NRtag{&\global\let\doalignNC\dodoalignNC\doalignNRtag}%

\def\doalignNRtag[#1]%
  {#1\crcr}

\starttext
\placeformula
\startformula
\startalign[n=3]
\NC x^2 + y^2 \NC = z^2 \NC             \NR[eq:1]
\NC           \NC = w^2 \NC + u^2       \NRtag[\text{(by \in{Equation}[eq:2])}]
\NC           \NC       \NC + v^2 + r^2 \NR[eq:2]
\NC           \NC       \NC + v^2 + r^2 \NR[eq:3]
\NC           \NC = v^2 \NC + r^2       \NR[eq:4]
\stopalign
\stopformula
\stoptext


> Also I don't like 
> manual alignment like \quad. AMS-TEX provide commands for automatic 
> alignment. It would be nice if context supports that too.

ConTeXt does support that (see above); but aligning at the + sign makes 
sense only for specific types of equations. In general, using \quad is 
considered good typography. (Imagine what would happen if the first term 
in one of the equations was very big).

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: alignment explanation
  2010-03-15 16:40       ` Aditya Mahajan
@ 2010-03-15 17:50         ` Mehdi Omidali
  2010-03-15 19:29           ` Aditya Mahajan
  0 siblings, 1 reply; 7+ messages in thread
From: Mehdi Omidali @ 2010-03-15 17:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/15/2010 8:10 PM, Aditya Mahajan wrote:
> On Mon, 15 Mar 2010, Mehdi Omidali wrote:
>
>    
>
> ConTeXt does not support that directly, but you can fake it.
>
> \def\NRtag{&\global\let\doalignNC\dodoalignNC\doalignNRtag}%
>
> \def\doalignNRtag[#1]%
>    {#1\crcr}
>
> \starttext
> \placeformula
> \startformula
> \startalign[n=3]
> \NC x^2 + y^2 \NC = z^2 \NC             \NR[eq:1]
> \NC           \NC = w^2 \NC + u^2       \NRtag[\text{(by \in{Equation}[eq:2])}]
> \NC           \NC       \NC + v^2 + r^2 \NR[eq:2]
> \NC           \NC       \NC + v^2 + r^2 \NR[eq:3]
> \NC           \NC = v^2 \NC + r^2       \NR[eq:4]
> \stopalign
> \stopformula
> \stoptext
>
> ConTeXt does support that (see above); but aligning at the + sign makes
> sense only for specific types of equations. In general, using \quad is
> considered good typography. (Imagine what would happen if the first term
> in one of the equations was very big).
>
> Aditya
>    
Thank you. It is perfect now. I think this solution deserve appearing in 
your MyWay manual. In fact, it deserves to be supported directly in MKIV.
Mehdi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: alignment explanation
  2010-03-15 17:50         ` Mehdi Omidali
@ 2010-03-15 19:29           ` Aditya Mahajan
  0 siblings, 0 replies; 7+ messages in thread
From: Aditya Mahajan @ 2010-03-15 19:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 15 Mar 2010, Mehdi Omidali wrote:

> Thank you. It is perfect now. I think this solution deserve appearing in your 
> MyWay manual. In fact, it deserves to be supported directly in MKIV.

I'll add it to the MyWay. MkIV will support it when we eventually get down 
to an overhaul of display math.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2010-03-15 19:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-14 21:53 do not understand \xmlindex Hans van der Meer
2010-03-14 22:01 ` alignment explanation Mehdi Omidali
2010-03-14 22:51   ` Aditya Mahajan
2010-03-15  8:32     ` Mehdi Omidali
2010-03-15 16:40       ` Aditya Mahajan
2010-03-15 17:50         ` Mehdi Omidali
2010-03-15 19:29           ` 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).