ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* ConText, TikZ and definecolor: undefined control sequence
@ 2010-10-26 10:20 Michael Murphy
  2010-10-27 12:49 ` Cedric Mauclair
  2010-11-11 11:07 ` Tikz figures not centred Michael Murphy
  0 siblings, 2 replies; 14+ messages in thread
From: Michael Murphy @ 2010-10-26 10:20 UTC (permalink / raw)
  To: ntg-context

Hi,

I've been trying to get colors to work in TikZ, and found a nice fix by
Aditya here:

http://archive.contextgarden.net/message/20100120.220124.f2d3f8bc.en.html

The problem is that the lua script doesn't work: I get a problem with
'colors'.

LuaTeX error <main ctx instance>:13: attempt to index global 'colors' (a
nil value)
stack traceback:
	<main ctx instance>:13: in function 'registercolor'
	<main ctx instance>:1: in main chunk.

The input file from Aditya (called colorfix.tex) is

\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

and my test file is

\usemodule[tikz]
\input colorfix

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

\starttext 
\starttikzpicture 
\fill[mycolor] (0,0) circle (1); 
\stoptikzpicture 
\stoptext 

I'm running the latest beta.

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-26 10:20 ConText, TikZ and definecolor: undefined control sequence Michael Murphy
@ 2010-10-27 12:49 ` Cedric Mauclair
  2010-10-27 17:18   ` Marius
  2010-11-11 11:07 ` Tikz figures not centred Michael Murphy
  1 sibling, 1 reply; 14+ messages in thread
From: Cedric Mauclair @ 2010-10-27 12:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

Same problem here with the latest TikZ 2.10.

Regards.

-- Cédric



On Tue, Oct 26, 2010 at 12:20, Michael Murphy <michael.murphy@uni-ulm.de> wrote:
> Hi,
>
> I've been trying to get colors to work in TikZ, and found a nice fix by
> Aditya here:
>
> http://archive.contextgarden.net/message/20100120.220124.f2d3f8bc.en.html
>
> The problem is that the lua script doesn't work: I get a problem with
> 'colors'.
>
> LuaTeX error <main ctx instance>:13: attempt to index global 'colors' (a
> nil value)
> stack traceback:
>        <main ctx instance>:13: in function 'registercolor'
>        <main ctx instance>:1: in main chunk.
>
> The input file from Aditya (called colorfix.tex) is
>
> \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
>
> and my test file is
>
> \usemodule[tikz]
> \input colorfix
>
> \definecolor[mycolor][r=1,g=0,b=1]
>
> \starttext
> \starttikzpicture
> \fill[mycolor] (0,0) circle (1);
> \stoptikzpicture
> \stoptext
>
> I'm running the latest beta.
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-27 12:49 ` Cedric Mauclair
@ 2010-10-27 17:18   ` Marius
  2010-10-27 20:08     ` Michael Murphy
  0 siblings, 1 reply; 14+ messages in thread
From: Marius @ 2010-10-27 17:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,
I had the same problem, so I desided to define colors by hand.

\definecolor [lightgray] [h=D3D3D3]

\usemodule[tikz]

\unprotect
\pgfutil@definecolor{black}{gray}{0}
\pgfutil@definecolor{gray}{gray}{0.5}
\pgfutil@definecolor{lightgray}{gray}{0.9}
\pgfutil@definecolor{white}{gray}{1}
\protect

If you want to fix script, you need to change line:

local cv = colors.value(attributes)

into

local cv = attributes.colors.values

Just guess, untested.

Regards,
Marius

On 27 October 2010 15:49, Cedric Mauclair <cedric.mauclair@gmail.com> wrote:
> Hi,
>
> Same problem here with the latest TikZ 2.10.
>
> Regards.
>
> -- Cédric
>
>
>
> On Tue, Oct 26, 2010 at 12:20, Michael Murphy <michael.murphy@uni-ulm.de> wrote:
>> Hi,
>>
>> I've been trying to get colors to work in TikZ, and found a nice fix by
>> Aditya here:
>>
>> http://archive.contextgarden.net/message/20100120.220124.f2d3f8bc.en.html
>>
>> The problem is that the lua script doesn't work: I get a problem with
>> 'colors'.
>>
>> LuaTeX error <main ctx instance>:13: attempt to index global 'colors' (a
>> nil value)
>> stack traceback:
>>        <main ctx instance>:13: in function 'registercolor'
>>        <main ctx instance>:1: in main chunk.
>>
>> The input file from Aditya (called colorfix.tex) is
>>
>> \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
>>
>> and my test file is
>>
>> \usemodule[tikz]
>> \input colorfix
>>
>> \definecolor[mycolor][r=1,g=0,b=1]
>>
>> \starttext
>> \starttikzpicture
>> \fill[mycolor] (0,0) circle (1);
>> \stoptikzpicture
>> \stoptext
>>
>> I'm running the latest beta.
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-27 17:18   ` Marius
@ 2010-10-27 20:08     ` Michael Murphy
  2010-10-28  7:54       ` Cedric Mauclair
  2010-10-28  9:44       ` Marius
  0 siblings, 2 replies; 14+ messages in thread
