Let
X

How to Add Images in LaTeX

Updated June 2026

To add an image in LaTeX, load the graphicx package with \usepackage{graphicx} in your preamble, then use \includegraphics[width=\linewidth]{filename} where you want the image. Wrap it in a figure environment to add a caption and label. On LetX you can upload the image file and compile instantly in the browser — no local TeX install needed.

Step by step

  1. 1

    Load graphicx

    Add \usepackage{graphicx} to your preamble (before \begin{document}).

  2. 2

    Upload the image

    Upload your .png, .jpg, or .pdf into the project so LaTeX can find it.

  3. 3

    Insert the image

    Use \includegraphics[width=0.8\linewidth]{filename} where you want it to appear.

  4. 4

    Add a caption

    Wrap it in a figure environment with \caption{...} and \label{fig:...} for cross-referencing.

  5. 5

    Compile

    Compile to PDF. On LetX this takes 1–2 seconds and updates the live preview.

Example

\usepackage{graphicx}
% ...
\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\linewidth]{diagram.png}
  \caption{System architecture.}
  \label{fig:arch}
\end{figure}

Refer to the figure in text with Figure~\ref{fig:arch}. The [h] placement hint asks LaTeX to put the figure “here”; use [ht] or [H] (with thefloat package) for stricter control.

Frequently asked questions

Which image formats does LaTeX support?

pdfLaTeX supports PNG, JPG, and PDF. EPS works with the classic latex+dvips route or by converting to PDF. On LetX, PNG/JPG/PDF work out of the box.

How do I resize an image in LaTeX?

Use the width or height option: \includegraphics[width=0.5\linewidth]{file} scales to half the text width. You can also use scale=0.5 to scale by a factor.

Why does my image not show up?

Check that the file is uploaded to the project, the filename matches exactly (case-sensitive), and graphicx is loaded. On LetX, the file browser shows what is available to include.

Try this in LetX now

Open the editor, paste the example, and compile in 1–2 seconds — free, in your browser.

Start Writing Free