Taking the MWE from Jake's answer to the question Background rectangles with equal width but 'fitting' height, I get an error when loading pgfplots after the tikz packages but not before. I'm assuming this is caused by pgfplots redefining the standard tikz layers (cf. tikz manual Section 4.26) but I don't quite understand if this is intentional and whether loading pgfplots before tikz has any consequences for how pgfplots expects its layers to work.
The error in question is:
! Package pgf Error: Sorry, the requested layer 'background' is not part of the
layer list. Please verify that you provided \pgfsetlayers and that 'background'
is part of this list.
See the pgf package documentation for explanation.
Type H <return> for immediate help.
...
l.49 \begin{pgfonlayer}{background}
MWE:
\documentclass{article}
\usepackage{pgfplots} % Works fine
\usepackage{tikz}
\usetikzlibrary{backgrounds,fit,calc}
%\usepackage{pgfplots} % Throws an error
\begin{document}
\tikzset{
schritt/.style={
draw,
rounded corners,
fill=blue!20,
inner xsep=2em,
},
background/.style={
draw,
fill=yellow!30,
align=right
}
}
% Returns three nodes: The argument, and the projections of the argument on the left and right borders of the bounding box
\newcommand{\extendnode}[1]{
(#1)
($(current bounding box.north east)!(#1)!(current bounding box.south east)$)
($(current bounding box.north west)!(#1)!(current bounding box.south west)$)
}
\begin{tikzpicture}
\matrix (matrix) [row sep=0.5cm,column sep=0.5cm] {
\node (elicit) [schritt] {Wissenserhebung}; & \\
\node (interpret) [schritt] {Interpretation}; & \\
& \node (model) [schritt] {Modellierung}; \\
\node (representation) [schritt] {Repräsentation}; & \\
\node (integration) [schritt] {Integration}; & \\
\node (maintenance) [schritt] {Wartung}; & \\
};
\path[->]
(elicit) edge (interpret)
(interpret) edge node[right] {\hspace{.35cm}\tiny Modellbasierter Ansatz} (model)
(interpret) edge node[right] {\tiny Rapid Prototyping} (representation)
(model) edge (representation)
(representation) edge (integration)
(integration) edge (maintenance);
\begin{pgfonlayer}{background}
\path [use as bounding box] (current bounding box.north west) (current bounding box.south east); % Freeze current bounding box
\node [fit={\extendnode{elicit}}, background] {First};
\node [fit={\extendnode{interpret} (model)}, background] {Second};
\node [fit=\extendnode{representation}, background] {Third};
\node [fit=\extendnode{integration}, background] {Fourth};
\node [fit=\extendnode{maintenance}, background] {Fifth};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
pgfplotsand Tikz doesn't have any options to change so it's redundant. Just letpgfplotsdo its magic internally. – percusse Mar 24 '13 at 01:10\usetikzlibrarywill necessarily come afterpgfplotsis loaded anyway. I'm guessing that means that loadingtikzsecond would not interfere with the layerspgfplotsestablishes then, aspgfplotspresumably takes care of that when loadingtikzin its own code. – ThomasH Mar 24 '13 at 01:41\pgfplotsset{compat=newest}(which uses version 1.10) solved the problem. – josteinb Aug 12 '14 at 21:12