Bug or feature: tikz interprets color specification differently for rectangles
When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.
In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
tikz-pgf color
add a comment |
When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.
In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
tikz-pgf color
add a comment |
When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.
In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
tikz-pgf color
When drawing a rectangle, Tikz interprets color in two different ways, depending on in which order it is specified among the options.
In the example below: When color is specified first, as in the first two example, it is used to color the frame of the rectangle---as I'd expect. But in the third rectangle, the red color specification actually fills the rectangle with red. Is this expected?
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,color=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
tikz-pgf color
tikz-pgf color
asked Jan 3 at 17:24
Máté WierdlMáté Wierdl
53729
53729
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Yes it's a feature, because this color
key rewrites the color value on the draw
,fill
and text
key, I quote the 3.1 manual on page 168 (15.2 Specifying a Color):
/tikz/color=<color name> (no default)
This option sets the color that
is used for fill, drawing, and text inside the current scope.
TikZ allows you to change the color value of the lines made with draw
and the color value of the coloring made with fill
separately.
The color
key, assigns the same color (< color value >
) to draw
and fill
. And since the keys are evaluated in the order in which they are written, the result you see is quite normal.
What does (no default) mean?
The majority of TikZ's usual keys can be called in 2 ways:
explicitly with for example
draw[color=red](0,0)rectangle(1,1);
Thekey
to which thered
value applies is explicitly given, here thecolor
key;implicitly with
draw[red](0,0)rectangle(1,1);
, here TikZ recognizes the color value and assigns it to thecolor
key. It is not mandatory to say to whichkey
the color value applies. TikZ implicitly assigns the color value to thecolor
key.
On the other hand, if you write draw[color]
, there is an error because the color value is not indicated. There is no default color. I quote the error:
Package pgfkeys Error: The key '/tikz/color' requires a value.
An example of a key that has a default value:
It is sometimes possible not to give a value to the key, in this case it takes the default value:
By example, the double
key has the default value of white
. You can omit the color and write
draw[double](0,-1)--(2,-1);
Which is the same as draw[double=white](0,-1)--(2,-1);
But it is possible to specify a color value other than the default value, for example, here cyan
draw[double=cyan](0,-2)--(2,-2);
The pgfkeys
The options are given with the key=value
system called pgfkeys
described starting on page 946 of the 3.1 manual (86 Key Management).
- The first word on the left is always the name of the
key
(the option), - the second word is always the name of the option
value
.
Thus:
color=red
, the key iscolor
, the value isred
.
draw=blue
, the key isdraw
, the value isblue
.
The color word is designated differently in the manual:
/tikz/color=< color name >
- the key is called
color
. - The manual write
< color name >
to indicate the value (red, blue, etc).
So, yes, we must be careful and specify what we are talking about. We commonly talk about "colour" but very often forget to specify whether it is the key
or its value
. This leads to confusion.
I corrected this answer and specified each time whether it is the key or its value. I hope that the answer is now clearer.
I see now. I do not understand the(no default)
part, since it seems the default color for text, fill and draw are black.
– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,draw
ortext
orfill
have default colors (they are black) and whether the keycolor
has a default value. Same word "color", but different meaning.
– Máté Wierdl
Jan 6 at 2:05
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
add a comment |
You are using the wrong key. color
sets fill
, draw
and text
. That said, it will only set the color and does not apply it/the operation.
draw[color=red]
will draw a red frame (equalsdraw[draw=red]
)
draw[color=red,fill]
will draw a red frame filled with red (equalsdraw[fill=red]
orfilldraw[red]
)
draw[color=red,fill,draw=none]
will draw a red fill but no frame (equalsfill[red]
)
draw[color=red] node {Test};
will draw a node with red text (equalsdraw[text=red] node {Test};
TLDR: Use draw
to change the frame.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy thetikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...
– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifyingcolor=red
or simplyred
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated bytext, fill, draw
. It also seems thatblack
is the default color specification.
– Máté Wierdl
Jan 5 at 2:42
In the answer, "draw[color=red,draw=none]
will draw a red fill but no frame (equalsfill[red]
)" needs to be changed by addingfill
to the options,draw[color=red,draw=none,fill]
.
– Máté Wierdl
Jan 5 at 5:39
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468439%2fbug-or-feature-tikz-interprets-color-specification-differently-for-rectangles%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes it's a feature, because this color
key rewrites the color value on the draw
,fill
and text
key, I quote the 3.1 manual on page 168 (15.2 Specifying a Color):
/tikz/color=<color name> (no default)
This option sets the color that
is used for fill, drawing, and text inside the current scope.
TikZ allows you to change the color value of the lines made with draw
and the color value of the coloring made with fill
separately.
The color
key, assigns the same color (< color value >
) to draw
and fill
. And since the keys are evaluated in the order in which they are written, the result you see is quite normal.
What does (no default) mean?
The majority of TikZ's usual keys can be called in 2 ways:
explicitly with for example
draw[color=red](0,0)rectangle(1,1);
Thekey
to which thered
value applies is explicitly given, here thecolor
key;implicitly with
draw[red](0,0)rectangle(1,1);
, here TikZ recognizes the color value and assigns it to thecolor
key. It is not mandatory to say to whichkey
the color value applies. TikZ implicitly assigns the color value to thecolor
key.
On the other hand, if you write draw[color]
, there is an error because the color value is not indicated. There is no default color. I quote the error:
Package pgfkeys Error: The key '/tikz/color' requires a value.
An example of a key that has a default value:
It is sometimes possible not to give a value to the key, in this case it takes the default value:
By example, the double
key has the default value of white
. You can omit the color and write
draw[double](0,-1)--(2,-1);
Which is the same as draw[double=white](0,-1)--(2,-1);
But it is possible to specify a color value other than the default value, for example, here cyan
draw[double=cyan](0,-2)--(2,-2);
The pgfkeys
The options are given with the key=value
system called pgfkeys
described starting on page 946 of the 3.1 manual (86 Key Management).
- The first word on the left is always the name of the
key
(the option), - the second word is always the name of the option
value
.
Thus:
color=red
, the key iscolor
, the value isred
.
draw=blue
, the key isdraw
, the value isblue
.
The color word is designated differently in the manual:
/tikz/color=< color name >
- the key is called
color
. - The manual write
< color name >
to indicate the value (red, blue, etc).
So, yes, we must be careful and specify what we are talking about. We commonly talk about "colour" but very often forget to specify whether it is the key
or its value
. This leads to confusion.
I corrected this answer and specified each time whether it is the key or its value. I hope that the answer is now clearer.
I see now. I do not understand the(no default)
part, since it seems the default color for text, fill and draw are black.
– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,draw
ortext
orfill
have default colors (they are black) and whether the keycolor
has a default value. Same word "color", but different meaning.
– Máté Wierdl
Jan 6 at 2:05
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
add a comment |
Yes it's a feature, because this color
key rewrites the color value on the draw
,fill
and text
key, I quote the 3.1 manual on page 168 (15.2 Specifying a Color):
/tikz/color=<color name> (no default)
This option sets the color that
is used for fill, drawing, and text inside the current scope.
TikZ allows you to change the color value of the lines made with draw
and the color value of the coloring made with fill
separately.
The color
key, assigns the same color (< color value >
) to draw
and fill
. And since the keys are evaluated in the order in which they are written, the result you see is quite normal.
What does (no default) mean?
The majority of TikZ's usual keys can be called in 2 ways:
explicitly with for example
draw[color=red](0,0)rectangle(1,1);
Thekey
to which thered
value applies is explicitly given, here thecolor
key;implicitly with
draw[red](0,0)rectangle(1,1);
, here TikZ recognizes the color value and assigns it to thecolor
key. It is not mandatory to say to whichkey
the color value applies. TikZ implicitly assigns the color value to thecolor
key.
On the other hand, if you write draw[color]
, there is an error because the color value is not indicated. There is no default color. I quote the error:
Package pgfkeys Error: The key '/tikz/color' requires a value.
An example of a key that has a default value:
It is sometimes possible not to give a value to the key, in this case it takes the default value:
By example, the double
key has the default value of white
. You can omit the color and write
draw[double](0,-1)--(2,-1);
Which is the same as draw[double=white](0,-1)--(2,-1);
But it is possible to specify a color value other than the default value, for example, here cyan
draw[double=cyan](0,-2)--(2,-2);
The pgfkeys
The options are given with the key=value
system called pgfkeys
described starting on page 946 of the 3.1 manual (86 Key Management).
- The first word on the left is always the name of the
key
(the option), - the second word is always the name of the option
value
.
Thus:
color=red
, the key iscolor
, the value isred
.
draw=blue
, the key isdraw
, the value isblue
.
The color word is designated differently in the manual:
/tikz/color=< color name >
- the key is called
color
. - The manual write
< color name >
to indicate the value (red, blue, etc).
So, yes, we must be careful and specify what we are talking about. We commonly talk about "colour" but very often forget to specify whether it is the key
or its value
. This leads to confusion.
I corrected this answer and specified each time whether it is the key or its value. I hope that the answer is now clearer.
I see now. I do not understand the(no default)
part, since it seems the default color for text, fill and draw are black.
– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,draw
ortext
orfill
have default colors (they are black) and whether the keycolor
has a default value. Same word "color", but different meaning.
– Máté Wierdl
Jan 6 at 2:05
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
add a comment |
Yes it's a feature, because this color
key rewrites the color value on the draw
,fill
and text
key, I quote the 3.1 manual on page 168 (15.2 Specifying a Color):
/tikz/color=<color name> (no default)
This option sets the color that
is used for fill, drawing, and text inside the current scope.
TikZ allows you to change the color value of the lines made with draw
and the color value of the coloring made with fill
separately.
The color
key, assigns the same color (< color value >
) to draw
and fill
. And since the keys are evaluated in the order in which they are written, the result you see is quite normal.
What does (no default) mean?
The majority of TikZ's usual keys can be called in 2 ways:
explicitly with for example
draw[color=red](0,0)rectangle(1,1);
Thekey
to which thered
value applies is explicitly given, here thecolor
key;implicitly with
draw[red](0,0)rectangle(1,1);
, here TikZ recognizes the color value and assigns it to thecolor
key. It is not mandatory to say to whichkey
the color value applies. TikZ implicitly assigns the color value to thecolor
key.
On the other hand, if you write draw[color]
, there is an error because the color value is not indicated. There is no default color. I quote the error:
Package pgfkeys Error: The key '/tikz/color' requires a value.
An example of a key that has a default value:
It is sometimes possible not to give a value to the key, in this case it takes the default value:
By example, the double
key has the default value of white
. You can omit the color and write
draw[double](0,-1)--(2,-1);
Which is the same as draw[double=white](0,-1)--(2,-1);
But it is possible to specify a color value other than the default value, for example, here cyan
draw[double=cyan](0,-2)--(2,-2);
The pgfkeys
The options are given with the key=value
system called pgfkeys
described starting on page 946 of the 3.1 manual (86 Key Management).
- The first word on the left is always the name of the
key
(the option), - the second word is always the name of the option
value
.
Thus:
color=red
, the key iscolor
, the value isred
.
draw=blue
, the key isdraw
, the value isblue
.
The color word is designated differently in the manual:
/tikz/color=< color name >
- the key is called
color
. - The manual write
< color name >
to indicate the value (red, blue, etc).
So, yes, we must be careful and specify what we are talking about. We commonly talk about "colour" but very often forget to specify whether it is the key
or its value
. This leads to confusion.
I corrected this answer and specified each time whether it is the key or its value. I hope that the answer is now clearer.
Yes it's a feature, because this color
key rewrites the color value on the draw
,fill
and text
key, I quote the 3.1 manual on page 168 (15.2 Specifying a Color):
/tikz/color=<color name> (no default)
This option sets the color that
is used for fill, drawing, and text inside the current scope.
TikZ allows you to change the color value of the lines made with draw
and the color value of the coloring made with fill
separately.
The color
key, assigns the same color (< color value >
) to draw
and fill
. And since the keys are evaluated in the order in which they are written, the result you see is quite normal.
What does (no default) mean?
The majority of TikZ's usual keys can be called in 2 ways:
explicitly with for example
draw[color=red](0,0)rectangle(1,1);
Thekey
to which thered
value applies is explicitly given, here thecolor
key;implicitly with
draw[red](0,0)rectangle(1,1);
, here TikZ recognizes the color value and assigns it to thecolor
key. It is not mandatory to say to whichkey
the color value applies. TikZ implicitly assigns the color value to thecolor
key.
On the other hand, if you write draw[color]
, there is an error because the color value is not indicated. There is no default color. I quote the error:
Package pgfkeys Error: The key '/tikz/color' requires a value.
An example of a key that has a default value:
It is sometimes possible not to give a value to the key, in this case it takes the default value:
By example, the double
key has the default value of white
. You can omit the color and write
draw[double](0,-1)--(2,-1);
Which is the same as draw[double=white](0,-1)--(2,-1);
But it is possible to specify a color value other than the default value, for example, here cyan
draw[double=cyan](0,-2)--(2,-2);
The pgfkeys
The options are given with the key=value
system called pgfkeys
described starting on page 946 of the 3.1 manual (86 Key Management).
- The first word on the left is always the name of the
key
(the option), - the second word is always the name of the option
value
.
Thus:
color=red
, the key iscolor
, the value isred
.
draw=blue
, the key isdraw
, the value isblue
.
The color word is designated differently in the manual:
/tikz/color=< color name >
- the key is called
color
. - The manual write
< color name >
to indicate the value (red, blue, etc).
So, yes, we must be careful and specify what we are talking about. We commonly talk about "colour" but very often forget to specify whether it is the key
or its value
. This leads to confusion.
I corrected this answer and specified each time whether it is the key or its value. I hope that the answer is now clearer.
edited Jan 14 at 14:47
answered Jan 3 at 17:30
AndréCAndréC
10.5k11548
10.5k11548
I see now. I do not understand the(no default)
part, since it seems the default color for text, fill and draw are black.
– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,draw
ortext
orfill
have default colors (they are black) and whether the keycolor
has a default value. Same word "color", but different meaning.
– Máté Wierdl
Jan 6 at 2:05
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
add a comment |
I see now. I do not understand the(no default)
part, since it seems the default color for text, fill and draw are black.
– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,draw
ortext
orfill
have default colors (they are black) and whether the keycolor
has a default value. Same word "color", but different meaning.
– Máté Wierdl
Jan 6 at 2:05
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
I see now. I do not understand the
(no default)
part, since it seems the default color for text, fill and draw are black.– Máté Wierdl
Jan 5 at 2:35
I see now. I do not understand the
(no default)
part, since it seems the default color for text, fill and draw are black.– Máté Wierdl
Jan 5 at 2:35
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl See here: tex.stackexchange.com/questions/370146/…
– CarLaTeX
Jan 5 at 7:44
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
@MátéWierdl I updated my answer, do you understand now?
– AndréC
Jan 5 at 8:34
I see, @AndréC, thanks. So it is different to say,
draw
or text
or fill
have default colors (they are black) and whether the key color
has a default value. Same word "color", but different meaning.– Máté Wierdl
Jan 6 at 2:05
I see, @AndréC, thanks. So it is different to say,
draw
or text
or fill
have default colors (they are black) and whether the key color
has a default value. Same word "color", but different meaning.– Máté Wierdl
Jan 6 at 2:05
1
1
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
@MátéWierdl I added some details about the pgfkeys system that manages the options and corrected my answer to avoid this ambiguity of language
– AndréC
Jan 6 at 7:54
add a comment |
You are using the wrong key. color
sets fill
, draw
and text
. That said, it will only set the color and does not apply it/the operation.
draw[color=red]
will draw a red frame (equalsdraw[draw=red]
)
draw[color=red,fill]
will draw a red frame filled with red (equalsdraw[fill=red]
orfilldraw[red]
)
draw[color=red,fill,draw=none]
will draw a red fill but no frame (equalsfill[red]
)
draw[color=red] node {Test};
will draw a node with red text (equalsdraw[text=red] node {Test};
TLDR: Use draw
to change the frame.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy thetikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...
– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifyingcolor=red
or simplyred
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated bytext, fill, draw
. It also seems thatblack
is the default color specification.
– Máté Wierdl
Jan 5 at 2:42
In the answer, "draw[color=red,draw=none]
will draw a red fill but no frame (equalsfill[red]
)" needs to be changed by addingfill
to the options,draw[color=red,draw=none,fill]
.
– Máté Wierdl
Jan 5 at 5:39
|
show 1 more comment
You are using the wrong key. color
sets fill
, draw
and text
. That said, it will only set the color and does not apply it/the operation.
draw[color=red]
will draw a red frame (equalsdraw[draw=red]
)
draw[color=red,fill]
will draw a red frame filled with red (equalsdraw[fill=red]
orfilldraw[red]
)
draw[color=red,fill,draw=none]
will draw a red fill but no frame (equalsfill[red]
)
draw[color=red] node {Test};
will draw a node with red text (equalsdraw[text=red] node {Test};
TLDR: Use draw
to change the frame.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy thetikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...
– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifyingcolor=red
or simplyred
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated bytext, fill, draw
. It also seems thatblack
is the default color specification.
– Máté Wierdl
Jan 5 at 2:42
In the answer, "draw[color=red,draw=none]
will draw a red fill but no frame (equalsfill[red]
)" needs to be changed by addingfill
to the options,draw[color=red,draw=none,fill]
.
– Máté Wierdl
Jan 5 at 5:39
|
show 1 more comment
You are using the wrong key. color
sets fill
, draw
and text
. That said, it will only set the color and does not apply it/the operation.
draw[color=red]
will draw a red frame (equalsdraw[draw=red]
)
draw[color=red,fill]
will draw a red frame filled with red (equalsdraw[fill=red]
orfilldraw[red]
)
draw[color=red,fill,draw=none]
will draw a red fill but no frame (equalsfill[red]
)
draw[color=red] node {Test};
will draw a node with red text (equalsdraw[text=red] node {Test};
TLDR: Use draw
to change the frame.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
You are using the wrong key. color
sets fill
, draw
and text
. That said, it will only set the color and does not apply it/the operation.
draw[color=red]
will draw a red frame (equalsdraw[draw=red]
)
draw[color=red,fill]
will draw a red frame filled with red (equalsdraw[fill=red]
orfilldraw[red]
)
draw[color=red,fill,draw=none]
will draw a red fill but no frame (equalsfill[red]
)
draw[color=red] node {Test};
will draw a node with red text (equalsdraw[text=red] node {Test};
TLDR: Use draw
to change the frame.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
draw[color=red,very thick] (0,0) rectangle (1,1);
draw[color=red,very thick,fill=blue] (2,0) rectangle (3,1);
draw[very thick,fill=blue,draw=red] (4,0) rectangle (5,1);
end{tikzpicture}
end{document}
edited Jan 5 at 7:42
answered Jan 3 at 17:29
TeXnicianTeXnician
25.9k63390
25.9k63390
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy thetikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...
– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifyingcolor=red
or simplyred
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated bytext, fill, draw
. It also seems thatblack
is the default color specification.
– Máté Wierdl
Jan 5 at 2:42
In the answer, "draw[color=red,draw=none]
will draw a red fill but no frame (equalsfill[red]
)" needs to be changed by addingfill
to the options,draw[color=red,draw=none,fill]
.
– Máté Wierdl
Jan 5 at 5:39
|
show 1 more comment
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy thetikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...
– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifyingcolor=red
or simplyred
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated bytext, fill, draw
. It also seems thatblack
is the default color specification.
– Máté Wierdl
Jan 5 at 2:42
In the answer, "draw[color=red,draw=none]
will draw a red fill but no frame (equalsfill[red]
)" needs to be changed by addingfill
to the options,draw[color=red,draw=none,fill]
.
– Máté Wierdl
Jan 5 at 5:39
2
2
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy the
tikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...– marmot
Jan 3 at 20:37
@Kpym I am not sure I agree. (Actually I like and upvoted your answer and am wondering why you removed it.) I guess the cleanest answer may be to just copy the
tikzoption{color}{....}
code and discuss what it means. This also clarifies the "hierarchy" and "inheritances" between the different keys. And, as you know very well, it is actually nontrivial to figure out what the current color is. And there are much more advanced discussions IMHO such as this one and the links there...– marmot
Jan 3 at 20:37
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@marmot I've tried to extend my post. Is it better now?
– TeXnician
Jan 4 at 8:23
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
@TeXnician Your answer was always good. I will remove my last comment now. The other comment will die with the one above it unless you ask me to remove it. ;-)
– marmot
Jan 4 at 15:35
I now see completely (can I say "thanks"?). So specifying
color=red
or simply red
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated by text, fill, draw
. It also seems that black
is the default color specification.– Máté Wierdl
Jan 5 at 2:42
I now see completely (can I say "thanks"?). So specifying
color=red
or simply red
sets the color for all three: text, fill, draw. But the color red is seen exactly when it is activated by text, fill, draw
. It also seems that black
is the default color specification.– Máté Wierdl
Jan 5 at 2:42
In the answer, "
draw[color=red,draw=none]
will draw a red fill but no frame (equals fill[red]
)" needs to be changed by adding fill
to the options, draw[color=red,draw=none,fill]
.– Máté Wierdl
Jan 5 at 5:39
In the answer, "
draw[color=red,draw=none]
will draw a red fill but no frame (equals fill[red]
)" needs to be changed by adding fill
to the options, draw[color=red,draw=none,fill]
.– Máté Wierdl
Jan 5 at 5:39
|
show 1 more comment
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468439%2fbug-or-feature-tikz-interprets-color-specification-differently-for-rectangles%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown