如何删除新报告章节之前的空白页?

如何删除新报告章节之前的空白页?

这个问题是在我在序言中添加了以下代码以将默认章节标题字体(以下代码中的“INTRODUCTION”)设置为默认常规文本字体后开始的,该字体很大、很粗而且很粗,我不喜欢。

\usepackage[rm,tiny]{titlesec} %added this to change the chapter title's font as default regular text font.
\titleformat{\chapter}{\normalfont\centering}{}{0pt}{}
\titlelabel{}
\titlespacing*{\chapter}{0pt}{-20pt}{4pt}

发生的事情是,我可以更改章节的字体,但在“简介”页面之前出现了一个空白页(页眉上有页码 1)。简介页面的页脚上现在有页码 2,而不是我格式化后显示的页眉。所有其他页码都在页眉中。

每当我使用该命令格式化其他章节(文献综述、方法论等)时,这种趋势都会持续下去\chapter{}。会创建一个空白页,并将新部分向下推一页,页码位于页脚而不是页眉上。

以下是更完整的代码:

\documentclass[12pt]{report}
\usepackage[left=1.5in, right=1in, top=1in, bottom=1.5in]{geometry}
\usepackage{setspace}
\usepackage{amsbsy}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{calc}
\newlength{\depthofsumsign}
\setlength{\depthofsumsign}{\depthof{$\sum$}}
\newlength{\totalheightofsumsign}
\newlength{\heightanddepthofargument}

\usepackage[rm,tiny]{titlesec} %added this to change the chapter title's font as default regular text font.

\usepackage{pdflscape,booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit} 
\usepackage[font=it,skip=0.5\baselineskip]{caption}

%to put page numbers in the header
\fancyhf{}
\fancyhead[C]{\thepage}
\pagestyle{fancy}

\titleformat{\chapter}{\normalfont\centering}{}{0pt}{}
\titlelabel{}
\titlespacing*{\chapter}{0pt}{-20pt}{4pt}

\begin{document}
\setlength{\headheight}{50pt} %to note where the header lies.
\setlength{\headsep}{15pt} %to set the distance between header and the first line after it.

\renewcommand{\headrulewidth}{0pt}
\doublespacing
\thispagestyle{empty}
\begin{center}
\vspace*{0.2in}
MY TITLE\\
\vspace*{0.4in}
by\\
My name\\\

\vspace*{1.4in}
\singlespacing
A thesis submitted in partial fulfillment\\
of the requirements for the degree\\
\doublespacing
of\\
My degree\\
in\\
My discipline\\\

\vspace*{1in}
MY UNIVERSITY\\
University, Location\\
\vspace*{0.2in}
April 2019
\end{center}
\pagebreak

\pagenumbering{gobble}
\begin{center}
\vspace*{1in}
\textcopyright COPYRIGHT\\
by\\
My name\\
2019\\
All Rights Reserved
\end{center}
\pagebreak

\pagenumbering{arabic}
\setcounter{page}{1}
\begin{center}
\chapter{INTRODUCTION}
\end{center}

My introduction section's first paragraph...

\end{document}

前两页没有问题(第一页是封面,上面有论文名称等,第二页是版权部分)。这些页面没有页码(因此\pagenumbering{gobble}第二页没有代码)。

编辑:我已通过删除代码解决了空白页的问题\begin{center} ... \end{center},但章节所在页面的页码仍显示在页脚而不是页眉中。所有其他页面的页码均显示在页眉中。有什么方法可以解决这个问题吗?

答案1

章节页面plain默认使用页面样式。如果您想要调整两种样式plainfancy使用页面样式。如果某些页眉和/或页脚字段的内容有所不同,请fancyplain使用。fancy\fancyplain{<content for plain style>}{<content for fancy style>}

\documentclass[12pt]{report}
\usepackage[left=1.5in, right=1in, top=1in, bottom=1.5in]{geometry}
\usepackage{setspace}
\usepackage{amsbsy}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{calc}
\newlength{\depthofsumsign}
\setlength{\depthofsumsign}{\depthof{$\sum$}}
\newlength{\totalheightofsumsign}
\newlength{\heightanddepthofargument}

\usepackage[rm,tiny]{titlesec} %added this to change the chapter title's font as default regular text font.

\usepackage{pdflscape,booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit} 
\usepackage[font=it,skip=0.5\baselineskip]{caption}

