How do I set labeling styles associated with each style type?
For example: (source below)
- I have an "input" style (medium circle) and a "junction" style (small dot) which I would like to have the labels below by default, but they default to above.
- I also have a "block" style (gradient shaded rectangle) which somehow already has the label default to below, and I want to use a smaller font for the label.
I can't figure out how to do either of these, the only thing I could figure out is how to use the every label/.style
to change the font of all labels.
https://www.writelatex.com/read/jrwtbtqxntyz
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit}
\begin{document}
\begin{tikzpicture}[node distance=5mm,
block/.style={
% The shape:
rectangle, minimum size=6mm,
% The rest
thick,draw=black,
top color=white,
bottom color=black!10
},
input/.style={
% The shape:
circle, minimum size=1mm,
% The rest
thick,draw=black,
fill = white,
},
junction/.style={
% The shape:
circle, minimum size=0.5mm, inner sep=0pt,
% The rest
thick,draw=black,
fill = black
},
every label/.style={
font=\small
},
>=latex
]
\node (wcmd) [input, label=below:$\omega_{cmd}$]{};
\node (wcmd2) at (0,1) [input, label=$\omega_{cmd}$]{};
\node (jj) at (1,1) [junction, label=Z] {};
\node (C) [block, right=of wcmd] {C};
\node (D) [block,right=of C] {D};
\node (E) [block,right=of D, label=below:Hey] {E};
\node (F) [block,below=of D] {F};
\draw[->] (wcmd) -- (C);
\draw[->] (C) -- (D);
\end{tikzpicture}
\end{document}
Best Answer
If you want to have differentiated attributes for labels under different style, one way is to add
label
in the definition of those styles. For example, if I want labels in theblock
style to be red, with small font and default position at north east, I'd define theblock
style asand use
\node[block={<label text>}]{<node text>};
, whereblock
takes one argument (which can be empty) that specifies the label text.Full Code
Output