From: Michael Murphy @ 2010-10-27 20:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 27/10/2010 19:18, Marius wrote:
> Hello,
> I had the same problem, so I desided to define colors by hand.
>
> \definecolor [lightgray] [h=D3D3D3]
>
> \usemodule[tikz]
>
> \unprotect
> \pgfutil@definecolor{black}{gray}{0}
> \pgfutil@definecolor{gray}{gray}{0.5}
> \pgfutil@definecolor{lightgray}{gray}{0.9}
> \pgfutil@definecolor{white}{gray}{1}
> \protect

Yes, this is what I've resorted to. But it would be nice to define 
things properly.

> If you want to fix script, you need to change line:
>
> local cv = colors.value(attributes)
>
> into
>
> local cv = attributes.colors.values
>
> Just guess, untested.

Nope, doesn't work. Using

local colors = colors or { }

gets me a little further, but then complains that 'value' is a nil 
value. I don't know enough Lua to fix this either. Strangely, it seems 
to work on some older MkIV versions of ConTeXt...

Michael.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-27 20:08     ` Michael Murphy
@ 2010-10-28  7:54       ` Cedric Mauclair
  2010-10-28  8:24         ` Cedric Mauclair
  2010-10-28 11:46         ` Hans Hagen
  2010-10-28  9:44       ` Marius
  1 sibling, 2 replies; 14+ messages in thread
From: Cedric Mauclair @ 2010-10-28  7:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, Oct 27, 2010 at 22:08, Michael Murphy <michael.murphy@uni-ulm.de> wrote:
> On 27/10/2010 19:18, Marius wrote:
>>
>> Hello,
>> I had the same problem, so I desided to define colors by hand.
>>
>> \definecolor [lightgray] [h=D3D3D3]
>>
>> \usemodule[tikz]
>>
>> \unprotect
>> \pgfutil@definecolor{black}{gray}{0}
>> \pgfutil@definecolor{gray}{gray}{0.5}
>> \pgfutil@definecolor{lightgray}{gray}{0.9}
>> \pgfutil@definecolor{white}{gray}{1}
>> \protect
>
> Yes, this is what I've resorted to. But it would be nice to define things
> properly.
>
>> If you want to fix script, you need to change line:
>>
>> local cv = colors.value(attributes)
The table "colors" is expected to have a function named "value" that
take the "attributes" parameter as its sole parameter itself. It then
assigns the result to the local variable cv. After some research,
adding  "local colors = global.attributes.colors" below the line
"local prtcatcodes = tex.prtcatcodes" works. There is a catch however,
you can't use opacity on these colors. I suppose we have to generate
all the transparency level by using spot colors or something like
that.

However, I still need to
add"\let\appendtoPDFdocumentcolorspaces\gobbleoneargument"
"\let\appendtoPDFdocumentextgstates\gobbleoneargument" and
"\let\PDFcolor\gobbleoneargument" before loading the TikZ module in
order for my documents to build without errors. These macros used to
be defined in mkii (spec-fdf.mkii) and TikZ relies on them
(tex/generic/pgf/utilities/pgfutil-context.def) but not anymore in
mkiv since the color support has changed between mkii and mkiv. I
suppose they had to do with the color support for PDF files, but
letting them gobble their argument still seems to work. On what side
should this problem be looked into: ConTeXt or TikZ?

Regards.

-- Cédric

>>
>> into
>>
>> local cv = attributes.colors.values
>>
>> Just guess, untested.
>
> Nope, doesn't work. Using
>
> local colors = colors or { }
>
> gets me a little further, but then complains that 'value' is a nil value. I
> don't know enough Lua to fix this either. Strangely, it seems to work on
> some older MkIV versions of ConTeXt...
>
> Michael.
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-28  7:54       ` Cedric Mauclair
@ 2010-10-28  8:24         ` Cedric Mauclair
  2010-10-28 11:47           ` Hans Hagen
  2010-10-28 11:46         ` Hans Hagen
  1 sibling, 1 reply; 14+ messages in thread
From: Cedric Mauclair @ 2010-10-28  8:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Actually, the opacity works great!

-- Cédric



On Thu, Oct 28, 2010 at 09:54, Cedric Mauclair
<cedric.mauclair@gmail.com> wrote:
> On Wed, Oct 27, 2010 at 22:08, Michael Murphy <michael.murphy@uni-ulm.de> wrote:
>> On 27/10/2010 19:18, Marius wrote:
>>>
>>> Hello,
>>> I had the same problem, so I desided to define colors by hand.
>>>
>>> \definecolor [lightgray] [h=D3D3D3]
>>>
>>> \usemodule[tikz]
>>>
>>> \unprotect
>>> \pgfutil@definecolor{black}{gray}{0}
>>> \pgfutil@definecolor{gray}{gray}{0.5}
>>> \pgfutil@definecolor{lightgray}{gray}{0.9}
>>> \pgfutil@definecolor{white}{gray}{1}
>>> \protect
>>
>> Yes, this is what I've resorted to. But it would be nice to define things
>> properly.
>>
>>> If you want to fix script, you need to change line:
>>>
>>> local cv = colors.value(attributes)
> The table "colors" is expected to have a function named "value" that
> take the "attributes" parameter as its sole parameter itself. It then
> assigns the result to the local variable cv. After some research,
> adding  "local colors = global.attributes.colors" below the line
> "local prtcatcodes = tex.prtcatcodes" works. There is a catch however,
> you can't use opacity on these colors. I suppose we have to generate
> all the transparency level by using spot colors or something like
> that.
>
> However, I still need to
> add"\let\appendtoPDFdocumentcolorspaces\gobbleoneargument"
> "\let\appendtoPDFdocumentextgstates\gobbleoneargument" and
> "\let\PDFcolor\gobbleoneargument" before loading the TikZ module in
> order for my documents to build without errors. These macros used to
> be defined in mkii (spec-fdf.mkii) and TikZ relies on them
> (tex/generic/pgf/utilities/pgfutil-context.def) but not anymore in
> mkiv since the color support has changed between mkii and mkiv. I
> suppose they had to do with the color support for PDF files, but
> letting them gobble their argument still seems to work. On what side
> should this problem be looked into: ConTeXt or TikZ?
>
> Regards.
>
> -- Cédric
>
>>>
>>> into
>>>
>>> local cv = attributes.colors.values
>>>
>>> Just guess, untested.
>>
>> Nope, doesn't work. Using
>>
>> local colors = colors or { }
>>
>> gets me a little further, but then complains that 'value' is a nil value. I
>> don't know enough Lua to fix this either. Strangely, it seems to work on
>> some older MkIV versions of ConTeXt...
>>
>> Michael.
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>>
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-27 20:08     ` Michael Murphy
  2010-10-28  7:54       ` Cedric Mauclair
@ 2010-10-28  9:44       ` Marius
  1 sibling, 0 replies; 14+ messages in thread
