From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/35391 Path: news.gmane.org!not-for-mail From: Jesse Alama Newsgroups: gmane.comp.tex.context Subject: Re: \overleftrightarrow Date: Wed, 11 Jul 2007 11:33:00 -0700 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1184178816 26998 80.91.229.12 (11 Jul 2007 18:33:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Jul 2007 18:33:36 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Wed Jul 11 20:33:33 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1I8h0H-00047P-5l for gctc-ntg-context-518@m.gmane.org; Wed, 11 Jul 2007 20:33:33 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id B91762021E; Wed, 11 Jul 2007 20:33:31 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25804-02; Wed, 11 Jul 2007 20:33:22 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2AC4820202; Wed, 11 Jul 2007 20:33:22 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 3F3F920202 for ; Wed, 11 Jul 2007 20:33:20 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26148-02 for ; Wed, 11 Jul 2007 20:33:13 +0200 (CEST) Original-Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by ronja.ntg.nl (Postfix) with ESMTP id 69894201FF for ; Wed, 11 Jul 2007 20:33:13 +0200 (CEST) Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1I8gzs-000391-C2 for ntg-context@ntg.nl; Wed, 11 Jul 2007 20:33:08 +0200 Original-Received: from calaveras.stanford.edu ([128.12.173.43]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jul 2007 20:33:08 +0200 Original-Received: from alama by calaveras.stanford.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jul 2007 20:33:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 161 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: calaveras.stanford.edu User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (darwin) Cancel-Lock: sha1:XAu2g62HSy4NcOnYzTNkInab//s= X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:35391 Archived-At: 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. > > \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 ___________________________________________________________________________________