TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following document has two tikzpictures in it, and they result in slightly different output. Why is this? I don't understand how the use of draw works in one but not the other. In the first one, the outline shows up and the rectangle is filled; in the second one just the labels "A" and "B" appear.




[ box/.style = {draw, rectangle, inner sep = 3mm, fill = lightgrey}
\node (A) at (0,0) [box] {$A$};
\node (B) at (2cm,0) [box] {$B$};
\draw [->] (A.east) -- (B.west);

\begin{scope}[draw, rectangle, inner sep = 3mm, fill = lightgrey]
    \node (A) at (0,0) {$A$};
    \node (B) at (2cm,0) {$B$};
\draw [->] (A.east) -- (B.west);

share|improve this question
up vote 2 down vote accepted

What's happening is that the default style of a node is going unchanged; the parameters you set on the scope don't apply to anything. To make it apply, you need to specify that it's the style for a node, using every node/.style:

  \begin{scope}[every node/.style={ draw
                                  , rectangle
                                  , inner sep = 3mm
                                  , fill      = lightgrey }]
      \node (A) at (0,0)   {$A$} ;
      \node (B) at (2cm,0) {$B$} ;
  \draw [->] (A.east) -- (B.west);

You could also remove the scope block and put the options directly after the tikzpicture environment, as you did in the first block with box/.style, unless you want to have nodes with other styles.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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