7

Please look at next code and its result:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}[every node/.style={draw=red,fill=green},]
\node[label=above:a] (A) {AAA};

\node[label={[draw]above:b}, right=of A] (B) {BBB};

\begin{scope}[every label/.style={draw}]
    \node[label=above:c, right=of B] (C) {CCC};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

I understand that labels are nodes which are created after its main node. (Look at Every non-label node in TikZ), so I understand that options draw or fill inherit main node colors as is shown in middle node. But I don't understand why every label/.style={draw} also fills the label, as is shown in right most node above. Could you explain it?

1
  • 2
    You might want to append style to \begin{scope}[every label/.style={draw}]. – Claudio Fiandrino Sep 2 '13 at 9:15
8

This happens because by default, every label is defined as draw=none,fill=none. By setting every label/.style=draw, you're overwriting these options, and the fill=green from the every node style is used. To get the expected behaviour, use every label/.append style=draw.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.