1 ページを超える TOC は、次のページの Tikz 絶対位置の調整に影響します。

1 ページを超える TOC は、次のページの Tikz 絶対位置の調整に影響します。

複数のページに TOC があると、PDF の残りの部分の tikz 配置が台無しになるという問題があります。例:

ここに画像の説明を入力してください

ヘッダーは、通常はページの上部にありますが、ページの下部に移動されました。

さて、コードです。次のようにしてヘッダーをページに読み込みます。

\begin{document}

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

    \AddToShipoutPicture{\BackgroundPic}

    \tableofcontents

\BackgroundPic は次のように定義されます:

\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

TOC が 1 ページしかない場合はまったく問題なく動作しますが、2 ページになるとバグが発生します。ご協力いただければ幸いです。よろしくお願いします。

アップデート:しばらく前にコメントとして投稿しましたが、より目立つようにここに移動することにしました。ここShareLatex には、この問題を示すオンライン バージョンがあります。そこでサンプル コードを確認し、編集して自分でコンパイルすることができます。

アップデート:TikzPictures のネストを削除してみましたが、効果はありませんでした。ネストされた画像のないコード:

\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}
}

アップデート:問題の原因は章スタイルであり、章スタイルを削除すると問題も解消されます。

\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}
  }

答え1

修正しました。問題は章のスタイルにありました。写真を思い出すtikzpicturesのオプションで問題は解決したようです。写真を思い出すオプションを選択すると、この問題が発生します。

\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}
  }

関連情報