4

I'm trying to use LaTeX to create a document but a random page is created after the front page and I'm not sure of the best way to remove it. As you can see in the document class I've added openany which should make the document one-sided and yet this page is still being randomly added. I've added the code below and an image of what's produced. Any help would be very much appreciated.

\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}

enter image description here

2

\frontmatter is the cause behind this as it inserts a \cleardoublepage. While \newpage and \clearpage are gobbled if used successively, \cleardoublepage does more than just clear a page or possibly more. In order to succeed in possibly clearing a blank page as well, it inserts an \hbox{} on a page (which prints nothing) and then issues another \newpage, otherwise it may be gobbled. Here's the actual definition (from latex.ltx):

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

So, here's your sequence of instructions:

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

\newpage

\frontmatter

The titlepage is constructed on page 1. Then you insert a \newpage, putting you on page 2. Issuing \frontmatter on page 2, leaves \cleardoublepage to call:

\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}

You can remove the blank page using atbegshi's \AtBeginShipoutNext{\AtBeginShipoutDiscard}:

\usepackage{atbegshi}

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

\newpage

\AtBeginShipoutNext{\AtBeginShipoutDiscard}% Discard next blank page

\frontmatter

or just do whatever \frontmatter does manually. Here's \frontmatter's definition from book.cls:

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

Since you're changing the page numbering anyway, just use

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

\newpage

\csname @mainmatterfalse\endcsname

(which avoids using a \makeatletter...\makeatother pair).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.