[Xy-pic] Macros in xygraph

Ross Moore ross at maths.mq.edu.au
Sun Oct 17 14:46:42 CEST 2004


On 17/10/2004, at 6:47 AM, Alan P Sexton wrote:

>
> I am having great difficulty getting macros in xygraph working. I know
> about using \POS to restart the parser but I can't get it to work 
> right.

Inside a graph, you can use the "graph-escape" mechanism.
This is often more convenient than using \POS.


> The following is for Hasse diagrams: I need to be able to draw filled
> nodes as well as empty nodes. Hence I use \circ and \bullet and change
> the frames around them to circular and change the size of the frame to
> make the lines touch the nodes but not cross into the centre of the
> \circ nodes.

The Xy-pic <objects>   @{*}  and  @{o}  can be used to
create zero-sized filled & open circles.
These are preferable to  \bullet  and  \circ  which may be shaped
and/or sized differently according to which font is used.

>
> The fully expanded version works perfectly. The macroised version shows
> very strange behavior: the locations are being set correctly (as can be
> seen from the lines drawn) but the objects are being dropped in the
> wrong places. Also the frames around the positions where the objects
> should be dropped have not been set correctly. Can anyone explain what 
> I
> am doing wrong and how to fix it?
>
> \xygraph{
> []
> *-<1.5pt,1.5pt>[o]{\circ}="A"
> [dr]
> *-<1.5pt,1.5pt>[o]{\bullet}="B"
> [ur]
> *-<1.5pt,1.5pt>[o]{\circ}="C"
> "A"-"B"
> "B"-"C"
> }



>
> \vspace{2cm}
>
> \newcommand{\node}{\POS*-<1.5pt,1.5pt>[o]{\circ}}
> \newcommand{\nodeFill}{\POS*-<1.5pt,1.5pt>[o]{\bullet}}
>
> \xygraph{
> []
> \node="A"
  ^^^^^^ ----  no, this is quite wrong !
> [dr]
> \nodeFill="B"
> [ur]
> \node="C"
> "A"-"B"
> "B"-"C"
> }

You cannot just call TeX macros like this within an  xygraph .
You need to wrap them inside a !-escape as shown below.

This is the correct way to do it:

\xygraph{
[] !{\node}="A"
[dr] !{\nodeFill}="B"
[ur] !{\node}="C"
"A"-"B"
"B"-"C"
}


Here's how to make it shorter, neater,
and self-contained using graph-escapes
(rather than TeX macro definitions):

\xygraph{
   !~O{[]*-<1.5pt,1.5pt>[o]{\circ}}
   !~F{[]*-<1.5pt,1.5pt>[o]{\bullet}}
[] !O="A"
[dr] !F="B"
[ur] !O="C"
"A"-"B"
"B"-"C"
}

or  (ditching the \circ and \bullet )

\xygraph{
   !~O{[]*+<2.5pt>[o]@{o}}
   !~F{[]*+<2.5pt>[o]@{*}}
[] !O="A"
[dr] !F="B"
[ur] !O="C"
"A"-"B"
"B"-"C"
}



Hope this helps,

	Ross



>
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic
>
------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------



More information about the xy-pic mailing list