如何删除目录中无用的空白页?(奇怪的行为)

如何删除目录中无用的空白页?(奇怪的行为)

我检查了所有类似问题的解决方案,但无济于事。我的目录中有一个额外的空白页,我注意到,如果我移动 \frontmatter 并将其放在标题页之后,问题就解决了!但这次在标题页之后又引入了一个空白页!!这是我的可重复性代码

\documentclass[12pt,openany,a4paper]{book}
\pagestyle{headings}        % Chapter on left page, Section on right.
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hspace{20pt}}{0pt}{\Huge\bfseries}
\titlespacing{\chapter}{0pt}{-40pt}{1em}
\raggedbottom

\usepackage[margin=2.5cm]{geometry}

\usepackage{blindtext}
\usepackage{multirow,tabularx}
\usepackage[%
    bibstyle=ieee,
    citestyle=numeric-comp,
    isbn=false, 
    doi=false,
    sorting=none,
    url=false,
    defernumbers=true,
    bibencoding=utf8,
    urldate=long,
    backend=biber
]{biblatex}
\bibliography{ref}


\begin{document}

\frontmatter
% By default, frontmatter has Roman page-numbering (i,ii,...).

\begin{titlepage}
My title
\end{titlepage}



\chapter{Abstract}
\blindtext

\tableofcontents

\mainmatter

\chapter{Introduction}
\blindtext


\chapter{Methodology}
Provides an outline of the methodological approach including a theoretical justification of the approach.
Describes any analytical techniques and research designs, if appropriate.


\chapter{Outcomes}
Describes the results to date and expected outcomes of future studies.
Discusses the findings.


While the outcome presented above is reasonable, it is still behind the ultimate target, which is a working algorithm on real human heads. Therefore, we keep pushing in this direction.

In more challenging and realistic scenarios
We report that fragility of neural nets is seriously limiting its use in such a sensitive application.

\chapter{Time-line}
This must include a clear plan for the completion of experiments, write up of papers (including a targeted list of suitable journals and conferences) and write up of the thesis.
\section{Year 1 (2019)}
    \begin{tabularx}{\textwidth}{l}
        \hline \vspace{-0.3cm}
    \end{tabularx}

\noindent
    \begin{tabularx}{\textwidth}{@{} p{2cm} p{13.5cm}}
        \\ Q1 -- Q2 & 
        \vspace{-0.74cm} 

\begin{itemize}
\item Getting acquainted with the project, the technical details entailed with calibrating the system and the type of data provided.

\item Reviewing the literature on machine learning.
\end{itemize}

        \\ Q3 -- Q4 & 
        \vspace{-0.74cm}

\begin{itemize}
\item blah

\item blah
\end{itemize}

    \end{tabularx}



\section{Year 2 (2020)}

    \begin{tabularx}{\textwidth}{l}
        \hline \vspace{-0.3cm}
    \end{tabularx}


\noindent
    \begin{tabularx}{\textwidth}{@{} p{2cm} p{13.5cm}}
        \\ Q1 -- Q2 & 
        \vspace{-0.74cm} 

\begin{itemize}
\item \blindtext
\item \blindtext
\end{itemize}


        \\ Q3 -- Q4 & 
        \vspace{-0.74cm}

\begin{itemize}
\item \blindtext
\item \blindtext
\end{itemize}

    \end{tabularx}


\section{Year 3 (2021)}
    \begin{tabularx}{\textwidth}{l}
        \hline \vspace{-0.3cm}
    \end{tabularx}


\noindent
    \begin{tabularx}{\textwidth}{@{} p{2cm} p{13.5cm}}
        \\ Q1 -- Q2 & 
        \vspace{-0.74cm} 

\begin{itemize}
\item \blindtext
\item \blindtext
\end{itemize}


        \\ Q3 -- Q4 & 
        \vspace{-0.74cm}

\begin{itemize}
\item \blindtext
\item \blindtext
\end{itemize}

    \end{tabularx}


\chapter{Bibliography}


    \begin{appendix}
\chapter{Publications}
\section{Unpublished work}
Hi there
    \end{appendix}

\end{document}

答案1

获得双分页符的原因是来自\mainmatter,而它又调用\cleardoublepage,其定义如下(来自latex.ltx):

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

解释:

  • \clearpage清除当前页面并开始新的页面。
  • \if@twoside如果文件是双面的
    • \ifodd\c@page\else如果当前页面不是奇数
      • \hbox{}\newpage插入一个空框和一个新页面(或列)
      • \if@twocolumn如果当前页面有两列
        • \hbox{}\newpage插入一个空框和一个新页面
      • \fi关闭\if@twocolumn测试
    • \fi关闭\ifodd测试
  • \fi关闭\if@twoside测试

那么,这在您的文档中是如何体现的?

该类的默认选项book意味着为\if@twoside真和\if@twocolumn为假。

当您调用\mainmatter目录后,即调用第 iii 页\cleardoublepage。首先插入一个新页面,使当前页面成为 iv。文档是双面的,当前页面现在不是奇数页(它是 iv),因此\hbox{}\clearpage插入。文档不是两列,因此这会插入一个空白页,并将页码重置为 1(按\mainmatter)。它需要对双面文档执行此操作,否则您将在两个对开页面的左侧看到第 1 页,这很奇怪。

解决方法是确保您的文档不使用双面设置。这样就不会有对开页,您的文档就可以从第 iii 页转到第 1 页,而不会显得奇怪。

因此解决方案是使用以下选项加载书籍类oneside

\documentclass[12pt,oneside,openany,a4paper]{book}

相关内容