Where is my understanding of TikZ styles wrong?Document compiling in online editor but not in TeXworks?How can I put a coloured outline around fraction lines?Tikz Polar GridNumerical conditional within tikz keys?polar chart heat mapTikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Drawing a Grid/Tikz image
Fix /dev/sdb after using dd with no device inserted
Why would guns not work in the dungeon?
School House Points (Python + SQLite)
Mbed Cortex-m hardfault when sending data via TCP
Why hasn't the U.S. government paid war reparations to any country it attacked?
A "Simple" Task
Help with understanding nuances of extremely popular Kyoto-ben (?) tweet
Can you negate disadvantage on throwing a net by using the Lunging Attack maneuver of the Battle Master fighter?
Optimising Table wrapping over a Select
Filtering fine silt/mud from water (not necessarily bacteria etc.)
Supporting developers who insist on using their pet language
What is temperature on a quantum level?
Are there any double stars that I can actually see orbit each other?
Extract an attribute value from XML
Password maker in C#
Why limit to revolvers?
Occasus nescius
How can an advanced civilization forget how to manufacture its technology?
Is `curl something | sudo bash -` a reasonably safe installation method?
Find the wrong number in the given series: 6, 12, 21, 36, 56, 81?
Conciousness in Buddhism and Advaita Vedanta
Can I intentionally omit previous work experience or pretend it doesn't exist when applying for jobs?
How to convert 1k to 1000 and 1m to 1000000 in Excel
Is this floating-point optimization allowed?
Where is my understanding of TikZ styles wrong?
Document compiling in online editor but not in TeXworks?How can I put a coloured outline around fraction lines?Tikz Polar GridNumerical conditional within tikz keys?polar chart heat mapTikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Drawing a Grid/Tikz image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to learn TikZ by reading the manual (p.34). I know my understanding must be completely off the rails, since nothing is working as I think I should; but I'm not sure what I misunderstood.
What I understood from the manual is this: let's say that you want to draw many circles of the form
draw[red, very thick, radius = 1] (0, 0) circle;
Instead of writing red, very thick, radius = 1, you could pack all of this into just one word, via TikZ style, like so
myCircle/.style = red, very thick, radius = 1;
and now you are able to draw circles faster, since you can just write
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
`myCircle/.style = red, very thick, radius = 1;`
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
enddocument
However, this does not work; it does not even compile.
This is perhaps even more confusing (for me): in the manual, they do something similar with help lines, which apparently is a predefined thing (a style?) in the TikZ package. Now the following does compile, but it does not work to make the grid lines blue and very thick.
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
help lines/. style = blue, very thick
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument
Could you please help me see where my understanding is wrong? Thanks.
tikz-pgf tikz-styles
add a comment |
I am trying to learn TikZ by reading the manual (p.34). I know my understanding must be completely off the rails, since nothing is working as I think I should; but I'm not sure what I misunderstood.
What I understood from the manual is this: let's say that you want to draw many circles of the form
draw[red, very thick, radius = 1] (0, 0) circle;
Instead of writing red, very thick, radius = 1, you could pack all of this into just one word, via TikZ style, like so
myCircle/.style = red, very thick, radius = 1;
and now you are able to draw circles faster, since you can just write
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
`myCircle/.style = red, very thick, radius = 1;`
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
enddocument
However, this does not work; it does not even compile.
This is perhaps even more confusing (for me): in the manual, they do something similar with help lines, which apparently is a predefined thing (a style?) in the TikZ package. Now the following does compile, but it does not work to make the grid lines blue and very thick.
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
help lines/. style = blue, very thick
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument
Could you please help me see where my understanding is wrong? Thanks.
tikz-pgf tikz-styles
1
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer I tried putting the linetikzset myCircle/. style = blue, very thick, radius = 1before my TikZ environment and then I putdraw[myCircle] (-4, -4) circle;in my TikZ environment, but it did not work.
– Ovi
8 hours ago
3
As @UlrikeFischer is saying, it should be a style definition. You only need to add[...]around them:begintikzpicture[myCircle/.style = red, very thick, radius = 1]andbegintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.
– marmot
8 hours ago
add a comment |
I am trying to learn TikZ by reading the manual (p.34). I know my understanding must be completely off the rails, since nothing is working as I think I should; but I'm not sure what I misunderstood.
What I understood from the manual is this: let's say that you want to draw many circles of the form
draw[red, very thick, radius = 1] (0, 0) circle;
Instead of writing red, very thick, radius = 1, you could pack all of this into just one word, via TikZ style, like so
myCircle/.style = red, very thick, radius = 1;
and now you are able to draw circles faster, since you can just write
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
`myCircle/.style = red, very thick, radius = 1;`
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
enddocument
However, this does not work; it does not even compile.
This is perhaps even more confusing (for me): in the manual, they do something similar with help lines, which apparently is a predefined thing (a style?) in the TikZ package. Now the following does compile, but it does not work to make the grid lines blue and very thick.
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
help lines/. style = blue, very thick
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument
Could you please help me see where my understanding is wrong? Thanks.
tikz-pgf tikz-styles
I am trying to learn TikZ by reading the manual (p.34). I know my understanding must be completely off the rails, since nothing is working as I think I should; but I'm not sure what I misunderstood.
What I understood from the manual is this: let's say that you want to draw many circles of the form
draw[red, very thick, radius = 1] (0, 0) circle;
Instead of writing red, very thick, radius = 1, you could pack all of this into just one word, via TikZ style, like so
myCircle/.style = red, very thick, radius = 1;
and now you are able to draw circles faster, since you can just write
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
`myCircle/.style = red, very thick, radius = 1;`
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
enddocument
However, this does not work; it does not even compile.
This is perhaps even more confusing (for me): in the manual, they do something similar with help lines, which apparently is a predefined thing (a style?) in the TikZ package. Now the following does compile, but it does not work to make the grid lines blue and very thick.
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture
help lines/. style = blue, very thick
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument
Could you please help me see where my understanding is wrong? Thanks.
tikz-pgf tikz-styles
tikz-pgf tikz-styles
asked 8 hours ago
OviOvi
2491 silver badge7 bronze badges
2491 silver badge7 bronze badges
1
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer I tried putting the linetikzset myCircle/. style = blue, very thick, radius = 1before my TikZ environment and then I putdraw[myCircle] (-4, -4) circle;in my TikZ environment, but it did not work.
– Ovi
8 hours ago
3
As @UlrikeFischer is saying, it should be a style definition. You only need to add[...]around them:begintikzpicture[myCircle/.style = red, very thick, radius = 1]andbegintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.
– marmot
8 hours ago
add a comment |
1
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer I tried putting the linetikzset myCircle/. style = blue, very thick, radius = 1before my TikZ environment and then I putdraw[myCircle] (-4, -4) circle;in my TikZ environment, but it did not work.
– Ovi
8 hours ago
3
As @UlrikeFischer is saying, it should be a style definition. You only need to add[...]around them:begintikzpicture[myCircle/.style = red, very thick, radius = 1]andbegintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.
– marmot
8 hours ago
1
1
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer I tried putting the line
tikzset myCircle/. style = blue, very thick, radius = 1 before my TikZ environment and then I put draw[myCircle] (-4, -4) circle; in my TikZ environment, but it did not work.– Ovi
8 hours ago
@UlrikeFischer I tried putting the line
tikzset myCircle/. style = blue, very thick, radius = 1 before my TikZ environment and then I put draw[myCircle] (-4, -4) circle; in my TikZ environment, but it did not work.– Ovi
8 hours ago
3
3
As @UlrikeFischer is saying, it should be a style definition. You only need to add
[...] around them: begintikzpicture[myCircle/.style = red, very thick, radius = 1] and begintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.– marmot
8 hours ago
As @UlrikeFischer is saying, it should be a style definition. You only need to add
[...] around them: begintikzpicture[myCircle/.style = red, very thick, radius = 1] and begintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.– marmot
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You have a couple (4?) of problems.
- if you want to define the style for one picture, you need to put it into the optional argument of the picture, in square brackets
[]; - The style is terminated by
,(or the end of the argument), not; - In a
tikzset, the style has the scope determined by the normal TeX rules. - You can't have a space between the
/and the.stylehandler.
This works:
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture[
myCircle/.style = red, very thick, radius = 1, % end with a comma, NOT semicolon!
]
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
tikzsethelp lines/.style = blue, very thick %% no spaces between / and .style!
begintikzpicture
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument

Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
add a 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%2f499776%2fwhere-is-my-understanding-of-tikz-styles-wrong%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have a couple (4?) of problems.
- if you want to define the style for one picture, you need to put it into the optional argument of the picture, in square brackets
[]; - The style is terminated by
,(or the end of the argument), not; - In a
tikzset, the style has the scope determined by the normal TeX rules. - You can't have a space between the
/and the.stylehandler.
This works:
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture[
myCircle/.style = red, very thick, radius = 1, % end with a comma, NOT semicolon!
]
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
tikzsethelp lines/.style = blue, very thick %% no spaces between / and .style!
begintikzpicture
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument

Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
add a comment |
You have a couple (4?) of problems.
- if you want to define the style for one picture, you need to put it into the optional argument of the picture, in square brackets
[]; - The style is terminated by
,(or the end of the argument), not; - In a
tikzset, the style has the scope determined by the normal TeX rules. - You can't have a space between the
/and the.stylehandler.
This works:
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture[
myCircle/.style = red, very thick, radius = 1, % end with a comma, NOT semicolon!
]
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
tikzsethelp lines/.style = blue, very thick %% no spaces between / and .style!
begintikzpicture
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument

Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
add a comment |
You have a couple (4?) of problems.
- if you want to define the style for one picture, you need to put it into the optional argument of the picture, in square brackets
[]; - The style is terminated by
,(or the end of the argument), not; - In a
tikzset, the style has the scope determined by the normal TeX rules. - You can't have a space between the
/and the.stylehandler.
This works:
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture[
myCircle/.style = red, very thick, radius = 1, % end with a comma, NOT semicolon!
]
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
tikzsethelp lines/.style = blue, very thick %% no spaces between / and .style!
begintikzpicture
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument

