如何在 Latex 中添加前两页的页面边框?

如何在 Latex 中添加前两页的页面边框?

我是 Latex 的初学者。我正在尝试创建我的实习报告,所以我想为前两页创建页面边框。我创建了第一页,但第二页没有边框,它得到了我提供的页眉和页脚。所以请帮我把边框也放在第二页上……

这是我尝试过的,

\documentclass[12pt]{book}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}

\pagenumbering{roman}
\begin{titlepage}

\begin{tikzpicture}[overlay,remember picture]
\draw [line width=3pt]
       ($ (current page.north west) + (1.5cm,-2.0cm) $)
    rectangle
    ($ (current page.south east) + (-1.5cm,1.8cm) $);
\draw [line width=1pt]
    ($ (current page.north west) + (1.65cm,-2.15cm) $)
    rectangle
    ($ (current page.south east) + (-1.65cm,1.95cm) $); 
\end{tikzpicture}

\section*{\large{DECLARATION}}

%-----some paragraph-------

\newpage

\begin{center}
\section*{\large{ACKNOWLEDGEMENT}}
\end{center}

%-----some paragraph-------
\end{titlepage}
\newpage

\tableofcontents
\newpage 

\pagenumbering{arabic}

%-----Start chapters-------
\end{document}

(在代码中我没有提到页眉和页脚)

我搜索了很多,但我只知道如何添加一个页面边框,所以帮我为两个页面添加边框

答案1

欢迎!这是使用 的一种可能方法eso-pic

\documentclass[12pt]{book}
\usepackage{tikz}
\usepackage{eso-pic}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\AddToShipoutPictureBG{\ifnum\value{page}<3% <- change this if you want more
% or less pages to have a frame
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=3pt]
       ($ (current page.north west) + (1.5cm,-2.0cm) $)
    rectangle
    ($ (current page.south east) + (-1.5cm,1.8cm) $);
\draw [line width=1pt]
    ($ (current page.north west) + (1.65cm,-2.15cm) $)
    rectangle
    ($ (current page.south east) + (-1.65cm,1.95cm) $); 
\end{tikzpicture}%
\fi}
\begin{document}

\begin{titlepage}


\section*{DECLARATION}

%-----some paragraph-------

\newpage
\thispagestyle{empty}
\begin{center}
\large\bfseries ACKNOWLEDGEMENT
\end{center}

%-----some paragraph-------
\end{titlepage}
\newpage
\chapter{Some chapter}
%-----Start chapters-------
\end{document}

在此处输入图片描述

答案2

以下是对我有用的方法 - 可能对其他人也有用。在一种book文档中 - 我希望第一页有边框。请注意使用\AddToShipoutPictureBG*而不是\AddToShipoutPictureBG{}

\begin{document}

\frontmatter
\begin{titlepage}
    \makeatletter
    \AddToShipoutPictureBG*{
        \begin{tikzpicture}[overlay,remember picture]
            \draw [line width=3pt]
            ($ (current page.north west) + (1.5cm,-2.0cm) $)
            rectangle
            ($ (current page.south east) + (-1.5cm,1.8cm) $);
            \draw [line width=1pt]
            ($ (current page.north west) + (1.65cm,-2.15cm) $)
            rectangle
            ($ (current page.south east) + (-1.65cm,1.95cm) $); 
        \end{tikzpicture}
    }
    \makeatother
    
    \input{./coverpage/coverpage-thesis}
\end{titlepage}

相关内容