From: Marius @ 2010-10-28  9:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

Here is the fixed script.

On 27 October 2010 23:08, Michael Murphy <michael.murphy@uni-ulm.de> wrote:
> On 27/10/2010 19:18, Marius wrote:
>>
>> Hello,
>> I had the same problem, so I desided to define colors by hand.
>>
>> \definecolor [lightgray] [h=D3D3D3]
>>
>> \usemodule[tikz]
>>
>> \unprotect
>> \pgfutil@definecolor{black}{gray}{0}
>> \pgfutil@definecolor{gray}{gray}{0.5}
>> \pgfutil@definecolor{lightgray}{gray}{0.9}
>> \pgfutil@definecolor{white}{gray}{1}
>> \protect
>
> Yes, this is what I've resorted to. But it would be nice to define things
> properly.
>
>> If you want to fix script, you need to change line:
>>
>> local cv = colors.value(attributes)
>>
>> into
>>
>> local cv = attributes.colors.values
>>
>> Just guess, untested.
>
> Nope, doesn't work. Using
>
> local colors = colors or { }
>
> gets me a little further, but then complains that 'value' is a nil value. I
> don't know enough Lua to fix this either. Strangely, it seems to work on
> some older MkIV versions of ConTeXt...
>
> Michael.
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>

[-- Attachment #2: colorfix.tex --]
[-- Type: application/x-tex, Size: 1191 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-28  7:54       ` Cedric Mauclair
  2010-10-28  8:24         ` Cedric Mauclair
@ 2010-10-28 11:46         ` Hans Hagen
  2010-10-28 12:14           ` Cedric Mauclair
  1 sibling, 1 reply; 14+ messages in thread
From: Hans Hagen @ 2010-10-28 11:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 4694 bytes --]

On 28-10-2010 9:54, Cedric Mauclair wrote:
> On Wed, Oct 27, 2010 at 22:08, Michael Murphy<michael.murphy@uni-ulm.de>  wrote:
>> On 27/10/2010 19:18, Marius wrote:
>>>
>>> Hello,
>>> I had the same problem, so I desided to define colors by hand.
>>>
>>> \definecolor [lightgray] [h=D3D3D3]
>>>
>>> \usemodule[tikz]
>>>
>>> \unprotect
>>> \pgfutil@definecolor{black}{gray}{0}
>>> \pgfutil@definecolor{gray}{gray}{0.5}
>>> \pgfutil@definecolor{lightgray}{gray}{0.9}
>>> \pgfutil@definecolor{white}{gray}{1}
>>> \protect
>>
>> Yes, this is what I've resorted to. But it would be nice to define things
>> properly.
>>
>>> If you want to fix script, you need to change line:
>>>
>>> local cv = colors.value(attributes)
> The table "colors" is expected to have a function named "value" that
> take the "attributes" parameter as its sole parameter itself. It then
> assigns the result to the local variable cv. After some research,
> adding  "local colors = global.attributes.colors" below the line
> "local prtcatcodes = tex.prtcatcodes" works. There is a catch however,
> you can't use opacity on these colors. I suppose we have to generate
> all the transparency level by using spot colors or something like
> that.

There are several solutions to the problem.

\usemodule[tikz]

\startmode[mkiv]

\startluacode
thirddata     = thirddata     or { }
thirddata.pgf = thirddata.pgf or { }

local texsprint, prtcatcodes, format = tex.sprint, tex.prtcatcodes, 
string.format

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

local colors = attributes.colors

function thirddata.pgf.registercolor(name,attribute) -- solution 1
     local cv = colors.value(attribute)
     if cv then
         local model = colors.forcedmodel(cv[1])
         if model > 3 then
             model = 3 -- no cmyk or spot or multitone
         end
         if model == 2 then
 
texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{%1.3f}", 
name, cv[2]))
         elseif model == 3 then
 
texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{rgb}{%1.3f,%1.3f,%1.3f}", 
name, cv[3], cv[4], cv[5]))
         else
             unsupported_color(name)
         end
     else
         unsupported_color(name)
     end
end

function lpdf.pdfcolor(attribute)
     context(lpdf.color(1,attribute))
end
\stopluacode

\stopmode

\unprotect

% solution 1 (also fallback when cmyk is used):

% \def\PDFcolor#1%
%   {\ctxlua{thirddata.pgf.pdfcolor(\thecolorattribute{#1})}}

% solution 2 (faster as less parsing at the tex end):

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

% solution 3 (backward compatible):

\def\PDFcolor#1%
   {\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}}

\protect

\definecolor[mycolora][r=1,g=0,b=1]
\definecolor[mycolorb][m=1]

\starttext
     \starttikzpicture
         \fill[mycolora] (0,0) circle (2);
         \fill[mycolorb] (0,0) circle (1);
     \stoptikzpicture
\stoptext

I'll define \pdfcolor for this purpose as that's what tikz expects.

> However, I still need to
> add"\let\appendtoPDFdocumentcolorspaces\gobbleoneargument"
> "\let\appendtoPDFdocumentextgstates\gobbleoneargument" and
> "\let\PDFcolor\gobbleoneargument" before loading the TikZ module in
> order for my documents to build without errors. These macros used to
> be defined in mkii (spec-fdf.mkii) and TikZ relies on them
> (tex/generic/pgf/utilities/pgfutil-context.def) but not anymore in
> mkiv since the color support has changed between mkii and mkiv. I
> suppose they had to do with the color support for PDF files, but
> letting them gobble their argument still seems to work. On what side
> should this problem be looked into: ConTeXt or TikZ?

In pgfutil-context.def there should be no such commands called when mkiv 
is used. Isn't there a

\doifmodeelse {mkiv} { ...

section? anyhow, in that section one can add

\ifdefined\PDFcolor \else

   \ctxlua{function lpdf.pdfcolor(attribute) 
context(lpdf.color(1,attribute)) end}

   \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}}

\fi

(in the next beta this is not needed as \PDFcolor is defined then)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: t-tikz-hans.tex --]
[-- Type: text/x-tex, Size: 9876 bytes --]

% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

% The aux files, needed for reading back coordinates

\def\pgfutil@aux@read@hook{
  \pgfutil@IfFileExists{\jobname.pgf}{\input \jobname.pgf\relax}{}
  \csname newwrite\endcsname\pgfutil@auxout
  \csname openout\endcsname\pgfutil@auxout\jobname.pgf
}

% XColor-like support for ConTeXt

\def\pgfutil@definecolor#1#2#3{\csname pgfutil@emu@#2\endcsname{#1}#3\@nil}

\def\pgfutil@emu@rgb#1#2,#3,#4\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#3,#4}}}
\def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#2,#2}}}

\pgfutil@definecolor{white}{gray}{1}
\pgfutil@definecolor{black}{gray}{0}
\pgfutil@definecolor{gray}{gray}{0.5}
\pgfutil@definecolor{red}{rgb}{1,0,0}
\pgfutil@definecolor{green}{rgb}{0,1,0}
\pgfutil@definecolor{blue}{rgb}{0,0,1}
\pgfutil@definecolor{cyan}{rgb}{0,1,1}
\pgfutil@definecolor{magenta}{rgb}{1,0,1}
\pgfutil@definecolor{yellow}{rgb}{1,1,0}
\pgfutil@definecolor{orange}{rgb}{1,0.5,0}
\pgfutil@definecolor{violet}{rgb}{0.5,0,0.5}
\pgfutil@definecolor{purple}{rgb}{0.75,0,0.25}
\pgfutil@definecolor{brown}{rgb}{0.75,0.5,0.25}

\def\pgfutil@color#1{%
  \pgfutil@colorlet{.}{#1}%
  \pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp%
  {%
    \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
    \pgfsysprotocol@bufferedtrue%
    \pgfsetcolor{.}%
    \expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}%
  }%
  \pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp%
  \aftergroup\pgfutil@reset@color%
}

