Re: [NTG-context] extentable arrows

2006-06-29 Thread Aditya Mahajan
On Thu, 29 Jun 2006, Hans Hagen wrote:

> Aditya Mahajan wrote:
>>
>> I am simply trying to copy from amsmath definition.
>>
>
> better think context -)
>
> \unprotect
>
> \def\mtharrfactor{1}
> \def\mtharrextra {0}
>
> \def\domthxarr#1#2#3#4#5#6#7#8%
>  {\begingroup
>   \def\mtharrfactor{1}%
>   \def\mtharrextra {0}%
>   \processaction[#1] % will be sped up
> [  \v!none=>\def\mtharrfactor{0},
>   \v!small=>\def\mtharrextra{10},
>  \v!medium=>\def\mtharrextra{15},
> \v!big=>\def\mtharrextra{20},
>  \v!normal=>,
> \v!default=>,
> \v!unknown=>\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]%
>   \mathsurround\zeropoint
>   \muskip0=#4mu \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra 
> mu
>   \muskip2=#5mu \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra 
> mu
>   \setbox0\hbox{$\scriptstyle
>  \if#20\else\mkern#2mu\fi
>  \mkern\muskip0\relax
>  #8\relax
>  \mkern\muskip2\relax
>  \if#30\else\mkern#3mu\fi
> $}%
>   \setbox4\hbox{#6}%
>   \dimen0\wd0
>   \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
>   \setbox2\hbox{$\scriptstyle
>  \if#20\else\mkern#2mu\fi
>  \mkern\muskip0\relax
>  #7\relax
>  \mkern\muskip2\relax
>  \if#30\else\mkern#3mu\fi
> $}%
>   \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
>   \setbox4\hbox to \dimen0{#6}%
>   \mathrel{\mathop{%
> \hbox to \dimen0{\hss\copy4\hss}}%
> \limits^{\box0}_{\box2}}
>   \endgroup}
>
> % ams:
>
> \def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow}
> \def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow}
>
> \def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow}
> \def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow }
>
> \def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}
> \def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}}
>
> \def\dodoxrightarrow#2#3{\mathrel{{\domthxarr{}0359\rightarrowfill{#1}{#2
> \def\dodoxleftarrow #2#3{\mathrel{{\domthxarr{}3095\leftarrowfill {#1}{#2
>
> % context:
>
> \def\xrightarrow  {\dosingleempty\doxrightarrow}
> \def\xleftarrow   {\dosingleempty\doxleftarrow}
>
> \def\doxrightarrow[#1]{\dotriplegroupempty\dodoxrightarrow{#1}}
> \def\doxleftarrow [#1]{\dotriplegroupempty\dodoxleftarrow {#1}}
>
> \def\dodoxrightarrow#1#2#3{\mathrel{{\domthxarr{#1}0359\rightarrowfill{#2}{#3
> \def\dodoxleftarrow #1#2#3{\mathrel{{\domthxarr{#1}3095\leftarrowfill 
> {#2}{#3
>
> \starttext
>
> \startformula \xrightarrow{}{stuff on top}\stopformula
> \startformula \xrightarrow{stuff below}{}\stopformula
> \startformula \xrightarrow{stuff below}{stuff on top}\stopformula
>
> \startformula \xleftarrow [none]{stuff below}{stuff on top}\stopformula
> \startformula \xleftarrow [small]{stuff below}{stuff on top}\stopformula
> \startformula \xleftarrow [medium]{stuff below}{stuff on top}\stopformula
> \startformula \xleftarrow [big]{stuff below}{stuff on top}\stopformula
>
> \stoptext


This definitely looks better. Can there be a setting for 
\setuparrowextension (or something) so that the default can be 
changed.


On Thu, 29 Jun 2006, Taco Hoekwater wrote:

> Perhaps it syntax should be identical to amsmath: no brackets
> and two required arguments.

But that is not the amsmath syntax. It has

\xrightarrow[below]{top} where the first argument is optional.

> It is what is expected anyway.
>
>  \def\xrightarrow#1#2{\mathrel
>  {{\domthxarr0359\rightarrowfill{#1}{#2
>

I agree that this makes more sense.


> I assume amsmath has a few others as well, for double arrows and such.
> Can you post those defs as well? Then we can move the whole definition
> into math-ext.tex for the new release
>

On Thu, 29 Jun 2006, Hans Hagen wrote:

> hm, this is not the context way, two equal kind of contents and then one
> of them in [], maybe

I agree. To me,

\xrightarrow[setting]{below}{top}

makes most sense. It is not same as ams syntax, but that does not 
matter too much. Maybe there can be a switch to enable ams type of 
syntax, but that will make things too messy, I guess.


>
> \def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow}
> \def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow}
>
> \def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow}
> \def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow }
>
> \def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}
> \def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}}
>
> which accepts
>
> \xrightarrow{x}{y}
> \xrightarrow{x}
> \xrightarrow{}{y}
> \xrightarrow[x]{y}
>
> etc, actyally, we should then also accept
>
> \xrightarrow[x][y]
>
> but more interesting is to use the optional arg for tuning purposes
>
>
> \if0#1\else\mkern#1mu\fi
>
> test, does a \mkern0mu hurt?

