The Basics

Graphics in LaTeX may take one of two forms: vector, or raster. Vector graphics are designed to be scalable to different sizes, and are represented by a series of “vectors”, or directional instructions, from one point to another. Raster graphics are traditional bitmap graphics represented by a grid of pixels, and a numeric value (typically 16 or 24 bit) that stores what is contained within that pixel. This post will focus on how to use and manipulate raster graphics in LaTeX.


LaTeX is incapable of directly displaying pictures. When a rasterized picture is displayed in LaTeX, a box must be defined to display the image, and the image to display must be defined. One of the most common ways to do this is by using the graphicx package.


This line must be included in the preamble of the LaTeX document, i.e. before the \begin{document} declaration. This document is being created using the pdfLaTeX compiler.

Importing graphics

Graphics can be imported with the \includegraphics command. For example, as can be seen in the ShareLaTeX example document:


The file universe.jpg needs to be in the same directory as the main .tex file in order for this to work correctly. Subfolders may be used with appropriate paths:


space_pictures is a folder under the root directory of the main TeX file.

Pictures can also be included as a whole by importing an entire folder, then using individual graphics out of it. This is done by defining a graphics path:


This can also be done with multiple folders:

\graphicspath{ {space_pictures/} {animal_pictures/} {landscape_pictures/} }

It’s important to include the trailing / as this rewrites the includegraphics path to start with the graphics path specified above, if the file exists. Caution needs to be practiced with this, though, as file names can collide if they are not unique. Relative paths are recommended for this, as they are less reliant on where the TeX files are stored.


There are a great many ways to format pictures using TeX. This section will cover the most common, useful ways to manipulate images.

Width and Height

If a specific height and/or width is needed, it can be specified in the includegraphics call. Height and width can be specified relative to document size, by imperial or metric unit, or by pixel.


Normal graphic in LaTeX

This will include a copy of the image 5cm tall, with the aspect ratio maintained (the width will scale with the height). If more than one dimension needs to be specified, just add a comma between the arguments.

\includegraphics[height=5cm, width=1cm]{universe.jpg}

Normal squished in LaTeX

Images can also be scaled based on document variables, like so:



If an image needs to be scaled simply by the original size of the picture, the scale parameter can be used:


The scale parameter specifies the multiplier of the original size the document will output. For example, the code above displays the image at 0.5x, or 50% of its original size. scale=3 would display the image at 3x, or 300% of its original size.


Images may need to be rotated in a document. The angle parameter can accomplish this like so:

\includegraphics[scale=2, angle=180]{universe.jpg}

Notice how multiple parameters may be used together. This displays universe.jpg at 200% size flipped 180 degrees, or upside down. angle can be used to rotate images by any degree, though 90, 180, 270, and in some cases multiples of 45 are the most common.


The graphicx package combined with LaTeX makes for easy insertion and manipulation of images into documents. Advanced graphics manipulation such as vector graphics and procedurally generated graphics will be covered in the future.

Posted by Cody Herring on 11 Apr 2013