我遇到一个问题,即目录位于多页上,破坏了 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
当目录只有 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}
}