Managing floating images
When a page break occurs, regular text can be broken to continue onto the next page. However, the automatic page breaking cannot divide pictures. That's why LaTeX provides a floating environment—namely, figure
. Such floating environments are also called floats. LaTeX may push their content, including captions, to a place suitable for page layout and page breaking.
We will now figure out how to deal with this.
The figure
environment takes an optional argument affecting the final placement of the figure. We will test the effect in our graphics example, as shown here:
- Go back to the previous example we had for Figure 5.1. This time, add the
h
andt
options in the highlighted line (whereh
andt
stands for here and top), as follows:\begin{figure}[ht] \centering \includegraphics{example-image} \caption{Test figure} \end{figure}
- Compile the document, and take a look at the output. It should look like...