ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \overleftrightarrow
@ 2007-06-29  0:50 Jesse Alama
  2007-06-29  3:31 ` \overleftrightarrow Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Jesse Alama @ 2007-06-29  0:50 UTC (permalink / raw)
  To: ntg-context

I'm preparing a geometry course using ConTeXt and am impressed with the
system so far.  One thing I need is to do is typeset various geometrical
symbols.  It looks like ConTeXt already has the \overleftarrow and
\overrightarrow commands, but one thing I'd like to have is
\overleftrightarrow, for typesetting the symbol customarily used to
denote the line determined by two points.  It seems, though, that this
isn't available in ConTeXt, or, at least, it is not available by
default.  I tried looking on the contextgarden and google, but didn't
come across anything.  Is the \overleftrightarrow command already
available?  If not, what can I do so that I can use it?

Thanks,

Jesse

-- 
Jesse Alama (alama@stanford.edu)
*65: "thesis" is allowed only inside a proof

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-06-29  0:50 \overleftrightarrow Jesse Alama
@ 2007-06-29  3:31 ` Aditya Mahajan
  2007-06-30  8:47   ` \overleftrightarrow Mojca Miklavec
  2007-07-11 18:33   ` \overleftrightarrow Jesse Alama
  0 siblings, 2 replies; 9+ messages in thread
From: Aditya Mahajan @ 2007-06-29  3:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Mojca Miklavec

On Thu, 28 Jun 2007, Jesse Alama wrote:

> I'm preparing a geometry course using ConTeXt and am impressed with the
> system so far.  One thing I need is to do is typeset various geometrical
> symbols.  It looks like ConTeXt already has the \overleftarrow and
> \overrightarrow commands, but one thing I'd like to have is
> \overleftrightarrow, for typesetting the symbol customarily used to
> denote the line determined by two points.  It seems, though, that this
> isn't available in ConTeXt, or, at least, it is not available by
> default.  I tried looking on the contextgarden and google, but didn't
> come across anything.  Is the \overleftrightarrow command already
> available?

Actually just adding overleftrightarrow is easy, but better will be an 
interface to easily define such commands. So ....

> If not, what can I do so that I can use it?

ConTeXt uses overleftarrow and overrightarrow as defined in plain 
tex. This does not work in subscripts.

$\overleftarrow{A}$ $\overleftarrow{ABC}$
$a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$

Here is a solution. First we patch math-ext so that arrowfills take a 
style.

\unprotect

