[texhax] Parsing ^ and _
Alex Scorpan
scorpan at gmail.com
Tue Sep 12 00:12:26 CEST 2006
> Is there any simple way of parsing ^ and _ that mimics what TeX
> does, but
> allows other procedures than just putting in super and subscripts?
> For
> example, I have a \to procedure that replaces the plain tex (which
> is a
> synonym for \rightarrow) and measures the sizes of the scripts and
> uses
> that information to choose the length of the arrow. As it is, I
> can use
> any of \to^{...}, \to_{...}, \to^{...}_{...} but not \to_{...}^
> {...}. I
> already have three uses of \@ifnextchar and the only way I can
> think to
> implement allowing all four would use several more. Is there a
> simpler
> way of doing this.
On one hand, \xrightarrow[bottom]{top} does pretty much what you want
in amsmath.
The simplest (but rather rigid) way could be
\def\to^#1_#2{\xrightarrow[#2]{#1}}
but you'd need both a super- and subscript, in the order used in
\def, as in
\[ A\to^{top}_{bottom}B \]
-- Alex
More information about the texhax
mailing list