[dev-context] My way on matharrows

Aditya Mahajan adityam at umich.edu
Wed Jul 19 00:50:14 CEST 2006


Hi,

  I am attaching myway on using matharrow. Are there any suggestions 
before I release it to public?

I found some surprises while making this my way.

1. Somewhere along the line of development, \xrightarrow{text} changed 
to placing text at the bottom of the arrow (rather than the top as in 
amstex). This is not a bug, just something that works differently. 
Should this be changed? These arrow definitions are pretty new, so I 
do not think that a change at this stage will effect too many users. 
It may not be possible to change later for compatibility reasons.

2. Something goes wrong with palatino (used by mag-01). Have a look at 
the \xmapsto and \xrightleftharpoons and \xleftrightharpoons in the 
pdf. \xmapsto can be corrected by changing its defintion to

\definematharrow [xmapsto]            [3599] [\mapstofill]

Basically, providing a bit more cusion on the left, so that the middle 
\relbar not overlap the \mapstochar.

Should this definition go to math-ext.tex or to something specific to 
palatino. I have not tested with other fonts, but what is the general 
strategy when definitions differ for different fonts?

I could not correct leftrightharpoons. Why does this not work?

\definematharrow [xleftrightharpoons] [3395,3359] [\leftharpoonupfill,\rightharpoondownfill]

\starttext
\math{\xleftrightharpoons}
\stoptext


Aditya
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arrows.xml
Type: text/xml
Size: 7074 bytes
Desc: 
URL: <http://mailman.ntg.nl/pipermail/dev-context/attachments/20060718/21a51ab3/attachment.xml>
-------------- next part --------------
\usemodule[mag-01]

\usemodule[int-load]
\def\loadsetups{}
\usemodule[mod-00]

\setupcolors[state=start]


\def\loadsetups{\complexorsimple\loadsetups}

\def\simpleloadsetups
 {\complexloadsetups[cont-en.xml]}

