[Xy-pic] defining color (xypdf, xcolor)
Thierry Masson
thilucmic at wanadoo.fr
Wed Nov 3 21:22:06 CET 2004
Hello,
I would like to create a macro to define a new xycolor from a color
defined by the very powerful package xcolor. I have tried the
following:
\def\extractcolorspecxy#1#2{\XC at split{#1}\aftergroupdef#2{\@@clr}}%
\def\@putawaycomma#1,#2,#3{#1 #2 #3}%
\def\createxycolorforcolor#1{%
\extractcolorspecxy{#1}{\@spec}%
\newxyColor{#1}{\expandafter\@putawaycomma\@spec}{rgb}{}\relax
}%
First line is a modification of a macro in the xcolor package. It
extracts the color specifications (I ALWAYS suppose the color to be in
the rgb model here), and put it in a macro. This macro expands to 3
numbers (r,g,b) separed by commas. I defined the macro in the second
line to put away the commas... The last definition, lines 3-5, creates
a color for xypic with a macro from the xycolor package.
What surprised me is that it works! When I write in my latex file
\colorlet{myred}[rgb]{red!50!white} % new color from the xcolor package
in the rgb model
\createxycolorforcolor{myred} % same color for use in xypic
then I can use "myred" to colorize arrows in my xymatrix (
\ar@[myred][d] ).
BUT, if I put a second definition in my latex file, with an other name
for my new color, the first color is replaced by the second one!
This I don't understand ! I can't define two colors with my definition.
Why???
I use pdflatex, and the package xypdf.
(Purpose of this: I use the package Beamer to create presentations with
pdflatex and I want the arrows in some diagrams to have the same color
as some nodes. I chose my color to fade away what is not the purpose of
my explanation, or on the contrary to reveal some parts of the diagram.
Very efficient!)
Thanks for any advice.
Thierry
More information about the xy-pic
mailing list