1

I have the settings of my document as follow:

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}

\renewcommand{\baselinestretch}{1.15}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}


\titleformat
{\part} 
[display]
{\bfseries \huge \itshape\centering} 
{Część \ \thepart} 
{0.5ex} 
{
    \rule{\textwidth}{0pt}
    \vspace{1ex}
    \centering
} 
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
] 

\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}

\pagestyle{fancy}
\fancyhf{}


\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~} 
\renewcommand{\headrulewidth}{0pt}

\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

\begin{document}

\part{The Part name}
...
\chapter{The First Chapter name}
...
\chapter{The Second Chapter name}
...
\chapter{The Third Chapter name}
...

\end{document}

I would like to achieve chapters begin at the same page, just after the end of the previous chapter? The solution from this post link doesn't work in my example.

1 Answer 1

1

You have to remove the \clearpages from the \chapter macro. The answer is basically the same as in the link you posted, except for one detail.

You are loading titlesec, and apparently it expects that you enter the \chapter macro in "vertical mode", that is, after a paragraph. The \clearpage does that by default, but since you want to remove it, you have to manually insert a \paragraph break before \chapter.

TL;DR

Put this in your preamble and you're good to go :)

\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
  {\if@openright\cleardoublepage\else\clearpage\fi}
  {\par}% Inserting a \par here!
  {}{}
\makeatother

Full MWE:

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}

\renewcommand{\baselinestretch}{1.15}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}

\titleformat
{\part} 
[display]
{\bfseries \huge \itshape\centering} 
{Część \ \thepart} 
{0.5ex} 
{
    \rule{\textwidth}{0pt}
    \vspace{1ex}
    \centering
} 
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
] 

\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}

\pagestyle{fancy}
\fancyhf{}


\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~} 
\renewcommand{\headrulewidth}{0pt}

\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
  {\if@openright\cleardoublepage\else\clearpage\fi}
  {\par}% Inserting a \par here!
  {}{}
\makeatother

\begin{document}

\part{The Part name}
...
\chapter{The First Chapter name}
...
\chapter{The Second Chapter name}
...
\chapter{The Third Chapter name}
...

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .