# How can I resolve the side effects of AddEverypageHook to external pgfplots?

I have quite a huge document with many pgfplots, which I would like to externalize. Well I can externalize them, but my \AddEverypageHook command from the everypage package affects this externalized plots.

I add a background picture to every page:

\AddEverypageHook{\ThisTileWallPaper{\paperwidth}{\paperheight}{res/background.pdf}}


Unfortunately this background picture appears in the externalized plots:

Has anyone an idea to resolve this?

# Update

Here is a minimal example:

\documentclass{scrreprt}

\usepackage[ngerman]{babel}

\usepackage{everypage}
\usepackage{wallpaper}
\usepackage{gnuplottex}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar}
\usepgfplotslibrary{external}
\tikzexternalize

\begin{document}
\ThisULCornerWallPaper{}{res/background.pdf}

\begin{figure}[h!tbp]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
height=5cm,
width=\textwidth,
domain=-3:10
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}

\end{document}


The background.pdf-file is an A4 paper. It produces this result:

-
Without a minimal working example (MWE), I think this could be very difficult to diagnose. Could you narrow down your large file to exhibit the issue with a simple pgfplot and basic background image from the mwe package or similar? This would make it more accessible to the community and you might discover the problem yourself in making the MWE. :-) –  Paul Gessler Mar 13 at 14:26
I would try TikZ and its absolute positioning instead of page hooking. Usually we deal with one resulting picture, then we put whole tikzpicture environment into header by using \fancyhead command from the fancyhdr package. –  Malipivo Mar 19 at 12:41
Sorry, for the long quiet time! I had to finish the paper first. I've finally added a minimal example. –  Sam Apr 13 at 19:46

You can use \tikzifexternalizing{<code for true>}{<code for false>} to make something different during the externalization:

\documentclass{scrreprt}

\usepackage{everypage}
\usepackage{wallpaper}
\usepackage{gnuplottex}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar}
\usepgfplotslibrary{external}
\tikzexternalize

\begin{document}
\tikzifexternalizing{}{%
\ThisULCornerWallPaper{}{PP.pdf}%
}

\begin{figure}[h!tbp]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
height=5cm,
width=\textwidth,
domain=-3:10]
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}

\end{document}


My image is

\documentclass{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}