# Why do images pull the text down?

Whenever I include a picture it pulls the text down. I don't want that, I wan the text to be normal and then for the image to be wherever it fits, either the current page or the next if it's too large.

The MWE would be:

\documentclass{book}

\usepackage[utf8]{inputenc}
\usepackage[margin = 2cm]{geometry}
\usepackage{array}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.5}
\usepackage{color}
\newcommand{\compl}[1]{ \textcolor{darkblue}{\textbf{\hl{ #1 }}}}
\definecolor{seccol}{rgb}{0,0.8,0.3}

\usepackage{graphicx}

\begin{document}

In a fully implemented Operating System, any global variables that need to be initialized before they are used, and any library initialization code needs to be called before these libraries cna be used. In our modest project, there are only a couple of libraries, but they need to be initialized nonetheless. Also, the  section must be cleared (i.e we must write a 0 to all addresses in the section). All of this is done in the  function.
\\
Although very humble in it's current state, if the project is extended so that more functionality is added, this is where we would call any library initialization code, in order to ensure that everything is setup before any function in a library gets called.
\\~\\
The very first thing we want to do is clear the  section. Thanks to our, we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all  sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can

In a fully implemented Operating System, any global variables that need to be initialized before they are used, and any library initialization code needs to be called before these libraries cna be used. In our modest project, there are only a couple of libraries, but they need to be initialized nonetheless. Also, the  section must be cleared (i.e we must write a 0 to all addresses in the section). All of this is done in the function.
\\
Although very humble in it's current state, if the project is extended so that more functionality is added, this is where we would call any library initialization code, in order to ensure that everything is setup before any function in a library gets called.
\\~\\
The very first thing we want to do is clear the  section. Thanks to our , we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can

The very first thing we want to do is clear the  section. Thanks to our , we have a label to indicate exactly where this section begins and another label to indicate exactly where it ends, the script also ensures that all sections of all files get contiguously put together in the final kernel image, so we know that, once we clear this section, all variables that need to be initialized to 0 will contain their correct values. Since the addresses form a continuous block of memory, we can
\centering
\includegraphics{FramebufferDiagram.png}
\end{document}


Pf.png

• Don't use \\  to end lines except in tabular, array etc. Use the \figure environment to include your image, since you want it to float. You are telling LaTeX, it must go here. It has to break the page, but it tries to make the text fit (presumably, it is set to keep the bottoms of pages flush). – cfr Jul 1 '17 at 0:12
• 1) Don’t use \\  (or, worse, \\~\\ ) to end paragraphs: leave an empty line in the source. 2) If you want a figure to float, use a figure environment. 3) Read a manual about LaTeX… ;-) – GuM Jul 1 '17 at 0:13
• I don't want the figure to float I want to avoid the figure pulling down the text and re-formatting the paragraphs. My latex compiler ignores white space, if I don't explicitely tell ti to skip a line, it won't – Makogan Jul 1 '17 at 0:33
• How can we help if we cannot test, not having at least the dimensions of the image? – Bernard Jul 1 '17 at 0:59

You need to put your picture into a figure environment to make it float:

\begin{figure}
\centering
\includegraphics{FramebufferDiagram.png}
\end{figure}


You can add an optional argument to setup the positioning. h for here (where it appears in the source), t for at the top of a page and/or b for at the bottom of a page (\begin{figure}[ht] for putting it here or, if it doesn't fit, on the top of the next page).

Note: your text only fills about half a page. And because you are using the book class it will still be streched out until you add more text. This is because the book class tries to make all pages the same height.

Edit:

In order to avoid stretching the page put \raggedbottom into the preamble. LaTeX will then no longer try to make all pages the same height.

Btw.: Since you don't want the picture to float, may I recommend to put \centering and \includegraphics in a group ({...}). This way the text after the image won't get centered anymore. (I guess you don't want this.)

• This results in the exact same behaviour as above even with the use of H, this is not a solution – Makogan Jul 1 '17 at 0:31
• @Makogan: see edit – Mike Jul 1 '17 at 0:59
• @Makogan: 1) If the figure is allowed to float, the gaps between the paragraphs should disappear, even wihout \raggedbottom. 2) Are you using h or H in the optional argument of the figure environment? 3) To get some vertical space between two given paragraphs, try separating them with, e.g., <blank line>\bigskip<blank line>. – GuM Jul 1 '17 at 1:06
• If I allow the figure to float completely freely, latex put's it at the end of my document (literally tens of pages below of where I want it) – Makogan Jul 1 '17 at 1:08
• @Makogan: Does that happen even if you say \begin{figure}[htp] ... \end{figure} (note the presence of the p specifier)? – GuM Jul 1 '17 at 1:17

Too long for a comment: \raggedbottom do not solve that the use of \\~\\ instead of a blank line (= \par) to leave a blank line between paragraphs is completely wrong. You are only inserting two line breaks within a paragraph. Even then, the paragraph skips are different and and there are no paragraph indentation in the fake paragraphs.

Moreover, you placed a \centering before of ending the last paragraph, so not only the image is centered, but also the last paragraph. The image is also part of the paragraph, and is acting like a huge character, so with some less height will end in the same line that "...memory, we can". Otherwise pass to the next page, but leaving a "hole" of about 10 cm. LaTeX then uses rubber spacing between true paragraphs which stretch in order to make the text vertically justified. This will happen even if the image is in a different paragraph.

If you want some fixed space between paragraphs, you should use a command as:

\setlength{\parskip}{\baselineskip}


Note that this do not need \raggedbottom at all because now the paragraph slip is a fixed length, not a rubber length.

Nonetheless, is usually much better left a adaptable length (but the same in all the paragraphs of the page) as:

\setlength{\parskip}{.5em plus .1em minus .1em}


or simpler: use the package parskip in the preamble.

In this case this apparently is not a good solutión because you force to Latex to decide between one evil and another (left about one half of the page empty, or left large space between paragraphs, even far of you wanted). The solution in this case, as Gustavo Mezzetti well pointed, a float with h, t or poptions because then the image is no longer part of a normal paragraphs.

It is worth mention that a float is also usually preferable because take care of left a decent space between the figure and text above and/or below (and allow numbered captions, list of figures, center vertically alone imgaes, etc.)

MWE without float:

\documentclass{book}
\usepackage[margin=2cm]{geometry}
\setlength{\parskip}{\baselineskip}
\usepackage{graphicx}
\usepackage{kantlipsum} % allow \kant[n] for dummy paragraphs
\begin{document}
\kant[2]\par\kant[1]\par\kant[2]\par\kant[1]\par

\centering
\includegraphics[height=12cm]{example-image}
\end{document}


MWE with float:

\documentclass{book}
\usepackage[margin=2cm]{geometry}
\setlength{\parskip}{.5em plus .1em minus .5em}
\usepackage{graphicx}
\usepackage{kantlipsum} % allow \kant[n] for dummy paragraphs
\begin{document}
\kant[2]\par\kant[1]\par\kant[2]\par\kant[1]
\begin{figure}[h]
\centering
\includegraphics[height=12cm]{example-image}
\end{figure}
\end{document}


Note : \par (=blank line) is already implicit in the \kant macros, but I leave it in the MWEs to remark that paragraphs end with \par (and because extra \par are ignored, of course).