我使用章节文件夹设置了我的文档,该文件夹包含每个章节的单个 .tex 文件。在主文件中,我已完成所有格式化。当我第一次包含一些示例章节时,一切看起来都很好。
然而,一旦第一章超出第一页,该章的格式就会被破坏。下一章的第一页使用了假定的格式(见截图)。
我使用了 fancyhdr 包来进行格式化。这是主 .tex 文件的源代码:
% packages and general setup
\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[a4paper, width = 150mm, top = 25mm, bottom = 20mm, bindingoffset = 6mm]{geometry}
\AtBeginDocument{\renewcommand{\bibname}{References}}
%----------------------------------------------------------------------------------------------------------
% package for Chapter Headings
\usepackage[T1]{fontenc}
\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
%----------------------------------------------------------------------------------------------------------
% package and setup for header and footer
\setlength{\headsep}{-15mm} % reduce space between header and textblock
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\fancyhf{}
\fancypagestyle{plain}{% the preset of fancyhdr
\fancyhf{} % clear all header and footer fields
\fancyhead{}
\fancyhead[RO, LE]{\ifnum\value{chapter}>0 \thechapter \hspace{1pt} \leftmark \fi}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, RE]{J. Berlemann}
}
%----------------------------------------------------------------------------------------------------------
% package used for underscores (solving the issues with underscores in bibtex)
\usepackage[strings]{underscore}
%----------------------------------------------------------------------------------------------------------
% package used to prevent floats to be in other sections
% use "\FloatBarrier" command to make sure a float stays in place
\usepackage[section]{placeins}
%----------------------------------------------------------------------------------------------------------
% multi-row for tables
\usepackage{multirow}
%----------------------------------------------------------------------------------------------------------
% package for list of symbols
\usepackage[printonlyused]{acronym}
%----------------------------------------------------------------------------------------------------------
\begin{document}
\pagenumbering{Roman}
\input{titlepage}
\setcounter{page}{1}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\cleardoublepage\pagenumbering{arabic}
\chapter{Introduction}
\input{chapters/01_Introduction}
\chapter{Another Example Chapter}
\input{chapters/02_State of the Art}
\bibliographystyle{acm}
\bibliography{references}
\end{document}
这可能是什么原因造成的?是因为 fancyhdr 包吗?我正在使用 overleaf 编写文档。
提前致谢!
答案1
该问题与章节内容的文件无关fancyhdr
。您可以使用 来设置顶部空间分隔,\setlength{\headsep}{<length>}
或者使用 来将其从默认值(由 设置的 25 pt geometry
)减小。\addtolength{\headsep}{-15pt}