Figures and Images in LaTeX

Use \includegraphics from the graphicx package to insert images into LaTeX documents.

Quick Answer

latex
\usepackage{graphicx}  % in preamble

\includegraphics[width=0.8\linewidth]{image.png}

Basic Image Insertion

latex
\usepackage{graphicx}

% Image at half the line width:
\includegraphics[width=0.5\linewidth]{photo.jpg}

% Fixed width:
\includegraphics[width=8cm]{diagram.pdf}

% Fixed height (aspect ratio preserved):
\includegraphics[height=5cm]{chart.png}

% Scale relative to original size:
\includegraphics[scale=0.5]{logo.pdf}

Figure Float with Caption

Wrap in a figure environment to add a caption, label, and let LaTeX position it automatically.

latex
\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\linewidth]{results.png}
  \caption{Experimental results showing accuracy over epochs.}
  \label{fig:results}
\end{figure}

% Reference it:
As shown in Figure~\ref{fig:results}, ...

Writing your thesis in LaTeX?

MonsterWriter's LaTeX Workspace gives you real-time PDF preview with no compile limits — at a fraction of Overleaf's price. Works just like Overleaf, costs 11× less.

Try MonsterWriter free

Placement Options

OptionMeaning
hHere (approximately)
tTop of the page
bBottom of the page
pSeparate page for floats
HExactly here (float package required)

Side-by-Side Figures

latex
\begin{figure}[htbp]
  \centering
  \begin{minipage}{0.45\linewidth}
    \includegraphics[width=\linewidth]{before.png}
    \caption{Before}
  \end{minipage}
  \hfill
  \begin{minipage}{0.45\linewidth}
    \includegraphics[width=\linewidth]{after.png}
    \caption{After}
  \end{minipage}
\end{figure}

Image Path Setup

latex
% Declare a folder so you don't repeat the path:
\graphicspath{{images/}{figures/}}

% Now just use the filename:
\includegraphics[width=\linewidth]{chart.pdf}

Related Topics