ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: ConText and definecolor: undefined control sequence
       [not found] <20100112150255.GA8216@shahin.dnsalias.com>
@ 2010-01-20 22:01 ` Aditya Mahajan
  0 siblings, 0 replies; only message in thread
From: Aditya Mahajan @ 2010-01-20 22:01 UTC (permalink / raw)
  To: Ben; +Cc: mailing list for ConTeXt users, pgf Mailing-List

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1890 bytes --]

On Tue, 12 Jan 2010, Ben wrote:

> Dear List,
> using the pgf build from 20100103 and texlive2009 from the Debian unstable
> I've just tried to do the following:
>
>    \enableregime[utf]
>    \usemodule[tikz]
>
>    \starttext
>
>    \startTEXpage
>    \pgfutil@definecolor{magenta}{rgb}{1,0,1}
>
>    \starttikzpicture
>      \draw (0,0) -- (1,1);
>    \stoptikzpicture
>    \stopTEXpage
>
>    \stoptext
>
> I always get
>
>    ! Undefined control sequence.
>    l.21 \pgfutil
>                 @definecolor{magenta}{rgb}{1,0,1}
>    ?
>    ! Emergency stop.
>    l.21 \pgfutil
>                 @definecolor{magenta}{rgb}{1,0,1}
>    End of file on the terminal!

You need to add \unprotect and \protect

\unprotect
\pgfutil@definecolor{...}
\protect

They are similar to \makeatletter and \makeatother in LaTeX.

The correct way is to ConTeXt's color mechanism to define colors. For 
example,

\usemodule[tikz]

\definecolor[mycolor][r=1,g=0,b=1]

\starttext
\starttikzpicture
   \node[text=mycolor] {Test} ;
\stoptikzpicture
\stoptext

This works with MkII but gives an error with MkIV.

! Undefined control sequence.
\pgfutil@registercolor ...ef \pgf@temp {\PDFcolor
                                                   {#1}}\edef \pgf@marshal 
{\...
\pgfutil@colorlet ...x \pgfutil@registercolor {#2}
                                                   \fi \edef \pgf@marshal 
{\n...
\tikz@next ...futil@colorlet {.}{\tikz@textcolor }
                                                   \fi \pgfsetcolor 
{.}\setbo...
l.7   \node[text=mycolor] {
                            Test}

That is because MkII and MkIV have a different color model, 
and tikz does not support the MkIV model yet.

I am attaching a fix for that. I do not know what is the best way to 
incorporate it into tikz (perhaps a pgfutils-mkiv.tex file). For the 
moment, you can just input it after loading tikz.

Aditya

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-tex; name=pgf-colorfix.tex, Size: 1183 bytes --]

\startluacode
  pgfutil = pgfutil or { } 
  local texsprint, format = tex.sprint, string.format
  local prtcatcodes = tex.prtcatcodes

  function pgfutil.unsupported_color(name)
    texsprint(prtcatcodes,format("\\PackageError{pgf}{color %s has unsupported model}{}", name))
    texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{0}", name))
  end

  function pgfutil.registercolor(name, attributes)
    print(name, attributes)
    local cv = colors.value(attributes) 
    if cv then
      local model = cv[1]
      if model == 1 then
        print("model=1")
        texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{%1.3f}", name, cv[2]))
      elseif model == 3 then
        print("model=2")
        texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{rgb}{%1.3f,%1.3f,%1.3f}", name, cv[3], cv[4], cv[5]))
      else
        print("no model")
        pgfutil.unsupported_color(name)
      end
    else
        print("no color")
      pgfutil.unsupported_color(name)
    end
  end
\stopluacode

\unprotect
\def\pgfutil@registercolor#1%
  {\ctxlua{pgfutil.registercolor("#1",\thecolorattribute       {#1})}}
\protect


[-- Attachment #3: Type: text/plain, Size: 420 bytes --]

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
pgf-users mailing list
pgf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-01-20 22:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20100112150255.GA8216@shahin.dnsalias.com>
2010-01-20 22:01 ` ConText and definecolor: undefined control sequence Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).