\def\pgfutil@extractcolorspec#1#2{%
  \def#2{{#1}}%
}

\def\pgfutil@convertcolorspec#1#2#3{%
  \edef#3{\expandafter\expandafter\expandafter\pgfutil@emu@select\csname\string\color@#1\endcsname}%
}


\def\pgfutil@doifcolorelse#1#2#3{%
  \expandafter\ifx\csname\string\color@#1\endcsname\relax%
    \doifcolorelse{#1}{\let\pgf@next=\pgfutil@firstoftwo}{\let\pgf@next=\pgfutil@secondoftwo}%
  \else
    \let\pgf@next=\pgfutil@firstoftwo%
  \fi%
  \pgf@next{#2}{#3}%
}


\def\pgfutil@reset@color{%
  \pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp%
  {%
    \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
    \pgfsysprotocol@bufferedtrue%
    \pgfsetcolor{.}%
    \expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}%
  }%
  \pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp%
}
\expandafter\def\csname\string\color@.\endcsname{\xcolor@{}{}{rgb}{0,0,0}}

\def\pgfutil@colorlet#1#2{%
  \edef\pgf@marshal{#2}%
  \expandafter\pgfutil@in@\expandafter!\expandafter{\pgf@marshal}%
  \ifpgfutil@in@%
    % compute mixture
    {%
      \expandafter\pgfutil@emu@mix\pgf@marshal!white!\@nil%
      \xdef\pgf@marshal{\noexpand\def\expandafter\noexpand\csname\string\color@#1\endcsname{%
          \noexpand\xcolor@{}{}{rgb}{\pgf@sys@tonumber\pgf@xa,\pgf@sys@tonumber\pgf@xb,\pgf@sys@tonumber\pgf@xc}}}%
    }%
    \pgf@marshal%
  \else%
    \expandafter\ifx\csname\string\color@#2\endcsname\relax%
      \pgfutil@registercolor{#2}%
    \fi%
    \edef\pgf@marshal{\noexpand\let\expandafter\noexpand\csname\string\color@#1\endcsname=%
                      \expandafter\noexpand\csname\string\color@#2\endcsname}%
    \pgf@marshal%
  \fi%
}
\def\pgfutil@emu@mix#1!#2!#3!#4\@nil{%
  \expandafter\ifx\csname\string\color@#1\endcsname\relax%
    \pgfutil@registercolor{#1}%
  \fi%
  \expandafter\ifx\csname\string\color@#3\endcsname\relax%
    \pgfutil@registercolor{#3}%
  \fi%
  \expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#1\endcsname%
  \pgf@ya=\pgf@xa%
  \pgf@yb=\pgf@xb%
  \pgf@yc=\pgf@xc%
  \expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#3\endcsname%
  \c@pgf@counta=#2\relax%
  \c@pgf@countb=100\relax%
  \advance\c@pgf@countb by-\c@pgf@counta\relax%
  \pgf@xa=\c@pgf@countb\pgf@xa%
  \advance\pgf@xa by\c@pgf@counta\pgf@ya%
  \divide\pgf@xa by 100\relax%
  \pgf@xb=\c@pgf@countb\pgf@xb%
  \advance\pgf@xb by\c@pgf@counta\pgf@yb%
  \divide\pgf@xb by 100\relax%
  \pgf@xc=\c@pgf@countb\pgf@xc%
  \advance\pgf@xc by\c@pgf@counta\pgf@yc%
  \divide\pgf@xc by 100\relax%
}
\def\pgfutil@emu@unpack#1#2#3#4#5{%
  \pgfutil@emu@@unpack#5\@nil%
}
\def\pgfutil@emu@@unpack#1,#2,#3\@nil{%
  \pgf@xa=#1pt%
  \pgf@xb=#2pt%
  \pgf@xc=#3pt%
}

\def\pgfutil@emu@select#1#2#3#4#5{#5}


