# Spacing in chapter 6

I specified the spacing in my document (before and after titles of chapter, section, subsection etc.). It works with first five chapters and their sections, subsections and so on but somehow it doesn't with the chapter 6, and then works again with chapter 7.

 \documentclass[12pt, a4paper, twoside]{report}
\titlespacing*{\chapter}{0pt}{0pt}{12pt}
\titlespacing*{\section}{0pt}{12pt}{12pt}
\titlespacing*{\subsection}{0pt}{12pt}{12pt}

\begin{document}
\chapter{Cel pracy}
\input{wstep}
\chapter{Barwa}
\input{barwa}
\section{Mieszanie barw}
\input{barwa_mieszanie}
\chapter{Rachunek trójchromatyczny}
\input{rachunek_trojchromatyczny}
\chapter{Obliczenia kolorymetryczne}
\input{obliczenia_kolorymetryczne}
\chapter{Złudzenia}
\input{zludzenia}
\chapter{Program komputerowy}
\input{programowanie}

\end{document}


The first five chapters looks like this (and it's ok):

but chapter 6 is a mess:

and then it's ok again.

Does anybody know how to fix this?

edit: Everything's ok when I input something under chapter and second section but when it comes to type something under first section, it looks like on the picture 1.

• presumably you have \flushbottom and the top of the next page is a large unbreakable box. – David Carlisle Jan 4 '17 at 12:12
• you don't show the following text for chapter 6. does it by chance contain a large, unbreakable image or math display? if so, that would be shifted to the next page, and spaces above/below headings and between paragraphs would be stretched so that the bottom line on the page is bottom-aligned with other pages. – barbara beeton Jan 4 '17 at 12:13
• The example code you post clearly didn't generate the output shown it just produces ! Undefined control sequence. <recently read> \titlespacing – David Carlisle Jan 4 '17 at 12:15
• I guess I have too much code to post everything but the \raggedbottom helps. But thanks for the interest! :) – Nat Jan 4 '17 at 12:19

This is in the design of the report class, which try to flush the text at the bottom of the page by stretching vertical white space.

\raggedbottom

\usepackage[bottom]{footmisc}

Pro and cons of \raggedbottom are discussed in this question.