You’re writing a paper in LaTeX. You’ve got beautiful text, perfect equations, maybe even some fancy tables. But now it’s time to insert a figure. Huh? How do you do that? Don’t panic! It’s easier than it sounds—and actually kind of fun. This beginner-friendly guide will show you how to add images in LaTeX step-by-step. And yes, you can make them look amazing too.
TL;DR
Inserting a figure in LaTeX requires the use of the figure environment. You’ll also need the graphicx package, which handles images. The main command used is \includegraphics. Once you’ve got that, adding a picture is a breeze!
1. First Things First: Load the Right Package
Before you can start adding images, you need to load a special package. LaTeX doesn’t handle figures on its own—it needs help.
Put this line in the preamble of your LaTeX document (before \begin{document}):
\usepackage{graphicx}
Why do this? Because the graphicx package gives you the \includegraphics command—your best friend when it comes to images.
2. Organize Your Files
Keep your image files in the same folder as your .tex file. It just makes life easier. LaTeX likes things neat.
You can use common image formats like:
- .png
- .jpg
- .pdf (especially good for vector graphics)
Note: If you’re using LaTeX with PDFLaTeX, avoid using .eps files. They’re not supported without extra work.
3. Basic Image Insertion
Here’s the bare-bones way to insert an image:
\begin{figure}
\centering
\includegraphics{myimage.png}
\caption{This is my awesome image}
\label{fig:awesome_image}
\end{figure}
Let’s break that down:
- \begin{figure} … \end{figure}: This is a special LaTeX environment for pictures. It handles placement and labels.
- \centering: This centers your image on the page.
- \includegraphics{myimage.png}: This command adds the image file called “myimage.png”.
- \caption{…}: Adds a caption under the image.
- \label{…}: Gives the figure a label for referencing it later in your text with
\ref.
4. Resize That Image!
Your image might be too big or too small. No worries! You can change its size easily.
\includegraphics[width=0.5\textwidth]{myimage.png}
This makes the image half the width of the text. Try changing the number for different sizes.
Here are some options:
- width: Set the image width (e.g.,
0.6\textwidth,3in) - height: Set the height (e.g.,
2in) - scale: Scale the image up or down (e.g.,
scale=0.75)
Example:
\includegraphics[width=3in, height=2in]{myimage.png}
5. Where’s My Image?!
Sometimes LaTeX puts your figure in a weird place—like on the next page. That’s normal. LaTeX tries to make your paper look good, so it floats figures to ideal spots.
You can give LaTeX some hints. Right after \begin{figure}, add an optional argument:
\begin{figure}[h]
This tells LaTeX:
- h: Place the figure here, if possible.
- t: Top of the page.
- b: Bottom of the page.
- p: On a special page just for floats (like images).
You can mix them too:
\begin{figure}[htbp]
Still doesn’t show up where you want? Shrink the image or move some text around. Welcome to the LaTeX shuffle!
6. Referencing an Image in Your Text
Now let’s say you want to say something like, “See Figure 2.” You can do this with \ref.
Add a label inside the figure:
\label{fig:cool_chart}
Then reference it like this:
As shown in Figure \ref{fig:cool_chart}, the results are awesome.
7. Add Some Style
Want your figures to look extra cool? Here are a few fun tricks.
Add a Frame
To surround your image with a box, use:
\fbox{\includegraphics[width=0.4\textwidth]{myimage.png}}
Use Minipage to Place Images Side-by-Side
Want two images next to each other? Here’s how:
\begin{figure}
\centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{image1.png}
\caption{First Image}
\label{fig:image1}
\end{minipage}
\hspace{0.1\textwidth}
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{image2.png}
\caption{Second Image}
\label{fig:image2}
\end{minipage}
\end{figure}
Looks neat and professional!
8. Common Mistakes to Avoid
- Forgetting to load the graphicx package: No images without this!
- Using the wrong file extension: Watch out—LaTeX is picky!
- Misspelling the filename: “MyImage.png” is different from “myimage.png”
- Image too big: Always scale it down to fit the page.
9. Tips for Using Overleaf
If you’re using Overleaf (a popular online LaTeX editor), adding images is even easier!
- Drag and drop your image file into the left-side panel.
- Use
\includegraphicsjust like before. No file paths needed. - Overleaf handles formats like JPG, PNG, PDF easily.
Super smooth and beginner-friendly!
10. Final Thoughts
Inserting a figure in LaTeX might look scary at first glance. All those commands! But once you understand the steps, it’s actually simple—and powerful.
Here’s the typical flow again:
- Load the graphicx package in the preamble.
- Put your image in the same folder as your .tex file.
- Use the figure environment to insert your image.
- Resize, center, caption, and label it.
- Use
\refto call out the figure in your text.
That’s it! You’ve just leveled up your LaTeX game.
Bonus: What About EPS Images?
Advanced users might work with .eps (Encapsulated PostScript) files, especially for scientific plots. If you’re using classic LaTeX (not PDFLa
How to Insert a Figure in LaTeX (A Beginner Guide)
yehiweb
Related posts
New Articles
How to Insert a Figure in LaTeX (A Beginner Guide)
You’re writing a paper in LaTeX. You’ve got beautiful text, perfect equations, maybe even some fancy tables. But now it’s…