LaTeX figure commands provide sophisticated tools for including and managing images, graphics, and visual elements in professional documents. This guide covers essential figure handling commands, from basic image inclusion to advanced layouts, ensuring you create publication-quality visual presentations.
For general LaTeX documentation and package information, visit CTAN (Comprehensive TeX Archive Network), the central repository for all LaTeX packages and documentation.
The Core Structure: figure Environment and \includegraphics
LaTeX figure commands use two main components: the \includegraphics command for importing images and the figure environment for positioning, scaling, and captioning.
Figure Environment Template
This template is the foundation for all professional visual content:
\begin{figure}[positioning]
\centering
\includegraphics[options]{filename}
\caption{Figure caption}
\label{fig:reference}
\end{figure}
Basic Image Inclusion and the graphicx Package
All image handling in LaTeX relies on the graphicx package and the fundamental \includegraphics command.
Essential Package Inclusion
Always include the graphics package in your preamble:
\usepackage{graphicx}
For detailed documentation, see the graphicx package on CTAN.
Simple Image Inclusion
LaTeX supports various file formats (JPG, PNG, PDF, EPS) and automatically detects them based on your compiler (e.g., PDFLaTeX).
\includegraphics{image.jpg} % Raster image
\includegraphics{image.pdf} % Vector graphic
\includegraphics{path/to/image} % Specify file path
Controlling Image Dimensions and Scaling
LaTeX figure commands offer precise control over image size, critical for consistent document design.
Scaling Options
Use relative units based on your document’s layout for best responsiveness:
| Command | Purpose |
|---|---|
width=5cm | Fixed width |
width=0.5\textwidth | Relative to text block width (Recommended) |
scale=0.5 | 50% of original size |
keepaspectratio | Prevents distortion when setting both width and height |
Example of Relative Sizing
\includegraphics[width=0.8\textwidth, keepaspectratio]{myimage}
Figure Placement, Captions, and References
The figure environment manages the figure as a “float,” allowing LaTeX to place it optimally.
Positioning Options
Use optional arguments in square brackets ([htbp]) to suggest placement priorities:
| Option | Meaning |
|---|---|
h | Here (as close to the source as possible) |
t | Top of page |
b | Bottom of page |
p | Separate page for floats |
! | Override LaTeX positioning restrictions |
Captions and Cross-Referencing
Captions and labels are vital for accessibility and academic referencing. For fine-tuning, you may need to adjust your text styling and document layout using custom caption settings.
\caption[Short caption for LoF]{Long, descriptive caption for the figure.}
\label{fig:unique-identifier}
% Reference the figure in your text: Figure~\ref{fig:unique-identifier}
Customizing Caption Appearance
Use the caption package for fine-tuning caption formatting:
\usepackage{caption}
\captionsetup{
font=small, % Smaller font size
labelfont=bf, % Bold "Figure X:"
justification=centering,
skip=10pt % Space between figure and caption
}
Learn more about caption customization in the caption package documentation.
Complete Example: Professional Figure Setup
Here’s a realistic, complete example showing all components together:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
% Set graphics path for organization
\graphicspath{{images/}{figures/}}
\begin{document}
\section{Experimental Results}
Our measurements demonstrate a clear correlation between temperature
and reaction rate, as shown in Figure~\ref{fig:temp-rate}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth, keepaspectratio]{temperature_plot}
\caption[Temperature vs. Reaction Rate]{Temperature dependence of
the reaction rate for catalyst A. Error bars represent standard
deviation from three independent measurements (n=3).}
\label{fig:temp-rate}
\end{figure}
The data in Figure~\ref{fig:temp-rate} clearly shows an exponential
relationship, consistent with Arrhenius behavior.
\end{document}
Advanced Layouts: Subfigures and Wrapping
For complex visual arrangements, specialized packages enable side-by-side figures or text integration.
Creating Subfigures (subcaption package)
The subcaption package places multiple images within a single main figure. See the subcaption package documentation for advanced options.
\usepackage{subcaption}
\begin{figure}[htbp]
\centering
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{image1}
\caption{First subfigure}
\label{fig:sub1}
\end{subfigure}
\hfill % Adds horizontal space between subfigures
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{image2}
\caption{Second subfigure}
\label{fig:sub2}
\end{subfigure}
\caption{Main caption for the complete visual.}
\label{fig:main}
\end{figure}
Multi-Row Subfigures
\begin{figure}[htbp]
\centering
% First row
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img1}
\caption{Condition A}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img2}
\caption{Condition B}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img3}
\caption{Condition C}
\end{subfigure}
\vspace{0.5cm} % Vertical space between rows
% Second row
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img4}
\caption{Result A}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img5}
\caption{Result B}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\includegraphics[width=\textwidth]{img6}
\caption{Result C}
\end{subfigure}
\caption{Comparison of experimental conditions and their results.}
\end{figure}
Wrapping Text Around Figures (wrapfig package)
Use the wrapfig environment to allow text to flow around an image. For more details, consult the wrapfig package documentation.
\usepackage{wrapfig}
\begin{wrapfigure}{r}{0.4\textwidth}
\centering
\includegraphics[width=0.35\textwidth]{image}
\caption{Figure with text wrapping.}
\end{wrapfigure}
This text will wrap around the figure on the right side of the page,
continuing until the bottom of the figure is reached. Additional
paragraphs will continue wrapping naturally.
Image Manipulation and Annotation
The \includegraphics command offers options for rotating, clipping, and trimming images.
Rotation and Trimming
% Rotate 90 degrees clockwise
\includegraphics[angle=90]{image}
% Clip: Trim 1cm from left, 2cm from bottom, 3cm from right, 4cm from top
\includegraphics[clip, trim=1cm 2cm 3cm 4cm]{image}
% Combined options
\includegraphics[width=0.5\textwidth, angle=45, clip, trim=0 1cm 0 1cm]{image}
Creating Graphics with TikZ
The tikz package allows programmatic drawing of diagrams and annotations directly in LaTeX. For comprehensive tutorials and examples, visit the TikZ & PGF documentation or explore TikZ examples.
Basic TikZ Figure:
\usepackage{tikz}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\draw[thick] (0,0) rectangle (4,3);
\draw[->] (0,0) -- (4,0) node[right] {$x$};
\draw[->] (0,0) -- (0,3) node[above] {$y$};
\node at (2,1.5) {Custom Diagram};
\end{tikzpicture}
\caption{A simple TikZ-generated diagram.}
\label{fig:tikz-example}
\end{figure}
Troubleshooting Common Issues
For additional troubleshooting help, the TeX Stack Exchange community is an excellent resource for solving specific LaTeX problems.
Image Not Appearing
Problem: Image doesn’t show; you see only the filename or a placeholder box. Solutions:
- Verify the file path is correct and the image file exists
- Check file extension matches actual format (sometimes
.jpgis actually.jpeg) - Ensure
graphicxpackage is loaded in preamble - Check compiler output for errors about missing files
- Try compiling on Overleaf to isolate local environment issues
Figure Appears in Wrong Location
Problem: Figure appears pages away from where you want it. Solutions:
- Use
[!htbp]to give LaTeX more flexibility - Avoid
[h]alone; always combine with other options like[htbp] - Use
\FloatBarrierfrom theplaceinspackage to prevent figures from floating past a certain point - For critical placement, use
[H]from thefloatpackage (forces exact placement, but may create white space) - Read more about float placement in this Overleaf guide on positioning figures
\usepackage{float}
\begin{figure}[H] % Forces figure HERE (use sparingly)
...
\end{figure}
Image Too Large or Distorted
Problem: Image doesn’t fit on page or looks stretched. Solutions:
- Always use
keepaspectratiowhen setting both width and height - Use relative sizing:
width=0.8\textwidthinstead of fixed measurements - Check original image resolution isn’t too low (causes pixelation)
Subfigures Not Aligning
Problem: Subfigures appear misaligned or stack vertically. Solutions:
- Ensure total width of subfigures plus spacing doesn’t exceed
\textwidth - Remove blank lines between subfigure environments (creates paragraph breaks)
- Use
\hfillfor even spacing or explicit spacing like\hspace{1cm}
References Showing ?? Instead of Numbers
Problem: \ref{fig:mylabel} displays ?? in the PDF. Solutions:
- Compile your document twice (LaTeX needs two passes for cross-references)
- Verify label is unique and placed after
\captioncommand - Check for typos in label name
Best Practices for Professional LaTeX Figures
- File Organization: Use
\graphicspath{{images/}{figures/}}in your preamble to organize images and simplify file references. - Relative Sizing: Always use
\textwidthor\columnwidthfor sizing to ensure figures scale correctly regardless of document class or column layout. - Vector Graphics: Use PDF or EPS formats for diagrams, plots, and line art (scales without quality loss). Use JPG or PNG only for photographs.
- Captions: Write clear, descriptive captions that allow the figure to be understood independently of the main text.
- Referencing: Always use
\labeland\ref(or\creffrom thecleverefpackage) for dynamic cross-referencing. Learn more about cross-referencing in LaTeX. - Consistent Naming: Use descriptive, consistent label prefixes like
fig:,tab:,eq:to avoid confusion. - Online Resources: For hands-on practice and templates, Overleaf provides an excellent online LaTeX editor with built-in templates and real-time collaboration features.
Conclusion
By mastering these LaTeX figure commands, you gain comprehensive control over every visual element in your document. From simple image insertion to intricate multi-panel subfigures, LaTeX ensures your graphics are presented with precision and consistency, maintaining professional quality throughout your document.
The key to success is using relative sizing, proper file organization, and understanding float behavior—combined with the troubleshooting techniques above, you’ll handle any figure challenge confidently.
Great job reaching the end of this LaTeX guide! You now know how to insert, format, and customize images like a pro.
Keep learning and building — explore more helpful tutorials and developer tips at Deadloq.

[…] ( For more styling, check our guide on LaTeX Figure Commands). […]
[…] more LaTeX tutorials covering Tables, Images, and Math commands, visit Deadloq. Thank […]