Look at the two diagrams at the top of page 50 and the diagram at the top of page 220 in the manual at the following web site.
http://mirrors.rit.edu/CTAN/graphics/pgf/base/doc/pgfmanual.pdf
I have two questions about these diagrams.
For the diagram on page 50, here is the code.
\begin{tikzpicture}
[place/.style={circle,draw=blue!50,fill=blue!20,thick},
transition/.style={rectangle,draw=black!50,fill=black!20,thick}]
\node at (0,2) [place] {};
\node at (0,1) [place] {};
\node at (0,0) [place] {};
\node at (1,1)[transition] {};
\node at(-1,1)[transition] {};
\end{tikzpicture}
For the diagram on page 220, here is the code.
\begin{tikzpicture}
\draw
(0,0) node[inner sep=0pt,draw] {tight}
(0cm,2em) node[inner sep=5pt,draw] {loose}
(0cm,4em) node[fill=yellow!80!black] {default};
\end{tikzpicture}
On page 50, it seems to me that variables "place" and "transition are being declared. What is the sytax for the /.style
command? I could have written
\node at (0,2) [circle,draw=blue!50,fill=blue!20,thick] {}
instead of
\node at (0,2) [place] {}; .
Is that right?
When does one use node
as was used on page 220 and when does one use \node
as on page 50?
On page 220, why does TikZ draw a rectangle about the given text?
I have three questions about the syntax for the code on page 50.
- The rectangle is drawn with
black!50
. Is there ablack50
? - Why is there an exclamation point?
- To what is
thick
referring?
Best Answer
In a nutshell,
<name>/.style
syntax is a container of other styles or codes that are called in the order of declaration.This is the instance of the more general
key=value
system and it is part of the powerfulpgfkeys
library which you can read up in the same manual under libraries section.So to your first question, yes that would be equivalent instead of calling the
place
style.If you only want to place a node on a path, it is kind of tedious to write everytime
\path node
instead\node
is defined which is a shorthand. But in case you have other path constructing commands then you usenode
, for example,As you can see from this first node has a rectangle and the second doesn't because we supplied
draw
key to the node in the first node. Every node has a shape which you can draw or not (unless we define a new node with no background but that's not relevant now). You can also fill that shape, exampleSo if you supply colors to these commands they draw or fill the value of the key.
TikZ uses
xcolor
package to define and use colors. Color mixing is done via!
and you can use more than two colors. If you omit the mix colors white is used by default. Here,black!50
is equal to mix black and white equally. The number between 0 and 100 selectsx
percent you take the left hand side and mix it with100-x
with the right hand side (well at least you can take it as a simple mental shortcut. Color models are tricky business). Examples;The drawing can have different line widths, and TikZ defines shortcuts for mostly used line width arguments as follows,
When you use
thick
on a path or a node together withdraw
the drawing is done using a pen with the line width of 0.8 pt.