Insert Images in LaTeX: Complete Guide with Examples
Date Published

Inserting Images in LaTeX
Adding images to LaTeX documents requires the graphicx package.
Quick answer: How do you insert an image in LaTeX? Add \usepackage{graphicx} to the preamble, put the image file (PNG, JPG or PDF) next to your .tex file, and place \includegraphics[width=0.8\linewidth]{file} inside a figure environment with \centering, a \caption{...} and a \label{fig:...}. Refer to it in the text with Figure~\ref{fig:...}.
Insert an Image in LaTeX
- Upload the file. Put the PNG, JPG or PDF in the same folder as the main .tex file (or in a subfolder such as images/).
- Load graphicx. Add
\usepackage{graphicx}to the preamble. - Insert the figure. Use
\includegraphicsinside a figure environment with a caption and label, as below. You can leave off the file extension. - Reference it. Write
Figure~\ref{fig:result}so the number updates automatically.
1\documentclass{article}2\usepackage{graphicx} % \includegraphics3\begin{document}4As Figure~\ref{fig:result} shows, the method converges quickly.56\begin{figure}[htbp]7 \centering8 % replace example-image-a with your file name, e.g. result.png9 \includegraphics[width=0.8\linewidth]{example-image-a}10 \caption{Convergence of the method.}11 \label{fig:result}12\end{figure}13\end{document}
Try this in Octree — free LaTeX editor with AI, compiles in your browser
Image Options Cheat Sheet
Size, scale, rotation, centering, subfigures (subcaption) and text wrapping (wrapfig) in one compilable document. The example-image files ship with TeX Live (mwe package); swap in your own file names:
1\documentclass{article}2\usepackage{graphicx} % \includegraphics3\usepackage{subcaption} % subfigure environment4\usepackage{wrapfig} % wrapfigure: text flows around the image5\usepackage{lipsum} % dummy text6\begin{document}7\includegraphics[width=0.5\linewidth]{example-image-a} % half the line width8\includegraphics[height=3cm]{example-image-b} % fixed height9\includegraphics[scale=0.2]{example-image-c} % 20% of natural size10\includegraphics[angle=90,width=3cm]{example-image-a} % rotated 90 degrees1112\begin{figure}[htbp]13 \centering14 \begin{subfigure}{0.48\linewidth}15 \includegraphics[width=\linewidth]{example-image-a}16 \caption{Left}\label{fig:left}17 \end{subfigure}\hfill18 \begin{subfigure}{0.48\linewidth}19 \includegraphics[width=\linewidth]{example-image-b}20 \caption{Right}\label{fig:right}21 \end{subfigure}22 \caption{Two images side by side.}\label{fig:pair}23\end{figure}2425\begin{wrapfigure}{r}{0.4\linewidth}26 \centering27 \includegraphics[width=\linewidth]{example-image-c}28 \caption{Text wraps around this figure.}29\end{wrapfigure}30\lipsum[1-2]31\end{document}
Basic Setup
\usepackage{graphicx}
Optionally specify graphics path:
\graphicspath{{images/}{figures/}}
Basic Image Insertion
\includegraphics{myimage}
LaTeX looks for myimage.pdf, myimage.png, myimage.jpg, etc.
Specifying Size
By Width
\includegraphics[width=0.8\textwidth]{image}
\includegraphics[width=10cm]{image}
By Height
\includegraphics[height=5cm]{image}
Both (may distort)
\includegraphics[width=5cm, height=3cm]{image}
Keep Aspect Ratio
\includegraphics[width=5cm, height=3cm, keepaspectratio]{image}
Scale Factor
\includegraphics[scale=0.5]{image}
The Figure Environment
Wrap images in figure for captions and positioning:
\begin{figure}[h] \centering \includegraphics[width=0.8\textwidth]{image} \caption{This is my caption} \label{fig:myimage} \end{figure}
Positioning Options
[h] — here (approximately) [t] — top of page [b] — bottom of page [p] — separate page for floats [H] — exactly here (requires float package) [!htbp] — try all options
Force Exact Position
\usepackage{float}
\begin{figure}[H] ... \end{figure}
Captions and References
Caption
\caption{Description of the figure}
Short Caption (for list of figures)
\caption[Short]{Long detailed caption}
Label and Reference
\label{fig:myimage}
Reference: Figure \ref{fig:myimage}
Image Manipulation
Rotation
\includegraphics[angle=90]{image}
Trimming/Cropping
\includegraphics[trim=1cm 2cm 1cm 2cm, clip]{image}
Order: left, bottom, right, top
Multiple Images
Side by Side
\begin{figure}[h] \centering \includegraphics[width=0.45\textwidth]{image1} \hfill \includegraphics[width=0.45\textwidth]{image2} \caption{Two images side by side} \end{figure}
Subfigures
\usepackage{subcaption}
\begin{figure}[h] \centering \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{image1} \caption{First image} \end{subfigure} \hfill \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{image2} \caption{Second image} \end{subfigure} \caption{Main caption} \end{figure}
Supported Formats
pdfLaTeX
- PDF (preferred for vector graphics) - PNG (for raster images) - JPG (for photos)
XeLaTeX/LuaLaTeX
Same as pdfLaTeX.
LaTeX → DVI → PS
- EPS only
Best Practices
1. Use vector graphics (PDF) when possible 2. High resolution (300+ DPI) for raster 3. Consistent sizing across figures 4. Meaningful captions that explain the figure 5. Reference all figures in the text
Common Problems
Image not found: Check path and file extension
Image too large: Reduce width or scale
Image in wrong place: Use float package with [H]
Blurry image: Use higher resolution source
Insert Image in LaTeX FAQ
How do you insert a picture in LaTeX?
Load \usepackage{graphicx} and write \includegraphics[width=0.8\linewidth]{picture} where you want it, ideally inside a figure environment with \caption and \label so LaTeX can number it and place it well.
Which image formats does LaTeX support?
With pdfLaTeX, XeLaTeX and LuaLaTeX you can include PNG, JPG and PDF directly; modern TeX Live converts EPS to PDF automatically. Use PDF for plots and diagrams (vector, sharp at any zoom) and PNG or JPG for photos and screenshots. SVG needs the svg package plus Inkscape and shell escape, so converting it to PDF first is simpler.
How do I fix "File not found" for \includegraphics?
The path is relative to the main .tex file, not the chapter file that contains the command. Check the spelling and the case (Linux servers are case-sensitive, so Figure.PNG is not figure.png), make sure the file was uploaded, and if you use \graphicspath{{images/}} keep the trailing slash and double braces.
Can an image file name or path contain spaces?
Current LaTeX (2019 or newer) handles spaces in \includegraphics{my figure.png}, but older installations and some tools do not. The safest fix is to rename the file to my-figure.png.
How do I put two images side by side in LaTeX?
Use two subfigure environments from the subcaption package, each 0.48\linewidth wide, separated by \hfill (see the cheat sheet above). For images without sub-captions, two \includegraphics[width=0.48\linewidth] commands with \hfill between them are enough.
Insert Images with Octree
Octree simplifies image handling:
- Drag-and-drop upload - Automatic path management - Real-time preview - AI helps with positioning
Try it at https://useoctree.com
Try this in Octree — free LaTeX editor with AI, compiles in your browser

Include a PDF in LaTeX: \includepdf[pages=-]{file.pdf} from pdfpages for whole pages, or \includegraphics[page=1]{file.pdf} for a PDF figure. Ranges, scaling.

Fix LaTeX PDFs that wont update after changes. Covers browser cache, aux file corruption, compilation errors, and more with step-by-step solutions.