\def\pgfutil@registercolor#1{%
  \edef\pgf@temp{\PDFcolor{#1}}%
  \edef\pgf@marshal{\noexpand\pgfutil@in@{ g}{\pgf@temp}}%
  \pgf@marshal%
  \ifpgfutil@in@%
    \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}%
  \else%
    \edef\pgf@marshal{\noexpand\pgfutil@in@{ rg}{\pgf@temp}}%
    \pgf@marshal%
    \ifpgfutil@in@%
      \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}%
    \else%
      \PackageError{pgf}{Color #1 has an unsupported color model.}{}%
      \pgfutil@definecolor{#1}{gray}{0}
    \fi%
  \fi%
}

\def\pgfutil@context@parse@gray#1 g#2\pgf@stop#3{%
  \pgfutil@definecolor{#3}{gray}{#1}
}

\def\pgfutil@context@parse@rgb#1 #2 #3 rg#4\pgf@stop#5{%
  \pgfutil@definecolor{#5}{rgb}{#1,#2,#3}
}

% Make this command available in general:
\let\colorlet=\pgfutil@colorlet


% pgfutil@minipage

\def\pgfutil@minipage[#1]#2{%
  \hbox to#2\bgroup%
    \hsize=#2\relax%
    \vbox\bgroup\leavevmode%
}
\def\pgfutil@endminipage{\egroup\egroup}



% Driver detector (how should we do this in ConTeXt?) :

\ifx\pdfoutput\@undefined\newcount\pdfoutput\fi
\ifx\pdfoutput\relax\newcount\pdfoutput\fi

\def\pgfutil@guessdriver{
  \ifx\XeTeXversion\@undefined
    \ifx\preloadedspecials\@undefined%
      \ifcase\pdfoutput%
        \def\pgfsysdriver{pgfsys-dvips.def}%
      \else%
        \def\pgfsysdriver{pgfsys-pdftex.def}% pdfTeX & LuaTeX
      \fi%
    \else%
      \pgfutil@driver@if@in{postscript}{pgfsys-dvips.def}
      \pgfutil@driver@if@in{tpd}{pgfsys-pdftex.def}
      \pgfutil@driver@if@in{dpm}{pgfsys-dvipdfm.def}
      \pgfutil@driver@if@in{dpx}{pgfsys-dvipdfmx.def}
      \pgfutil@driver@if@in{xetex}{pgfsys-xetex.def}
      \ifx\pgfsysdriver\relax%
        \PackageWarning{pgf}{I was not able to discern the driver, the
          preloaded specials were \preloadedspecials. I am going to use
          pgfsys-dvips.def}%
        \def\pgfsysdriver{pgfsys-dvips.def}
      \fi%
    \fi
  \else
    \def\pgfsysdriver{pgfsys-xetex.def}% should be right
  \fi
}
\def\pgfutil@driver@if@in#1#2{%
  \edef\pgf@marshal{\noexpand\pgfutil@in@{#1}{\preloadedspecials}}
  \pgf@marshal
  \ifpgfutil@in@%
    \def\pgfsysdriver{#2}%
  \fi%
}


% Global colors

\let\pgfutil@globalcolorsfalse=\relax
\let\pgfutil@globalcolorstrue=\relax



% Font stuff

\def\pgfutil@font@tiny{\tfxx}
\def\pgfutil@font@scriptsize{\tfxx}
\def\pgfutil@font@footnotesize{\tfx}
\def\pgfutil@font@small{\tfx}
\def\pgfutil@font@normalsize{\tf}
\def\pgfutil@font@large{\tfa}
\def\pgfutil@font@Large{\tfb}
\def\pgfutil@font@huge{\tfc}
\def\pgfutil@font@Huge{\tfc}

\def\pgfutil@font@itshape{\it}
\def\pgfutil@font@bfseries{\bf}

\let\pgfutil@font@normalfont=\tf

\let\pgfutil@selectfont=\tf


% Extra counters, registers, boxes

\newcount\pgfutil@tempcnta
\newcount\pgfutil@tempcntb

\newbox\pgfutil@tempboxa

\newdimen\pgfutil@tempdima
\newdimen\pgfutil@tempdimb

\newbox  \pgfutil@voidb@x
\newtoks \pgfutil@toks@

% Module stuff

\def\pgfutil@usemodule#1{\usemodule[#1]}

% % % % begin patches by HH % % % %

\let\pgfutil@insertatbegincurrentpagefrombox\flushatshipout
\let\pgfutil@insertatbegincurrentpage       \flushatshipout
\def\pgfutil@insertatbegineverypage         #1{\appendtoks#1\to\everyshipout} % space removed after #1

\let\pgfutil@setuppdfresources \relax

\doifmodeelse {mkiv} {

    \def\pgf@sys@pdf@pdfbackendset@one#1#2%
      {\normalexpanded{\noexpand\pgf@sys@pdf@pdfbackendset@two\noexpand#1#2\relax}}

    \def\pgf@sys@pdf@pdfbackendset@two#1/#2 #3\relax
      {#1{#2}{#3}}

    \def\pgf@sys@pdf@addtopageresource@pattern   {\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetpattern}
    \def\pgf@sys@pdf@addtopageresource@colorspace{\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetcolorspace}
    \def\pgf@sys@pdf@addtopageresource@extgstate {\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetextgstate}
    \def\pgf@sys@pdf@possible@resources          {\pdfbackendcurrentresources}
    \def\pgf@sys@pdf@check@resources             {}

    \ifdefined\PDFcolor \else

        \ctxlua{function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute)) end}

        \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}}

    \fi

} {

    \def\pgf@sys@pdf@addtopageresource@extgstate  {\appendtoPDFdocumentextgstates }
    \def\pgf@sys@pdf@addtopageresource@colorspace {\appendtoPDFdocumentcolorspaces}
    \def\pgf@sys@pdf@addtopageresource@pattern    {\appendtoPDFdocumentpatterns   }
    \def\pgf@sys@pdf@possible@resources           {\currentPDFresources}
    \def\pgf@sys@pdf@check@resources              {}

}

\let\pgf@sys@addpdfresource@extgs@plain      \pgf@sys@pdf@addtopageresource@extgstate
\let\pgf@sys@addpdfresource@patterns@plain   \pgf@sys@pdf@addtopageresource@pattern
\let\pgf@sys@addpdfresource@colorspaces@plain\pgf@sys@pdf@addtopageresource@colorspace
\let\pgf@sys@pdf@check@resources@plain       \pgf@sys@pdf@check@resources

\pgf@sys@addpdfresource@colorspaces@plain{/pgfprgb [/Pattern /DeviceRGB]}

% % % % end patches by HH % % % %

% Do something at the end of a job

\appendtoks \the\pgfutil@everybye \to \everybye

% The following is still messy and needs to be cleanup up (everything
% prefixed by pgfutil@):

\def\PackageInfo#1#2{}
\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}%
\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}%
\long\def\AtBeginDocument#1{#1}%

