# Formatting is changing spacing

I'm currently working on my thesis, and have come across little problem. If you take a look at the attached images below:

Here you can see, that there is clearly a problem in the first one, with too much spacing after the subsubsection, and it even makes a break before an indent.

The only difference is this:

Don't know if you can see it, but basically, the only difference in the two is, that the first one has a few more lines of text than the other. And it is this that is causing this error (I have it some other places to). I really have no idea what is going on. I've tried to write it over a couple of times, and if I just write something random, instead of the whole segment, it actually works. So if I change the last segment with: "My name is Robert", then it formats correctly. But somehow, when the text is the other thing, then I get this formatting error.

The code I'm using, before the document begins is:

``````\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{mathptmx}
\graphicspath{ {images/} }
\usepackage[font={footnotesize},labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage[a4paper,width=140mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage{fancyhdr}
\usepackage{quoting}
\usepackage{wrapfig}
\usepackage[toc,page]{appendix}
\usepackage{changepage}
\usepackage[nottoc,numbib]{tocbibind}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername}\ \thechapter. \ #1}{}}

\fancyfoot[C]{\thepage}
\renewcommand{\footrulewidth}{0.4pt}

\renewcommand{\labelitemi}{\$-\$}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\usepackage[style=authoryear, dashed=false, backend=biber,maxbibnames=10, maxcitenames=3]{biblatex}
\setlength\bibitemsep{1.5\itemsep}

\title{Thesis Title}
\author{Author Name}
\date{Day Month Year}
``````

So yeah, anyone know why it's doing this ?

Please always provide a complete small document that demonstrates the problem. Not images of code, which is a lot less useful. The output you show would be expected if you had unstretchable `\parskip` space, stretchable space after headings, and `\flushbottom` as then the only way TeX could make the last line reach the bottom of the page would be to stretch the space after the head. –  David Carlisle May 11 '14 at 11:11
I think this is not an error, just auto-formatted by latex. In the first picture, latex try to put `section 6.4` in the same page but there is no amount of available space. so, it putted on the next page. –  Asis Pattisahusiwa May 11 '14 at 11:54
Not the problem but if you are using `geometry`, best not to set e.g. `\headheight` manually since `geometry` is designed to handle that stuff and needs to know about it in order to do the calculations properly. You are using things like `\\[12pt]` between paragraphs which is not a good idea. Essentially, that is unstretchable `\parskip`, I think. –  cfr May 11 '14 at 12:58
Add `\raggedbottom` in your preamble. –  Harish Kumar May 11 '14 at 13:51