I did not see any difference when I tested it. I do not know why that 
is there.


On Thu, 29 Jun 2006, Tac

Re: [NTG-context] extentable arrows

2006-06-29 Thread Hans Hagen
Aditya Mahajan wrote:
>
> I am simply trying to copy from amsmath definition.
>   

better think context -)

\unprotect

\def\mtharrfactor{1}
\def\mtharrextra {0}

\def\domthxarr#1#2#3#4#5#6#7#8%
  {\begingroup
   \def\mtharrfactor{1}%
   \def\mtharrextra {0}%
   \processaction[#1] % will be sped up
 [  \v!none=>\def\mtharrfactor{0},
   \v!small=>\def\mtharrextra{10},
  \v!medium=>\def\mtharrextra{15},
 \v!big=>\def\mtharrextra{20},
  \v!normal=>,
 \v!default=>,
 \v!unknown=>\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]%
   \mathsurround\zeropoint
   \muskip0=#4mu \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
   \muskip2=#5mu \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
   \setbox0\hbox{$\scriptstyle
  \if#20\else\mkern#2mu\fi
  \mkern\muskip0\relax
  #8\relax
  \mkern\muskip2\relax
  \if#30\else\mkern#3mu\fi
 $}%
   \setbox4\hbox{#6}%
   \dimen0\wd0
   \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
   \setbox2\hbox{$\scriptstyle
  \if#20\else\mkern#2mu\fi
  \mkern\muskip0\relax
  #7\relax
  \mkern\muskip2\relax
  \if#30\else\mkern#3mu\fi
 $}%
   \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
   \setbox4\hbox to \dimen0{#6}%
   \mathrel{\mathop{%
 \hbox to \dimen0{\hss\copy4\hss}}%
 \limits^{\box0}_{\box2}}
   \endgroup}

% ams:

\def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow}
\def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow}

\def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow}
\def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow }

\def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}
\def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}}

\def\dodoxrightarrow#2#3{\mathrel{{\domthxarr{}0359\rightarrowfill{#1}{#2
\def\dodoxleftarrow #2#3{\mathrel{{\domthxarr{}3095\leftarrowfill {#1}{#2

% context:

\def\xrightarrow  {\dosingleempty\doxrightarrow}
\def\xleftarrow   {\dosingleempty\doxleftarrow}