\endinput

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-28  8:24         ` Cedric Mauclair
@ 2010-10-28 11:47           ` Hans Hagen
  0 siblings, 0 replies; 14+ messages in thread
From: Hans Hagen @ 2010-10-28 11:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 28-10-2010 10:24, Cedric Mauclair wrote:
> Actually, the opacity works great!

Officially it could hook into the context transparency model but I guess 
that that is too much hassle.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: ConText, TikZ and definecolor: undefined control sequence
  2010-10-28 11:46         ` Hans Hagen
@ 2010-10-28 12:14           ` Cedric Mauclair
  0 siblings, 0 replies; 14+ messages in thread
From: Cedric Mauclair @ 2010-10-28 12:14 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

Sadly no. I once tried to modify it to make it work and I ended up
with what I proposed. Not very nice, but worked for me.

Thanks for your solution.

-- Cédric



On Thu, Oct 28, 2010 at 13:46, Hans Hagen <pragma@wxs.nl> wrote:
>
> \ifdefined\PDFcolor \else
>
>  \ctxlua{function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute))
> end}
>
>  \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}}
>
> \fi
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Tikz figures not centred
  2010-10-26 10:20 ConText, TikZ and definecolor: undefined control sequence Michael Murphy
  2010-10-27 12:49 ` Cedric Mauclair
@ 2010-11-11 11:07 ` Michael Murphy
  2010-11-11 11:14   ` Vedran Miletić
  1 sibling, 1 reply; 14+ messages in thread
From: Michael Murphy @ 2010-11-11 11:07 UTC (permalink / raw)
  To: Context Mailing List

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

Hi,

I've been having some problems with tikz figures. When I define a new
tikz figure, I normally put it in a buffer:

\startbuffer[mypic]
	\starttikzfigure
		...
	\stoptikzfigure
\stopbuffer

which I use later when I place the figure

\placefigure{My picture}{\getbuffer[mypic]}

The problem is that the figure is not centred: it is always aligned with
the left side of the document. I guess this has something to do with
Context not being able to get the image bounds, since it works fine for
tikz images that are already precompiled into PDFs:

\placefigure{My picture}{\externalimage[mypic.pdf]}

Minimal example is attached.

Michael.

-- 
Michael Murphy <michael.murphy@uni-ulm.de>
University of Ulm

[-- Attachment #2: min_tikz_nocenter.tex --]
[-- Type: text/x-tex, Size: 390 bytes --]

\usemodule[tikz]

\starttext

\startbuffer[tikz-picture]
  \starttikzpicture
    \fill[red] (0,0) circle (2);
  \stoptikzpicture
\stopbuffer

\placefigure{A tikz figure}{\getbuffer[tikz-picture]}

\placefigure{Another tikz figure}{
  \starttikzpicture
    \fill[red] (0,0) circle (2);
  \stoptikzpicture
}

\placefigure{An external tikz figure}{
  \externalfigure[tikzfig.pdf]
}

\stoptext

[-- Attachment #3: tikzfig.pdf --]
[-- Type: application/pdf, Size: 3107 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Tikz figures not centred
  2010-11-11 11:07 ` Tikz figures not centred Michael Murphy
@ 2010-11-11 11:14   ` Vedran Miletić
  2010-11-11 16:18     ` Michael Murphy
  0 siblings, 1 reply; 14+ messages in thread
From: Vedran Miletić @ 2010-11-11 11:14 UTC (permalink / raw)
  To: michael.murphy, mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 949 bytes --]

2010/11/11 Michael Murphy <michael.murphy@uni-ulm.de>

