仅为特定页面添加边距

仅为特定页面添加边距

我尝试为几页应用特定边距,但它适用于所有页面。我在 stack tex 上尝试了几种解决方案,但都不起作用。

对于前 3 页,我不需要边距,应该采用默认设置(默认是指当我注释该\usepackage[left=3.5cm,top=2.5cm,right=1.25cm,bottom=1.25cm]{geometry}行及其显示的结果时)。但对于其他部分页面,应该应用边距更改。

你能帮我一下吗?谢谢。

图片-1 图片-2

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{fancybox}
\usepackage{float}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{mwe}
\linespread{1.5}

\usepackage[left=3.5cm,top=2.5cm,right=1.25cm,bottom=1.25cm]{geometry}

\begin{document}

\begin{center}
    
    \begin{tikzpicture}[remember picture,overlay]
        \draw[black,line width=2pt] ([xshift=-1.5cm,yshift=-1.5cm]current page.north east)
        coordinate (A)--([xshift=1.5cm,yshift=-1.5cm]current page.north west)
        coordinate(B)--([xshift=1.5cm,yshift=1.5cm]current page.south west)
        coordinate (C)--([xshift=-1.5cm,yshift=1.5cm]current page.south east)
        coordinate(D)--cycle;
    \end{tikzpicture}

    \thispagestyle{empty}
    Title
    
    Subtitle
    \begin{figure}[h]
        \centering
        \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
    \end{figure}
    
    {\large \textbf{Project Name}} \\
    
    {\normalsize On} \\
    
    {\large \textbf{Project Title}} \\
    \textit{subtext} \\
    {\large \textbf{Degree}} \\
    {\normalsize \textbf{In}} \\
    {\large \textbf{Degree Title}} \\
    {\normalsize \textbf{Submitted by}} \\
    {\normalsize Name} \\
    {\normalsize \textbf{Under}} \\
    Name \\
    {\normalsize \textbf{Under}} \\
    Name \\
    SCHOOL name \\
    Address. \\
    Year
\end{center}

\newpage
    \vspace*{-30pt}
    \begin{tikzpicture}[remember picture,overlay]
        \draw[black,line width=3pt] ([xshift=-1cm,yshift=-1cm]current page.north east)
        coordinate (A)--([xshift=1cm,yshift=-1cm]current page.north west)
        coordinate(B)--([xshift=1cm,yshift=1cm]current page.south west)
        coordinate (C)--([xshift=-1cm,yshift=1cm]current page.south east)
        coordinate(D)--cycle;
    \end{tikzpicture}
    \begin{center}
    \thispagestyle{empty}
        \thispagestyle{empty}
    Title
    
    Subtitle
        \begin{figure}[H]
            \centering
            \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
        \end{figure}
        {\large INST NAME} \\ [10pt]
        {\LARGE \textbf{\textcolor{black}{TITLE}}}
    \end{center}

\newpage
\tableofcontents

\cleardoublepage
\pagenumbering{arabic}
\newpage
\section{Intro}
\lipsum[2-4]

\newpage
\section{Title1}
\lipsum[1-2]

\newpage
\section{Title2}
\lipsum[1-2]

\end{document}

答案1

一种方法是加载不带选项的包geometry。它将使用 A4 纸的默认边距加载。

\newgeometry{left=1.5cm,top=2.5cm,right=1.5cm,bottom=1.25cm}然后在标题页之前使用并最终发布\restoregeometry回到初始条件。

A

\documentclass[12pt,a4paper]{article}

\usepackage{fancybox}
\usepackage{float}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{mwe}
\linespread{1.5}


\usepackage{geometry} % changed <<<<<<<<<<<<<<<<<<<<<<<

\begin{document}
    
    \newgeometry{left=1.5cm,top=2.5cm,right=1.5cm,bottom=1.25cm}% added <<<<<<<<<
    
    \begin{center}
    
        \begin{tikzpicture}[remember picture,overlay]
            \draw[black,line width=2pt] ([xshift=-1.5cm,yshift=-1.5cm]current page.north east)
            coordinate (A)--([xshift=1.5cm,yshift=-1.5cm]current page.north west)
            coordinate(B)--([xshift=1.5cm,yshift=1.5cm]current page.south west)
            coordinate (C)--([xshift=-1.5cm,yshift=1.5cm]current page.south east)
            coordinate(D)--cycle;
        \end{tikzpicture}
        
        \thispagestyle{empty}
        Title
        
        Subtitle
        
        \begin{figure}[h]
            \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
        \end{figure}
        
        {\large \textbf{Project Name}} \\
        
        {\normalsize On} \\
        
        {\large \textbf{Project Title}} \\
        \textit{subtext} \\
        {\large \textbf{Degree}} \\
        {\normalsize \textbf{In}} \\
        {\large \textbf{Degree Title}} \\
        {\normalsize \textbf{Submitted by}} \\
        {\normalsize Name} \\
        {\normalsize \textbf{Under}} \\
        Name \\
        {\normalsize \textbf{Under}} \\
        Name \\
        SCHOOL name \\
        Address. \\
        Year
    \end{center}
    
    \newpage

    \begin{center}
        \begin{tikzpicture}[remember picture,overlay]
            \draw[black,line width=2pt] ([xshift=-1.5cm,yshift=-1.5cm]current page.north east)
            coordinate (A)--([xshift=1.5cm,yshift=-1.5cm]current page.north west)
            coordinate(B)--([xshift=1.5cm,yshift=1.5cm]current page.south west)
            coordinate (C)--([xshift=-1.5cm,yshift=1.5cm]current page.south east)
            coordinate(D)--cycle;
        \end{tikzpicture}

        \thispagestyle{empty}
        Title
        
        Subtitle
        
        \begin{figure}[h]
            \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
        \end{figure}
