![如何删除 LaTex 中标题页后的空白页?](https://linux22.com/image/425239/%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4%20LaTex%20%E4%B8%AD%E6%A0%87%E9%A2%98%E9%A1%B5%E5%90%8E%E7%9A%84%E7%A9%BA%E7%99%BD%E9%A1%B5%EF%BC%9F.png)
我正在尝试使用 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