如何删除 LaTex 中标题页后的空白页?

如何删除 LaTex 中标题页后的空白页?

我正在尝试使用 LaTeX 创建文档,但在首页之后会创建一个随机页面,我不确定删除它的最佳方法。正如您在我添加的文档类中看到的那样,openany这应该会使文档变成单面,但此页面仍然是随机添加的。我添加了下面的代码和生成的图像。任何帮助都将不胜感激。

\documentclass[a4paper, 12pt, openany]{book}
\RequirePackage{fullpage}
\RequirePackage{graphicx}
\RequirePackage{ragged2e}
\RequirePackage{mathptmx}
\RequirePackage{anyfontsize}
\RequirePackage{t1enc}
\RequirePackage{setspace}
\RequirePackage[utf8]{inputenc}
\graphicspath{ {figures/} }
\RequirePackage{array}



\RequirePackage{etoolbox} % for "\patchcmd" macro
\makeatletter
% No extra space between chapter number and chapter header lines:
\patchcmd{\@makechapterhead} {\vskip 20}{\vskip 0} {}{}
% Reduce extra space between chapter header and section header lines by 50%:
\patchcmd{\@makechapterhead} {\vskip 40}{\vskip 20}{}{}
\patchcmd{\@makeschapterhead}{\vskip 40}{\vskip 20}{}{} % for unnumbered chapters
\makeatother

\begin{document}
    \begin{titlepage}
        \begin{center}
            \vspace*{1cm}
            
            \Huge
            \textbf{Engineering + Engineering = Engineering}
            
            \vspace{0.5cm}
            \LARGE
            Design of of something something something
            \includegraphics[width=0.7\columnwidth]{university.jpg}
            \centering
            
            
            
            
            \textbf{John Smith}
            
            \vfill
            
            A thesis submitted to the School of Engineering\\ 
            at the University of Hull for the degree of\\ 
            MASTER OF ENGINEERING    
            
            
            \vspace{0.8cm}
            
            
            
            
            
            
            
            \Large
            School of  Engineering\\
            University of Hull\\
            United Kingdom\\
            October 2023
            
        \end{center}
    \end{titlepage}
    
    \newpage
    \frontmatter
    \pagenumbering{Roman}
    \centering
    
    \topskip0pt
    \vspace*{\fill}
    \Huge
    
    \normalsize
    \par
    \emph{“Some Sort of Inspirational Quote.” }
    John Smith
    \vspace*{\fill}

在此处输入图片描述

答案1

\frontmatter是造成这种情况的原因,因为它插入了一个\cleardoublepage。虽然\newpage\clearpage如果连续使用会被吞噬,\cleardoublepage但不仅仅是清除一页或可能更多。为了成功清除空白页,它会\hbox{}在一页上插入一个(不打印任何内容),然后发出另一个\newpage,否则它可能会被吞噬。这是实际的定义(来自latex.ltx):

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}

因此,这是您的指令顺序:

\begin{titlepage}
  % <title stuff>
\end{titlepage}

\newpage

\frontmatter

在第 1 页上构建titlepage了 。然后插入\newpage,将您带到第 2 页。\frontmatter在第 2 页上发出 ,调用\cleardoublepage

\clearpage % ...this is gobbled, since the it follows from a \newpage
\if@twoside % ...this is true within book
  \ifodd\c@page % ...this is false, so
  \else %         ...follow this branch
    \hbox{}%      ...insert something that doesn't print anything
    \newpage%     ...issue a (legal) \newpage
    \if@twocolumn%...this is false...
      \hbox{}%
      \newpage%
    \fi
  \fi
\fi}

您可以使用以下方式删除空白页atbegshi\AtBeginShipoutNext{\AtBeginShipoutDiscard}

\usepackage{atbegshi}

\begin{titlepage}
  % <title stuff>
\end{titlepage}

\newpage

\AtBeginShipoutNext{\AtBeginShipoutDiscard}% Discard next blank page

\frontmatter

或者直接手动执行\frontmatter。以下是\frontmatter的定义book.cls

\newcommand\frontmatter{%
    \cleardoublepage
  \@mainmatterfalse
  \pagenumbering{roman}}

由于您要更改页码,因此只需使用

\begin{titlepage}
  % <title stuff>
\end{titlepage}

\newpage

\csname @mainmatterfalse\endcsname

(避免使用\makeatletter...\makeatother一对)。

相关内容