2

I have an issue where a TOC on more than one page, ruins the tikz-positioning for the rest of the pdf. Example:

enter image description here

The header has been moved to the bottom of the page where it usually stays on the top of the page.

Now to the code: Load the header into the page like this:

\begin{document}

    \input{graphics/pagestyle/titlepage.tex}
    \pagecolor{none}
    \newpage

    \AddToShipoutPicture{\BackgroundPic}

    \tableofcontents

\BackgroundPic is defined like this:

\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\headerbg{
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=WLEBlue1] (0,0) rectangle
          (\paperwidth,3cm);
          \node (label) at (10,1.5){
            \includegraphics[width=660pt]{graphics/pagestyle/header_bg.png}
          };
          \node (label) at (1.4,1.5){
            \includegraphics[width=60pt]{graphics/pagestyle/WLE_Logo.png}
          };
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
  }

\usepackage{eso-pic}
\newcommand\BackgroundPic{
\headerbg
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\begin{tikzpicture}[remember picture,overlay]
    \node at (-10,12.5)
      {\begin{tikzpicture}[remember picture, overlay]
            \draw [WLEBlue1, fill=WLEBlue1] (0,0) -- (0.05,0) -- (0.05,-22.2) -- (0.25,-22.2) -- (0.25, -23) -- (0, -23);
       \end{tikzpicture}
      };
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
\node at (8.5,12.5)
      {\begin{tikzpicture}[remember picture, overlay]
            \draw [WLEBlue1, fill=WLEBlue1] (-1, -23) -- (0, -23) -- (0, -22) -- (-0.08, -22) -- (-0.08, -22.92) -- (-1, -22.92);
       \end{tikzpicture}
      };
\end{tikzpicture}
\vfill
}}}
        \newpage

It works totally fine when the TOC is only 1 page long, with 2 pages it bugs up. Any help is greatly appreciated! Thank you in advance.

Update: Posted this as a comment a while ago, but decided to move it up here for more visiblity: Here is an online version at ShareLatex showing the issue. You can see, and edit some example code there and compile it for yourself.

Update: Tried removing the nesting of the TikzPictures but it didn't help. Code without nested pictures:

\newcommand*\headerbg{
    \begin{tikzpicture}[overlay]
        \node(base) at (current page.north west) {};
        \node at ($(base)+(9.1,0.7)$){
            \includegraphics[width=660pt]{header_bg.png}
        };
        \node at ($(base)+(0.5,0.7)$){
            \includegraphics[width=60pt]{WLE_Logo.png}
        };
    \end{tikzpicture}
}

Update: It's the Chapter Style that is causing the issue, removing the chapter style removes the issue aswell.

\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node at (0,0)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[WLEBlue2, fill=WLEBlue2] (0,0) rectangle
          (\textwidth,1cm);
        \node[
            inner xsep=1ex,
            text width=\linewidth-2*\pgfkeysvalueof{/pgf/inner xsep},
            align=left] at (9,0.5)
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
  • 2
    Can you complete your example into a compilable one ? It's quite long anyway so why not adding a few more lines and make it start from \documentclass{...} to \end{document}. Without reading thoroughly I am pretty sure it's due to the nesting of TikZ pictures. – percusse Apr 11 '13 at 10:05
  • Welcome to TeX.sx! – Peter Jansson Apr 11 '13 at 10:15
  • Here is an online version at ShareLatex showing the issue. Can't get more compilable than that ;) – LukasPJ Apr 11 '13 at 13:12
  • @percusse I removed the nesting of the TikZ pictures but with no luck – LukasPJ Apr 18 '13 at 21:56
  • @LukasPJ Well, I did a test with the snippets you provided; since I didn't have your images I had to use the demo option for graphicx, and I couldn't detect any problems. Please see the code that I used here: pastebin.com/7k8qTP4h . Processing that simpledocument produces no undesired behaviour. If you want us to detect the problem, you will have to provide a sample document like mine (complete and simple) but allowing us to really reproduce the problem. – Gonzalo Medina Apr 18 '13 at 23:16
0

Fixed, the issue was in the chapter style. I removed the remember picture options on the tikzpictures which seems to have resolved the issue. I'm not entirely sure why the remember picture option would cause this issue.

\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[overlay]
    \node at (0,0)
      {\begin{tikzpicture}[overlay]
        \draw[WLEBlue2, fill=WLEBlue2] (0,0) rectangle
          (\textwidth,1cm);
        \node[
            inner xsep=1ex,
            text width=\linewidth-2*\pgfkeysvalueof{/pgf/inner xsep},
            align=left] at (9,0.5)
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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