Hi Jesse, I am CCing to the context list also. On Mon, 18 Feb 2008, Jesse Alama wrote:
Hi Aditya,
I recently came across a thread on the PGF users mailing list in which you mention some problems with ConTeXt, PGF and colors. For example:
http://article.gmane.org/gmane.comp.tex.pgf.user/38
Have these issues beein resolved for your? I just downloaded PFG 1.18 from the modules part of the contextgarden, installed it, and, when trying to compile the following example PGF code
\starttikzpicture[scale=3] \clip (-2,-0.2) rectangle (2,0.8); \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc (0:30:3mm) -- cycle; \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis); \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis); \draw (0,0) circle (1cm);
\draw[very thick,red] (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis); \draw[very thick,blue] (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0); \draw[very thick,orange] (1,0) -- node [right=1pt,fill=white] {$\displaystyle \tan \alpha \color{black}= \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$} (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
\draw (0,0) -- (t); \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1} \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {$\xtext$}; \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1} \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$}; \stoptikzpicture
(which is taken from the PGF manual), I get
! Use of \color doesn't match its definition. \tikz@temp ...{$\displaystyle \tan \alpha \color { black}= \frac {{\color {re...
\tikz@invoke@collected@onpath ...mmand \tikz@temp \pgf@stop \tikz@node@is@a@...
\tikz@scan@next@command ...nvoke@collected@onpath \fi \afterassignment \tikz... l.86 ...(intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t); ?
The problem does seem to be that PGF and ConTeXt both want to define \color.
Any ideas how to get around the problem? As it stands, it seems safe to say that, if colors don't work, then PGF is quite crippled in ConTeXt.
No, the reason for the error is more subtle. PGF does try its best to work with ConTeXt colors. However, there is a difference between latex and context color usage, that gives rise to the error. The culprit in this case is: {$\displaystyle \tan \alpha \color{black}= \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$} Try this in a standalong context file (no pgf) and you will get an error. First you need to change \color{black} to \color[black]. Even then you will get an error. You need to use {$\displaystyle \tan \alpha {\color[black]= \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$} (Notice the {...} around \color[black]). Then everything works fine. Here is a working example (latest pgf from cvs, but should also work with 1.18). \usemodule[tikz] \setupcolors[state=start] \starttext \starttikzpicture[scale=3] \clip (-2,-0.2) rectangle (2,0.8); \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc (0:30:3mm) -- cycle; \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis); \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis); \draw (0,0) circle (1cm); \draw[very thick,red] (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis); \draw[very thick,blue] (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0); \draw[very thick,orange] (1,0) -- node [right=1pt,fill=white] {$\displaystyle \tan \alpha {\color[black]= \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$} (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t); \draw (0,0) -- (t); \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1} \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {$\xtext$}; \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1} \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$}; \stoptikzpicture \stoptext Aditya