I have some document which contains header line and I also specified that chapters can begin on same page
Minimalized example below:
% !TeX program = xelatex
\documentclass[10pt,a4paper,twoside]{report}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,250mm},
outer=15mm,
inner=20mm,
top=15mm,
}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
% to specify chapter titles
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{5pt}{\LARGE}
\titlespacing*{\chapter}{0pt}{0pt}{0pt}
\raggedbottom
\usepackage{lipsum}
\titleformat{\chapter}[display]
{\normalfont\bfseries}{}{0pt}{\Large}
\titleformat{\chapter}[hang]{\LARGE\bfseries}{\thechapter{. }}{0pt}{\LARGE\bfseries}
% to specify headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{\fancyhf{}\renewcommand{\headrulewidth}{1pt}
\fancyhead[RE,LO]{}
\fancyfoot[LE,RO]{}
\fancyfoot[RE,LO]{\jobname}}
% to specify that chapters are on same page
\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
{\if@openright\cleardoublepage\else\clearpage\fi}
{\par}
{}{}
\makeatother
\begin{document}
\chapter{INTRODUCTION}
Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text
\chapter{FIRST CHAPTER}
Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text
\end{document}
Using this code, I get this
However, I want to reduce the distance between header line and beginning of the chapter. This can be done by changing
\titlespacing*{\chapter}{0pt}{0pt}{0pt}
to, for example,
\titlespacing*{\chapter}{0pt}{-20pt}{0pt}
However, if I do this, I get this:
As you can see, I get overlapping between end of one chapter and beggining of another one, which I do not want. In this specific example, I can get rid of this by inserting \vspace{0.5cm} (or any other desired number) before \chapter{FIRST CHAPTER}, but I want a more generic solution (I don't want to do this for each chapter alone, but for all chapters simultaneously).
What is the best way to achieve this?
Best Answer
With
\titlespacing
you are able adjust all the chapters at the same time.Of course you have to choose good values for the
before
and theafter
separation.For example
\titlespacing*{\chapter}{0pt}{-3ex}{-3ex}
works fine.Using
ex
units will keep the proportions if you change the main text font size e.g. from 10pt to 12pt.