* Bug when mathmatrix is used inside mathalign
@ 2019-03-27 15:56 Aditya Mahajan
2019-03-27 17:13 ` Hans Hagen
2019-03-27 17:13 ` Hans Hagen
0 siblings, 2 replies; 4+ messages in thread
From: Aditya Mahajan @ 2019-03-27 15:56 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
It was reported on TeX.SE[1] that there is a bug when math matrix is used
inside a math align:
\starttext
\startformula
\startalign[n=2,align={right,left}]
\NC x
\NC = a ~ long ~ sequence ~ of ~ terms
\NR
\NC y
\NC = ok ~ left
\NR
\NC \startmatrix[left={\left\lbrack},right={\right\rbrack}]
\NC x \NR
\NC y \NR
\stopmatrix
\NC = why ~ right?
\NR
\NC y
\NC = ok ~ left ~ again
\NR
\stopalign
\stopformula
\stoptext
gives
https://i.stack.imgur.com/ZTAp3.png
It appears that \startmatrix globally resets \NC. I haven't looked into
the code yet to see why this is happening.
Aditya
[1]: https://tex.stackexchange.com/q/481411/323
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug when mathmatrix is used inside mathalign
2019-03-27 15:56 Bug when mathmatrix is used inside mathalign Aditya Mahajan
@ 2019-03-27 17:13 ` Hans Hagen
2019-03-27 17:13 ` Hans Hagen
1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2019-03-27 17:13 UTC (permalink / raw)
To: mailing list for ConTeXt users, Aditya Mahajan
On 3/27/2019 4:56 PM, Aditya Mahajan wrote:
> Hi,
>
> It was reported on TeX.SE[1] that there is a bug when math matrix is used
> inside a math align:
>
> \starttext
> \startformula
> \startalign[n=2,align={right,left}]
> \NC x
> \NC = a ~ long ~ sequence ~ of ~ terms
> \NR
> \NC y
> \NC = ok ~ left
> \NR
> \NC \startmatrix[left={\left\lbrack},right={\right\rbrack}]
> \NC x \NR
> \NC y \NR
> \stopmatrix
> \NC = why ~ right?
> \NR
> \NC y
> \NC = ok ~ left ~ again
> \NR
> \stopalign
> \stopformula
> \stoptext
>
> gives
>
> https://i.stack.imgur.com/ZTAp3.png
>
> It appears that \startmatrix globally resets \NC. I haven't looked into
> the code yet to see why this is happening.
you can play with
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug when mathmatrix is used inside mathalign
2019-03-27 15:56 Bug when mathmatrix is used inside mathalign Aditya Mahajan
2019-03-27 17:13 ` Hans Hagen
@ 2019-03-27 17:13 ` Hans Hagen
2019-03-27 23:09 ` Aditya Mahajan
1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2019-03-27 17:13 UTC (permalink / raw)
To: Aditya Mahajan,
ntg-context@ntg.nl >> mailing list for ConTeXt users
On 3/27/2019 4:56 PM, Aditya Mahajan wrote:
> Hi,
>
> It was reported on TeX.SE[1] that there is a bug when math matrix is used
> inside a math align:
>
> \starttext
> \startformula
> \startalign[n=2,align={right,left}]
> \NC x
> \NC = a ~ long ~ sequence ~ of ~ terms
> \NR
> \NC y
> \NC = ok ~ left
> \NR
> \NC \startmatrix[left={\left\lbrack},right={\right\rbrack}]
> \NC x \NR
> \NC y \NR
> \stopmatrix
> \NC = why ~ right?
> \NR
> \NC y
> \NC = ok ~ left ~ again
> \NR
> \stopalign
> \stopformula
> \stoptext
>
> gives
>
> https://i.stack.imgur.com/ZTAp3.png
>
> It appears that \startmatrix globally resets \NC. I haven't looked into
> the code yet to see why this is happening.
you can play with
\unprotect
\newcount\c_math_eqalign_column_saved
\newcount\c_math_eqalign_first_saved
\unexpanded\def\math_matrix_start#1%
{\begingroup
\c_math_eqalign_column_saved\c_math_eqalign_column
\c_math_eqalign_first_saved \c_math_eqalign_first
\edef\currentmathmatrix{#1}%
\dosingleempty\math_matrix_start_indeed}
\def\math_matrix_stop
{\math_matrix_stop_processing
\global\c_math_eqalign_column\c_math_eqalign_column_saved
\global\c_math_eqalign_first\c_math_eqalign_first_saved
\endgroup}
\protect
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug when mathmatrix is used inside mathalign
2019-03-27 17:13 ` Hans Hagen
@ 2019-03-27 23:09 ` Aditya Mahajan
0 siblings, 0 replies; 4+ messages in thread
From: Aditya Mahajan @ 2019-03-27 23:09 UTC (permalink / raw)
To: ntg-context@ntg.nl >> mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]
On Wed, 27 Mar 2019, Hans Hagen wrote:
> On 3/27/2019 4:56 PM, Aditya Mahajan wrote:
>> Hi,
>>
>> It was reported on TeX.SE[1] that there is a bug when math matrix is used
>> inside a math align:
>>
>> \starttext
>> \startformula
>> \startalign[n=2,align={right,left}]
>> \NC x
>> \NC = a ~ long ~ sequence ~ of ~ terms
>> \NR
>> \NC y
>> \NC = ok ~ left
>> \NR
>> \NC \startmatrix[left={\left\lbrack},right={\right\rbrack}]
>> \NC x \NR
>> \NC y \NR
>> \stopmatrix
>> \NC = why ~ right?
>> \NR
>> \NC y
>> \NC = ok ~ left ~ again
>> \NR
>> \stopalign
>> \stopformula
>> \stoptext
>>
>> gives
>>
>> https://i.stack.imgur.com/ZTAp3.png
>>
>> It appears that \startmatrix globally resets \NC. I haven't looked into
>> the code yet to see why this is happening.
> you can play with
>
> \unprotect
>
> \newcount\c_math_eqalign_column_saved
> \newcount\c_math_eqalign_first_saved
>
> \unexpanded\def\math_matrix_start#1%
> {\begingroup
> \c_math_eqalign_column_saved\c_math_eqalign_column
> \c_math_eqalign_first_saved \c_math_eqalign_first
> \edef\currentmathmatrix{#1}%
> \dosingleempty\math_matrix_start_indeed}
>
> \def\math_matrix_stop
> {\math_matrix_stop_processing
> \global\c_math_eqalign_column\c_math_eqalign_column_saved
> \global\c_math_eqalign_first\c_math_eqalign_first_saved
> \endgroup}
>
> \protect
Yes, this works. But we still need \globalpushmacro\c_math_matrix_first,
otherwise nested matrices have wrong distance.
https://mailman.ntg.nl/pipermail/ntg-context/2017/089631.html
So, the following appears to work correctly:
\unprotect
\newcount\c_math_eqalign_column_saved
\newcount\c_math_eqalign_first_saved
\unexpanded\def\math_matrix_start#1%
{\begingroup
\globalpushmacro\c_math_matrix_first
\c_math_eqalign_column_saved\c_math_eqalign_column
\c_math_eqalign_first_saved \c_math_eqalign_first
\edef\currentmathmatrix{#1}%
\dosingleempty\math_matrix_start_indeed}
\def\math_matrix_stop
{\math_matrix_stop_processing
\global\c_math_eqalign_column\c_math_eqalign_column_saved
\global\c_math_eqalign_first\c_math_eqalign_first_saved
\globalpopmacro\c_math_matrix_first
\endgroup}
\protect
I am not sure why the assignments in math_matrix_start are not global but
those in math_matrix_stop are global.
Aditya
[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-27 23:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 15:56 Bug when mathmatrix is used inside mathalign Aditya Mahajan
2019-03-27 17:13 ` Hans Hagen
2019-03-27 17:13 ` Hans Hagen
2019-03-27 23:09 ` 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).