在下一页上重复脚注作为页眉和脚注

在下一页上重复脚注作为页眉和脚注

我对 Latex 还不熟悉,我正在尝试解决一个问题,但我自己无法解决。问题是,我正在编辑一个文档,我希望文档中有一个页眉和“脚注”作为绘图。我设法做到了,但仅限于第一页。在接下来的几页中,我希望页眉和脚注都是与第一页的脚注相同的图形。我能做到吗?怎么做?在这里您可以查看代码。我还附上了一张图片一张图片胜过千言万语 在此处输入图片描述

\documentclass[]{article}

\usepackage{lipsum} 

\RequirePackage{tikz}


\tikzstyle{cajanaranja}=[rectangle, fill=orange, anchor=north, minimum width=\paperwidth, minimum height=.15cm]

\tikzstyle{cajagris}=[rectangle, fill=gray, anchor=north, minimum width=\paperwidth, minimum height=3cm]

\tikzstyle{cajanaranjaabajo}=[rectangle, fill=orange, anchor=south, minimum width=\paperwidth, minimum height=.15cm]

\tikzstyle{cajagrisabajo}=[rectangle, fill=gray, anchor=south, minimum width=\paperwidth, minimum height=.15cm]

\newcommand{\header}{%
  \begin{tikzpicture}[remember picture,overlay]
    \node [cajanaranja] (boxorange) at (current page.north){};
        \node [cajagris] (boxgray) at (boxorange.south){};
        \node [cajagrisabajo] (boxgraydown) at (current page.south){};
        \node [cajanaranjaabajo] (boxorangedown) at (boxgraydown.north){};
  \end{tikzpicture}
  \vspace{1.5cm}
  \vspace{-3\parskip}
}


\begin{document}


\header

\lipsum

\end{document}

答案1

使用包scrlayer-scrpage可以定义一个新层,将图片插入页面背景的顶部和底部。然后您可以将此层添加到每个页面样式中。

\documentclass{article}
\usepackage{blindtext}% dummy text
\usepackage{tikz}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot*{\pagemark}

\tikzset{
  margins/.style={rectangle,anchor=north, minimum width=\paperwidth, minimum height=.15cm,outer sep=0pt},
  cajanaranja/.style={margins, fill=orange},
  cajagris/.style={margins,fill=gray,minimum height=3cm},
  %cajanaranjaabajo/.style={margins, fill=orange},
  cajagrisabajo/.style={margins, fill=gray}
}

\newsavebox\firstheader
\savebox\firstheader{\tikz{
  \node [cajanaranja] (boxorange){};
  \node [cajagris] (boxgray) at (boxorange.south){};
}}
\newsavebox\headerorfooter
\savebox\headerorfooter{\tikz{
  \node [cajanaranja] (boxorange){};
  \node [cajagrisabajo] (boxgray) at (boxorange.south){};
}}

\DeclareNewLayer[
  background,
  mode=picture,
  contents={
  \ifnum \value{page}=1
  \putUL{\raisebox{-\height}{\usebox\firstheader}}
  \else
  \putUL{\raisebox{-\height}{\usebox\headerorfooter}}
  \fi
  \putLL{\usebox\headerorfooter}}
]{margins.bg}
\AddLayersToPageStyle{@everystyle@}{margins.bg}


\begin{document}
\blinddocument
\end{document}

结果:

在此处输入图片描述

相关内容