[NTG-context] extentable arrows

Aditya Mahajan adityam at umich.edu
Thu Jun 29 16:56:30 CEST 2006


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, Taco Hoekwater wrote:

> 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

These are the only ones defined in amsmath. However extarrows.sty 
defines the following

   \xlongequal (===)

   \xLongleftarrow (<===)

(Perhaps a better name is \xLeftarrow and we can have 
\xLeftarrow[medium] )


   \xLongrightarrow (===>)

(Perhaps a better name is \xRightarrow?)


   \xLongleftrightarrow (<=====>)

(again, \xLeftrightarrow[medium] )

   \xLeftrightarrow ( <===> )


   \xlongleftrightarrow (<------->)

(again \xleftrightarrow[medium] )

   \xleftrightarrow (<---->)

   \xlongleftarrow
   \xlongrightarrow

(These two are there with \xrightarrow[medium])

The definitions in extarrows are

\def\x at arrow{\DOTSB\Relbar}
\def\xlongequalsignfill@{\arrowfill@\x at arrow\Relbar\x at arrow}

\newcommand{\xlongequal}[2][]{%
 	\ext at arrow 0099\xlongequalsignfill@{#1}{#2}}

\def\xLongleftrightarrowfill@{%
   \arrowfill@\Longleftarrow\Relbar\Longrightarrow}
\newcommand{\xLongleftrightarrow}[2][]{%
 	\ext at arrow 0099\xLongleftrightarrowfill@{#1}{#2}}

\def\xlongleftrightarrowfill@{%
   \arrowfill@\longleftarrow\relbar\longrightarrow}
\newcommand{\xlongleftrightarrow}[2][]{%
 	\ext at arrow 0099\xlongleftrightarrowfill@{#1}{#2}}

\def\xLeftrightarrowfill@{\arrowfill@\Leftarrow\Relbar\Rightarrow}
\newcommand{\xLeftrightarrow}[2][]{%
 	\ext at arrow 0099\xLeftrightarrowfill@{#1}{#2}}

\def\xleftrightarrowfill@{\arrowfill@\leftarrow\relbar\rightarrow}
\newcommand{\xleftrightarrow}[2][]{%
 	\ext at arrow 0099\xleftrightarrowfill@{#1}{#2}}

\def\xLongleftarrowfill@{\arrowfill@\Longleftarrow\Relbar\Relbar}
\newcommand{\xLongleftarrow}[2][]{%
 	\ext at arrow 0099\xLongleftarrowfill@{#1}{#2}}

\def\xLongrightarrowfill@{\arrowfill@\Relbar\Relbar\Longrightarrow}
\newcommand{\xLongrightarrow}[2][]{%
 	\ext at arrow 0099\xLongrightarrowfill@{#1}{#2}}

\def\xlongleftarrowfill@{\arrowfill@\longleftarrow\relbar\relbar}
\newcommand{\xlongleftarrow}[2][]{%
 	\ext at arrow 0099\xlongleftarrowfill@{#1}{#2}}

\def\xlongrightarrowfill@{\arrowfill@\relbar\relbar\longrightarrow}
\newcommand{\xlongrightarrow}[2][]{%
 	\ext at arrow 0099\xlongrightarrowfill@{#1}{#2}}


I do not think that change is syntax is that big a deal, as long as it 
is documented (I will do that). Otherwise we will still be using latex 
syntax here :)

Aditya






More information about the ntg-context mailing list