[Xy-pic] Using macros in xymatrix

Ross Moore ross at ics.mq.edu.au
Sat Jul 28 09:24:19 CEST 2007


Hi Andrew,

On 28/07/2007, at 12:15 PM, Andrew Clegg wrote:

> Sorry, I should have said in those last mails -- \xmpl is just an
> alias for \textsl and \vdu is an alias for \texttt -- that wouldn't
> cause a problem would it?

No. that's irrelevant, provided these macros are correctly defined.

By alias, do you mean:
    \let \xmpl \textsl     or   \def\xmpl{\textsl}
or    \newcommand{\xmpl}[1]{\textsl{#1}}  ?
All of these should work just fine.

>
> Andrew.
>
> On 7/28/07, Andrew Clegg <andrew.clegg at gmail.com> wrote:
>> On 7/28/07, Ross Moore <ross at ics.mq.edu.au> wrote:
>>>
>>> Simply extend your \arr  macro above to a variant having a 2nd 
>>> argument:
>>>
>>>      \newcommand{\arrlab}[2]{\ar@*{[|(2)]}[#1]|+[F]\txt{\tt #2}}

Oops. There's an error here.  It should be:

      \newcommand{\arrlab}[2]{\ar@*{[|(2)]}[#1]|*+[F]\txt{\tt #2}}
   note the need for * after | here ----------------^^

(Hopefully this lines up OK in your mailer.)


>>>
>>> Use it, for the above examples, as:
>>>
>>>          \lab{foo} \arr{r}
>>>          \arrlab{r}{bar}
>>
>> Err, this doesn't quite work, sorry :-)

See the missing * above.

>>
>> It compiles, the lines are right, but I only get a plus symbol in each
>> label (and no frame).
>>
>> Example:
>>
>> \xymatrix at +0.5cm{
>> & & *+\txt{\vdu{VBD} \xmpl{saw}} \arrlab{dl}{nsubj} \arrlab{dr}{dobj} 
>> & & \\
>> & *+\txt{\vdu{NN} \xmpl{man}} \arrlab{dl}{det} & &  *+\txt{\vdu{NN}
>> \xmpl{dog}} \arrlab{dr}{det} & \\
>> *+\txt{\vdu{DT} \xmpl{the}} & & & & *+\txt{\vdu{DT} \xmpl{the}}
>> }
>>
>> Unless I'm using an out of date version or something? It's 3.7.

No. There's nothing version related here.
With the correct expansion for  \arrlab  you should get the 2nd
diagram in the attached image.



Also, in a previous message you wrote:

>>> \newcommand{\lab}[1]{*+[F]\txt{\tt #1}}
>>
>> This cannot work, as it does not turn on Xy-pic parsing.
>> The * is a shorthand for \drop , within an Xy-pic parsing context,
>> so you need to define this macro as either:
>>
>>     \newcommand{\lab}[1]{\drop+[F]\txt{\tt #1}}
>
> Umm... Neither of these work. They cause an error like this:
>
> [25] [26] [27] <xymatrix
> ! Illegal parameter number in definition of \lastprentry@@.
> <to be read again>
>                    1
> l.293 }
>
> The table causing the error looks like this:
>
> xymatrix{
>  & & & & & \lab{Os} \ar@{-}`l[ldd][ldd] \ar@{-}`r[rrdd][rrdd] & & \\
>  & \lab{Ds} \ar@{-}`l[ld][ld] \ar@{-}`r[rd][rd] & & \lab{Ss}
> \ar@{-}`l[ld][ld] \ar@{-}`r[rd][rd] & & & \lab{Ds} \ar@{-}`l[ld][ld]
> \ar@{-}`r[rd][rd] & \\
> \xmpl{the} & & \xmpl{man.n} & & \xmpl{saw.v} & \xmpl{the} & & 
> \xmpl{dog} \\
> }

Aaah, an example!
That helps wonderfully.

In all of your uses of  \lab  it is the *first* thing within a matrix 
cell,
so it is expanded immediately --- remember what I said about this!
In that case, having the \drop or \POS is indeed wrong --- sorry,
I didn't say this earlier, as I didn't know what you were trying to do.

However, try this example:

$$
\let \xmpl\textsf
\def\lab#1{\drop+[F]\txt{\tt #1}}
\xymatrix{
  & & & & &{}\lab{Os} \ar@{-}`l[ldd][ldd] \ar@{-}`r[rrdd][rrdd] & &\\
  &B\lab{Ds} \ar@{-}`l[ld][ld] \ar@{-}`r[rd][rd] & & C\lab{Ss}
\ar@{-}`l[ld][ld] \ar@{-}`r[rd][rd] & & &D\lab{Ds} \ar@{-}`l[ld][ld]
\ar@{-}`r[rd][rd] &\\
\xmpl{the} & & \xmpl{man.n} & & \xmpl{saw.v} & \xmpl{the} & &\xmpl{dog} 
\\
}
$$

The attached image shows what I get with these 2 examples,
in reverse order.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic1.pdf
Type: application/pdf
Size: 31558 bytes
Desc: not available
Url : http://tug.org/pipermail/xy-pic/attachments/20070728/629d7120/attachment-0001.pdf 
-------------- next part --------------



>> Cheers,
>>
>> Andrew.

Hopeflly you can get this working properly now.


Regards,

	Ross


More information about the xy-pic mailing list