Comprehensive guide to including, positioning, and formatting images in LaTeX. Learn professional techniques for graphics, subfigures, and advanced image layouts.
Master the art of including and formatting images in LaTeX documents. This comprehensive guide covers everything from basic image inclusion to advanced layouts, optimization, and professional formatting techniques.
Prerequisites: Basic LaTeX knowledge and the graphicx package Time to complete: 25-30 minutes Difficulty: Intermediate What you’ll learn: Image formats, positioning, sizing, captions, subfigures, wrapping text, and advanced techniques
\begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{example-image} \caption{A descriptive caption for the image} \label{fig:example}\end{figure}% Reference the figureAs shown in Figure~\ref{fig:example}, the results are clear.% Short caption for list of figures\begin{figure}[htbp] \centering \includegraphics[width=0.6\textwidth]{data-plot} \caption[Short caption]{Long descriptive caption with detailed explanation} \label{fig:data}\end{figure}
% Don't use both width and height unless needed\includegraphics[width=5cm, height=3cm]{image} % May distort\includegraphics[width=5cm]{image} % Maintains ratio
Figure placement issues:
Copy
% Too strict placement\begin{figure}[h] % May cause bad spacing\begin{figure}[htbp] % More flexible
Overflow into margins:
Copy
% Image too wide\includegraphics[width=\textwidth]{image}% Better: leave some margin\includegraphics[width=0.95\textwidth]{image}
% Show frame around images\usepackage[draft]{graphicx}% Show figure boundaries\usepackage{showframe}% Track float placement\usepackage{float}\floatplacement{figure}{H}% List all figures\listoffigures
\documentclass[11pt, a4paper]{article}\usepackage{graphicx}\usepackage{subcaption}\usepackage{wrapfig}\usepackage{float}\usepackage{caption}% Setup\graphicspath{{images/}{figures/}}\captionsetup{font=small, labelfont=bf}\begin{document}\title{Comprehensive Image Examples}\author{Your Name}\date{\today}\maketitle\section{Introduction}This document demonstrates various image inclusion techniques in LaTeX.\section{Basic Figure}\begin{figure}[htbp] \centering \includegraphics[width=0.6\textwidth]{example-image-a} \caption{A simple centered figure} \label{fig:simple}\end{figure}As shown in Figure~\ref{fig:simple}, basic image inclusion is straightforward.\section{Wrapped Figure}\begin{wrapfigure}{r}{0.4\textwidth} \centering \includegraphics[width=0.35\textwidth]{example-image-b} \caption{Wrapped figure} \label{fig:wrapped}\end{wrapfigure}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris. The wrapped figure appears to the right of this text, demonstrating how text flows around images.\section{Multiple Images}\begin{figure}[htbp] \centering \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{example-image-a} \caption{First subfigure} \label{fig:sub1} \end{subfigure} \hfill \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{example-image-b} \caption{Second subfigure} \label{fig:sub2} \end{subfigure} \vspace{0.5cm} \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{example-image-c} \caption{Third subfigure} \label{fig:sub3} \end{subfigure} \hfill \begin{subfigure}{0.45\textwidth} \includegraphics[width=\textwidth]{example-image} \caption{Fourth subfigure} \label{fig:sub4} \end{subfigure} \caption{Grid layout with four subfigures} \label{fig:grid}\end{figure}Figure~\ref{fig:grid} shows a 2×2 grid layout, with individual subfigures \ref{fig:sub1} through \ref{fig:sub4}.\section{Rotated and Scaled Image}\begin{figure}[H] \centering \includegraphics[angle=45, scale=0.5]{example-image} \caption{Rotated and scaled image} \label{fig:rotated}\end{figure}\section{Conclusion}This document demonstrated various image handling techniques in LaTeX, from basic inclusion to advanced layouts.\listoffigures\end{document}
Pro tip: Always keep high-resolution originals of your images. You can create lower-resolution versions for drafts and switch to high-resolution for final output using conditional inclusion.