Skip to content
EasyLaTeXDocs

Inserting Images

Insert project images with \includegraphics from graphicx. Keep images with the source and refer to them using project-relative paths.

EasyLaTeX compiler setting: pdfLaTeX with article; load graphicx. Examples using external images require the named files in the project.

Prepare the Image Files

Upload images through the EasyLaTeX file tree and organize them under images/. These examples place main.tex at the project root:

text
my-document/
├── main.tex
└── images/
    └── experiment-result.png

Prefer portable names such as experiment-result.png, using letters, digits, hyphens, or underscores. Avoid spaces and platform-specific characters that complicate paths.

Insert One Image

Load the package in the preamble:

latex
\usepackage{graphicx}

Then reference the image in the body:

latex
\includegraphics{images/experiment-result.png}

Use the exact filename and extension. PNG, JPEG, and PDF are standard choices with the supported engines; PDF works well for vector artwork, while PNG and JPEG suit raster images.

Control the Size

Set width, height, or scale instead of relying on the original image size:

latex
\includegraphics[width=0.7\linewidth]{images/experiment-result.png}

\linewidth is the width available at the current position, so relative widths adapt to columns and list environments. They are usually more robust than a fixed measurement such as 12cm.

Set only width or height to preserve proportions. To impose both limits, add keepaspectratio:

latex
\includegraphics[
  width=0.8\linewidth,
  height=6cm,
  keepaspectratio
]{images/experiment-result.png}

Image Search Paths

For many images, define a search path in the preamble:

latex
\graphicspath{{images/}}

You can then shorten an image reference:

latex
\includegraphics[width=0.7\linewidth]{experiment-result.png}

Each entry in \graphicspath needs its own braces. This setting affects image lookup, not every file path in the project.

Crop and Rotate

trim specifies left, bottom, right, and top. Use clip to hide the trimmed regions:

latex
\includegraphics[
  width=0.7\linewidth,
  trim=1cm 0.5cm 1cm 0.5cm,
  clip
]{images/experiment-result.png}

Use angle for rotation:

latex
\includegraphics[width=0.6\linewidth,angle=90]{images/experiment-result.png}

Keep essential axes, scales, legends, and source information visible when adjusting a crop.

Common Problems

File ... not found

Check the uploaded file, extension, capitalization, and directory. Use a project path rather than a path on your own computer.

The Image Extends Past the Margin

Use width=\linewidth or a smaller proportion rather than reducing the whole document's font size.

The Image and Description Separate

Put them in a figure environment with \caption and \label. See Captions, Labels, and Float Placement.

Complete Example

Upload experiment-result.png into images/ before compiling:

latex
\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\graphicspath{{images/}}

\begin{document}

Insert an image at  70\%  of the current line width.

\begin{center}
  \includegraphics[width=0.7\linewidth]{experiment-result.png}
\end{center}

\end{document}