\def\mtharrowfill#1#2#3#4#5#6#7#8% AM: Added #8 (for displaystyle)
  {$\mathsurround 0pt
    \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
    \relax#8#5%
    \mkern-#1mu
    \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
    \mkern-#4mu#7$}

%D Now we need to make sure that the extensible arrows do not get 
%D affected. So...

\def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
  {\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=\thirdoffourarguments  #2mu
   \muskip2=\fourthoffourarguments #2mu
   \muskip4=\firstoffourarguments  #2mu
   \muskip6=\secondoffourarguments #2mu
   \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
   \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
   \setbox0\hbox{$\scriptstyle
                  \mkern\muskip4\relax
                  \mkern\muskip0\relax
                  #5\relax
                  \mkern\muskip2\relax
                  \mkern\muskip6\relax
                 $}%
   \setbox4\hbox{#3\displaystyle}% AM: Added displaystyle
   \dimen0\wd0
   \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
   \setbox2\hbox{$\scriptstyle
                  \mkern\muskip4\relax
                  \mkern\muskip0\relax
                  #4\relax
                  \mkern\muskip2\relax
                  \mkern\muskip6\relax
                 $}%
   \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
   \setbox4\hbox to \dimen0{#3\displaystyle}% AM: added dislaystyle
   \mathrel{\mathop{\hbox to 
\dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
   \endgroup}

\let\domthxarrsingle\domthxarr

%D Now, for defining overarrows.

\def\definemathoverarrow
  {\dotripleargument\dodefinemathoverarrow}

\def\dodefinemathoverarrow[#1][#2][#3]%
  {\ifthirdargument
    \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
   \else
    \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
   \fi}

\def\dohandlemathoverarrow[#1][#2]%
  {\mathpalette{\dodohanglemathoverarrow{#1}{#2}}}

% Note: math-pln has \kern-\onepoint, amsmath does not. I keep the
% kern amount as an option. This is useful with overharpoons.


\def\dodohanglemathoverarrow#1#2#3#4%
  {\vbox{\ialign{##\crcr
   #2#3\crcr
   \noalign{\kern#1\nointerlineskip}
   $\m@th\hfil#3#4\hfil$\crcr}}}

\protect

\definemathoverarrow  [overleftarrow]       [\leftarrowfill]
\definemathoverarrow  [overrightarrow]      [\rightarrowfill]
\definemathoverarrow  [overleftrightarrow]  [\leftrightarrowfill]


$\overleftarrow{A}$ $\overleftarrow{ABC}$
$a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$

$\overleftrightarrow{A}$ $\overleftrightarrow{ABC}$

$a_{\overleftrightarrow{A}}$ $b_{\overleftrightarrow{ABC}}$


As an added bonus:

\definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
\definemathoverarrow [overtwoheadleftarrow]       [\twoheadleftarrowfill]
\definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
\definemathoverarrow [overrightharpoonup]         [\rightharpoonupfill]
\definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
\definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]

$\overtwoheadrightarrow  {XYZ}$
$\overtwoheadleftarrow   {XYZ}$
$\overrightharpoondown   {XYZ}$
$\overrightharpoonup     {XYZ}$
$\overleftharpoondown    {XYZ}$
$\overleftharpoonup      {XYZ}$

There are also underarrows, which will not be too hard to do. I will 
patch math-ext with both overarrows and underarrows. I think that 
there needs to be some "italic correction" for the arrow. It is 
centered on the math box, but the math box is tilted to the right. Any 
way to determine the "correct" horizontal skip that should be added.

Mojca, I remember that you had some trouble with overharpoons. Does 
this take care of that?

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-06-29  3:31 ` \overleftrightarrow Aditya Mahajan
@ 2007-06-30  8:47   ` Mojca Miklavec
  2007-07-01 16:29     ` \overleftrightarrow Hans Hagen
  2007-07-19  7:01     ` \overleftrightarrow Aditya Mahajan
  2007-07-11 18:33   ` \overleftrightarrow Jesse Alama
  1 sibling, 2 replies; 9+ messages in thread
From: Mojca Miklavec @ 2007-06-30  8:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 6/29/07, Aditya Mahajan wrote:
> Actually just adding overleftrightarrow is easy, but better will be an
> interface to easily define such commands. So ....
>
> > If not, what can I do so that I can use it?
>
> ConTeXt uses overleftarrow and overrightarrow as defined in plain
> tex. This does not work in subscripts.
>
> $\overleftarrow{A}$ $\overleftarrow{ABC}$
> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>
> Here is a solution. First we patch math-ext so that arrowfills take a
> style.

/.../

Wow! Aditya, thanks a lot! I didn't do any extensive testing, but the
functionality should really end up in the core (including the added
bonus if possible ;).

> As an added bonus:
>
> \definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
> \definemathoverarrow [overtwoheadleftarrow]       [\twoheadleftarrowfill]
> \definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
> \definemathoverarrow [overrightharpoonup]         [\rightharpoonupfill]
> \definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
> \definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]
>
> $\overtwoheadrightarrow  {XYZ}$
> $\overtwoheadleftarrow   {XYZ}$
> $\overrightharpoondown   {XYZ}$
> $\overrightharpoonup     {XYZ}$
> $\overleftharpoondown    {XYZ}$
> $\overleftharpoonup      {XYZ}$
>
> There are also underarrows, which will not be too hard to do. I will
> patch math-ext with both overarrows and underarrows. I think that
> there needs to be some "italic correction" for the arrow. It is
> centered on the math box, but the math box is tilted to the right. Any
> way to determine the "correct" horizontal skip that should be added.
>
> Mojca, I remember that you had some trouble with overharpoons. Does
> this take care of that?

\vec is not good for two reasons:

a) often stretchable arrows are needed (vectors both over single
letters and things like {AB} are mixed, and \vec looks really weird in
cases where letters are longer, or when we have combinations of them)

b) vectors should be harpoons (not arrows) according to our conventions.


My old \overrightharpoonup definitions had two other problems:

c) scalability/interfering with style change: you solved exactly that
one in a really nice way - thanks a lot (I did patch it, but it looked
like really ugly code)

d) glyphs themselves and their size (probably only the Polish guys can
help here) - and that's the real problem at the moment

Consider
\def\myvec#1{\overrightharpoonup{#1}}
$(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$,
$\myvec{\sigma}$, $\myvec{r}$, ...
The base size on top of i, j, k, ... is just too long and the harpoon
is also slightly too big.

----

But to sum up: I really like your patch, and I vote for its inclusion.
(The most annoying problem is stil open though.)

Thanks a lot,
     Mojca
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-06-30  8:47   ` \overleftrightarrow Mojca Miklavec
@ 2007-07-01 16:29     ` Hans Hagen
  2007-07-19  7:01     ` \overleftrightarrow Aditya Mahajan
  1 sibling, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2007-07-01 16:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Mojca Miklavec wrote:

> But to sum up: I really like your patch, and I vote for its inclusion.
> (The most annoying problem is stil open though.)

don't worry, since Aditya is now mostly responsible for the math stuff 
in context, the patches will be integrated when he thinks they're ok, 
unless of course this was a personal patch for you -)


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
-----------------------------------------------------------------
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-06-29  3:31 ` \overleftrightarrow Aditya Mahajan
  2007-06-30  8:47   ` \overleftrightarrow Mojca Miklavec
@ 2007-07-11 18:33   ` Jesse Alama
  2007-07-11 18:42     ` \overleftrightarrow Aditya Mahajan
  1 sibling, 1 reply; 9+ messages in thread
From: Jesse Alama @ 2007-07-11 18:33 UTC (permalink / raw)
  To: ntg-context

Hi Aditya,

Aditya Mahajan <adityam@umich.edu> writes:

> On Thu, 28 Jun 2007, Jesse Alama wrote:
>
>> I'm preparing a geometry course using ConTeXt and am impressed with the
>> system so far.  One thing I need is to do is typeset various geometrical
>> symbols.  It looks like ConTeXt already has the \overleftarrow and
>> \overrightarrow commands, but one thing I'd like to have is
>> \overleftrightarrow, for typesetting the symbol customarily used to
>> denote the line determined by two points.  It seems, though, that this
>> isn't available in ConTeXt, or, at least, it is not available by
>> default.  I tried looking on the contextgarden and google, but didn't
>> come across anything.  Is the \overleftrightarrow command already
>> available?
>
> Actually just adding overleftrightarrow is easy, but better will be an 
> interface to easily define such commands. So ....
>
>> If not, what can I do so that I can use it?
>
> ConTeXt uses overleftarrow and overrightarrow as defined in plain 
> tex. This does not work in subscripts.
>
> $\overleftarrow{A}$ $\overleftarrow{ABC}$
> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>
> Here is a solution. First we patch math-ext so that arrowfills take a 
> style.
>
> \unprotect
>
> \def\mtharrowfill#1#2#3#4#5#6#7#8% AM: Added #8 (for displaystyle)
>   {$\mathsurround 0pt
>     \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
>     \relax#8#5%
>     \mkern-#1mu
>     \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
>     \mkern-#4mu#7$}
>
> %D Now we need to make sure that the extensible arrows do not get 
> %D affected. So...
>
> \def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
>   {\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=\thirdoffourarguments  #2mu
>    \muskip2=\fourthoffourarguments #2mu
>    \muskip4=\firstoffourarguments  #2mu
>    \muskip6=\secondoffourarguments #2mu
>    \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
>    \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
>    \setbox0\hbox{$\scriptstyle
>                   \mkern\muskip4\relax
>                   \mkern\muskip0\relax
>                   #5\relax
>                   \mkern\muskip2\relax
>                   \mkern\muskip6\relax
>                  $}%
>    \setbox4\hbox{#3\displaystyle}% AM: Added displaystyle
>    \dimen0\wd0
>    \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
>    \setbox2\hbox{$\scriptstyle
>                   \mkern\muskip4\relax
>                   \mkern\muskip0\relax
>                   #4\relax
>                   \mkern\muskip2\relax
>                   \mkern\muskip6\relax
>                  $}%
>    \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
>    \setbox4\hbox to \dimen0{#3\displaystyle}% AM: added dislaystyle
>    \mathrel{\mathop{\hbox to 
> \dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
>    \endgroup}
>
> \let\domthxarrsingle\domthxarr
>
> %D Now, for defining overarrows.
>
> \def\definemathoverarrow
>   {\dotripleargument\dodefinemathoverarrow}
>
> \def\dodefinemathoverarrow[#1][#2][#3]%
>   {\ifthirdargument
>     \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
>    \else
>     \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
>    \fi}
>
> \def\dohandlemathoverarrow[#1][#2]%
>   {\mathpalette{\dodohanglemathoverarrow{#1}{#2}}}
>
> % Note: math-pln has \kern-\onepoint, amsmath does not. I keep the
> % kern amount as an option. This is useful with overharpoons.
>
>
> \def\dodohanglemathoverarrow#1#2#3#4%
>   {\vbox{\ialign{##\crcr
>    #2#3\crcr
>    \noalign{\kern#1\nointerlineskip}
>    $\m@th\hfil#3#4\hfil$\crcr}}}
>
> \protect
>
> \definemathoverarrow  [overleftarrow]       [\leftarrowfill]
> \definemathoverarrow  [overrightarrow]      [\rightarrowfill]
> \definemathoverarrow  [overleftrightarrow]  [\leftrightarrowfill]
>
>
> $\overleftarrow{A}$ $\overleftarrow{ABC}$
> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>
> $\overleftrightarrow{A}$ $\overleftrightarrow{ABC}$
>
> $a_{\overleftrightarrow{A}}$ $b_{\overleftrightarrow{ABC}}$
>
>
> As an added bonus:
>
> \definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
> \definemathoverarrow [overtwoheadleftarrow]       [\twoheadleftarrowfill]
> \definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
> \definemathoverarrow [overrightharpoonup]         [\rightharpoonupfill]
> \definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
> \definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]
>
> $\overtwoheadrightarrow  {XYZ}$
> $\overtwoheadleftarrow   {XYZ}$
> $\overrightharpoondown   {XYZ}$
> $\overrightharpoonup     {XYZ}$
> $\overleftharpoondown    {XYZ}$
> $\overleftharpoonup      {XYZ}$
>
> There are also underarrows, which will not be too hard to do. I will 
> patch math-ext with both overarrows and underarrows. I think that 
> there needs to be some "italic correction" for the arrow. It is 
> centered on the math box, but the math box is tilted to the right. Any 
> way to determine the "correct" horizontal skip that should be added.

Have your changes been integrated into the ConTeXt code base yet?  If
not, how can I use your code?  Is it enough to just include the relevant
parts in my project's environment file?

Thanks,

Jesse

-- 
Jesse Alama (alama@stanford.edu)
*60: Something remains to be proved in this case

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-07-11 18:33   ` \overleftrightarrow Jesse Alama
@ 2007-07-11 18:42     ` Aditya Mahajan
  2007-07-11 18:57       ` \overleftrightarrow Jesse Alama
  0 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2007-07-11 18:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, 11 Jul 2007, Jesse Alama wrote:

> Hi Aditya,
>
> Aditya Mahajan <adityam@umich.edu> writes:
>
>> On Thu, 28 Jun 2007, Jesse Alama wrote:
>>
>>> I'm preparing a geometry course using ConTeXt and am impressed with the
>>> system so far.  One thing I need is to do is typeset various geometrical
>>> symbols.  It looks like ConTeXt already has the \overleftarrow and
>>> \overrightarrow commands, but one thing I'd like to have is
>>> \overleftrightarrow, for typesetting the symbol customarily used to
>>> denote the line determined by two points.  It seems, though, that this
>>> isn't available in ConTeXt, or, at least, it is not available by
>>> default.  I tried looking on the contextgarden and google, but didn't
>>> come across anything.  Is the \overleftrightarrow command already
>>> available?
>>
>> Actually just adding overleftrightarrow is easy, but better will be an
>> interface to easily define such commands. So ....
>>
>>> If not, what can I do so that I can use it?
>>
>> ConTeXt uses overleftarrow and overrightarrow as defined in plain
>> tex. This does not work in subscripts.
>>
>> $\overleftarrow{A}$ $\overleftarrow{ABC}$
>> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>>
>> Here is a solution. First we patch math-ext so that arrowfills take a
>> style.

              Cut Here
------------------%< ----------------------------

>> \unprotect
>>
>> \def\mtharrowfill#1#2#3#4#5#6#7#8% AM: Added #8 (for displaystyle)
>>   {$\mathsurround 0pt
>>     \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
>>     \relax#8#5%
>>     \mkern-#1mu
>>     \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
>>     \mkern-#4mu#7$}
>>
>> %D Now we need to make sure that the extensible arrows do not get
>> %D affected. So...
>>
>> \def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
>>   {\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=\thirdoffourarguments  #2mu
>>    \muskip2=\fourthoffourarguments #2mu
>>    \muskip4=\firstoffourarguments  #2mu
>>    \muskip6=\secondoffourarguments #2mu
>>    \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
>>    \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
>>    \setbox0\hbox{$\scriptstyle
>>                   \mkern\muskip4\relax
>>                   \mkern\muskip0\relax
>>                   #5\relax
>>                   \mkern\muskip2\relax
>>                   \mkern\muskip6\relax
>>                  $}%
>>    \setbox4\hbox{#3\displaystyle}% AM: Added displaystyle
>>    \dimen0\wd0
>>    \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
>>    \setbox2\hbox{$\scriptstyle
>>                   \mkern\muskip4\relax
>>                   \mkern\muskip0\relax
>>                   #4\relax
>>                   \mkern\muskip2\relax
>>                   \mkern\muskip6\relax
>>                  $}%
>>    \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
>>    \setbox4\hbox to \dimen0{#3\displaystyle}% AM: added dislaystyle
>>    \mathrel{\mathop{\hbox to
>> \dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
>>    \endgroup}
>>
>> \let\domthxarrsingle\domthxarr
>>
>> %D Now, for defining overarrows.
>>
>> \def\definemathoverarrow
>>   {\dotripleargument\dodefinemathoverarrow}
>>
>> \def\dodefinemathoverarrow[#1][#2][#3]%
>>   {\ifthirdargument
>>     \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
>>    \else
>>     \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
>>    \fi}
>>
>> \def\dohandlemathoverarrow[#1][#2]%
>>   {\mathpalette{\dodohanglemathoverarrow{#1}{#2}}}
>>
>> % Note: math-pln has \kern-\onepoint, amsmath does not. I keep the
>> % kern amount as an option. This is useful with overharpoons.
>>
>>
>> \def\dodohanglemathoverarrow#1#2#3#4%
>>   {\vbox{\ialign{##\crcr
>>    #2#3\crcr
>>    \noalign{\kern#1\nointerlineskip}
>>    $\m@th\hfil#3#4\hfil$\crcr}}}
>>
>> \protect
>>
>> \definemathoverarrow  [overleftarrow]       [\leftarrowfill]
>> \definemathoverarrow  [overrightarrow]      [\rightarrowfill]
>> \definemathoverarrow  [overleftrightarrow]  [\leftrightarrowfill]
>>

------------------------------%<-----------------------------------------
                 To Here

>> $\overleftarrow{A}$ $\overleftarrow{ABC}$
>> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>>
>> $\overleftrightarrow{A}$ $\overleftrightarrow{ABC}$
>>
>> $a_{\overleftrightarrow{A}}$ $b_{\overleftrightarrow{ABC}}$
>>
>>
>> As an added bonus:
>>
>> \definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
>> \definemathoverarrow [overtwoheadleftarrow]       [\twoheadleftarrowfill]
>> \definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
>> \definemathoverarrow [overrightharpoonup]         [\rightharpoonupfill]
>> \definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
>> \definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]
>>
>> $\overtwoheadrightarrow  {XYZ}$
>> $\overtwoheadleftarrow   {XYZ}$
>> $\overrightharpoondown   {XYZ}$
>> $\overrightharpoonup     {XYZ}$
>> $\overleftharpoondown    {XYZ}$
>> $\overleftharpoonup      {XYZ}$
>>
>> There are also underarrows, which will not be too hard to do. I will
>> patch math-ext with both overarrows and underarrows. I think that
>> there needs to be some "italic correction" for the arrow. It is
>> centered on the math box, but the math box is tilted to the right. Any
>> way to determine the "correct" horizontal skip that should be added.
>
> Have your changes been integrated into the ConTeXt code base yet?  If
> not, how can I use your code?  Is it enough to just include the relevant
> parts in my project's environment file?

Hi Jesse,

They have not been integrated into context yet. While changing one of 
the core macros, one needs to test that it does not break existing 
documents. I have been busy for the last two weeks and have not been 
able to do that.

In order to use these macro right now, cut between the two lines above 
(you will need to remove the quotes, or cut from the previous message) 
and put them in your environment file. Then you can use 
\overrightarrow in your documents.

I will send an updated math-ext in about a week.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-07-11 18:42     ` \overleftrightarrow Aditya Mahajan
@ 2007-07-11 18:57       ` Jesse Alama
  0 siblings, 0 replies; 9+ messages in thread
From: Jesse Alama @ 2007-07-11 18:57 UTC (permalink / raw)
  To: ntg-context

Aditya Mahajan <adityam@umich.edu> writes:

> On Wed, 11 Jul 2007, Jesse Alama wrote:
>
>> Hi Aditya,
>>
>> Aditya Mahajan <adityam@umich.edu> writes:
>>
>>> On Thu, 28 Jun 2007, Jesse Alama wrote:
>>>
>>>> I'm preparing a geometry course using ConTeXt and am impressed with the
>>>> system so far.  One thing I need is to do is typeset various geometrical
>>>> symbols.  It looks like ConTeXt already has the \overleftarrow and
>>>> \overrightarrow commands, but one thing I'd like to have is
>>>> \overleftrightarrow, for typesetting the symbol customarily used to
>>>> denote the line determined by two points.  It seems, though, that this
>>>> isn't available in ConTeXt, or, at least, it is not available by
>>>> default.  I tried looking on the contextgarden and google, but didn't
>>>> come across anything.  Is the \overleftrightarrow command already
>>>> available?
>>>
>>> Actually just adding overleftrightarrow is easy, but better will be an
>>> interface to easily define such commands. So ....
>>>
>>>> If not, what can I do so that I can use it?
>>>
>>> ConTeXt uses overleftarrow and overrightarrow as defined in plain
>>> tex. This does not work in subscripts.
>>>
>>> $\overleftarrow{A}$ $\overleftarrow{ABC}$
>>> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>>>
>>> Here is a solution. First we patch math-ext so that arrowfills take a
>>> style.
>
>               Cut Here
> ------------------%< ----------------------------
>
>>> \unprotect
>>>
>>> \def\mtharrowfill#1#2#3#4#5#6#7#8% AM: Added #8 (for displaystyle)
>>>   {$\mathsurround 0pt
>>>     \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
>>>     \relax#8#5%
>>>     \mkern-#1mu
>>>     \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
>>>     \mkern-#4mu#7$}
>>>
>>> %D Now we need to make sure that the extensible arrows do not get
>>> %D affected. So...
>>>
>>> \def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
>>>   {\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=\thirdoffourarguments  #2mu
>>>    \muskip2=\fourthoffourarguments #2mu
>>>    \muskip4=\firstoffourarguments  #2mu
>>>    \muskip6=\secondoffourarguments #2mu
>>>    \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
>>>    \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
>>>    \setbox0\hbox{$\scriptstyle
>>>                   \mkern\muskip4\relax
>>>                   \mkern\muskip0\relax
>>>                   #5\relax
>>>                   \mkern\muskip2\relax
>>>                   \mkern\muskip6\relax
>>>                  $}%
>>>    \setbox4\hbox{#3\displaystyle}% AM: Added displaystyle
>>>    \dimen0\wd0
>>>    \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
>>>    \setbox2\hbox{$\scriptstyle
>>>                   \mkern\muskip4\relax
>>>                   \mkern\muskip0\relax
>>>                   #4\relax
>>>                   \mkern\muskip2\relax
>>>                   \mkern\muskip6\relax
>>>                  $}%
>>>    \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
>>>    \setbox4\hbox to \dimen0{#3\displaystyle}% AM: added dislaystyle
>>>    \mathrel{\mathop{\hbox to
>>> \dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
>>>    \endgroup}
>>>
>>> \let\domthxarrsingle\domthxarr
>>>
>>> %D Now, for defining overarrows.
>>>
>>> \def\definemathoverarrow
>>>   {\dotripleargument\dodefinemathoverarrow}
>>>
>>> \def\dodefinemathoverarrow[#1][#2][#3]%
>>>   {\ifthirdargument
>>>     \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
>>>    \else
>>>     \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
>>>    \fi}
>>>
>>> \def\dohandlemathoverarrow[#1][#2]%
>>>   {\mathpalette{\dodohanglemathoverarrow{#1}{#2}}}
>>>
>>> % Note: math-pln has \kern-\onepoint, amsmath does not. I keep the
>>> % kern amount as an option. This is useful with overharpoons.
>>>
>>>
>>> \def\dodohanglemathoverarrow#1#2#3#4%
>>>   {\vbox{\ialign{##\crcr
>>>    #2#3\crcr
>>>    \noalign{\kern#1\nointerlineskip}
>>>    $\m@th\hfil#3#4\hfil$\crcr}}}
>>>
>>> \protect
>>>
>>> \definemathoverarrow  [overleftarrow]       [\leftarrowfill]
>>> \definemathoverarrow  [overrightarrow]      [\rightarrowfill]
>>> \definemathoverarrow  [overleftrightarrow]  [\leftrightarrowfill]
>>>
>
> ------------------------------%<-----------------------------------------
>                  To Here
>
>>> $\overleftarrow{A}$ $\overleftarrow{ABC}$
>>> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>>>
>>> $\overleftrightarrow{A}$ $\overleftrightarrow{ABC}$
>>>
>>> $a_{\overleftrightarrow{A}}$ $b_{\overleftrightarrow{ABC}}$
>>>
>>>
>>> As an added bonus:
>>>
>>> \definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
>>> \definemathoverarrow [overtwoheadleftarrow]       [\twoheadleftarrowfill]
>>> \definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
>>> \definemathoverarrow [overrightharpoonup]         [\rightharpoonupfill]
>>> \definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
>>> \definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]
>>>
>>> $\overtwoheadrightarrow  {XYZ}$
>>> $\overtwoheadleftarrow   {XYZ}$
>>> $\overrightharpoondown   {XYZ}$
>>> $\overrightharpoonup     {XYZ}$
>>> $\overleftharpoondown    {XYZ}$
>>> $\overleftharpoonup      {XYZ}$
>>>
>>> There are also underarrows, which will not be too hard to do. I will
>>> patch math-ext with both overarrows and underarrows. I think that
>>> there needs to be some "italic correction" for the arrow. It is
>>> centered on the math box, but the math box is tilted to the right. Any
>>> way to determine the "correct" horizontal skip that should be added.
>>
>> Have your changes been integrated into the ConTeXt code base yet?  If
>> not, how can I use your code?  Is it enough to just include the relevant
>> parts in my project's environment file?
>
> Hi Jesse,
>
> They have not been integrated into context yet. While changing one of 
> the core macros, one needs to test that it does not break existing 
> documents. I have been busy for the last two weeks and have not been 
> able to do that.
>
> In order to use these macro right now, cut between the two lines above 
> (you will need to remove the quotes, or cut from the previous message) 
> and put them in your environment file. Then you can use 
> \overrightarrow in your documents.
>
> I will send an updated math-ext in about a week.

Your suggestion worked out just fine -- thanks!

Jesse

-- 
Jesse Alama (alama@stanford.edu)
*60: Something remains to be proved in this case

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: \overleftrightarrow
  2007-06-30  8:47   ` \overleftrightarrow Mojca Miklavec
  2007-07-01 16:29     ` \overleftrightarrow Hans Hagen
@ 2007-07-19  7:01     ` Aditya Mahajan
  2007-07-19 15:42       ` overleftrightarrow Aditya Mahajan
  1 sibling, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2007-07-19  7:01 UTC (permalink / raw)
  To: Mojca Miklavec; +Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3637 bytes --]

On Sat, 30 Jun 2007, Mojca Miklavec wrote:

> On 6/29/07, Aditya Mahajan wrote:
>> Actually just adding overleftrightarrow is easy, but better will be an
>> interface to easily define such commands. So ....
>> 
>> > If not, what can I do so that I can use it?
>> 
>> ConTeXt uses overleftarrow and overrightarrow as defined in plain
>> tex. This does not work in subscripts.
>> 
>> $\overleftarrow{A}$ $\overleftarrow{ABC}$
>> $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
>> 
>> Here is a solution. First we patch math-ext so that arrowfills take a
>> style.
>>
>> There are also underarrows, which will not be too hard to do. I will
>> patch math-ext with both overarrows and underarrows. I think that
>> there needs to be some "italic correction" for the arrow. It is
>> centered on the math box, but the math box is tilted to the right. Any
>> way to determine the "correct" horizontal skip that should be added.

I am attaching an updated math-ext.tex that defines over and under 
arrows. To use it, copy it to your current directory and add \input 
math-ext somewhere in your environment file.

Hans, this file also contains some minor typo corrections in the 
earlier documentation. I have also changed the text width for comments 
to 70, as 80 characters do not look nice on contextgarden.


>> Mojca, I remember that you had some trouble with overharpoons. Does
>> this take care of that?
>
> \vec is not good for two reasons:
>
> a) often stretchable arrows are needed (vectors both over single
> letters and things like {AB} are mixed, and \vec looks really weird in
> cases where letters are longer, or when we have combinations of them)
>
> b) vectors should be harpoons (not arrows) according to our conventions.
>
>
> My old \overrightharpoonup definitions had two other problems:
>
> c) scalability/interfering with style change: you solved exactly that
> one in a really nice way - thanks a lot (I did patch it, but it looked
> like really ugly code)
>
> d) glyphs themselves and their size (probably only the Polish guys can
> help here) - and that's the real problem at the moment

Long ago, for some other problem, Taco had suggested that it will be 
nice to have just the arrow heads. Then we could stack them the way we 
want. IIRC, this is what the cow font does. If nothing else works, you 
can try the cow font for writing math. I think that it matches nicely 
with iwona-heavy :)

> Consider
> \def\myvec#1{\overrightharpoonup{#1}}
> $(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$,
> $\myvec{\sigma}$, $\myvec{r}$, ...
> The base size on top of i, j, k, ... is just too long and the harpoon
> is also slightly too big.

A realy realy ugly solution (if you do not want extensible arrows).

\def\definemathshortarrow
   {\dotripleargument\dodefinemathshortarrow}

\def\dodefinemathshortarrow[#1][#2][#3]%
   {\ifthirdargument
       \setvalue{#1}{\dohandlemathshortarrow[#2][#3]}%
     \else
       \setvalue{#1}{\dohandlemathshortarrow[\zeropoint][#2]}%
     \fi}

\def\dohandlemathshortarrow[#1][#2]%
   {\mathpalette{\dodohandlemathshortarrow{#1}{#2}}}

\def\dodohandlemathshortarrow#1#2#3#4%
   {\setbox0\hbox{$\m@th#3#4$}%
    \vbox{\ialign{##\crcr
    \mirror{\clip[width=\wd0]{\mirror{$\m@th#2#3$}}}\crcr
    \noalign{\kern#1\nointerlineskip}%
    $\m@th\hfil#3#4\hfil$\crcr}}}

\definemathshortarrow  [shortoverrightharpoonup]
                        [\rightharpoonup]


\let\myvec\shortoverrightharpoonup


I do not like mirror->clip->mirror but I could not find how to clip 
from the left rather than the right.

I guess now is the time to update the myway on math arrows :)

Aditya

[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 16883 bytes --]

%D \module
%D   [       file=math-ext,
%D        version=2007.07.19,
%D          title=\CONTEXT\ Math Macros,
%D       subtitle=Extra Macros,
%D         author={Hans Hagen \& Taco Hoekwater \& Aditya Mahajan},
%D           date=\currentdate,
%D      copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
%M \input math-ext

\unprotect

%D These will be generalized!

\def\exmthfont#1{\symbolicsizedfont#1\plusone{MathExtension}}

\def\domthfrac#1#2#3#4#5#6#7%
  {\begingroup
   \mathsurround\zeropoint
   \setbox0\hbox{$#1 #6$}%
   \setbox2\hbox{$#1 #7$}%
   \dimen0\wd0
   \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
   \setbox4\hbox to \dimen0{\exmthfont#2#3\leaders\hbox{#4}\hss#5}%
   \mathord{\vcenter{{\offinterlineskip
     \hbox to \dimen0{\hss\box0\hss}%
     \kern \ht4%
     \hbox to \dimen0{\hss\copy4\hss}%
     \kern \ht4%
     \hbox to \dimen0{\hss\box2\hss}}}}%
   \endgroup}

\def\domthsqrt#1#2#3#4#5%
  {\begingroup
   \mathsurround\zeropoint
   \setbox0\hbox{$#1 #5$}%
   \dimen0=1.05\ht0 \advance\dimen0 1pt  \ht0 \dimen0
   \dimen0=1.05\dp0 \advance\dimen0 1pt  \dp0 \dimen0
   \dimen0\wd0
   \setbox4\hbox to \dimen0{\exmthfont#2\leaders\hbox{#3}\hfill#4}%
   \delimitershortfall=0pt
   \nulldelimiterspace=0pt
   \setbox2\hbox{$\left\delimiter"0270370 \vrule height\ht0 depth \dp0 width0pt
                  \right.$}%
   \mathord{\vcenter{\hbox{\copy2
                           \rlap{\raise\dimexpr\ht2-\ht4\relax\copy4}\copy0}}}%
   \endgroup}

\def\mthfrac#1#2#3#4#5{\mathchoice
  {\domthfrac\displaystyle     \textface        {#1}{#2}{#3}{#4}{#5}}
  {\domthfrac\textstyle        \textface        {#1}{#2}{#3}{#4}{#5}}
  {\domthfrac\scriptstyle      \scriptface      {#1}{#2}{#3}{#4}{#5}}
  {\domthfrac\scriptscriptstyle\scriptscriptface{#1}{#2}{#3}{#4}{#5}}}

\def\mthsqrt#1#2#3{\mathchoice
  {\domthsqrt\displaystyle     \textface    {#1}{#2}{#3}}
  {\domthsqrt\textstyle        \textface    {#1}{#2}{#3}}
  {\domthsqrt\scriptstyle      \textface    {#1}{#2}{#3}}
  {\domthsqrt\scriptscriptstyle\textface    {#1}{#2}{#3}}}

% temp here

%D We next define extensible arrows. Extensible arrows are arrows that
%D change their length according to the width of the text to be placed
%D above and below the arrow. Since we need to define a lot of arrows,
%D we first define some helper macros. The basic idea is to measure
%D the width of the box to be placed above and below the arrow, and
%D make the \quotation{body} of the arrow as long as the bigger of the
%D two widths.

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

\def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
  {\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=\thirdoffourarguments  #2mu
   \muskip2=\fourthoffourarguments #2mu
   \muskip4=\firstoffourarguments  #2mu
   \muskip6=\secondoffourarguments #2mu
   \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
   \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
   \setbox0\hbox{$\scriptstyle
                  \mkern\muskip4\relax
                  \mkern\muskip0\relax
                  #5\relax
                  \mkern\muskip2\relax
                  \mkern\muskip6\relax
                 $}%
   \setbox4\hbox{#3\displaystyle}%
   \dimen0\wd0
   \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
   \setbox2\hbox{$\scriptstyle
                  \mkern\muskip4\relax
                  \mkern\muskip0\relax
                  #4\relax
                  \mkern\muskip2\relax
                  \mkern\muskip6\relax
                 $}%
   \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
   \setbox4\hbox to \dimen0{#3\displaystyle}%
   \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
   \endgroup}

\let\domthxarrsingle\domthxarr

%D There are some arrows which are created by stacking two arrows. The next
%D macro helps in defining such \quotation{double arrows}.

\def\domthxarrdouble#1#2#3#4#5#6#7% opt l r sp rs top bot
  {\mathrel
     {\scratchdimen.22ex\relax
      \setbox0\hbox{$\domthxarr{#1}{#2}{#4}{\phantom{#6}}{#7}$}%
      \setbox2\hbox{$\domthxarr{#1}{#3}{#5}{#6}{\phantom{#7}}$}%
      \raise\scratchdimen\box0
      \kern-\wd2
      \lower\scratchdimen\box2}}

%D \macros{definematharrow}
%D
%D Macro for defining new arrows. We can define two types of
%D arrows|<|single arrows and double arrows. Single arrows are defined
%D as
%D \starttyping
%D \definematharrow [xrightarrow]        [0359] [\rightarrowfill]
%D \stoptyping
%D The first argument is the name of the arrow (\tex{xrightarrow} in
%D this case.) The second argument consists of a set of 4 numbers and
%D specify the spacing correction in math units~\type{mu}. These
%D numbers define:
%D \startlines
%D   1st number: arrow||tip correction
%D   2nd number: arrow||tip correction
%D   3rd number: space (multiplied by \tex{matharrfactor} and advanced by \tex{matharrextra})
%D   4th number: space (multiplied by \tex{matharrfactor} and advanced by \tex{matharrextra})
%D \stoplines
%D 
%D The third argument is the name of the extensible fill. The third
%D argument is optional when the arrow is redefined later (this is
%D useful for font specific tweaking of the skips.) For example,
%D \startbuffer
%D \math{\xrightarrow{above}}
%D \definematharrow[xrightarrow][0000]
%D \math{\xrightarrow{above}}
%D \definematharrow[xrightarrow][55{50}{50}]
%D \math{\xrightarrow{above}}
%D \stopbuffer
%D \typebuffer gives {\getbuffer}
%D
%D The double arrows are defined as follows
%D \starttyping
%D \definematharrow [xrightleftharpoons] [3095,0359] 
%D                  [\rightharpoonupfill,\leftharpoondownfill]
%D \stoptyping
%D The second and the third set of arguments consist of comma
%D separated values. The first element of the second argument
%D (\type{3095}) corresponds to the spacing correction of top arrow
%D fill (\tex{rightarrowupfill}).  Similarly, \type{0359} corresponds
%D to bottom arrow fill \tex{leftharpoondownfill}). Stacking them on
%D top of each other we get $\xrightleftharpoons[big]{above}{below}$.
%D The following math arrows are defined
%D \midaligned{\starttable[|l|m|]
%D   \NC \tex{xrightarrow        }  \NC \xrightarrow        [big]  \NC \NR
%D   \NC \tex{xleftarrow         }  \NC \xleftarrow         [big]  \NC \NR
%D   \NC \tex{xequal             }  \NC \xequal             [big]  \NC \NR
%D   \NC \tex{xRightarrow        }  \NC \xRightarrow        [big]  \NC \NR
%D   \NC \tex{xLeftarrow         }  \NC \xLeftarrow         [big]  \NC \NR
%D   \NC \tex{xLeftrightarrow    }  \NC \xLeftrightarrow    [big]  \NC \NR
%D   \NC \tex{xleftrightarrow    }  \NC \xleftrightarrow    [big]  \NC \NR
%D   \NC \tex{xmapsto            }  \NC \xmapsto            [big]  \NC \NR
%D   \NC \tex{xtwoheadrightarrow }  \NC \xtwoheadrightarrow [big]  \NC \NR
%D   \NC \tex{xtwoheadleftarrow  }  \NC \xtwoheadleftarrow  [big]  \NC \NR
%D   \NC \tex{xrightharpoondown  }  \NC \xrightharpoondown  [big]  \NC \NR
%D   \NC \tex{xrightharpoonup    }  \NC \xrightharpoonup    [big]  \NC \NR
%D   \NC \tex{xleftharpoondown   }  \NC \xleftharpoondown   [big]  \NC \NR
%D   \NC \tex{xleftharpoonup     }  \NC \xleftharpoonup     [big]  \NC \NR
%D   \NC \tex{xhookleftarrow     }  \NC \xhookleftarrow     [big]  \NC \NR
%D   \NC \tex{xhookrightarrow    }  \NC \xhookrightarrow    [big]  \NC \NR
%D   \NC \tex{xleftrightharpoons }  \NC \xleftrightharpoons [big]  \NC \NR
%D   \NC \tex{xrightleftharpoons }  \NC \xrightleftharpoons [big]  \NC \NR
%D \stoptable}

\def\definematharrow
  {\doquadrupleargument\dodefinematharrow}

\def\dodefinematharrow[#1][#2][#3][#4]% name type[none|both] template command
  {\iffourthargument
      \executeifdefined{dodefine#2arrow}\gobblethreearguments{#1}{#3}{#4}%
   \else\ifthirdargument
      \dodefinebotharrow{#1}{#2}{#3}%
   \else\ifsecondargument
      \redefinebotharrow{#1}{#2}{#3}%
   \fi\fi\fi}

\def\redefinebotharrow#1#2#3% real dirty, this overload!
  {\doifdefined{#1}
     {\pushmacro\dohandlemtharrow
      \def\dohandlemtharrow[##1][##2]{\setvalue{#1}{\dohandlemtharrow[#2][##2]}}%
      % == \def\dohandlemtharrow[##1][##2]{\dodefinebotharrow{#1}{#2}{##2}}%
      \getvalue{#1}%
      \popmacro\dohandlemtharrow}}

\def\dodefinebotharrow#1#2#3%
  {\setvalue{#1}{\dohandlemtharrow[#2][#3]}}

\def\dohandlemtharrow
  {\dotripleempty\doxmtharrow}

\def\doxmtharrow[#1][#2][#3]% #3 == optional arg
  {\def\dodoxmtharrow{\dododoxmtharrow[#1,\empty,\empty][#2,\empty,\empty][#3]}% {##1}{##2}
   \dodoublegroupempty\dodoxmtharrow}

\def\dododoxmtharrow[#1,#2,#3][#4,#5,#6][#7]#8#9% [3] is the optional arg
  {\edef\!!stringa{#2}%
   \ifx\!!stringa\empty
     \ifsecondargument
       \mathrel{\domthxarrsingle{#7}{#1}{#4}{#8}{#9}}%
     \else
       \mathrel{\domthxarrsingle{#7}{#1}{#4}{}{#8}}%
     \fi
   \else
     \ifsecondargument
       \mathrel{\domthxarrdouble{#7}{#1}{#2}{#4}{#5}{#8}{#9}}%
     \else
       \mathrel{\domthxarrdouble{#7}{#1}{#2}{#4}{#5}{}{#8}}%
     \fi
   \fi}

% Adapted from amsmath.

%D \macros{mtharrowfill,defaultmtharrowfill}
%D
%D To extend the arrows we need to define a \quotation{math arrow
%D fill}. This command takes 7 arguments: the first four correspond
%D the second argument of \tex{definematharrow} explained above. The
%D other three specify the tail, body and head of the arrow.
%D \tex{defaultmtharrowfill} has values tweaked to match latin modern
%D fonts. For fonts that are significantly different (e.g.  cows) a
%D different set of values need to be determined.

\def\mtharrowfill#1#2#3#4#5#6#7#8%
  {$\mathsurround 0pt
    \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
    \relax#8#5%
    \mkern-#1mu
    \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
    \mkern-#4mu#7$}

\def\defaultmtharrowfill{\mtharrowfill 7227}

%D We now define some arrow fills that will be used for defining the
%D arrows. \tex{leftarrowfill} and \tex{rightarrowfill} are redefined
%D using \tex{defaultmtharrowfill}.

\def\rightarrowfill       {\defaultmtharrowfill \relbar              \relbar \rightarrow       }
\def\leftarrowfill        {\defaultmtharrowfill \leftarrow           \relbar \relbar           }
\def\equalfill            {\defaultmtharrowfill \Relbar              \Relbar \Relbar           }
\def\Rightarrowfill       {\defaultmtharrowfill \Relbar              \Relbar \Rightarrow       }
\def\Leftarrowfill        {\defaultmtharrowfill \Leftarrow           \Relbar \Relbar           }
\def\Leftrightarrowfill   {\defaultmtharrowfill \Leftarrow           \Relbar \Rightarrow       }
\def\leftrightarrowfill   {\defaultmtharrowfill \leftarrow           \relbar \rightarrow       }
\def\mapstofill           {\defaultmtharrowfill {\mapstochar\relbar} \relbar \rightarrow       }
\def\twoheadrightarrowfill{\defaultmtharrowfill \relbar              \relbar \twoheadrightarrow}
\def\twoheadleftarrowfill {\defaultmtharrowfill \twoheadleftarrow    \relbar \relbar           }
\def\rightharpoondownfill {\defaultmtharrowfill \relbar              \relbar \rightharpoondown }
\def\rightharpoonupfill   {\defaultmtharrowfill \relbar              \relbar \rightharpoonup   }
\def\leftharpoondownfill  {\defaultmtharrowfill \leftharpoondown     \relbar \relbar           }
\def\leftharpoonupfill    {\defaultmtharrowfill \leftharpoonup       \relbar \relbar           }

\def\hookleftfill {\defaultmtharrowfill \leftarrow            \relbar{\relbar\joinrel\rhook}}
\def\hookrightfill{\defaultmtharrowfill{\lhook\joinrel\relbar}\relbar \rightarrow}

%D Now we define most commonly used arrows. These include arrows
%D defined in \filename{amsmath.sty}, \filename{extarrows.sty},
%D \filename{extpfel.sty} and \filename{mathtools.sty} packages for
%D \LATEX.

\definematharrow [xrightarrow]        [0359] [\rightarrowfill]
\definematharrow [xleftarrow]         [3095] [\leftarrowfill]
\definematharrow [xequal]             [0099] [\equalfill]
\definematharrow [xRightarrow]        [0359] [\Rightarrowfill]
\definematharrow [xLeftarrow]         [3095] [\Leftarrowfill]
\definematharrow [xLeftrightarrow]    [0099] [\Leftrightarrowfill]
\definematharrow [xleftrightarrow]    [0099] [\leftrightarrowfill]
\definematharrow [xmapsto]            [3599] [\mapstofill]
\definematharrow [xtwoheadrightarrow] [5009] [\twoheadrightarrowfill]
\definematharrow [xtwoheadleftarrow]  [0590] [\twoheadleftarrowfill]
\definematharrow [xrightharpoondown]  [0359] [\rightharpoondownfill]
\definematharrow [xrightharpoonup]    [0359] [\rightharpoonupfill]
\definematharrow [xleftharpoondown]   [3095] [\leftharpoondownfill]
\definematharrow [xleftharpoonup]     [3095] [\leftharpoonupfill]

\definematharrow [xleftrightharpoons] [3399,3399] [\leftharpoonupfill,\rightharpoondownfill]
\definematharrow [xrightleftharpoons] [3399,3399] [\rightharpoonupfill,\leftharpoondownfill]

\definematharrow [xhookleftarrow]  [3095] [\hookleftfill]
\definematharrow [xhookrightarrow] [0395] [\hookrightfill]

%D These arrows can be used as follows:
%D \startbuffer
%D \startformula \xrightarrow{stuff on top}\stopformula
%D \startformula \xrightarrow{}{stuff on top}\stopformula
%D \startformula \xrightarrow{stuff below}{}\stopformula
%D \startformula \xrightarrow{stuff below}{stuff on top}\stopformula
%D
%D \startformula \xleftarrow [none]{stuff below}{stuff on top}\stopformula
%D \startformula \xleftarrow [small]{stuff below}{stuff on top}\stopformula
%D \startformula \xleftarrow [medium]{stuff below}{stuff on top}\stopformula
%D \startformula \xleftarrow [big]{stuff below}{stuff on top}\stopformula
%D \stopbuffer
%D \typebuffer which gives \getbuffer

%D \macros{definemathoverarrow,defineunderarrow}
%D
%D These macros for define math-overarrows are adapted from
%D \filename{amsmath.sty}

\def\definemathoverarrow
  {\dotripleargument\dodefinemathoverarrow}

\def\dodefinemathoverarrow[#1][#2][#3]%
  {\ifthirdargument
      \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
    \else
      \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
    \fi}

\def\dohandlemathoverarrow[#1][#2]%
  {\mathpalette{\dodohandlemathoverarrow{#1}{#2}}}

%D Note: \filename{math-pln.tex} has \type{\kern-\onepoint} and
%D \filename{amsmath.sty} does not. We keep the kern amount
%D configurable. This is useful for harpoons.

\def\dodohandlemathoverarrow#1#2#3#4%
  {\vbox{\ialign{##\crcr
   #2#3\crcr
   \noalign{\kern#1\nointerlineskip}%
   $\m@th\hfil#3#4\hfil$\crcr}}}

%D Now the under arrows

\def\definemathunderarrow
  {\dotripleargument\dodefinemathunderarrow}

%D For underarrows the default kern is 0.3ex

\def\dodefinemathunderarrow[#1][#2][#3]%
  {\ifthirdargument
      \setvalue{#1}{\dohandlemathunderarrow[#2][#3]}%
    \else
      \setvalue{#1}{\dohandlemathunderarrow[0.3ex][#2]}%
    \fi}

\def\dohandlemathunderarrow[#1][#2]%
  {\mathpalette{\dodohandlemathunderarrow{#1}{#2}}}

\def\dodohandlemathunderarrow#1#2#3#4%
  {\vtop{\ialign{##\crcr
   $\m@th\hfil#3#4\hfil$\crcr
   \noalign{\nointerlineskip\kern#1}%
   #2#3\crcr}}}

%D Now we define the arrows

\definemathoverarrow  [overleftarrow]         [\leftarrowfill]
\definemathoverarrow  [overrightarrow]        [\rightarrowfill]
\definemathoverarrow  [overleftrightarrow]    [\leftrightarrowfill]
\definemathoverarrow  [overtwoheadrightarrow] [\twoheadrightarrowfill]
\definemathoverarrow  [overtwoheadleftarrow]  [\twoheadleftarrowfill]
\definemathoverarrow  [overrightharpoondown]  [1pt] [\rightharpoondownfill]
\definemathoverarrow  [overrightharpoonup]    [\rightharpoonupfill]
\definemathoverarrow  [overleftharpoondown]   [1pt] [\leftharpoondownfill]
\definemathoverarrow  [overleftharpoonup]     [\leftharpoonupfill]

\definemathunderarrow [underleftarrow]        [\leftarrowfill]
\definemathunderarrow [underrightarrow]       [\rightarrowfill]
\definemathunderarrow [underleftrightarrow]   [\leftrightarrowfill]
\definemathunderarrow [undertwoheadrightarrow][\twoheadrightarrowfill]
\definemathunderarrow [undertwoheadleftarrow] [\twoheadleftarrowfill]
\definemathunderarrow [underrightharpoondown] [\rightharpoondownfill]
\definemathunderarrow [underrightharpoonup]   [\rightharpoonupfill]
\definemathunderarrow [underleftharpoondown]  [\leftharpoondownfill]
\definemathunderarrow [underleftharpoonup]    [\leftharpoonupfill]

%D These can be used as follows:
%D \startbuffer
%D  $\overleftarrow{A}$ $\overleftarrow{ABC}$
%D  $a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
%D \stopbuffer
%D \typebuffer which gives \getbuffer

%D TODO: Possibly have a single arrow command define all the arrows.


\protect \endinput

[-- Attachment #3: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: overleftrightarrow
  2007-07-19  7:01     ` \overleftrightarrow Aditya Mahajan
@ 2007-07-19 15:42       ` Aditya Mahajan
  0 siblings, 0 replies; 9+ messages in thread
From: Aditya Mahajan @ 2007-07-19 15:42 UTC (permalink / raw)
  To: ntg-context

Quoting Aditya Mahajan <adityam@umich.edu>:

> On Sat, 30 Jun 2007, Mojca Miklavec wrote:

>> Consider
>> \def\myvec#1{\overrightharpoonup{#1}}
>> $(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$,
>> $\myvec{\sigma}$, $\myvec{r}$, ...
>> The base size on top of i, j, k, ... is just too long and the harpoon
>> is also slightly too big.
>
> A realy realy ugly solution (if you do not want extensible arrows).

Here is a slightly better solution; I have tested it only for harpoons, 
and there are no configuration options for other "accents". But it 
works for both short and long objects.

\def\definemathfancyarrow
  {\dotripleargument\dodefinemathfancyarrow}

\def\dodefinemathfancyarrow[#1][#2][#3]% arrow short long
  {\setvalue{#1}{\dohandlemathfancyarrow[#2][#3]}}

\def\dohandlemathfancyarrow[#1][#2]%
  {\mathpalette{\dodohandlemathfancyarrow{#1}{#2}}}

%TODO: The clip operation should be configurable, whether you want to clip
%right or clip left.

\unexpanded\def\dodohandlemathfancyarrow#1#2#3#4% short long style text
  {\setbox0\hbox{$\m@th#3#4$}%
   \setbox2\hbox{$\m@th#1#3$}%
   \vbox{\ialign{##\crcr
   \ifdim\wd0<\wd2
     \mirror{\clip[width=\wd0]{\mirror{$\m@th#1#3$}}}%
   \else
     #2#3%
   \fi\crcr
   \noalign{\kern-\onepoint\nointerlineskip}%
   $\m@th\hfil#3#4\hfil$\crcr}}}

\definemathfancyarrow  [fancyoverrightharpoonup]
                       [\rightharpoonup]
                       [\rightharpoonupfill]


\let\myvec\fancyoverrightharpoonup

\starttext
$\myvec{\imath} \myvec{\jmath} \myvec{ABCD}$
\stoptext

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2007-07-19 15:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-29  0:50 \overleftrightarrow Jesse Alama
2007-06-29  3:31 ` \overleftrightarrow Aditya Mahajan
2007-06-30  8:47   ` \overleftrightarrow Mojca Miklavec
2007-07-01 16:29     ` \overleftrightarrow Hans Hagen
2007-07-19  7:01     ` \overleftrightarrow Aditya Mahajan
2007-07-19 15:42       ` overleftrightarrow Aditya Mahajan
2007-07-11 18:33   ` \overleftrightarrow Jesse Alama
2007-07-11 18:42     ` \overleftrightarrow Aditya Mahajan
2007-07-11 18:57       ` \overleftrightarrow Jesse Alama

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