> Hi,
>
> I've been having some problems with tikz figures. When I define a new
> tikz figure, I normally put it in a buffer:
>
> \startbuffer[mypic]
>        \starttikzfigure
>                ...
>        \stoptikzfigure
> \stopbuffer
>
> which I use later when I place the figure
>
> \placefigure{My picture}{\getbuffer[mypic]}
>
> The problem is that the figure is not centred: it is always aligned with
> the left side of the document. I guess this has something to do with
> Context not being able to get the image bounds, since it works fine for
> tikz images that are already precompiled into PDFs:
>
> \placefigure{My picture}{\externalimage[mypic.pdf]}
>
> Minimal example is attached.
>
> Michael.
>
>
You have to wrap up the picture inside of a \hbox, e.g.

\hbox{\starttikzfigure
       ...
    \stoptikzfigure}

Regards,

-- 
Vedran Miletić

[-- Attachment #1.2: Type: text/html, Size: 1361 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Tikz figures not centred
  2010-11-11 11:14   ` Vedran Miletić
@ 2010-11-11 16:18     ` Michael Murphy
  2010-11-11 19:34       ` Aditya Mahajan
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Murphy @ 2010-11-11 16:18 UTC (permalink / raw)
  To: Vedran Miletić; +Cc: mailing list for ConTeXt users

On Thu, 2010-11-11 at 12:14 +0100, Vedran Miletić wrote:
> 2010/11/11 Michael Murphy <michael.murphy@uni-ulm.de>
>         Hi,
>         
>         I've been having some problems with tikz figures. When I
>         define a new
>         tikz figure, I normally put it in a buffer:
>         
>         \startbuffer[mypic]
>                \starttikzfigure
>                        ...
>                \stoptikzfigure
>         \stopbuffer
>         
>         which I use later when I place the figure
>         
>         \placefigure{My picture}{\getbuffer[mypic]}
>         
>         The problem is that the figure is not centred: it is always
>         aligned with
>         the left side of the document. I guess this has something to
>         do with
>         Context not being able to get the image bounds, since it works
>         fine for
>         tikz images that are already precompiled into PDFs:
>         
>         \placefigure{My picture}{\externalimage[mypic.pdf]}
>         
>         Minimal example is attached.
>         
>         Michael.
>         
> 
> You have to wrap up the picture inside of a \hbox, e.g.
> 
> \hbox{\starttikzfigure
>        ...
>     \stoptikzfigure}
> 
> Regards,
> 
> -- 
> Vedran Miletić

Hmm, why didn't I think of that... Thanks!

-- 
Michael Murphy <michael.murphy@uni-ulm.de>
University of Ulm

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Tikz figures not centred
  2010-11-11 16:18     ` Michael Murphy
@ 2010-11-11 19:34       ` Aditya Mahajan
  0 siblings, 0 replies; 14+ messages in thread
From: Aditya Mahajan @ 2010-11-11 19:34 UTC (permalink / raw)
  To: michael.murphy, mailing list for ConTeXt users

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

On Thu, 11 Nov 2010, Michael Murphy wrote:

> On Thu, 2010-11-11 at 12:14 +0100, Vedran Miletić wrote:
>> 2010/11/11 Michael Murphy <michael.murphy@uni-ulm.de>
>>         Hi,
>>
>>         I've been having some problems with tikz figures. When I
>>         define a new
>>         tikz figure, I normally put it in a buffer:
>>
>>         \startbuffer[mypic]
>>                \starttikzfigure
>>                        ...
>>                \stoptikzfigure
>>         \stopbuffer
>>
>>         which I use later when I place the figure
>>
>>         \placefigure{My picture}{\getbuffer[mypic]}
>>
>>         The problem is that the figure is not centred: it is always
>>         aligned with
>>         the left side of the document. I guess this has something to
>>         do with
>>         Context not being able to get the image bounds, since it works
>>         fine for
>>         tikz images that are already precompiled into PDFs:
>>
>>         \placefigure{My picture}{\externalimage[mypic.pdf]}
>>
>>         Minimal example is attached.
>>
>>         Michael.
>>
>>
>> You have to wrap up the picture inside of a \hbox, e.g.
>>
>> \hbox{\starttikzfigure
>>        ...
>>     \stoptikzfigure}
>>
>> Regards,
>>
>> --
>> Vedran Miletić
>
> Hmm, why didn't I think of that... Thanks!

See 
http://archive.contextgarden.net/thread/20090722.010815.d9c051d3.en.html 
for an old discussion on this.

Aditya

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-11-11 19:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 10:20 ConText, TikZ and definecolor: undefined control sequence Michael Murphy
2010-10-27 12:49 ` Cedric Mauclair
2010-10-27 17:18   ` Marius
2010-10-27 20:08     ` Michael Murphy
2010-10-28  7:54       ` Cedric Mauclair
2010-10-28  8:24         ` Cedric Mauclair
2010-10-28 11:47           ` Hans Hagen
2010-10-28 11:46         ` Hans Hagen
2010-10-28 12:14           ` Cedric Mauclair
2010-10-28  9:44       ` Marius
2010-11-11 11:07 ` Tikz figures not centred Michael Murphy
2010-11-11 11:14   ` Vedran Miletić
2010-11-11 16:18     ` Michael Murphy
2010-11-11 19:34       ` 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).