1

I am trying to customize the chapter style in the report class :

  • Remove the blank page generated between chapter : Done with the etoolbox package : \patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
  • Remove the "Chapter Number Something" : Done with the titlesec package : \titleformat{\chapter}[display]{\normalfont\bfseries}}{}{0pt}{\Huge}
  • And here is where I am confused, when I want to remove the space before the chapter name. I tried with titlesec \titlespacing{\chapter}{0pt}{0pt}{0pt} but there is still space before the chaptername and I also tried with negative values in the second curly brackets but the text is writing other itself.

I would like the chapter name to be at the top of the page and not so much blank space for the other chapters before and after it. If the top margin is set at 2.5cm, I would like the chatper name to be at 2.5cm

enter image description here

Here is my code :

\documentclass[12pt,oneside]{report}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

\usepackage{titlesec}
\titleformat{\chapter}[display]
    {\normalfont\bfseries}{}{0pt}{\Huge}

\titlespacing{\chapter}{0pt}{-50pt}{0pt}

\begin{document}

\chapter{My chapter}
lol

\chapter{Another chapter}
lol

\end{document}
  • Welcome to TeX SX! You do not want chapters to start on a new page? – Bernard May 1 at 18:17
  • 1
    Why not use \sections instead? – Andrew Swann May 1 at 18:56
  • Bernard No, on the same page, the answer of schtandard works fine, thanks ! Andrew Swann I wanted to keep sections for further sectioning – Azerth anis May 1 at 20:01
0

Firstly, you don't actually need to patch \chapter, since openright is not the default for report. If you use a document class where it is, you can use the option openany to prevent empty pages between chapters.

Now, there are several possibilities to tackle this:


You could use KOMA-Script, which provides many macros that allow an easier modification of the layout than the standard classes:

\documentclass{scrreprt}

% makes the page borders visible
\usepackage{showframe}

\renewcommand*\chapterformat{}
\renewcommand*\chapterheadstartvskip{}

\begin{document}

\chapter{My chapter}
lol

\chapter{Another chapter}
lol


\end{document}

First MWE output


If you prefer working with report and titlesec, the correct syntax of \titlespacing is

\titlespacing{\chapter}{0pt}{*0}{*0}

or

\titlespacing*{\chapter}{0pt}{0pt}{0pt}

To get rid of some of the space above the chapter title, you can drop the display option of \titleformat. I did however not manage to get rid of all the space without some hacking of internal commands. If we do that, we can just as well do it without titlesec:


You could redefine \@makechapterhead which typesets the chapter title. Here I took the default definition and commented everything you don't want.

\documentclass{report}

% makes the page borders visible
\usepackage{showframe}

\makeatletter
    \renewcommand*\@makechapterhead[1]{%
%       \vspace*{50\p@}%
        {%
            \parindent\z@\raggedright\normalfont
%           \ifnum\c@secnumdepth>\m@ne
%               \huge\bfseries\@chapapp\space\thechapter\par
%               \nobreak\vskip 20\p@
%           \fi
%           \interlinepenalty\@M
            \Huge\bfseries
            #1\par
            \nobreak\vskip 40\p@
        }
    }
\makeatother

\begin{document}

\chapter{My chapter}
lol

\chapter{Another chapter}
lol

\end{document}

Second MWE output

  • Mmh it worked fine by redefining \@makechapterhead I didn't have a look at the other possibilities yet Thanks for the quick answer ! – Azerth anis May 1 at 19:59
1

Not sure what the patch is meant to do: its main effect is that no page break will happen when a \chapter begins.

No blank page will ever appear with the report class, unless you pass it the openright option.

\documentclass[12pt,oneside]{report}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{lipsum}

\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\bfseries\Huge}
  {}
  {0pt}
  {}

\titlespacing{\chapter}
  {0pt}
  {-50pt}
  {0pt}

\begin{document}

\chapter{My chapter}

\lipsum[1-5]

\chapter{Another chapter}

\lipsum[1-5]

\end{document}

enter image description here

  • I am trying to generate a document with verso figures and recto text. I tried to keep this format when using \chapter – Azerth anis May 1 at 20:18

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.