# TikZposter does not work with pgfplots

I can't use axis environment in tikzposter, when I add \usepackage{pgfplots}, I will get:

Package pgf Error: Sorry, the requested layer 'backgroundlayer' is not part o
f the layer list. Please verify that you provided \pgfsetlayers and that 'backg
roundlayer' is part of this list.


Here's an example:

\documentclass[landscape,a0paper, margin=9mm, innermargin=9mm,
blockverticalspace=14mm, colspace=12mm, subcolspace=0.1mm]{tikzposter}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{block}
\begin{tikzfigure}
\begin{tikzpicture}[>=latex]
\begin{pgfonlayer}{backgroundlayer}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
at={(0.803629in,0.513333in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=25,
xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25},
xticklabels={{},{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{}},
xmajorgrids,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=1300,
ymax=2000,
ytick={1300, 1800, 1900, 2000},
ymajorgrids
]
\addplot [color=red,solid,line width=4.0pt,mark size=10.0pt,mark=*,mark options={solid,fill=red},forget plot]
table[row sep=crcr]{%
1   1912\\
2   1895\\
3   1916\\
...
24  1878\\
};
\end{axis}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzfigure}
}
\end{document}


What's wrong?

• background not backgroundlayer and you need to declare it I think. – percusse Apr 3 '15 at 14:12
• Then I have problem with ! 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. – user75547 Apr 3 '15 at 14:15
• I add an issue at our TikZposter repo. Feel free to comment and extend the thread: bitbucket.org/surmann/tikzposter/issue/26/… – Dirk Jun 3 '15 at 9:06

@ percusse is right:

Adding \pgfdeclarelayer{backgroundlayer} in the correct place works.

PGF requires you to define any layer before you can use it.

\documentclass[landscape,a0paper, margin=9mm, innermargin=9mm,
blockverticalspace=14mm, colspace=12mm, subcolspace=0.1mm]{tikzposter}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{block}{Title}{Text}
\begin{tikzpicture}[>=latex]
\pgfdeclarelayer{backgroundlayer}
\begin{pgfonlayer}{backgroundlayer}
\begin{axis}[%
width=20cm,height=20cm,
at={(0.803629in,0.513333in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
xmin=0,
xmax=25,
xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25},
xticklabels={{},{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{}},
xmajorgrids,
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
ymin=1300,
ymax=2000,
ytick={1300, 1800, 1900, 2000},
ymajorgrids
]
\addplot [color=red,solid,line width=4.0pt,mark size=10.0pt,mark=*,mark options={solid,fill=red},forget plot]
table[row sep=crcr]{%
1   1912\\
2   1895\\
3   1916\\
24  1878\\
};
\end{axis}
\end{pgfonlayer}
\end{tikzpicture}
\end{block}

\end{document}


The problem is that the tikzposter class uses (of course) the tikz package. Thus if you use pgfplots, it is loaded after tikz, messing up the layers somehow (according to this thread). My solution is to edit the tikzposter.cls file and change the \usepackage{tikz} to a \usepackage{pgfplots}. As pgfplots also loads tikz, that does the trick for me.

• Don't fiddle with the installation files yourself. There is already a working solution from the pgfplots author above anyways. – percusse Jul 28 '15 at 9:19
• Using the class together with pgfplots seems to be a general problem. I am not using the pgfonlayer command and still get the same error (maybe because I am changing the poster theme, I don't know). So changing the installation file is an easy workaround, even though it is not an optimal solution. – Simon Jul 28 '15 at 9:39