16 Including Figures & Pictures

16.1 Including Figures

Graphicx package and basic figures

The LaTeX package graphicx makes it possible to insert external graphics into your document. To use the package, simply include the tag \usepackage{graphicx} in the preamble of your document, as in the example below.

\documentclass{article}
%load packages:
\usepackage{graphicx}
%document info:
\title{Sample LaTeX document}
\date{20 April 2019}
\author{John Doe \\ 
    Department of Politics and International Studies \\ 
    University of Warwick}
\begin{document}
    Some sample text.
\end{document}

16.2 Including a Picture

In order to include a picture, simply use the \includegraphics markup tag surrounded by the figure environment, as seen in the screenshot below.

\begin{figure}
    \includegraphics{koala.jpg}
\end{figure}

Note that for that to work, the picture ‘coala.jpg’ has to be in the same directory (i.e. folder) as your .tex file. To insert a picture from another folder, simply reference its directory explicitly, as shown in the example below.

For Windows:

\begin{figure}
\includegraphics{C:/Users/Jon Doe/Pictures/koala.jpg}
\end{figure}

For Mac:

\begin{figure}
\includegraphics{/Library/Desktop Pictures/koala.jpg}
\end{figure}

16.3 Picture Dimensions

As you can see the resulting picture is rather oversized, doesn’t fit the page and takes up a lot of space. That’s because, by default, LaTeX inserts a picture in its original size – similarly as when you insert graphics in traditional text editors such as Word. To avoid that, we can specify the picture’s size using square brackets before the curly brackets with the file name, as shown in the screenshot below.

\begin{figure}
    \includegraphics[width = \textwidth]{koala.jpg}
\end{figure}

The resulting figure takes the width of the text written around the picture while maintaining its aspect ratio. We can also specify the size of the pictures manually in centimetres.

\begin{figure}
    \includegraphics[width = 12cm, height = 4cm]{koala.jpg}
\end{figure}

This, however, can result in distorting the original picture, as in the example. To fix that we can use the ‘keepaspectratio’ option. Which will make the picture as close as possible to the desired size, while maintaining the original aspect ratio of the file.

\begin{figure}
    \includegraphics[
    width = 12cm,
    height = 4cm,
    keepaspectratio]{koala.jpg}
\end{figure}