3.5 Styles
Syntax
Styles are predefined collections of TikZ options. They are used to bundle frequently used formatting options (e.g. shapes, colors, arrows, line widths) in a central place. They can be defined either in the preamble or inside the tikzpicture environment.
\tikzset{
stylename/.style={option1, option2, ...}
}
Copy
Example
The following example additionally requires \usetikzlibrary{positioning, shapes.geometric} in the preamble.
\begin{tikzpicture}
\tikzset{
process/.style={
draw,
rectangle,
rounded corners,
minimum width=3cm,
minimum height=1cm,
align=center,
fill=gray!10
},
decision/.style={
draw,
diamond,
aspect=2,
align=center,
fill=blue!10
},
flow/.style={
->,
thick
}
}
\node[process] (start) {Start};
\node[decision, below=of start] (check) {Condition met?};
\node[process, below left=of check] (yes) {Action A};
\node[process, below right=of check] (no) {Action B};
\draw[flow] (start) -- (check);
\draw[flow] (check) -- node[left]{Yes} (yes);
\draw[flow] (check) -- node[right]{No} (no);
\end{tikzpicture}
Copy