Skip to Main Content

LaTeX for Publications: Images

Inserting an Image

Inserting images "by hand" requires a little work, but it isn't terribly complex or difficult to understand. The feature is fairly powerful, giving you great control over how the image is presented in the document.

Required Package
Packages in LaTeX are macros, which are loaded in the preamble. The graphicx package is all that's needed to enable insertion of images in your document.

Enabling the graphicx package in a LaTeX document (with an optional comment, for clarity):
 
\usepackage{graphicx} % Required for inserting images

Now let's see how to insert an image in a LaTeX document. The image should be in the same folder as the document where it is being inserted.
 
\begin{figure}
 \centering  % Indenting is for clarity
 \includegraphics[width=3.6in]{raven.jpg} % Filename is raven.jpg
 \label{fig:nevermore} % Each image needs a unique label
\end{figure}

A complete description of the (not very difficult) process of placing images in a LaTeX documents can be found in the LaTeX/Floats, Figures and Captions chapter of the LaTeX wikibook.

"Floating" Images

Floats in LaTeX are "containers" that can hold things such as images. Floats have some properties that make them very useful in LaTeX documents:
  • Floats cannot be "broken" over a page break. The float appears in its complete form on a single page.
  • LaTeX has a limit of 18 floats in one document.
  • If you need more than 18 floats, include the morefloats package in your preamble.
  • Images and tables inserted using the figure or table environments, respectively, are floated. An example of the figure environment is shown above

Images in Overleaf

Controlling Where Floats Appear

When a floated figure is inserted into a LaTeX document, they appear in what LaTeX determines to be the "best" position. If you disagree, you can add a specifier to the figure environment to change the location. Simply use square brackets to add it to the \begin{figure} command.
\begin{figure}[h] % Place image float HERE (approximately)
  ...figure contents ...
\end{figure}
This is a list of the available specifiers for use with floated images and/or tables. The table is from the LaTeX wikibook. It is used under Creative Commons license.
LaTeX float specifiers and permissions
Staff LADR