You have a couple (4?) of problems.
- if you want to define the style for one picture, you need to put it into the optional argument of the picture, in square brackets
[]; - The style is terminated by
,(or the end of the argument), not; - In a
tikzset, the style has the scope determined by the normal TeX rules. - You can't have a space between the
/and the.stylehandler.
This works:
documentclassbook
usepackagetikz
usepackageparskip
begindocument
begintikzpicture[
myCircle/.style = red, very thick, radius = 1, % end with a comma, NOT semicolon!
]
draw[myCircle] (0, 0) circle;
draw[myCircle] (1, 2) circle;
draw[myCircle] (3, 4) circle;
endtikzpicture
tikzsethelp lines/.style = blue, very thick %% no spaces between / and .style!
begintikzpicture
draw[help lines] (-4, -4) grid (4, 4);
endtikzpicture
enddocument

edited 7 hours ago
answered 7 hours ago
RmanoRmano
9,5582 gold badges17 silver badges52 bronze badges
9,5582 gold badges17 silver badges52 bronze badges
Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
add a comment |
Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
Thanks for the example! I wasn't able to fix it just based on the comments alone.
– Ovi
7 hours ago
5
5
It is often easier to show than explain.
– John Kormylo
7 hours ago
It is often easier to show than explain.
– John Kormylo
7 hours ago
add a 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%2f499776%2fwhere-is-my-understanding-of-tikz-styles-wrong%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
1
Your style definition should be in a tikzset command.
– Ulrike Fischer
8 hours ago
@UlrikeFischer And that goes outside of the TikZ picture environment, right? But then what is the point of the style definition inside the TikZ environment? Is it only used to modify styles that were already defined outside of the TikZ environment?
– Ovi
8 hours ago
@UlrikeFischer I tried putting the line
tikzset myCircle/. style = blue, very thick, radius = 1before my TikZ environment and then I putdraw[myCircle] (-4, -4) circle;in my TikZ environment, but it did not work.– Ovi
8 hours ago
3
As @UlrikeFischer is saying, it should be a style definition. You only need to add
[...]around them:begintikzpicture[myCircle/.style = red, very thick, radius = 1]andbegintikzpicture[help lines/. style = blue, very thick]. The examples in the pgfmanual do have these brackets.– marmot
8 hours ago