Insert an image in Overleaf with upload, graphicx and figure code.
To insert an image in Overleaf, upload your image file to the project directory, load \usepackage{graphicx} in your preamble and place the graphic using \includegraphics{filename} or a floating figure environment.
The short answer: upload your PNG, JPEG or PDF, add \usepackage{graphicx} to your preamble and use \includegraphics[width=\linewidth]{filename} inside a figure environment for automatic numbering and captions.
Step 1: Upload the image to your project
Before LaTeX can display an image, the file must live inside your project directory. Click the upload icon above the file tree on the left side of the screen to open the file selector, or drag and drop your image directly from your computer into the folder list.
Keep filenames clean. Avoid spaces, accent marks and multiple dots in your image files. Name your files with hyphens, such as experimental-data-02.png rather than Final Chart (Draft).png, which can break the compiler path.
Step 2: Load the graphicx package
LaTeX cannot manage external images on its own. You need to load the standard graphics inclusion package in your document preamble before the \begin{document} command.
Add this line to your preamble:
Step 3: Insert the image with includegraphics
The core command for putting an image in your document is \includegraphics. Omit the file extension so LaTeX can search for PNG, JPEG or vector PDF versions automatically.
Here is a simple example showing how to add an image and scale it to fit the text column:
Step 4: Wrap the image in a figure environment
If you place an image directly in text without a figure environment, it will not float, generate a caption or receive an automatic number. Wrap your graphic in a figure block to give it a caption and a label for cross-referencing.
Always place the \label command after the \caption command so LaTeX binds the reference number to the figure rather than the surrounding section.
Resizing and rotating images
You can control the dimensions of your graphics by passing optional arguments inside square brackets before the filename. Setting width to \linewidth or \textwidth keeps your image aligned with your document margins.
If you need to rotate a diagram or a wide chart, add the angle parameter to the optional bracket list.
Questions
What image formats are supported in Overleaf?
Overleaf supports PNG, JPEG, PDF and EPS files. Vector PDFs are recommended for plots, diagrams and charts because they keep sharp edges at any zoom level.
Why is my image not showing up in Overleaf?
Check that \usepackage{graphicx} is in your preamble, that the filename matches exactly without its extension and that the file was successfully uploaded to your project file tree.
How do I make an image fill the text width?
Pass width=\linewidth or width=\textwidth inside the optional brackets of your includegraphics command, such as \includegraphics[width=\linewidth]{figure-name}.
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing