{ TexDrop }

How to Insert Images in LaTeX and Control Their Position

Português: Leia este tutorial em português.

LaTeX treats most figures as floating elements. This allows the typesetting engine to preserve a balanced page, but it can surprise beginners when an image moves away from the point where it was written in the source.

Load the graphicx package

\usepackage{graphicx}

Keep image files in a dedicated folder and, when useful, define the path once:

\graphicspath{{images/}}

Insert a basic figure

\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.75\textwidth]{chart.pdf}
  \caption{Results by experimental group.}
  \label{fig:results}
\end{figure}

Use \textwidth for page-relative sizing and \linewidth inside columns, lists, or boxes. Avoid specifying both width and height unless you intend to change the aspect ratio.

Understand placement options

  • h: approximately here.
  • t: top of the page.
  • b: bottom of the page.
  • p: a page reserved for floats.
  • !: relaxes some internal placement restrictions.

The flexible combination [htbp] is a good default. It gives LaTeX several acceptable choices instead of forcing a fragile layout.

Force a figure only when necessary

The float package provides [H]:

\usepackage{float}

\begin{figure}[H]
  \centering
  \includegraphics[width=0.6\textwidth]{diagram.pdf}
  \caption{A figure fixed at this location.}
\end{figure}

Use this option sparingly. Too many fixed figures can create large blank spaces and poor page breaks.

Reference figures correctly

As shown in Figure~\ref{fig:results}, the values increased.

Place \label after \caption so the reference receives the correct number.

Place text beside an image

For small illustrations, the wrapfig package can wrap text around a figure:

\usepackage{wrapfig}

\begin{wrapfigure}{r}{0.35\textwidth}
  \centering
  \includegraphics[width=0.32\textwidth]{example.png}
  \caption{Wrapped figure.}
\end{wrapfigure}

Wrapped figures are best for short, simple layouts. They may conflict with lists, headings, and page boundaries.

Create subfigures

\usepackage{subcaption}

\begin{figure}[htbp]
  \centering
  \begin{subfigure}{0.47\textwidth}
    \includegraphics[width=\linewidth]{before.pdf}
    \caption{Before}
  \end{subfigure}
  \hfill
  \begin{subfigure}{0.47\textwidth}
    \includegraphics[width=\linewidth]{after.pdf}
    \caption{After}
  \end{subfigure}
  \caption{Comparison of the two conditions.}
\end{figure}

Choose the right format

  • PDF: diagrams, charts, and vector artwork.
  • PNG: screenshots and images with transparency.
  • JPG: photographs.

Common problems

  • Image not found: check the path, extension, and capitalization.
  • Image too large: use a relative width such as 0.8\textwidth.
  • Figure moves too far: add reasonable placement options and review nearby floats.
  • Caption and image separate: keep both inside the same figure environment.

For a complete starting structure, use a TexDrop LaTeX template and organize all visual assets in a dedicated folder.