Inheriting styles
You noticed that we used the commands for sans-serif and bold font and white text color both in the vertex and number styles. To avoid repetition and to have a single point of definition, we can define a style used by both. Let’s call it mytext
. Then, we can use it within the definitions of both vertex
and number
:
\tikzset{ mytext/.style = {font=\sffamily\bfseries, text=white}, vertex/.style = {mytext, shape=circle, ball color = blue}, number/.style = {mytext, draw, fill=red}}
That way, we can define fundamental styles for our drawings and create further specific styles based on them.
Similarly, we can define specific styles based on other styles, such as highlighting elements in a drawing. Here, we define a general highlight
style and combine it with other styles:
\tikzset{highlight/.style = {draw...