1. Introduction

In this tutorial, we’ll show how figures can be positioned and scaled in LaTeX according to the needs of the document. We’ll show that the basic command that needs to be used is \includegraphics, which belongs to the graphicx package.

We’ll use a picture of the St. Honorat Monastery in France, which is free to use at the U.S. Library of Congress, as our example figure and will illustrate our techniques using a set of self-contained examples.

2. Including a Figure

We’ll assume the figure is stored in the file monastery.jpg. This can be included in a document as follows:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

\includegraphics{monastery.jpg}

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\end{document}

This yields the following result:

source1a crop

Lorem ipsum dolor…, etc., is dummy Latin text that is traditionally popular for use in text formatting examples.

2.1. Scaling a Figure

We now show how the above figure can be scaled by 50%:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

\includegraphics[scale=0.5]{monastery.jpg}

Duis aute irure dolor in reprehenderit in voluptatevelit esse cillum dolore eu fugiat nulla pariatur.
\end{document}

This yields the same result as before, but with the figure scaled by 0.5:

source2a crop

2.2. Cropping

Let’s crop the figure, that is, remove slabs of the figure on its four borders. This is done by supplying the argument [left bottom right top] to the \includegraphics command. In our example we use left=1cm, bottom=2.7cm, right=2.5cm and top=1cm. We’ve used “cm” (centimeters) as our units of measurement but could have used “in” (inches) or any other units acceptable to LaTeX. We must remember to use the “trim=” and “clip” keywords as shown:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

\includegraphics[trim={1cm 2.7cm 2.5cm 1cm},clip]{monastery.jpg}

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\end{document}

This results in a figure cropped to our specifications:

source3a crop

2.3. Specifying the Height or Width of a Figure

In some situations, we need to scale the figure to a specific width or height. Here’s an example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

\includegraphics[height=2.7cm]{monastery.jpg}

\medskip

\includegraphics[width=4.5cm]{monastery.jpg}

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\end{document}

We can see that the aspect ratio of the figure remains unchanged, regardless of width or height:

source4a

4. Centering Figures

We often need to center figures with respect to the text of a document. We’ll show two techniques for this, \centering and \begin{center}…\end{center}:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean erat enim, malesuada at turpis sed, vulputate bibendum massa.

{\centering
\includegraphics[scale=0.7]{monastery.jpg}\par
}

Duis et scelerisque ipsum, sed rutrum est. Maecenas dignissim suscipit aliquet. Integer ut venenatis eros. Duis in condimentum metus.

\begin{center}
\includegraphics[scale=0.7]{monastery.jpg}
\end{center}

Donec semper feugiat urna, at laoreet diam dapibus nec. Mauris elementum
erat ut nisi fermentum, non gravida eros eleifend. Nulla purus risus,
pulvinar eu nunc eget, porttitor elementum augue.
\end{document}

We notice that \centering results in the figure being tightly bound to the text, while the \begin{center}\end{center} approach leads to more relaxed spacing:

source5a

5. Combining the Techniques

We’ll now present an elaborate example that combines most of the techniques described above. Here, we first want the figure cropped into a thin vertical strip and centered below the text. We then want the figure cropped into a horizontal strip and expanded to the width of the text:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean erat enim, malesuada at turpis sed, vulputate bibendum massa.

{\centering
\includegraphics[scale=1.5,trim={4cm 0cm 4cm 0cm},clip]{monastery.jpg}
\par}
Donec semper feugiat urna, at laoreet diam dapibus nec. Mauris elementum
erat ut nisi fermentum, non gravida eros eleifend. Nulla purus risus,
pulvinar eu nunc eget, porttitor elementum augue.

{\centering
\includegraphics[width=\textwidth,trim={0cm 3cm 0cm 3cm},clip]{monastery.jpg}
\par}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean erat enim, malesuada at turpis sed, vulputate bibendum massa.
\end{document}

We can see that the end result satisfies our requirements:

source6a

6. Inserting Figures Inside Text

Sometimes we’d like to insert figures inside text. This could be for the sake of appearance or for saving space. We can do this using the wrapfigure command from the wrapfig package.
We must tell wrapfigure whether the figure is to be put on the right {r} or left {l} and also how much space to set aside for the figure, for example {0.5\linewidth}. In the following, the \blindtext command from the blindtext package is used to generate a large amount of dummy text:

\documentclass{article}
\usepackage{graphicx}
\usepackage{wrapfig,blindtext}
\begin{document}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\includegraphics[height=4cm]{monastery.jpg}
\caption{Large Monastery.}
\label{fig:myfig1}
\end{wrapfigure}

\blindtext

\begin{wrapfigure}{l}{0.4\linewidth}
\centering
\includegraphics[height=3cm]{monastery.jpg}
\caption{Small Monastery.}
\label{fig:myfig2}
\end{wrapfigure}

\blindtext
\end{document}

We can use this technique to produce documents that are compact and pleasing to the eye:

source7a

7. Conclusion

In this article, we’ve presented several techniques for positioning figures in a LaTeX document. We’ve included examples of scaling, cropping, and centering. We’ve presented our material as a set of brief, self-contained examples that will allow the reader to experiment with these techniques.

The power of LaTeX in producing documents with figures is vast and extends well beyond these introductory examples. Nonetheless, the material presented gives the reader the tools to produce fairly elaborate documents.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.