(I'm guessing a lot here.) I think that it is down to the way in which PGF inserts colours in to the output file. To see this, it's worth reviewing the levels in the TikZ/PGF system.
- At the top, we have TikZ. This is the frontendlayer and defines the syntax that the user (usually) uses. It's job is to translate user-friendly stuff into a simpler state ready for further processing.
- In the middle, we have PGF. This is the basiclayer. This is where all the detail takes place. Here, things are done in a machine/program-friendly way. The full power of TeX is used to do some heavy machinery. All the path decorations and similar are done here. The goal of this layer is to translate what the user wants in to basic path entities.
- At the bottom, we have the drivers. These form the systemlayer. Here is where the PGF code is interpreted in to specific instructions. These have to be specific to the planned output type.
So the thing to remember in this is that when you say \fill[color=RedSpot]
then that is a TikZ command to set the colour to RedSpot
which then gets further interpreted by PGF and then the driver. Chasing definitions through, we find that color=RedSpot
calls \pgfsetcolor
which calls \pgf@setcolor
which calls \pgfsys@color@<model>
. This is now a driver level command. Its definition, say for CMYK, is
\def\pgfsys@color@cmyk@stroke#1#2#3#4{\pgfsysprotocol@literal{#1 #2 #3 #4 K}}
from which we can see (and tracing back through the definitions, this gets clearer) that even if we've defined a colour name, it is the CMYK values that get put in the file.
The point is that PGF cannot know that it is possible in PDF to alias colours, because it doesn't know that the final output will be PDF. So it translates the colours to their raw values. And 0 1 1 0 setcmykcolor
isn't the spot colour.
A lot of the above is speculation, I'll admit. Here's my evidence for this being the case. If you compile the PSTricks
file above and look at the PS, you'll find that the drawing code is:
tx@Dict begin STP newpath /ArrowA { moveto } def /ArrowB { } def
0.8 SLW TeXDict begin XC@black end 142.26378 142.26378 113.81102
.5 CLW mul sub 0 360 arc closepath gsave TeXDict begin XC@RedSpot
end 1. .setopacityalpha fill grestore end
But if you compile the TikZ
version and look at the PS, you'll find:
0 1 1 0 setcmykcolor
141.73404 141.73404 moveto
255.12128 141.73404 moveto
255.12128 204.35689 204.35689 255.12128 141.73404 255.12128 curveto
79.11119 255.12128 28.3468 204.35689 28.3468 141.73404 curveto
28.3468 79.11119 79.11119 28.3468 141.73404 28.3468 curveto
204.35689 28.3468 255.12128 79.11119 255.12128 141.73404 curveto
closepath
So the RedSpot
gets put literally in to the PS from PSTricks
but is translated back to 0 1 1 0
internally by PGF first.
The clincher is to do the following. Edit the PS file and replace the 0 1 1 0 setcmykcolor
by XC@RedSpot
. Then do the gs
and montage
stuff, and you get:
which is what you wanted.
However, editing the postscript isn't a great way to do this! Here's what I think you'd have to do to use spot colours in TikZ. I think you'd have to define a new colour model, say spot
. You'd then tell PGF that the spot
colour model is to be treated specially in that the name of the colour is to be used (or at least XC@<name>
). To define a spot colour, you could (I think) use xcolor
to define it using one model and then convert it to another. That would ensure that the definition got in to the PS file (which it does already). I don't know how to do all those steps, because it relies on knowing how xcolor
works and I don't know much about that. But that's what I would do.
Set the colors after loading tikz
; moreover use the following pattern:
\input eplain
\beginpackages
\usepackage{url}
\usepackage{color}
\endpackages
\input tikz
\enablehyperlinks
\definecolor{urlcolor}{rgb}{.2,.4,.6}
\hlopts{colormodel=,color=urlcolor}
\definexref{anchor}{display}{type} Hi there. This refers to the \ref{anchor}.
\bye
Using
\hlopts{colormodel=rgb,color={.2,.4,.6}}
(that according to the docs should work) breaks tikz
. Remember that tikz
supports only the rgb and gray color models.
Best Answer
Despite the lack of response to my comments I'll post an answer here anyway, as I seem to have a working solution. I'm very tentative about this one, as the packages
pstricks
andtikz
are so large that there may well be some other interactions I know nothing about. I have to say that if your objective is the simplicity of plain TeX then using both of these packages at the same time appears to be a recipe for a headache.The error about the undefined colour macro occurs because tikz redefines the colour commands used by pstricks, so
\\color@black
(note the extra\
) gets mapped to\xcolor@{}{}{rgb}{0,0,0}
and\\color@blue
to\xcolor@{}{}{rgb}{0,0,1}
etc.But neither
pstricks
nortikz
defines an\xcolor@
command, so you get an error.IMHO the best way to fix this would be not to use tikz here, but since you want to try using both, here is a "reverse-engineered" fix that works at least for this simple example, and might form the base for further development.
Notes: On line 3 above we open a group and set the catcode of "@" to be 11, which makes TeX treat it like an ordinary letter, so we can use it in a control sequence name. On line 4, we define a "dec@mma" command that takes an argument "{a,b,c}" and produces "a b c". The name is meant to sound like "de-comma". On line 5 we define the missing "xcolor@" command. We define it to expect four arguments. We ignore arguments #1 and #2; we expect #3 to be a colour space name - well actually we expect it to be "rgb" to be honest; and we expect #4 to be three numbers separated by commas. We call "decomma" to get rid of the commas. One line 6 we close the group.
The commands use "gdef" rather than "def" so that they are visible outside the local group.
The only colour space name used by TikZ appears to be "rgb", so we could have written
\gdef\xcolor@#1#2#3#4{\dec@mma#4 setrgbcolor}
without loss of function. The other possible colour space names include "gray" and "cmyk", but to support these properly we would need to cope with a variable number of arguments - gray needs just one number, cmyk needs four - which would make things more complicated.