\def\complexloadsetups[#1]%
 {\startXMLmapping[zero]
  \processXMLfilegrouped{#1}
  \stopXMLmapping}

\loadsetups[arrows.xml]

\setupheadertexts[section]

\setvariables
  [magazine]
  [title={Arrows in \CONTEXT},
   author=Aditya Mahajan,
   date=\currentdate,
  ]

\startbuffer[abstract]
This document describes how to use {\em extensible arrows} in \CONTEXT. It
also explains how you can define new arrows on your own.
\stopbuffer

\starttext \setups[titlepage] \setups[title]

\section{Introduction}
Sometimes one needs to typeset arrows like $\xrightarrow{\text{below}}{\text{above the
arrow}}$. \CONTEXT\ provides extensible arrows to get this result. This {\em
My Way} describes how to use extensible arrows and how to define new ones on
your own.

\section{Usage Syntax}
The following extensible arrows are defined in \CONTEXT.

\midaligned{\starttable[|l|m|]
  \NC \tex{xrightarrow        }  \NC \xrightarrow          \NC \NR
  \NC \tex{xleftarrow         }  \NC \xleftarrow           \NC \NR
  \NC \tex{xequal             }  \NC \xequal               \NC \NR
  \NC \tex{xRightarrow        }  \NC \xRightarrow          \NC \NR
  \NC \tex{xLeftarrow         }  \NC \xLeftarrow           \NC \NR
  \NC \tex{xLeftrightarrow    }  \NC \xLeftrightarrow      \NC \NR
  \NC \tex{xleftrightarrow    }  \NC \xleftrightarrow      \NC \NR
  \NC \tex{xmapsto            }  \NC \xmapsto              \NC \NR
  \NC \tex{xtwoheadrightarrow }  \NC \xtwoheadrightarrow   \NC \NR
  \NC \tex{xtwoheadleftarrow  }  \NC \xtwoheadleftarrow    \NC \NR
  \NC \tex{xrightharpoondown  }  \NC \xrightharpoondown    \NC \NR
  \NC \tex{xrightharpoonup    }  \NC \xrightharpoonup      \NC \NR
  \NC \tex{xleftharpoondown   }  \NC \xleftharpoondown     \NC \NR
  \NC \tex{xleftharpoonup     }  \NC \xleftharpoonup       \NC \NR
  \NC \tex{xleftrightharpoons }  \NC \xleftrightharpoons   \NC \NR
  \NC \tex{xrightleftharpoons }  \NC \xrightleftharpoons   \NC \NR
\stoptable}

The syntax of using these commands is
\startTEX
  \arrowname[options]{below}{above}
\stopTEX

\showsetup{xrightarrow}

where \type{<arrowname>} is one of the arrows shown above. The options effect
the spacing around the above and below material. It can be one of the keywords
or a number (which is converted to math units~\type{mu}.) Compare:

\def\below{\text{\framed{below}}}
\def\above{\text{\framed{above}}}
\midaligned{\starttable[|l|m|]
  \NC  \tex{xrightarrow        } \NC \xrightarrow        {\below}{\above} \NC\NR
  \NC  \tex{xrightarrow[none]  } \NC \xrightarrow  [none]{\below}{\above} \NC\NR
  \NC  \tex{xrightarrow[small] } \NC \xrightarrow [small]{\below}{\above} \NC\NR
  \NC  \tex{xrightarrow[medium]} \NC \xrightarrow[medium]{\below}{\above} \NC\NR
  \NC  \tex{xrightarrow[big]   } \NC \xrightarrow   [big]{\below}{\above} \NC\NR
  \NC  \tex{xrightarrow[50]    } \NC \xrightarrow    [50]{\below}{\above} \NC\NR
\stoptable}

All the arguments are optional, so you can also use
\startTEX
  \arrowname[option]{below}
  \arrowname{below}
  \arrowname[option]
  \arrowname
\stopTEX
for example\footnote{This is different from \AMSTEX\ syntax, where
\type<<\arrowname{above}>> places the material {\em above} the arrow.}

\midaligned{\starttable[|l|m|]
  \NC \type<<\xrightarrow{below}      >> \NC \xrightarrow{\below}     \NC\NR
  \NC \type<<\xrightarrow[big]{below} >> \NC \xrightarrow[big]{\below}\NC\NR
  \NC \type<<\xrightarrow[big]        >> \NC \xrightarrow[big]        \NC\NR
  \NC \type<<\xrightarrow             >> \NC \xrightarrow             \NC\NR
\stoptable}

\section{Defining new arrows}
There are two types of extensible arrows
\startitemize[r,text][stopper=]
  \item Those with a single arrow (e.g.\ \tex{xrightarrow}, \tex{xleftarrow},
    etc.) and,
  \item those with two arrows (e.g.\ \tex{xleftrightharpoons},
    \tex{leftrightharpoons} etc.)
\stopitemize
Here I will explain how to define both kinds of arrows. First you need to define
an {\em extensible arrow fill}, which consists of three parts, which define the
left, middle and right part of the arrow, where the middle part is stretched in
a way that the arrow is atleast as long as the material above and below it. This
can be define using \tex{mtharrowfill}, e.g.\ for \tex{xrightarrow} one defines
\startTEX
\def\rightarrowfill{\mtharrowfill \relbar \relbar \rightarrow}
\stopTEX 
Here \tex{relbar} is \math{\relbar} character, which is basically a horizontal
bar at the middle of math line. Thus \tex{rightarrowfill} is an arrow fill in
which the left part is \tex{relbar}, the middle stretchable part is \tex{relbar}
and the right part is \tex{rightarrow}. Similarly, for \tex{xleftarrow} one
defines
\startTEX
\def\leftarrowfill{\mtharrowfill \leftarrow \relbar \relbar}
\stopTEX 
and so on for different arrows.

An extensible arrow can be defined using the \tex{definearrow} command.
\showsetup{definearrow}
It can best be explained by means of an example. \tex{xrightarrow} is defined as
\startTEX
\definematharrow [xrightarrow]        [0359] [\rightarrowfill]
\stopTEX
The first argument is the name of the arrow (\tex{xrightarrow} in this case.)
The second argument consists of a set of 4 numbers and specify the spacing
correction in math units~\type{mu}. These numbers define:

% Where is the fun, if you do everything manually :-)
\defineconversion[ordinal][\enordinaldaynumber]

% Can 9*broad be calculated automatically?
\startitemize[ordinal,9*broad][stopper={ number:}]
  \item left arrow||tip correction
  \item right arrow||tip correction
  \item left space (multiplied by \tex{matharrfactor} and advanced by
    \tex{matharrextra})
  \item right space (multiplied by \tex{matharrfactor} and advanced by
    \tex{matharrextra})
\stopitemize

The third argument is the name of the extensible fill, that we defined earlier.
This gives us an extensible arrow of the first kind.

To define an extenisble arrow the second kind, (e.g.\ \tex{xrightleftharpoons})
we need to define two extensible fills. 
\startTEX
\def\rightharpoonupfill%
    {\mtharrowfill \relbar          \relbar \rightharpoonup}
\def\leftharpoondownfill%
    {\mtharrowfill \leftharpoondown \relbar \relbar        }
\stopTEX  
Next we need to tell \tex{definearrow} to stack them together.
\startTEX
\definematharrow [xrightleftharpoons] [3095,0359] 
                 [\rightharpoonupfill,\leftharpoondownfill]
\stopTEX
The second and the third set of arguments consist of comma separated values. The
first element of the second argument (\type{3095}) corresponds to the spacing
correction of top arrow fill (\tex{rightarrowupfill}). Similarly, \type{0359}
corresponds to bottom arrow fill \tex{leftharpoondownfill}). Stacking them on
top of each other we get
\math{\xrightleftharpoons[big]{\tex{leftharpoondownfill}}{\tex{rightharpoonupfill}}}.

\section{Concluding Comments}
This is just meant as a usage guide for {\em extensible arrows} in \CONTEXT,and
is by no means exhaustive. If you really want to understand the nitty gritty of
the implementation, you need to look at the code (in \type{math-ext.tex}).

\stoptext





More information about the dev-context mailing list