I'm trying to place an image in the background using TikZ layers but as soon as I enable the layers option, everything in the background layer disappears. I have no idea why. I found some hints about the main layer but this problem seems to be with the background layer. I also tried the backgrounds library. Same problem. (I've had success with layers on this same machine before but I'm no expert.)



\tikzstyle{userblock}=[draw,rectangle,fill=gray!15,minimum height=4em,minimum width=4em, node distance=6em];    

\tikzstyle{tasklabels}=[node distance=5em];  
\tikzstyle{compblock}=[draw=blue, fill=blue!15,node distance=5em, minimum height=4em, minimum width=20em, inner sep=1em];      

\node[userblock]                (u1)    {user$_1$} ; 
\node[userblock,right of=u1]    (u2)    {user$_2$} ;
\node[userblock, draw=none,fill=none,right of=u2]   (udots) {\ldots} ;
\node[userblock,right of=udots] (un)    {user$_n$} ;

\node[tasklabels,below of=u1]               (l1)    {compiler} 
    edge [<->] (u1); 
\node[tasklabels, below of=u2]              (l2)    {assembler}
    edge [<->] (u2) ;   
\node[tasklabels, below of=udots]           (ldots)     {...}
\node[tasklabels, below of=un]              (ln)    {database system}
    edge [<->] (un) ;   

\node[compblock,fit=(l1)(ln)]               (L1)    {System and Application Programs}
    edge [-,dashed] (l1) 
    edge [-,dashed] (l2) 
    edge [-,dashed] (ln)  ;
\node[compblock,below of=L1]  (L2) {Operating System}
    edge [<->] (L1) ;
\node[compblock,below of=L2]  (L3) {Computer Hardware}
    edge [<->] (L2) ;


1 Answer 1


Use \usetikzlibrary and declare and set the layers before you start the tikzpicture environment. When I did this, the missing nodes and edges appeared.

You could move also \tikzstyle, but here it would be better to use \tikzset instead, or to give the styles as option to the tikzpicture environment.

  userblock/.style={draw,rectangle,fill=gray!15,minimum height=4em,
    minimum width=4em, node distance=6em},
  tasklabels/.style={node distance=5em]}, 
  compblock/.style={draw=blue, fill=blue!15,node distance=5em,
    minimum height=4em, minimum width=20em, inner sep=1em}]
  • So, simply moving the usetikzlibrary out of the tikzpicture environment solved it.
    – recluze
    Commented Jan 15, 2012 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .