LaTeX Graphics
The process of embedding an image or graphic into a LaTeX document can be done in many ways.
Contents
Basic Usage
\usepackage{graphicx} \graphicspath{ { ./images/ } { ./charts/ } { ./tables } } % ... \includegraphics{foo}
Graphics Options
The most basic tool for embedding an image into a document is \includegraphics. There are a number of options to configure the image.
\includegraphics[scale=2.5]{foo} \includegraphics[width=5cm, height=5cm]{bar} \includegraphics[angle=90]{baz}
Figures
To position an image, and to create a table of figures throughout a document, use figures.
Quick Start
\begin{figure}[h] \includegraphics{foo} \end{figure}
Positioning Graphics
Figures take a mandatory option, like h in the example above. Valid values and their meanings are:
Option |
Effect |
h |
Insert here |
H |
Insert here, exactly |
t |
Insert at page top |
b |
Insert at page bottom |
p |
Insert into a separate page for floating figures |
! |
Override LaTeX placement algorithm |
Centering a Graphic
To center a graphic, simply use centering inside the figure.
Side-by-Side Graphics
To display two images side-by-side, try:
\begin{figure} \centering \begin{subfigure}{.5\textwidth} \centering \includegraphics{foo} \end{subfigure} % \begin{subfigure}{.5\textwidth} \centering \includegraphics{bar} \end{subfigure} \end{figure}
Labeling and Captioning a Graphic
To label an image, use \label{my-label}. The standard practice is to use a label composed as prefix:identifier, so that labels of subfigures can be grouped.
To caption an image, use \caption{my-caption}.