How to insert and position images in LaTeX

Load graphicx and insert the image with \includegraphics[width=0.8\linewidth]{plot}, usually inside a figure environment so it gets a caption and a number. Placement specifiers such as [t] are hints — use [H] from float if you need the figure to stay exactly where you wrote it.

\usepackage{graphicx}
% ...
\begin{figure}[t]
  \centering
  \includegraphics[width=0.8\linewidth]{plots/loss.pdf}
  \caption{Training loss.}
  \label{fig:loss}
\end{figure}
As Figure~\ref{fig:loss} shows, ...
A centred figure at 80% of the text width with the caption 'Training loss.' and a sentence referring to it as Figure 1.

A complete document you can paste

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[t]
  \centering
  \includegraphics[width=0.7\linewidth]{plots/loss.pdf}
  \caption{Training loss over 50 epochs.}
  \label{fig:loss}
\end{figure}

Training converges by epoch 30, as Figure~\ref{fig:loss} shows.

\end{document}
A complete document with a top-placed figure captioned 'Training loss over 50 epochs.' and a paragraph referring to Figure 1.

Sizing

\includegraphics[width=\linewidth]{fig}        % full text width
\includegraphics[width=0.5\linewidth]{fig}    % half
\includegraphics[height=4cm]{fig}             % fix the height instead
\includegraphics[scale=0.6]{fig}              % fraction of natural size
\includegraphics[angle=90,width=\linewidth]{fig}

Placement

[t], [b], [h], and [p] are hints — LaTeX places floats where they fit. Combine them ([tbp]) to give it room, or load float and use [H] to pin the figure exactly where it appears in the source.

\usepackage{float}
% ...
\begin{figure}[H]
  \centering
  \includegraphics[width=0.6\linewidth]{plots/loss.pdf}
  \caption{Pinned exactly here.}
\end{figure}
A figure pinned exactly where it was written using the H placement specifier, captioned 'Pinned exactly here.'

Two images side by side

subcaption gives each panel its own lettered caption inside a shared figure number.

\usepackage{graphicx}
\usepackage{subcaption}
% ...
\begin{figure}[t]
  \centering
  \begin{subfigure}{0.48\linewidth}
    \includegraphics[width=\linewidth]{before}
    \caption{Before.}
  \end{subfigure}
  \hfill
  \begin{subfigure}{0.48\linewidth}
    \includegraphics[width=\linewidth]{after}
    \caption{After.}
  \end{subfigure}
  \caption{The effect of the correction.}
\end{figure}
Two subfigures side by side, captioned (a) Before and (b) After, under a shared caption 'The effect of the correction.'

Use a vector format (PDF) for plots so they stay crisp at any zoom. Writing in Typst? See figures in Typst.

In KL studiothe live preview re-runs on each change, so nudging width or the placement hint shows the reflowed page right away instead of after a slow full compile.

Common questions

How do I insert an image in LaTeX?
Load the graphicx package and use \includegraphics[width=0.8\linewidth]{file}, usually inside a figure environment so it gets a caption and a number. Leave the extension off and LaTeX picks the best available format.
Why is my LaTeX figure not where I put it?
The [h], [t] and [b] specifiers are hints, not commands: LaTeX places a float where it fits without leaving a bad gap. To force the exact position, load the float package and use [H].
How do I put two images side by side in LaTeX?
Put two minipage environments of about 0.48\linewidth each inside one figure, or use subcaption's subfigure environment when each image needs its own (a) and (b) caption.
What image format should I use in LaTeX?
PDF for plots and diagrams, since it is vector and stays sharp at any zoom, and PNG or JPEG only for photographs. With pdflatex, EPS files need converting first.
How do I scale an image to the text width in LaTeX?
Use width=\linewidth for the current text width, or width=0.8\linewidth for a fraction of it. \textwidth ignores the current indentation, which matters inside lists and two-column layouts.