Automating image positioning
When there's not enough free space on a page when you include an image, that image will go to the next page. This will leave white space at the end of the page. You could manually move some text to compensate. But imagine having a large document with many images; manually moving images to balance page breaks could cause a headache. Fortunately, LaTeX provides an automatism for us.
How to do it...
This is a very common way of including images as figures:
- Use a
figure
environment. - Center the content, if desired.
- Include the image.
- Add a caption.
- Add a label for cross-referencing.
A typical command sequence is as follows:
\begin{figure}[htbp!] \centering \includegraphics{filename} \caption{Some text} \label{fig:name} \end{figure}
In the document, you can refer to the figure number by using the \label{fig:name}
command.
How it works...
The automatism is called floating, and it works for images; that means figures and tables. A figure
environment lets its content...