Different colors in LaTeX and ConTeXt
Dear list, I wanted to draw some nice pictures using TikZ and pgfplots, but then I noticed that the colors of the ticks in my pgfplots graph were unusually bright and it looked very weird. So I set up a test
\usemodule[tikz] \starttext \starttikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \stoptikzpicture
\externalfigure[test-crop] \stoptext
where I produced test-crop.pdf from the following plain TeX sample, which I also typeset with LuaTeX 0.95 (to make sure it's not a LuaTeX regression).
\input luatex85.sty \input tikz \tikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \endtikzpicture \bye
Attached you find the output of the ConTeXt example and you can see that the color of the upper line (the one produced with TikZ inside ConTeXt) has a much brighter color than the one produced with plain TeX. I'm using ConTeXt MkIV distributed with TL 2016. How can I adjust the colors in ConTeXt to match the ones produced by plain TeX? I need the adjustment in that direction, because I also have old images produced with plain TeX/LaTeX that I'd like to seamlessly integrate in my ConTeXt documents. Cheers, Henri
On 7/12/2016 1:53 PM, Henri Menke wrote:
Dear list,
I wanted to draw some nice pictures using TikZ and pgfplots, but then I noticed that the colors of the ticks in my pgfplots graph were unusually bright and it looked very weird. So I set up a test
\usemodule[tikz] \starttext \starttikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \stoptikzpicture
\externalfigure[test-crop] \stoptext
where I produced test-crop.pdf from the following plain TeX sample, which I also typeset with LuaTeX 0.95 (to make sure it's not a LuaTeX regression).
\input luatex85.sty \input tikz \tikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \endtikzpicture \bye
Attached you find the output of the ConTeXt example and you can see that the color of the upper line (the one produced with TikZ inside ConTeXt) has a much brighter color than the one produced with plain TeX.
I'm using ConTeXt MkIV distributed with TL 2016.
How can I adjust the colors in ConTeXt to match the ones produced by plain TeX? I need the adjustment in that direction, because I also have old images produced with plain TeX/LaTeX that I'd like to seamlessly integrate in my ConTeXt documents.
you need to figure out the default definitions in tikz then (i suppose 'help lines' is related to some color) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Dear Hans, thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround. Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem. Cheers, Henri On 07/12/2016 02:29 PM, Hans Hagen wrote:
On 7/12/2016 1:53 PM, Henri Menke wrote:
Dear list,
I wanted to draw some nice pictures using TikZ and pgfplots, but then I noticed that the colors of the ticks in my pgfplots graph were unusually bright and it looked very weird. So I set up a test
\usemodule[tikz] \starttext \starttikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \stoptikzpicture
\externalfigure[test-crop] \stoptext
where I produced test-crop.pdf from the following plain TeX sample, which I also typeset with LuaTeX 0.95 (to make sure it's not a LuaTeX regression).
\input luatex85.sty \input tikz \tikzpicture \draw[help lines,very thick] (0,0) -- (1,0); \endtikzpicture \bye
Attached you find the output of the ConTeXt example and you can see that the color of the upper line (the one produced with TikZ inside ConTeXt) has a much brighter color than the one produced with plain TeX.
I'm using ConTeXt MkIV distributed with TL 2016.
How can I adjust the colors in ConTeXt to match the ones produced by plain TeX? I need the adjustment in that direction, because I also have old images produced with plain TeX/LaTeX that I'd like to seamlessly integrate in my ConTeXt documents.
you need to figure out the default definitions in tikz then (i suppose 'help lines' is related to some color)
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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 ___________________________________________________________________________________
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well. Perhaps, one could define a macro `\enabletikzcolors[...list..]` that will do the appropriate translations. Aditya
On 7/12/2016 5:07 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well.
I have no clue what you mean. \definecolor[red][g=1] \startTEXpage \starttikzpicture \fill[red] (0,0) circle (1cm); \stoptikzpicture \stopTEXpage works ok here and gives green. So, one can collect a list of colors defined in tikz in a colo-imp-tikz.mkiv and load that one if needed.
Perhaps, one could define a macro `\enabletikzcolors[...list..]` that will do the appropriate translations.
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 5:07 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well.
I have no clue what you mean.
\definecolor[red][g=1]
\startTEXpage \starttikzpicture \fill[red] (0,0) circle (1cm); \stoptikzpicture \stopTEXpage
works ok here and gives green. So, one can collect a list of colors defined in tikz in a colo-imp-tikz.mkiv and load that one if needed.
I guess it is a bug with pgfplots rather than tikz (which also means that it may be easier to pursuade pgfplot maintainers to use low level tikz interface, since tikz is already playing nice with context). \usemodule[tikz,pgfplots] \definecolor[red][g=1] \startmode[bug] \unprotect \pgfutil@definecolor{red} {rgb} {0,1,0} \protect \stopmode \starttext \startTEXpage \starttikzpicture \startaxis \addplot[color=red] coordinates { (0,0) (1,1) }; \stopaxis \stoptikzpicture \stopTEXpage \stoptext Aditya
Dear Aditya and Hans, I'm not so sure about it being a bug in pgfplots. I played a little and encountered the following.
\usemodule[tikz] \starttext
% Original gray \blackrule[color=gray,width=1cm,height=1pt]
\starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% New colors \definecolor[gray][s=0.5] \unprotect \pgfutil@definecolor{tikzgray}{gray}{0.5} \protect
% Now ConTeXt's gray = tikzgray \blackrule[color=gray,width=1cm,height=1pt]
\starttikzpicture \draw[tikzgray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% Inside TikZ gray is still off \starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
\stoptext
Cheers, Henri On 07/12/2016 08:23 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 5:07 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
% no need for x colors (users can load it if needed) ... %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
\csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well.
I have no clue what you mean.
\definecolor[red][g=1]
\startTEXpage \starttikzpicture \fill[red] (0,0) circle (1cm); \stoptikzpicture \stopTEXpage
works ok here and gives green. So, one can collect a list of colors defined in tikz in a colo-imp-tikz.mkiv and load that one if needed.
I guess it is a bug with pgfplots rather than tikz (which also means that it may be easier to pursuade pgfplot maintainers to use low level tikz interface, since tikz is already playing nice with context).
\usemodule[tikz,pgfplots] \definecolor[red][g=1]
\startmode[bug] \unprotect \pgfutil@definecolor{red} {rgb} {0,1,0} \protect \stopmode
\starttext \startTEXpage \starttikzpicture \startaxis \addplot[color=red] coordinates { (0,0) (1,1) }; \stopaxis \stoptikzpicture \stopTEXpage \stoptext
Aditya
___________________________________________________________________________________ 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 ___________________________________________________________________________________
What is the fuss? \starttext \startMPcode draw origin--right scaled 1cm withpen pencircle scaled 1pt withcolor gray ; \stopMPcode \stoptext works just fine... :-) Alan
On 7/12/2016 9:39 PM, Henri Menke wrote:
Dear Aditya and Hans,
I'm not so sure about it being a bug in pgfplots. I played a little and encountered the following.
As Aditya pointed out, these (probably used for tracing) colors are defined in such a way that they don't go via the context resolver. As these (few) colors are basically x windows colors, you can start your document with: \usecolors[xwi] which will set the context colors differently.
\usemodule[tikz] \starttext
% Original gray \blackrule[color=gray,width=1cm,height=1pt]
\starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% New colors \definecolor[gray][s=0.5] \unprotect \pgfutil@definecolor{tikzgray}{gray}{0.5} \protect
% Now ConTeXt's gray = tikzgray \blackrule[color=gray,width=1cm,height=1pt]
How is that supposed to work? Context will not inherit colors from tikz, the most you can expect is the reverse: tikz using context color definitions.
\starttikzpicture \draw[tikzgray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% Inside TikZ gray is still off \starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
\stoptext
Cheers, Henri
On 07/12/2016 08:23 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 5:07 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote:
Dear Hans,
thanks for your reply. Indeed there are color definitions in `pgfutil-context.def`. However, they are commented out with the message
> % no need for x colors (users can load it if needed) > ... > %\pgfutil@definecolor{gray}{gray}{0.5}
If I add
> \csname pgfutil@definecolor\endcsname{gray}{gray}{0.5}
to my document the gray shows up fine. So that's for sure a feasible workaround.
Can you comment on the phrase »no need for x colors (users can load it if needed)«? I'm not quite sure what it means and it suggests that there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well.
I have no clue what you mean.
\definecolor[red][g=1]
\startTEXpage \starttikzpicture \fill[red] (0,0) circle (1cm); \stoptikzpicture \stopTEXpage
works ok here and gives green. So, one can collect a list of colors defined in tikz in a colo-imp-tikz.mkiv and load that one if needed.
I guess it is a bug with pgfplots rather than tikz (which also means that it may be easier to pursuade pgfplot maintainers to use low level tikz interface, since tikz is already playing nice with context).
\usemodule[tikz,pgfplots] \definecolor[red][g=1]
\startmode[bug] \unprotect \pgfutil@definecolor{red} {rgb} {0,1,0} \protect \stopmode
\starttext \startTEXpage \starttikzpicture \startaxis \addplot[color=red] coordinates { (0,0) (1,1) }; \stopaxis \stoptikzpicture \stopTEXpage \stoptext
Aditya
___________________________________________________________________________________ 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 ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 07/12/2016 10:03 PM, Hans Hagen wrote:
On 7/12/2016 9:39 PM, Henri Menke wrote:
Dear Aditya and Hans,
I'm not so sure about it being a bug in pgfplots. I played a little and encountered the following.
As Aditya pointed out, these (probably used for tracing) colors are defined in such a way that they don't go via the context resolver. As these (few) colors are basically x windows colors, you can start your document with:
\usecolors[xwi]
which will set the context colors differently.
Adding \usecolors[xwi] to the example does not change anything. Looking at base/colo-imp-xwi.mkiv revealed, that it does not alter the way colors are defined, but just defines a huge bunch of additional ones.
\usemodule[tikz] \starttext
% Original gray \blackrule[color=gray,width=1cm,height=1pt]
\starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% New colors \definecolor[gray][s=0.5] \unprotect \pgfutil@definecolor{tikzgray}{gray}{0.5} \protect
% Now ConTeXt's gray = tikzgray \blackrule[color=gray,width=1cm,height=1pt]
How is that supposed to work? Context will not inherit colors from tikz, the most you can expect is the reverse: tikz using context color definitions.
I'm very sorry for the confusion. What I did was to adjust ConTeXt's gray to have the same grayscale value as the tikzgray. As is shown below, the redefinition of gray does not propagate to TikZ.
\starttikzpicture \draw[tikzgray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
% Inside TikZ gray is still off \starttikzpicture \draw[gray,line width=1pt] (0,0) -- (1,0); \stoptikzpicture
\stoptext
In pgfutil-context.def there is though \let\pgfutil@registergray \pgf@context@registergray So it seems as if gray *should* be propagated from ConTeXt to TikZ, which apparently takes place when loading TikZ. Moving \definecolor[gray][s=0.5] before \usemodule[tikz] shows this behavior. The question is how to keep colors from ConTeXt and TikZ in sync. Cheers, Henri
Cheers, Henri
On 07/12/2016 08:23 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 5:07 PM, Aditya Mahajan wrote:
On Tue, 12 Jul 2016, Hans Hagen wrote:
On 7/12/2016 3:44 PM, Henri Menke wrote: > Dear Hans, > > thanks for your reply. Indeed there are color definitions in > `pgfutil-context.def`. However, they are commented out with the message > >> % no need for x colors (users can load it if needed) >> ... >> %\pgfutil@definecolor{gray}{gray}{0.5} > > If I add > >> \csname pgfutil@definecolor\endcsname{gray}{gray}{0.5} > > to my document the gray shows up fine. So that's for sure a > feasible > workaround. > > Can you comment on the phrase »no need for x colors (users can > load it > if needed)«? I'm not quite sure what it means and it suggests that > there exists a proper solution to my color problem.
normally you want the same colors in tikz images as in context so then defining them in tikz is creating incompatibilities (your case is the reverse and a-typical)
However, without such redefinitions, tikz does not understand ConTeXt colors. I use a similar workaround in my documents as well.
I have no clue what you mean.
\definecolor[red][g=1]
\startTEXpage \starttikzpicture \fill[red] (0,0) circle (1cm); \stoptikzpicture \stopTEXpage
works ok here and gives green. So, one can collect a list of colors defined in tikz in a colo-imp-tikz.mkiv and load that one if needed.
I guess it is a bug with pgfplots rather than tikz (which also means that it may be easier to pursuade pgfplot maintainers to use low level tikz interface, since tikz is already playing nice with context).
\usemodule[tikz,pgfplots] \definecolor[red][g=1]
\startmode[bug] \unprotect \pgfutil@definecolor{red} {rgb} {0,1,0} \protect \stopmode
\starttext \startTEXpage \starttikzpicture \startaxis \addplot[color=red] coordinates { (0,0) (1,1) }; \stopaxis \stoptikzpicture \stopTEXpage \stoptext
Aditya
___________________________________________________________________________________
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 ___________________________________________________________________________________
On 7/12/2016 11:17 PM, Henri Menke wrote:
Adding \usecolors[xwi] to the example does not change anything. Looking at base/colo-imp-xwi.mkiv revealed, that it does not alter the way colors are defined, but just defines a huge bunch of additional ones.
afaiks it has the same 'gray' as tikz 'gray' and that is what you want
I'm very sorry for the confusion. What I did was to adjust ConTeXt's gray to have the same grayscale value as the tikzgray. As is shown below, the redefinition of gray does not propagate to TikZ.
that is as Aditya mentioned probably due to the fact that some of these built in colors are not using the normal color resolver and there's nothing we can do about (apart from rewriting part of the tikz color interface which is not on my agenda)
So it seems as if gray *should* be propagated from ConTeXt to TikZ, which apparently takes place when loading TikZ. Moving \definecolor[gray][s=0.5] before \usemodule[tikz] shows this behavior.
The question is how to keep colors from ConTeXt and TikZ in sync.
by defining them in your document (at least these 10 or so predefined colors) (you could have similar issues with colors defined in rgb or cmky in one or the other) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Aditya Mahajan
-
Alan BRASLAU
-
Hans Hagen
-
Henri Menke