ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* intertext for aligned equations
@ 2006-03-27  7:23 Aditya Mahajan
  2006-03-27  9:02 ` Taco Hoekwater
  0 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2006-03-27  7:23 UTC (permalink / raw)


Hi,
  I was looking at trying to implement something similar to 
amsmath's intertext command. I can get the basic functionality working 
as follows.

\def\startintertext#1\stopintertext{%
     \noalign{#1}\NR}

\startformula \startalign
   \NC A_1 \NC= \left| \int_0^1 (x^2 - 3x)\, dx \right|
     + \left| \int_1^2 (x^2 -5x + 6)\, dx \right| \NR
   \startintertext
     Take limis of both integrals %\input tufte
   \stopintertext
   \NC \NC = \left| \frac{x^3}{3} - \frac{3}{2} x^2 \right|_0^1
     + \left| \frac {x ^3}{3} - 7 \frac{5}{2} x^2 + 6x \right|_1^2 \NR
     \NC \NC = \left| - \frac{7}{6} \right| + \left|\frac{14}{3} -
     \frac{23}{6}\right| = \frac{7}{6} + \frac{5}{6} = 2 \NR
\stopalign \stopformula

This seems to be working fine. However, \intertext defined in 
amsmath.sty seems to be doing  a lot more (I just can't figure out 
what it is doing?) Can someone suggest how to make the above command 
more robust on the lines of \intertext?

%----- from amsmath.sty -------------
\def\intertext@{%
   \def\intertext##1{%
     \ifvmode\else\\\@empty\fi
     \noalign{%
       \penalty\postdisplaypenalty\vskip\belowdisplayskip
       \vbox{\normalbaselines
         \ifdim\linewidth=\columnwidth
         \else \parshape\@ne \@totalleftmargin \linewidth
         \fi
         \noindent##1\par}%
       \penalty\predisplaypenalty\vskip\abovedisplayskip%
     }%
}}

Thanks,
Aditya

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

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

* Re: intertext for aligned equations
  2006-03-27  7:23 intertext for aligned equations Aditya Mahajan
@ 2006-03-27  9:02 ` Taco Hoekwater
  2006-03-27 12:27   ` Hans Hagen
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Taco Hoekwater @ 2006-03-27  9:02 UTC (permalink / raw)




Hi,

Aditya Mahajan wrote:

> This seems to be working fine. However, \intertext defined in 
> amsmath.sty seems to be doing  a lot more (I just can't figure out 
> what it is doing?) Can someone suggest how to make the above command 
> more robust on the lines of \intertext?

It inserts a post/pre-display skip&penalty pair around the intertext,
then creates a \vbox for use a paragraph. The result is (almost) as if
it the text was part of the 'normal' text flow between two displays.

I cannot tell you if this would work exactly the same as expected in
ConTeXt (needs further testing), but a context-like solution would
look like this:

\def\startintertext#1\stopintertext{%
   \noalign{\dointertext{#1}}\NR}

\unexpanded\def\dointertext#1%
    {\penalty\postdisplaypenalty
     \afterdisplayspace  % the matching \before... is not needed
     \vbox{\forgetall \noindent #1\par}%
     \penalty\postdisplaypenalty }

Cheers, taco

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

* Re: intertext for aligned equations
  2006-03-27  9:02 ` Taco Hoekwater
@ 2006-03-27 12:27   ` Hans Hagen
  2006-03-27 13:53     ` Taco Hoekwater
  2006-03-27 12:50   ` Hans Hagen
  2006-03-29  6:42   ` Aditya Mahajan
  2 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2006-03-27 12:27 UTC (permalink / raw)