%       {\large INST NAME} \\ [10pt]
        {\LARGE \textbf{\textcolor{black}{TITLE}}}
    \end{center}
    
    \restoregeometry % added <<<<<<<<<<<<<<<<<<<<<
    
    \tableofcontents
    
    \cleardoublepage
    \pagenumbering{arabic}
    \newpage
    \section{Intro}
    \lipsum[2-4]
    
    \newpage
    \section{Title1}
    \lipsum[1-2]
    
    \newpage
    \section{Title2}
    \lipsum[1-2]
    
\end{document}

答案2

如果加载geometry包时不带任何选项。边距仍将根据geometry包设置为默认值。要完成,请返回文章类默认边距设置。使用pass中的选项\usepackage[pass]{geometry}。这将禁用所有几何设置,并使用文章类中的默认边距设置。然后可以在打印出目录页后使用 设置新的边距\newgeometry{left=3.5cm,top=2.5cm,right=1.25cm,bottom=1.25cm}

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{fancybox}
\usepackage{float}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{mwe}
\linespread{1.5}

\usepackage[pass]{geometry}

\begin{document}
\begin{center}
    
    \begin{tikzpicture}[remember picture,overlay]
        \draw[black,line width=2pt] ([xshift=-1.5cm,yshift=-1.5cm]current page.north east)
        coordinate (A)--([xshift=1.5cm,yshift=-1.5cm]current page.north west)
        coordinate(B)--([xshift=1.5cm,yshift=1.5cm]current page.south west)
        coordinate (C)--([xshift=-1.5cm,yshift=1.5cm]current page.south east)
        coordinate(D)--cycle;
    \end{tikzpicture}

    \thispagestyle{empty}
    Title
    
    Subtitle
    \begin{figure}[h]
        \centering
        \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
    \end{figure}
    
    {\large \textbf{Project Name}} \\
    
    {\normalsize On} \\
    
    {\large \textbf{Project Title}} \\
    \textit{subtext} \\
    {\large \textbf{Degree}} \\
    {\normalsize \textbf{In}} \\
    {\large \textbf{Degree Title}} \\
    {\normalsize \textbf{Submitted by}} \\
    {\normalsize Name} \\
    {\normalsize \textbf{Under}} \\
    Name \\
    {\normalsize \textbf{Under}} \\
    Name \\
    SCHOOL name \\
    Address. \\
    Year
\end{center}

\newpage
    \vspace*{-30pt}
    \begin{tikzpicture}[remember picture,overlay]
        \draw[black,line width=3pt] ([xshift=-1cm,yshift=-1cm]current page.north east)
        coordinate (A)--([xshift=1cm,yshift=-1cm]current page.north west)
        coordinate(B)--([xshift=1cm,yshift=1cm]current page.south west)
        coordinate (C)--([xshift=-1cm,yshift=1cm]current page.south east)
        coordinate(D)--cycle;
    \end{tikzpicture}
    \begin{center}
    \thispagestyle{empty}
        \thispagestyle{empty}
    Title
    
    Subtitle
        \begin{figure}[H]
            \centering
            \includegraphics[height=0.4\textwidth,width=1\textwidth]{example-image-a}
        \end{figure}
        {\large INST NAME} \\ [10pt]
        {\LARGE \textbf{\textcolor{black}{TITLE}}}
    \end{center}

\newpage
\newgeometry{left=3.5cm,top=2.5cm,right=1.25cm,bottom=1.25cm}
\tableofcontents

\cleardoublepage
\pagenumbering{arabic}
\newpage
\section{Intro}
\lipsum[2-4]

\newpage
\section{Title1}
\lipsum[1-2]

\newpage
\section{Title2}
\lipsum[1-2]

\end{document}

在此处输入图片描述 在此处输入图片描述

相关内容