\def\doxrightarrow[#1]{\dotriplegroupempty\dodoxrightarrow{#1}}
\def\doxleftarrow [#1]{\dotriplegroupempty\dodoxleftarrow {#1}}

\def\dodoxrightarrow#1#2#3{\mathrel{{\domthxarr{#1}0359\rightarrowfill{#2}{#3
\def\dodoxleftarrow #1#2#3{\mathrel{{\domthxarr{#1}3095\leftarrowfill 
{#2}{#3

\starttext

\startformula \xrightarrow{}{stuff on top}\stopformula
\startformula \xrightarrow{stuff below}{}\stopformula
\startformula \xrightarrow{stuff below}{stuff on top}\stopformula

\startformula \xleftarrow [none]{stuff below}{stuff on top}\stopformula
\startformula \xleftarrow [small]{stuff below}{stuff on top}\stopformula
\startformula \xleftarrow [medium]{stuff below}{stuff on top}\stopformula
\startformula \xleftarrow [big]{stuff below}{stuff on top}\stopformula

\stoptext
 

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

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


Re: [NTG-context] extentable arrows

2006-06-29 Thread Hans Hagen
Aditya Mahajan wrote:
>
> The syntax can be made identical (even better) than that of amsmath.
>
> \def\xrightarrow{\dosingleempty\doxrightarrow}
>
> \def\xleftarrow {\dosingleempty\doxleftarrow}
>
> \def\doxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}
>
> \def\doxleftarrow[#1]{\dodoublegroupempty\dodoxleftarrow{#1}}
>
> \def\dodoxrightarrow#1#2{\mathrel
> {{\domthxarr0359\rightarrowfill{#1}{#2
>
> \def\dodoxleftarrow#1#2{\mathrel
> {{\domthxarr3095\leftarrowfill{#1}{#2
>
> \starttext
>   $$
>   A \xrightarrow[]{stuff on top} B
>   $$
>
> $$
> A \xrightarrow[stuff below]{} B
> $$
>
> \startformula
>   A \xleftarrow[stuff below]{stuff on top} B
> \stopformula
>
>   $$
>   A \xleftarrow B
>   $$
> $$
>   \rightarrow A \xrightarrow{stuff on top} B \leftarrow
> $$
>
>
> $$
>   \rightarrow A \xleftarrow[stuff below] B \leftarrow
> $$
>
>   \stoptext
>   
hm, this is not the context way, two equal kind of contents and then one 
of them in [], maybe

\def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow}
\def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow}

\def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow}
\def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow }

\def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}
\def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}}

which accepts

\xrightarrow{x}{y}
\xrightarrow{x}
\xrightarrow{}{y}
\xrightarrow[x]{y}

etc, actyally, we should then also accept

\xrightarrow[x][y]

but more interesting is to use the optional arg for tuning purposes


\if0#1\else\mkern#1mu\fi

test, does a \mkern0mu hurt?

>
> Will make copy paste a bit easier! Though these days I find myself 
> writing more in context and soon will face the reverse problem. I will 
> need to copy context math into latex (needed for final journal 
> submission) and some of the math features are simply missing from 
> latex :)
>   

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
-

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


Re: [NTG-context] extentable arrows

2006-06-29 Thread Taco Hoekwater


Aditya Mahajan wrote:
> On Wed, 28 Jun 2006, Taco Hoekwater wrote:
> 
> 
>>Aditya Mahajan wrote:
>>
>>>\xrightarrow{big superscipt}
>>>
>>>Any suggestions?
>>
>>
>>Not completely identical, but similar.
> 
> 
> The syntax can be made identical (even better) than that of amsmath.

Perhaps it syntax should be identical to amsmath: no brackets
and two required arguments. It is what is expected anyway.

  \def\xrightarrow#1#2{\mathrel
  {{\domthxarr0359\rightarrowfill{#1}{#2

I assume amsmath has a few others as well, for double arrows and such.
Can you post those defs as well? Then we can move the whole definition
into math-ext.tex for the new release

Cheers,
Taco
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] extentable arrows

2006-06-28 Thread Aditya Mahajan
On Wed, 28 Jun 2006, Taco Hoekwater wrote:

> Aditya Mahajan wrote:
>> \xrightarrow{big superscipt}
>>
>> Any suggestions?
>
>
> Not completely identical, but similar.

The syntax can be made identical (even better) than that of amsmath.

\def\xrightarrow{\dosingleempty\doxrightarrow}

\def\xleftarrow {\dosingleempty\doxleftarrow}

\def\doxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}}

\def\doxleftarrow[#1]{\dodoublegroupempty\dodoxleftarrow{#1}}

\def\dodoxrightarrow#1#2{\mathrel
{{\domthxarr0359\rightarrowfill{#1}{#2

\def\dodoxleftarrow#1#2{\mathrel
{{\domthxarr3095\leftarrowfill{#1}{#2

\starttext
  $$
  A \xrightarrow[]{stuff on top} B
  $$

$$
A \xrightarrow[stuff below]{} B
$$

\startformula
  A \xleftarrow[stuff below]{stuff on top} B
\stopformula

  $$
  A \xleftarrow B
  $$
$$
  \rightarrow A \xrightarrow{stuff on top} B \leftarrow
$$


$$
  \rightarrow A \xleftarrow[stuff below] B \leftarrow
$$

  \stoptext


Will make copy paste a bit easier! Though these days I find myself 
writing more in context and soon will face the reverse problem. I will 
need to copy context math into latex (needed for final journal 
submission) and some of the math features are simply missing from 
latex :)

Aditya

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


Re: [NTG-context] extentable arrows

2006-06-28 Thread Aditya Mahajan
On Wed, 28 Jun 2006, Taco Hoekwater wrote:

> Aditya Mahajan wrote:
>> \xrightarrow{big superscipt}
>>
>> Any suggestions?
>
>
> Not completely identical, but similar.
>
> Cheers, Taco
>
>
> \def\domthxarr#1#2#3#4#5#6#7%
>   {\begingroup
>\mathsurround\zeropoint
>\setbox0\hbox{$\scriptstyle
>   \if0#1\else\mkern#1mu\fi
>   \mkern#3mu#7\mkern#4mu
>   \if0#2\else\mkern#2mu\fi $}%
>\setbox4\hbox{#5}%
>\dimen0\wd0
>\ifdim\wd4>\dimen0 \dimen0\wd4 \fi
>\setbox2\hbox{$\scriptstyle
>  \if0#1\else\mkern#1mu\fi
>  \mkern#3mu#6\mkern#4mu
>  \if0#2\else\mkern#2mu\fi $}%
>\ifdim\wd2>\dimen0 \dimen0\wd2 \fi
>\setbox4\hbox to \dimen0{#5}%
>\mathord{\vcenter{{\offinterlineskip
>  \hbox to \dimen0{\hss\box0\hss}%
>  \kern .2ex
>  \hbox to \dimen0{\hss\copy4\hss}%
>  \kern .2ex
>  \hbox to \dimen0{\hss\box2\hss%
>\endgroup}
>
> \def\xrightarrow{\dodoubleempty\doxrightarrow }
>
> \def\xleftarrow {\dodoubleempty\doxleftarrow }
>
> \def\doxrightarrow[#1][#2]{\mathrel
>   {{\domthxarr0359\rightarrowfill{#1}{#2
>
> \def\doxleftarrow[#1][#2]{\mathrel
>   {{\domthxarr3095\leftarrowfill{#1}{#2

Thanks Taco! However, the arrow is not centered when there is only 
subscript or superscript. Compare the height of arrows in the 
following.

$$
  \rightarrow A \xrightarrow[][stuff on top] B \leftarrow
$$


$$
  \rightarrow A \xleftarrow[stuff below][] B \leftarrow
$$

How about,

\def\domthxarr#1#2#3#4#5#6#7%
{\begingroup
 \mathsurround\zeropoint
 \setbox0\hbox{$\scriptstyle
\if0#1\else\mkern#1mu\fi
\mkern#3mu#7\mkern#4mu
\if0#2\else\mkern#2mu\fi $}%
 \setbox4\hbox{#5}%
 \dimen0\wd0
 \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
 \setbox2\hbox{$\scriptstyle
   \if0#1\else\mkern#1mu\fi
   \mkern#3mu#6\mkern#4mu
   \if0#2\else\mkern#2mu\fi $}%
 \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
 \setbox4\hbox to \dimen0{#5}%
 \mathrel{\mathop{%
   \hbox to \dimen0{\hss\copy4\hss}}%
   \limits^{\box0}_{\box2}}
% \mathord{\vcenter{{\offinterlineskip
%   \hbox to \dimen0{\hss\box0\hss}%
%   \kern .2ex
%   \hbox to \dimen0{\hss\copy4\hss}%
%   \kern .2ex
%   \hbox to \dimen0{\hss\box2\hss%
 \endgroup}


I am simply trying to copy from amsmath definition.

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


Re: [NTG-context] extentable arrows

2006-06-28 Thread Taco Hoekwater
Aditya Mahajan wrote:
> \xrightarrow{big superscipt}
> 
> Any suggestions?


Not completely identical, but similar.

Cheers, Taco



\def\domthxarr#1#2#3#4#5#6#7%
   {\begingroup
\mathsurround\zeropoint
\setbox0\hbox{$\scriptstyle
   \if0#1\else\mkern#1mu\fi
   \mkern#3mu#7\mkern#4mu
   \if0#2\else\mkern#2mu\fi $}%
\setbox4\hbox{#5}%
\dimen0\wd0
\ifdim\wd4>\dimen0 \dimen0\wd4 \fi
\setbox2\hbox{$\scriptstyle
  \if0#1\else\mkern#1mu\fi
  \mkern#3mu#6\mkern#4mu
  \if0#2\else\mkern#2mu\fi $}%
\ifdim\wd2>\dimen0 \dimen0\wd2 \fi
\setbox4\hbox to \dimen0{#5}%
\mathord{\vcenter{{\offinterlineskip
  \hbox to \dimen0{\hss\box0\hss}%
  \kern .2ex
  \hbox to \dimen0{\hss\copy4\hss}%
  \kern .2ex
  \hbox to \dimen0{\hss\box2\hss%
\endgroup}

\def\xrightarrow{\dodoubleempty\doxrightarrow }

\def\xleftarrow {\dodoubleempty\doxleftarrow }

\def\doxrightarrow[#1][#2]{\mathrel
   {{\domthxarr0359\rightarrowfill{#1}{#2

\def\doxleftarrow[#1][#2]{\mathrel
   {{\domthxarr3095\leftarrowfill{#1}{#2


\starttext
$$
A \xrightarrow[][stuff on top] B
$$


$$
A \xleftarrow[stuff below][stuff on top] B
$$

$$
A \xleftarrow B
$$

\stoptext
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] extentable arrows

2006-06-28 Thread Aditya Mahajan
On Wed, 28 Jun 2006, Aditya Mahajan wrote:

> Hi,
>  Does ConTeXt have anything equivalent to xleftarrow, xrightarrow of
> amsmath. Basically, I need a command that can do
>
> A \xleftarrow[subscript]{superscript} B
>
> should give
>
>superscript
> A <--- B
>subscript
>
> and similar for xrightarrow, xleftrightarrow, xLeftarrow, xRightarrow
> and xLeftRightarrow.
>
>
> The closest that I could come to it was (only for superscripts)
>
> \def\xrightarrow#1{\buildrel{#1}\over\longrightarrow}
>
> But this is not extendable.
>
> \xrightarrow{big superscipt}
>
>
> Any suggestions?

This is how it is defined in amsmath.sty

[EMAIL PROTECTED]
   \mathrel{\mathop{%
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]@th
   \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
   \hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}%
   \copy\z@
 }%
 \hbox [EMAIL PROTECTED]@}}%
   \limits
 [EMAIL PROTECTED]
#7\if0#2\else\mkern#2mu\fi}}%
 [EMAIL PROTECTED]
#6\if0#2\else\mkern#2mu\fi}}}%
}
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]

I tried to contextify this, but keep on getting missing $ errors.

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


[NTG-context] extentable arrows

2006-06-28 Thread Aditya Mahajan
Hi,
  Does ConTeXt have anything equivalent to xleftarrow, xrightarrow of 
amsmath. Basically, I need a command that can do

A \xleftarrow[subscript]{superscript} B

should give

superscript
A <--- B
subscript

and similar for xrightarrow, xleftrightarrow, xLeftarrow, xRightarrow 
and xLeftRightarrow.


The closest that I could come to it was (only for superscripts)

\def\xrightarrow#1{\buildrel{#1}\over\longrightarrow}

But this is not extendable.

\xrightarrow{big superscipt}


Any suggestions?

Aditya

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