Adding figures to a LaTeX document requires three steps: place the image file in your project folder, write a figure environment in your code, and compile the document to see the result

LaTeX treats images differently than word processors do. You do not straightforward paste a picture into your document. Instead, you write commands that tell LaTeX where to find the image file, how large to make it, and where on the page it should appear. The image itself stays separate from your LaTeX code — your document just references it by filename.

This separation has a real advantage: if you update the image file, your document automatically uses the new version the next time you compile. You do not have to re-insert it or re-size it. But it also means you need to keep the image file in the right place and use the correct filename in your code.

Key Takeaways

  • The graphicx package must be loaded in your document preamble before you can insert any images.
  • Image files should sit in the same folder as your LaTeX document, or in a subfolder you specify in the file path.
  • The \includegraphics command inserts the image, and the figure environment lets you add captions and labels.
  • Common image formats are PNG, JPG, and PDF — avoid BMP and GIF unless your LaTeX setup specifically supports them.
  • Wrapping your image in a figure environment with a caption makes it easier to reference in your text and keeps it positioned where you want it.

Loading the graphicx package in your preamble

Before you can use any image commands, you must tell LaTeX to load the graphicx package. This package provides the tools you need to insert and resize images. Add this line to the preamble of your document — the section before \begin{document} — on its own line:

\usepackage{graphicx}

The preamble is where you load all packages and set up your document. If you already have other \usepackage commands there, add this one alongside them. You only need to load graphicx once per document, no matter how many images you insert.

Organizing your image files

LaTeX looks for image files in the same folder as your main document file by default. If your document is called thesis.tex and your image is called chart.png, place chart.png in the same folder. When you compile, LaTeX will find it.

For larger projects with many images, create a subfolder called images or figures in your project directory. Then tell LaTeX where to look by adding this line to your preamble after loading graphicx:

\graphicspath{{images/}}

If you have multiple folders, list them all: \graphicspath{{images/}{diagrams/}}. Now when you reference an image by filename, LaTeX will search these folders automatically. You still write just the filename in your code — you do not need to type the folder path each time.

Inserting an image with \includegraphics

The simplest way to add an image is the \includegraphics command. Write it inline where you want the image to appear:

\includegraphics{chart.png}

This inserts the image at its original size. Usually you want to control the size. Add the width option to scale it to a specific width, and LaTeX will adjust the height automatically to keep the image proportional:

\includegraphics[width=0.6\textwidth]{chart.png}

This makes the image 60 percent as wide as your text area. You can also use height instead, or specify exact measurements like width=4cm or width=3in. The \textwidth command is useful because it scales with your page size — if you change margins or page size later, the image scales with it.

Using the figure environment for captions and positioning

Inserting an image directly with \includegraphics works, but it treats the image like text. LaTeX may break it across pages or position it awkwardly. The figure environment solves this by letting you add a caption, a label for cross-references, and control over placement:

\begin{figure}[h]\centering\includegraphics[width=0.7\textwidth]{chart.png}\caption{Sales by region, 2024}\label{fig:sales}\end{figure}

The [h] option tells LaTeX to place the figure "here" — roughly where you wrote it in your code. Other options are [t] for top of page, [b] for bottom, and [p] for a dedicated page of figures. LaTeX treats these as suggestions and may move the figure if it does not fit. The \centering command centers the image horizontally on the page.

The \caption command adds text below the image. LaTeX automatically numbers captions — the first figure is "Figure 1", the second is "Figure 2", and so on. The \label command creates a marker you can reference elsewhere in your document with \ref{fig:sales}, which will print the figure number. This way, if you add or remove figures, all your references update automatically.

Choosing the right image format

LaTeX works best with PNG, JPG, and PDF formats. PNG is ideal for diagrams, screenshots, and images with solid colors because it compresses without losing detail. JPG works well for photographs and complex images. PDF is useful if you have vector graphics created in drawing software — they scale perfectly without pixelation.

Avoid BMP and GIF unless your LaTeX installation specifically supports them. Most modern setups do not. If you have an image in BMP or GIF format, convert it to PNG or JPG using free tools like GIMP or online converters before adding it to your project.

For the best results, use images that are already close to the size you want in your document. A very large image scaled down wastes file space and compilation time. A very small image scaled up will look blurry. Resize your images before inserting them if they are significantly larger or smaller than your intended display size.

Troubleshooting common image problems

If LaTeX cannot find your image, you will see an error message during compilation. Check that the filename in your code matches the actual filename exactly — filenames are case-sensitive on Mac and Linux. Verify the image file is in the same folder as your document or in a subfolder you specified with \graphicspath.

If your image appears in the wrong place or on the wrong page, the figure environment is moving it. Try changing the placement option from [h] to [!h] to give LaTeX a stronger suggestion to keep it where you wrote it. If that does not work, try [H] (capital H) — this requires the float package, added with \usepackage{float} — and forces the image to stay exactly where you placed it.

If your image looks pixelated or blurry, it was likely scaled up too much. Check the width value in your \includegraphics command and reduce it, or replace the image with a higher-resolution version.

Frequently Asked Questions

Can I add multiple images side by side?

Yes, using the minipage environment. Create two minipages inside a figure environment, each holding one image. This lets you place images next to each other and give them a shared caption, or separate captions for each.

How do I rotate an image?

Add the angle option to \includegraphics: \includegraphics[width=0.5\textwidth,angle=90]{chart.png}. The angle is in degrees, so 90 rotates the image a quarter turn clockwise.

What if I want the image to wrap with text around it?

Use the wrapfig package instead of the standard figure environment. Add \usepackage{wrapfig} to your preamble, then use \begin{wrapfigure} instead of \begin{figure}. This lets text flow around the image on the page.

Can I use images from the internet directly?

No — LaTeX needs the image file on your computer. read the image, save it to your project folder, and reference it by filename. This also makes your document portable: if you share the folder with someone else, all images travel with it.

How do I make an image a specific height instead of width?

Use the height option: \includegraphics[height=3cm]{chart.png}. LaTeX will adjust the width to keep the image proportional. Do not use both width and height at the same time unless you want to distort the image.