0

I have setup my document using a chapters folder that contains single .tex files for each chapter. In the main file, I have done all the formatting. When I first included some sample chapters, everything looked fine.

However, as soon as the first chapter exceeded the first page, the formatting of that chapter was destroyed. The first page of the following chapter used the supposed format (see screenshot).

I used the fancyhdr package to do the formatting. Here is the source code of the main .tex file:

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

What can be the possible reason for that? Is it due to the fancyhdr package? I am using overleaf to write the document.

Thanks in advance!

Bernard
  • 271,350
  • Set the length \headsep like \setlength{\headsep}{10pt} to reduce the space between the header and the textblock. – Simon Dispa Apr 04 '22 at 14:14
  • Right now, you have headsep set to a negative number with the line \setlength{\headsep}{-15mm}. You can set it to 0mm, but if you set it a negative number it'll pull the text over the headerrule. BTW you can set headsep = 0mm right in the geometry package options; you don't need to use a separate command. Not sure why you had that there though, there may be something else you want to accomplish which should be done differently. – frabjous Apr 04 '22 at 14:22
  • Yes, the \setlength{\headsep}{10pt} command solved the problem. Now, I have uge spaces before each chapter starts. This is why I initially placed the -15mm command. Is there a way to reduce the space above the chapter heading? – Jannik Ber Apr 04 '22 at 14:26
  • 1
    @Jannik Ber This site works best if you only have one question at a time, to benefit future readers. I suggest you ask another question on the subject of space before the chapter titles. – Simon Dispa Apr 04 '22 at 14:36
  • @Jannik Ber Or for example see https://tex.stackexchange.com/a/63393/161015 – Simon Dispa Apr 04 '22 at 14:41
  • Ok, will do so next time. Thank you guys for helping me out! – Jannik Ber Apr 04 '22 at 14:51

1 Answers1

0

The problem is not related to fancyhdr nor separate files for chapter content. You can set the head space separation by setting it with \setlength{\headsep}{<length>} or you can reduce it from its default value (25 pt set by geometry) with \addtolength{\headsep}{-15pt}

Simon Dispa
  • 39,141