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
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
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
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 -----------------------------------------------------------------
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
Quoting Aditya Mahajan
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
Hi Aditya,
Aditya Mahajan
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
On Wed, 11 Jul 2007, Jesse Alama wrote:
Hi Aditya,
Aditya Mahajan
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
Aditya Mahajan
On Wed, 11 Jul 2007, Jesse Alama wrote:
Hi Aditya,
Aditya Mahajan
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
participants (4)
-
Aditya Mahajan
-
Hans Hagen
-
Jesse Alama
-
Mojca Miklavec