%to put page numbers in the header
\fancyhf{}
\fancyhead[C]{\thepage}
%\fancyfoot[C]{\fancyplain{plain style}{fancy style}}% <- to show the usage of \fancyplain
\pagestyle{fancyplain}% <- changed

\titleformat{\chapter}{\normalfont\centering}{}{0pt}{}
\titlelabel{}
\titlespacing*{\chapter}{0pt}{-20pt}{4pt}

\setlength{\headheight}{50pt} %to note where the header lies.
\setlength{\headsep}{15pt} %to set the distance between header and the first line after it.

\renewcommand{\headrulewidth}{0pt}

\begin{document}
\doublespacing
\thispagestyle{empty}
\begin{center}
\vspace*{0.2in}
MY TITLE\\
\vspace*{0.4in}
by\\
My name\\\

\vspace*{1.4in}
\singlespacing
A thesis submitted in partial fulfillment\\
of the requirements for the degree\\
\doublespacing
of\\
My degree\\
in\\
My discipline\\\

\vspace*{1in}
MY UNIVERSITY\\
University, Location\\
\vspace*{0.2in}
April 2019
\end{center}
\clearpage

\thispagestyle{empty}
\begin{center}
\vspace*{1in}
\textcopyright COPYRIGHT\\
by\\
My name\\
2019\\
All Rights Reserved
\end{center}
\cleardoublepage

\pagenumbering{arabic}
\setcounter{page}{1}

\chapter{INTRODUCTION}
\lipsum

\end{document}

结果

截屏

答案2

\chapter这里使用重新定义命令并添加\thispagestyle{fancy}到章节命令(每个版本)的每个调用的代码来修复:

\documentclass[12pt]{report}
\usepackage[left=1.5in, right=1in, top=1in, bottom=1.5in]{geometry}
\usepackage{setspace}
\usepackage{amsbsy}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{calc}
\newlength{\depthofsumsign}
\setlength{\depthofsumsign}{\depthof{$\sum$}}
\newlength{\totalheightofsumsign}
\newlength{\heightanddepthofargument}

\usepackage[rm,tiny]{titlesec} %added this to change the chapter title's font as default regular text font.
\usepackage{lipsum}
\usepackage{pdflscape,booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit} 
\usepackage[font=it,skip=0.5\baselineskip]{caption}

%to put page numbers in the header
\fancyhf{}
\fancyhead[C]{\thepage}
\fancyfoot{}
\pagestyle{fancy}

\titleformat{\chapter}{\normalfont\centering}{}{0pt}{}
\titlelabel{}
\titlespacing*{\chapter}{0pt}{-20pt}{4pt}


%koleygr: Redefining chapter to include \thispagestyle{fancy}
\let\oldchapter\chapter
\makeatletter
\def\chapter{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldchapter*{#2}%
\thispagestyle{fancy}
}
\def\@StarredWithout#1{
\oldchapter*{#1}%
\thispagestyle{fancy}
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldchapter[#1]{#2}%
\thispagestyle{fancy}
}
\def\@nonStarredWithout#1{%
\oldchapter{#1}%
\thispagestyle{fancy}
}
\makeatother


\begin{document}
\setlength{\headheight}{50pt} %to note where the header lies.
\setlength{\headsep}{15pt} %to set the distance between header and the first line after it.

\renewcommand{\headrulewidth}{0pt}
\doublespacing
\thispagestyle{empty}
\begin{center}
\vspace*{0.2in}
MY TITLE\\
\vspace*{0.4in}
by\\
My name\\\

\vspace*{1.4in}
\singlespacing
A thesis submitted in partial fulfillment\\
of the requirements for the degree\\
\doublespacing
of\\
My degree\\
in\\
My discipline\\\

\vspace*{1in}
MY UNIVERSITY\\
University, Location\\
\vspace*{0.2in}
April 2019
\end{center}
\pagebreak

\pagenumbering{gobble}
\begin{center}
\vspace*{1in}
\textcopyright COPYRIGHT\\
by\\
My name\\
2019\\
All Rights Reserved
\end{center}
\pagebreak

\pagenumbering{arabic}
\setcounter{page}{1}
%\begin{center}

\chapter{INTRODUCTION}
%\end{center}

My introduction section's first paragraph...
\lipsum[1-5]

\chapter{Another Chapter}
\lipsum[1-5]
\end{document}

PS:我用了我以前的答案这里重新定义章节命令,但你可以使用@GonzaloMedina 的答案这里如果你不喜欢我的代码……

相关内容