[Xy-pic] \newdir

Ross Moore ross@ics.mq.edu.au
Tue, 9 Jul 2002 08:57:33 +1000 (EST)

> Does anyone know how to use \newdir to produce an arrow with a tick.  Say,
> \newdir{+}{<definition>} so that \ar{+>} would produce an arrow like
> ----+---> ?  You can get the effect by \ar@{>}|-{\object@{|}} .

Several comments:

 1.  Firstly, do you want to use  \ar{+>}  (as stated)  or  \ar@{+>}  
     by analogy with line styles, such as  \ar@{.>}, \ar@{=>} ?

     Either is possible; neither is easy, for various reassons.

 2.  \dir{+}  is already defined as a directional --- an oriented cross
     with one arm along the current direction (as distinct from \dir{x}
     which has the arms at 45\degrees to the current direction).

     Thus \ar@{+>} *should* currently work as an arrow built from
     repeated aligned crosses.

     Changing the result of a connection built with \dir{+} to be
     what you are asking-for is certainly possible, but would require
     working at an internal level, I think.

 3.  The alternative is to *overload* the \ar macro.

     It could be made to: 
      a.  look ahead, to read the next non-space token
      b.  if it is { then read the full argument
      c.  test the argument against specified patterns using \ifx
          e.g. {+>} for this case, but other patterns could be checked also
      d.  if a particular pattern is found, then do something special...
      e.  ... otherwise put the tokens back, for usual Xy-pic parsing.

  The *doing something special* at step d. could be simply inserting
extra tokens into the parsing stream, so that effectively..

  \ar{+>}  ---->  \realXyar @{>}|-*@{|}

where \let\realXyar\ar  has captured a pointer to the real Xy-pic expansion
of \ar before any re-definition has been made.

In OOP terms, TeX's \let primitive provides the pointer to allow *inheritance*
of the existing meaning of a macro, so that it can be redefined locally,
using \def or \edef, to call-up a specialised method for a sub-class type of object.

Hope this helps,


> Michael Barr
> _______________________________________________
> Xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic