[texhax] Parsing ^ and _

Uwe Lück uwe.lueck at web.de
Thu Sep 14 00:15:55 CEST 2006

At 00:12 12.09.06, Alex Scorpan wrote
[Michael Barr]:
> > 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.

Perhaps the following helps to estimate how far Michael Barr
was from an ideal solution:

    \begingroup % drop when sure that \subcontent/supcontent
                % not used for a different purpose outside
     \let\subcontent\empty \let\supcontent\empty
       {\load at and\subcontent^\supcontent}%
         {\load at and\supcontent_\subcontent}%
   \newcommand*{\load at and}[5]{%
       {\@firstoftwo{\afterassignment\tooodooo \def#3}}%
   % \CheckCommand{\@firstoftwo}[2]{#1} % reminder (preamble only)


   \newcommand{\tooodooo}{% replace this:
   %   [arrow long enough for both of `\subcontent'/`\supcontent']%
   % ... by your `\to_{\subcontent}^{\supcontent}', e.g.
    \endgroup % drop when sure that \subcontent/supcontent
              % not used for a different purpose outside

   % outcome:


   X \tooo_{oo}^{ooo} Y \SEPARATE
   X \tooo^{oo}_{ooo} Y \SEPARATE
   X \tooo_{oooo}     Y \SEPARATE
   X \tooo^{ooooo}    Y \SEPARATE

-- Spent hours instead of a few minutes -- as often ...

Note that it may be considered a key-value situation
-- start with thinking of primitive TeX' width, height, depth ...

>On one hand, \xrightarrow[bottom]{top} does pretty much what you want
>in amsmath.

-- Don't know this, not found ...



More information about the texhax mailing list