我刚刚开始使用 tikz,并尝试在每页中添加页眉和页脚。我有此代码,但这是我的(非常小的)问题:
\newcommand\Footer{%
\begin{tikzpicture}[remember picture, overlay]
\node[above, yshift=-3] (footer) at (current page.south) {\includegraphics[width=\paperwidth]{footer.png}};
\draw [fill=otherdarkblue, draw=none] (0.1,0.1) rectangle (\paperwidth,0.2); % I want this to be just above the footer and centered horizontally
\end{tikzpicture}%
}
我希望矩形绘制在页脚节点正上方(矩形的底部应与页脚的顶部相对应)并相对于页脚水平居中。
答案1
像这样?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{eso-pic}
\newcommand\Footer{%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=south,inner sep=0pt, outer sep=0pt] (footer) at (current page.south) {\includegraphics[width=\paperwidth,height=1cm]{example-image}};
\node [fill=blue, draw=none,minimum width=\paperwidth,inner ysep=0.1cm,outer sep=0pt] at (footer.north){}; % I want this to be just above the footer and centered horizontally
\end{tikzpicture}%
}%
\AddToShipoutPictureBG{%
\AtPageLowerLeft{\put(0,0){\Footer}}%
}
\begin{document}
Some text
\clearpage
Some text again
\end{document}
与包相同background
:
\documentclass{article}
\usepackage{background}
\usetikzlibrary{calc}
\newcommand\Footer{%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=south,inner sep=0pt, outer sep=0pt] (footer) at (current page.south) {\includegraphics[width=\paperwidth,height=1cm]{example-image}};
\node [fill=blue, draw=none,minimum width=\paperwidth,inner ysep=0.1cm,outer sep=0pt] at (footer.north){}; % I want this to be just above the footer and centered horizontally
\end{tikzpicture}%
}%
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
contents={\Footer}
}
\begin{document}
Some text
\clearpage
Some text again
\end{document}