Taco Hoekwater wrote:
> Hi,
>
> Aditya Mahajan wrote:
>
>   
>> This seems to be working fine. However, \intertext defined in 
>> amsmath.sty seems to be doing  a lot more (I just can't figure out 
>> what it is doing?) Can someone suggest how to make the above command 
>> more robust on the lines of \intertext?
>>     
>
> It inserts a post/pre-display skip&penalty pair around the intertext,
> then creates a \vbox for use a paragraph. The result is (almost) as if
> it the text was part of the 'normal' text flow between two displays.
>
> I cannot tell you if this would work exactly the same as expected in
> ConTeXt (needs further testing), but a context-like solution would
> look like this:
>
> \def\startintertext#1\stopintertext{%
>    \noalign{\dointertext{#1}}\NR}
>
> \unexpanded\def\dointertext#1%
>     {\penalty\postdisplaypenalty
>      \afterdisplayspace  % the matching \before... is not needed
>      \vbox{\forgetall \noindent #1\par}%
>      \penalty\postdisplaypenalty }
>   
can someone wrap up the accumulated patches/suggestions for the math environments? 

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] 9+ messages in thread

* Re: intertext for aligned equations
  2006-03-27  9:02 ` Taco Hoekwater
  2006-03-27 12:27   ` Hans Hagen
@ 2006-03-27 12:50   ` Hans Hagen
  2006-03-29  6:42   ` Aditya Mahajan
  2 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2006-03-27 12:50 UTC (permalink / raw)


Taco Hoekwater wrote:
> Hi,
>
> Aditya Mahajan wrote:
>
>   
>> This seems to be working fine. However, \intertext defined in 
>> amsmath.sty seems to be doing  a lot more (I just can't figure out 
>> what it is doing?) Can someone suggest how to make the above command 
>> more robust on the lines of \intertext?
>>     
>
> It inserts a post/pre-display skip&penalty pair around the intertext,
> then creates a \vbox for use a paragraph. The result is (almost) as if
> it the text was part of the 'normal' text flow between two displays.
>
> I cannot tell you if this would work exactly the same as expected in
> ConTeXt (needs further testing), but a context-like solution would
> look like this:
>
> \def\startintertext#1\stopintertext{%
>    \noalign{\dointertext{#1}}\NR}
>
> \unexpanded\def\dointertext#1%
>     {\penalty\postdisplaypenalty
>      \afterdisplayspace  % the matching \before... is not needed
>      \vbox{\forgetall \noindent #1\par}%
>      \penalty\postdisplaypenalty }
>
>   
added (preliminary) but i need an example of usage for the core-mat file/docu -) 

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] 9+ messages in thread

* Re: intertext for aligned equations
  2006-03-27 12:27   ` Hans Hagen
@ 2006-03-27 13:53     ` Taco Hoekwater
  2006-03-27 14:47       ` Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2006-03-27 13:53 UTC (permalink / raw)




Hans Hagen wrote:
> 
> can someone wrap up the accumulated patches/suggestions for the math environments? 
> 

I hope someone else can do that (Aditya?) I lost track myself

Cheers, Taco

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

* Re: intertext for aligned equations
  2006-03-27 13:53     ` Taco Hoekwater
@ 2006-03-27 14:47       ` Aditya Mahajan
  0 siblings, 0 replies; 9+ messages in thread
From: Aditya Mahajan @ 2006-03-27 14:47 UTC (permalink / raw)


<--- On Mar 27, Taco Hoekwater wrote --->
> Hans Hagen wrote:
>>
>> can someone wrap up the accumulated patches/suggestions for the math environments?
>>
>
> I hope someone else can do that (Aditya?) I lost track myself

I have a list of all the patches that were sent to the ML but have not 
been included in the core yet. I will make a list on the wiki.

Aditya

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

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

* Re: intertext for aligned equations
  2006-03-27  9:02 ` Taco Hoekwater
  2006-03-27 12:27   ` Hans Hagen
  2006-03-27 12:50   ` Hans Hagen
@ 2006-03-29  6:42   ` Aditya Mahajan
  2006-03-29  7:49     ` Taco Hoekwater
  2 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2006-03-29  6:42 UTC (permalink / raw)


<--- On Mar 27, Taco Hoekwater wrote --->

>
>
> Hi,
>
> Aditya Mahajan wrote:
>
>> This seems to be working fine. However, \intertext defined in
>> amsmath.sty seems to be doing  a lot more (I just can't figure out
>> what it is doing?) Can someone suggest how to make the above command
>> more robust on the lines of \intertext?
>
> It inserts a post/pre-display skip&penalty pair around the intertext,
> then creates a \vbox for use a paragraph. The result is (almost) as if
> it the text was part of the 'normal' text flow between two displays.
>
> I cannot tell you if this would work exactly the same as expected in
> ConTeXt (needs further testing), but a context-like solution would
> look like this:
>
> \def\startintertext#1\stopintertext{%
>   \noalign{\dointertext{#1}}\NR}
>
> \unexpanded\def\dointertext#1%
>    {\penalty\postdisplaypenalty
>     \afterdisplayspace  % the matching \before... is not needed
>     \vbox{\forgetall \noindent #1\par}%
>     \penalty\postdisplaypenalty }
>

This does not look good. Consider,

\def\startintertext#1\stopintertext{%
    \noalign{\dointertext{#1}}\NR}

\unexpanded\def\dointertext#1%
   {\penalty\postdisplaypenalty
    \afterdisplayspace  % the matching \before... is not needed
    \vbox{\forgetall \noindent #1\par}%
    \penalty\postdisplaypenalty }

\startformula \startalign
   \NC A_1 \NC= \left| \int_0^1 (x^2 - 3x)\, dx \right|
     + \left| \int_1^2 (x^2 -5x + 6)\, dx \right| \NR
   \startintertext
     Take limits of both integrals
   \stopintertext
   \NC \NC = \left| \frac{x^3}{3} - \frac{3}{2} x^2 \right|_0^1
     + \left| \frac {x ^3}{3} - 7 \frac{5}{2} x^2 + 6x \right|_1^2 \NR
     \NC \NC = \left| - \frac{7}{6} \right| + \left|\frac{14}{3} -
     \frac{23}{6}\right| = \frac{7}{6} + \frac{5}{6} = 2 \NR
\stopalign \stopformula

There is too much space after the intertext and the next line. Can you 
provide some magic to reduce this space.

Thanks,
Aditya

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

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

* Re: intertext for aligned equations
  2006-03-29  6:42   ` Aditya Mahajan
@ 2006-03-29  7:49     ` Taco Hoekwater
  2006-03-29 15:46       ` Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2006-03-29  7:49 UTC (permalink / raw)




Aditya Mahajan wrote:
> 
> This does not look good. Consider,
> 
> There is too much space after the intertext and the next line. Can you 
> provide some magic to reduce this space.

Ok, got it. The \NR has to go away, and the \beforedisplayspace
reinserted, like so:

\def\startintertext#1\stopintertext
    {\noalign{\dointertext{#1}}}

\unexpanded\def\dointertext#1%
    {\penalty\postdisplaypenalty
     \afterdisplayspace
     \vbox{\forgetall \noindent #1\par}%
     \penalty\predisplaypenalty
     \beforedisplayspace }

Looks much better (over here).

Taco

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

* Re: intertext for aligned equations
  2006-03-29  7:49     ` Taco Hoekwater
@ 2006-03-29 15:46       ` Aditya Mahajan
  0 siblings, 0 replies; 9+ messages in thread
From: Aditya Mahajan @ 2006-03-29 15:46 UTC (permalink / raw)


<--- On Mar 29, Taco Hoekwater wrote --->
> Aditya Mahajan wrote:
>>
>> This does not look good. Consider,
>>
>> There is too much space after the intertext and the next line. Can you
>> provide some magic to reduce this space.
>
> Ok, got it. The \NR has to go away, and the \beforedisplayspace
> reinserted, like so:
>
> \def\startintertext#1\stopintertext
>    {\noalign{\dointertext{#1}}}
>
> \unexpanded\def\dointertext#1%
>    {\penalty\postdisplaypenalty
>     \afterdisplayspace
>     \vbox{\forgetall \noindent #1\par}%
>     \penalty\predisplaypenalty
>     \beforedisplayspace }
>
> Looks much better (over here).

Thanks a lot. This indeed looks pretty good.

Aditya

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

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-27  7:23 intertext for aligned equations Aditya Mahajan
2006-03-27  9:02 ` Taco Hoekwater
2006-03-27 12:27   ` Hans Hagen
2006-03-27 13:53     ` Taco Hoekwater
2006-03-27 14:47       ` Aditya Mahajan
2006-03-27 12:50   ` Hans Hagen
2006-03-29  6:42   ` Aditya Mahajan
2006-03-29  7:49     ` Taco Hoekwater
2006-03-29 15:46       ` 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).