The basic command to insert an image in LaTeX
To add a picture in LaTeX, you use the \includegraphics command inside the document body. The command tells LaTeX where to find the image file and how to display it. Before you can use this command, you need to load the graphicx package at the top of your document by writing \usepackage{graphicx} in the preamble — the section between \documentclass and \begin{document}.
The simplest version looks like this: \includegraphics{filename.jpg}. LaTeX will insert the image at its original size. You can place this command anywhere in your document where you want the picture to appear, and it will show up in the compiled PDF.
The image file needs to be in the same folder as your LaTeX document, or you need to provide the full path to where it lives on your computer. Common image formats that work are JPG, PNG, and PDF.
Key Takeaways
- Load the graphicx package with \usepackage{graphicx} at the top of your document before you can insert any images.
- Use \includegraphics{filename} to place an image, and put the command where you want the picture to appear in your document.
- Resize images with the width or height option — for example, \includegraphics[width=3in]{filename.jpg} — to control how large they appear.
- Wrap images in a figure environment with \begin{figure} and \end{figure} if you want LaTeX to position them automatically and add captions.
- Store image files in the same folder as your LaTeX document, or use the full file path if they are stored elsewhere.
Resizing images to fit your page
By default, LaTeX inserts images at their original pixel size, which often makes them too large or too small for your document. You control the size by adding options inside square brackets after \includegraphics.
To set the width, write \includegraphics[width=4in]{filename.jpg}. You can use inches (in), centimeters (cm), or a percentage of the page width — for example, width=0.8\textwidth makes the image 80 percent as wide as your text area. If you set only the width, LaTeX automatically adjusts the height to keep the image from stretching or squashing.
You can also set height instead: \includegraphics[height=2in]{filename.jpg}. If you set both width and height, the image will be forced to those exact dimensions, which can distort it, so usually you pick one or the other.
Rotating and positioning images
Sometimes you need to turn an image sideways or flip it. Add the angle option to rotate: \includegraphics[angle=90]{filename.jpg} rotates the image 90 degrees clockwise. You can use any number of degrees.
To center an image on the page, wrap it in a center environment. Write \begin{center} before the \includegraphics command and \end{center} after it. This pushes the image to the middle of the page horizontally.
If you want the image to sit to the left or right of text instead of on its own line, use the wrapfig package. This is more advanced and requires loading \usepackage{wrapfig} at the top, then wrapping your image in a wrapfigure environment. Most beginners center or place images on their own lines first.
Using the figure environment for captions and labels
The figure environment tells LaTeX to treat an image as a floating object — meaning LaTeX can move it slightly to fit the page layout better. More importantly, it lets you add a caption and a label so you can refer to the image by number in your text.
The structure looks like this:
\begin{figure} \centering \includegraphics[width=4in]{filename.jpg} \caption{This is the caption that appears below the image} \label{fig:myimage} \end{figure}
The \caption command adds text below the image. The \label command gives the image a name you can reference later. To refer to it in your text, write \ref{fig:myimage} and LaTeX will automatically insert the figure number. This is useful in longer documents where you might move images around — the numbers update automatically.
Troubleshooting common image problems
If LaTeX says it cannot find your image, check that the filename is spelled exactly right, including the file extension (.jpg, .png, or .pdf). File names are case-sensitive on Mac and Linux, so Photo.jpg and photo.jpg are different files. Also verify that the image file is actually in the same folder as your LaTeX document, or that you have provided the correct path.
If the image appears blurry or pixelated, the original file may be low resolution. You can try reducing the size with the width option — smaller images look less blurry than large ones. If the image is a screenshot or diagram, PNG format usually preserves sharpness better than JPG.
If your image is sideways or upside down, use the angle option to rotate it. If the image is stretched or squashed, you probably set both width and height — remove one of them and let LaTeX calculate the other automatically to maintain the correct proportions.
Organizing images in a separate folder
For documents with many images, create a folder called images or figures in the same location as your LaTeX file. Then reference images by their path: \includegraphics{images/filename.jpg}. This keeps your workspace organized and makes it easier to find files later.
If you move your LaTeX document to a different computer or folder, move the images folder with it. As long as the folder structure stays the same, all your image references will still work. If you only move the document without the images, LaTeX will not be able to find the pictures.
Frequently Asked Questions
What image formats does LaTeX support?
LaTeX works with JPG, PNG, and PDF files. JPG is good for photographs, PNG is better for diagrams and screenshots because it preserves sharp edges, and PDF works if you have vector graphics. Some LaTeX editors also support other formats, but these three are the most reliable.
Can I add multiple images side by side?
Yes, use the minipage environment to create columns. Put one image in each minipage, and LaTeX will arrange them horizontally. This requires wrapping each image in \begin{minipage} and \end{minipage} with a specified width, which is more advanced but works well for layouts with two or three images across.
How do I make an image the same width as my text?
Use \includegraphics[width=\textwidth]{filename.jpg}. The \textwidth command tells LaTeX to make the image as wide as your text area. You can also use a percentage like width=0.9\textwidth to leave a small margin on each side.
What if I want a caption but no figure number?
Use \caption*{Your caption text} instead of \caption{}. The asterisk tells LaTeX to print the caption without numbering it. You also cannot use \label with \caption*, so you will not be able to reference it by number in your text.
Can I crop or zoom into part of an image?
Yes, use the trim option: \includegraphics[trim=1in 0.5in 1in 0.5in, clip]{filename.jpg}. The four numbers are the distances to trim from the left, bottom, right, and top. You must also add clip to actually remove the trimmed parts. This is useful for removing unwanted borders or focusing on a specific area of a larger image.