LaTeX Figures and Graphics: A Practical Guide to Images, Floats, and TikZ
Figures carry a lot of weight in academic and technical writing. A plot, a diagram, a photo of an experimental rig: these often do more work than a paragraph of prose. LaTeX gives you precise control over how figures and graphics behave, but that control comes with a learning curve. This guide walks through the parts that actually trip people up.
Understanding LaTeX Figure Management
The Float System
LaTeX treats figures as “floats”, elements that can move to optimize page layout. The float system keeps documents looking clean, and it confuses almost everyone the first time a figure lands three pages away from where they wrote it:
% Basic figure environment
\begin{figure}[placement specifiers]
% Figure content
\caption{Figure description}
\label{fig:unique-label}
\end{figure} Placement Specifiers Explained
\begin{figure}[htbp]
% h - here (approximately at this position)
% t - top of page
% b - bottom of page
% p - separate page for floats
% ! - override LaTeX's internal parameters
% H - HERE (requires float package) Pro tip: Use [htbp] for most figures, allowing LaTeX maximum flexibility.
Including External Graphics
Basic Image Inclusion
First, load the graphicx package:
\usepackage{graphicx}
% Optional: Set graphics path
\graphicspath{{images/}{figures/}{../assets/}} Include images with:
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{experiment-results.png}
\caption{Experimental results showing quantum entanglement}
\label{fig:quantum-results}
\end{figure} Advanced includegraphics Options
% Size control
\includegraphics[width=5cm]{image.jpg}
\includegraphics[height=3cm]{image.jpg}
\includegraphics[scale=0.5]{image.jpg}
% Maintain aspect ratio
\includegraphics[width=0.5\textwidth,keepaspectratio]{image.jpg}
% Rotation and clipping
\includegraphics[angle=90,origin=c]{image.jpg}
\includegraphics[trim=1cm 2cm 1cm 2cm,clip]{image.jpg}
% Advanced example
\includegraphics[
width=0.7\textwidth,
angle=15,
origin=c,
trim=0.5cm 0.5cm 0.5cm 0.5cm,
clip
]{complex-diagram.pdf} Supported Image Formats
% PDFLaTeX supports:
% - PDF (vector, preferred for diagrams)
% - PNG (raster, good for photos)
% - JPG/JPEG (raster, compressed photos)
% XeLaTeX/LuaLaTeX additionally support:
% - EPS (with conversion)
% - SVG (with svg package) Professional Figure Layouts
Side-by-Side Figures
Using minipage environments:
\begin{figure}[htbp]
\centering
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{before.png}
\caption{Before treatment}
\label{fig:before}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{after.png}
\caption{After treatment}
\label{fig:after}
\end{minipage}
\caption{Comparison of results}
\label{fig:comparison}
\end{figure} Subfigures with subcaption Package
\usepackage{subcaption}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{fig1.png}
\caption{Initial state}
\label{fig:sub1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{fig2.png}
\caption{Intermediate state}
\label{fig:sub2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{fig3.png}
\caption{Final state}
\label{fig:sub3}
\end{subfigure}
\caption{Evolution of the system over time}
\label{fig:evolution}
\end{figure} Grid Layouts
For complex arrangements:
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{topleft.png}
\caption{Dataset A}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{topright.png}
\caption{Dataset B}
\end{subfigure}
\vspace{0.5cm}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{bottomleft.png}
\caption{Dataset C}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{bottomright.png}
\caption{Dataset D}
\end{subfigure}
\caption{Comparison across multiple datasets}
\label{fig:grid-comparison}
\end{figure} Creating Graphics with TikZ
Basic TikZ Diagrams
TikZ allows creating publication-quality diagrams directly in LaTeX:
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
box/.style={rectangle, draw, rounded corners,
minimum width=3cm, minimum height=1cm},
arrow/.style={->, thick}
]
% Nodes
\node[box] (input) {Input};
\node[box, right=of input] (process) {Process};
\node[box, right=of process] (output) {Output};
% Arrows
\draw[arrow] (input) -- (process);
\draw[arrow] (process) -- (output);
% Labels
\node[above=0.5cm of process] {System Overview};
\end{tikzpicture}
\caption{Simple system diagram}
\label{fig:system}
\end{figure} Scientific Plots with pgfplots
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel={Time (s)},
ylabel={Amplitude},
grid=major,
width=0.8\textwidth,
height=6cm,
legend pos=north east
]
% Plot from data
\addplot[blue, thick] coordinates {
(0,0) (1,2) (2,3) (3,3.5) (4,3.8) (5,4)
};
\addlegendentry{Experimental}
% Plot from function
\addplot[red, dashed, domain=0:5, samples=100]
{4*(1-exp(-0.5*x))};
\addlegendentry{Theoretical}
\end{axis}
\end{tikzpicture}
\caption{Comparison of experimental and theoretical results}
\label{fig:plot-comparison}
\end{figure} Flow Charts and Diagrams
\usetikzlibrary{shapes.geometric, arrows.meta}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
node distance=2cm,
startstop/.style={rectangle, rounded corners,
minimum width=3cm, minimum height=1cm,
text centered, draw=black, fill=red!30},
process/.style={rectangle, minimum width=3cm,
minimum height=1cm, text centered,
draw=black, fill=orange!30},
decision/.style={diamond, minimum width=3cm,
minimum height=1cm, text centered,
draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth}
]
\node[startstop] (start) {Start};
\node[process, below of=start] (init) {Initialize};
\node[decision, below of=init] (decide) {Condition?};
\node[process, below of=decide, xshift=-3cm] (yes) {Process A};
\node[process, below of=decide, xshift=3cm] (no) {Process B};
\node[startstop, below of=decide, yshift=-3cm] (stop) {End};
\draw[arrow] (start) -- (init);
\draw[arrow] (init) -- (decide);
\draw[arrow] (decide) -- node[left] {Yes} (yes);
\draw[arrow] (decide) -- node[right] {No} (no);
\draw[arrow] (yes) |- (stop);
\draw[arrow] (no) |- (stop);
\end{tikzpicture}
\caption{Algorithm flowchart}
\label{fig:flowchart}
\end{figure} Managing Complex Figures
Wrapping Text Around Figures
\usepackage{wrapfig}
\begin{wrapfigure}{r}{0.4\textwidth}
\centering
\includegraphics[width=0.35\textwidth]{molecule.png}
\caption{Molecular structure}
\label{fig:molecule}
\end{wrapfigure}
This text will wrap around the figure. The wrapfigure environment
is particularly useful for small figures that don't need the full
text width. Continue writing your paragraph here... Full-Width Figures in Two-Column Documents
\begin{figure*}[htbp]
\centering
\includegraphics[width=\textwidth]{panoramic-view.png}
\caption{Full-width figure spanning both columns}
\label{fig:fullwidth}
\end{figure*} Landscape Figures
\usepackage{rotating}
\begin{sidewaysfigure}
\centering
\includegraphics[width=\textwidth]{wide-table.png}
\caption{Rotated figure for landscape orientation}
\label{fig:landscape}
\end{sidewaysfigure} Optimizing Figure Quality
Resolution Guidelines
% Print quality: 300 DPI minimum
% Screen viewing: 150 DPI acceptable
% Calculate required pixel dimensions:
% Width in inches × DPI = pixel width
% Example: 6 inches × 300 DPI = 1800 pixels wide Vector vs Raster Graphics
% Use vector formats (PDF, EPS) for:
% - Diagrams
% - Charts
% - Line drawings
% - Text-heavy graphics
% Use raster formats (PNG, JPG) for:
% - Photographs
% - Screenshots
% - Complex gradients
% - Scanned images
% Converting formats:
% inkscape input.svg --export-pdf=output.pdf
% convert input.png output.pdf Color Management
\usepackage{xcolor}
% Define custom colors for consistency
\definecolor{primaryblue}{RGB}{0,102,204}
\definecolor{secondaryred}{RGB}{204,0,0}
\definecolor{accentgreen}{RGB}{0,153,0}
% Use in figures
\begin{tikzpicture}
\draw[color=primaryblue, thick] (0,0) -- (2,2);
\fill[color=secondaryred] (1,1) circle (0.1);
\end{tikzpicture} Working on Figures with a Team
Heavy TikZ and pgfplots figures are slow to compile. A complex flowchart or a plot with thousands of sampled points can take several seconds on its own, and that adds up fast in a thesis full of them. This is where compile limits start to matter. inscrive.io gives you a 60-second compile window on the free tier and 480 seconds on Pro, which is room for the kind of graphics-heavy document that times out on stricter editors.
A few things help when several people are editing the same figures:
- Real-time collaboration means two authors can adjust a
tikzpictureand its caption at the same time without merge conflicts. - Advanced version history lets you rewind a figure or caption to an earlier version if a change broke the layout.
- Files live in the EU. inscrive hosts on Hetzner in Germany and Finland, in ISO 27001-certified data centres, with a signed DPA and no third-country transfers. For research images tied to human subjects or unpublished results, that matters.
You write and compile in the browser, so there is no TeX install to manage across a team. The free tier covers up to 10 active projects with unlimited collaborators on each.
Best Practices for Team Projects
% Organize figures systematically
figures/
├── chapter1/
│ ├── experiment-setup.png
│ └── results-graph.pdf
├── chapter2/
│ ├── algorithm-flow.tikz
│ └── comparison-table.png
└── shared/
├── logo.pdf
└── common-diagram.svg
% Include with clear naming
\includegraphics{figures/chapter1/experiment-setup} Figure Libraries and Templates
Create reusable figure templates:
% Define custom figure environment
\newenvironment{resultfigure}[2]{
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{#1}
\caption{#2}
}{
\end{figure}
}
% Usage
\begin{resultfigure}{results.png}{Experimental outcomes}
\label{fig:results}
\end{resultfigure} Advanced Techniques
Overlaying Text on Images
\usepackage{overpic}
\begin{figure}[htbp]
\centering
\begin{overpic}[width=0.8\textwidth,grid,tics=10]{background.jpg}
\put(20,70){\color{white}\Large\textbf{Label A}}
\put(60,30){\color{yellow}\Large$\rightarrow$}
\put(65,30){\color{yellow}\Large Important Feature}
\end{overpic}
\caption{Annotated experimental setup}
\label{fig:annotated}
\end{figure} Creating Figure Animations (Beamer)
\documentclass{beamer}
\usepackage{animate}
\begin{frame}{Animated Results}
\begin{figure}
\animategraphics[loop,controls,width=0.8\textwidth]{10}
{frames/frame-}{001}{050}
\caption{Time evolution animation}
\end{figure}
\end{frame} Conditional Figure Inclusion
% Define switches
\newif\ifshowfigures
\showfigurestrue % or \showfiguresfalse
% Conditional inclusion
\ifshowfigures
\begin{figure}[htbp]
\includegraphics{detailed-analysis.png}
\caption{Detailed analysis (included in full version)}
\end{figure}
\fi Troubleshooting Common Issues
Figure Placement Problems
% Force figure placement
\usepackage{float}
\begin{figure}[H] % Capital H forces "HERE"
\includegraphics{urgent-figure.png}
\end{figure}
% Clear all pending floats
\clearpage % or \cleardoublepage for books
% Adjust float parameters
\setcounter{topnumber}{3}
\renewcommand{\topfraction}{0.9}
\renewcommand{\textfraction}{0.1} Missing Figures
% Debug missing figures
\usepackage[draft]{graphicx} % Shows frames with filenames
% Check file paths
\graphicspath{{./images/}{../figures/}{/absolute/path/}}
% List loaded files
\listfiles % In preamble Memory Issues with Large Images
% Reduce image size on-the-fly
\includegraphics[width=5cm,draft]{huge-image.png}
% Use lower resolution for draft
\ifdraft
\graphicspath{{images/low-res/}}
\else
\graphicspath{{images/high-res/}}
\fi Figure Accessibility
Adding Alternative Text
\usepackage{accessibility}
\begin{figure}[htbp]
\centering
\includegraphics[alt={Graph showing exponential growth
from 0 to 100 over 5 years}]{growth-chart.png}
\caption{Company growth over time}
\label{fig:growth}
\end{figure} Creating Accessible Color Schemes
% Colorblind-friendly palette
\definecolor{cb-blue}{RGB}{0,114,178}
\definecolor{cb-orange}{RGB}{230,159,0}
\definecolor{cb-green}{RGB}{0,158,115}
\definecolor{cb-red}{RGB}{204,121,167}
\definecolor{cb-purple}{RGB}{86,180,233}
% High contrast for readability
\definecolor{hc-black}{RGB}{0,0,0}
\definecolor{hc-white}{RGB}{255,255,255} Performance Optimization
Efficient Figure Handling
% Externalize TikZ graphics
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz-cache/]
% Compile once, reuse many times
\begin{tikzpicture}
% Complex diagram code
\end{tikzpicture} Batch Processing
# Convert all images to appropriate format
for img in *.png; do
convert "$img" -quality 90 "${img%.png}.jpg"
done
# Optimize PDFs
for pdf in *.pdf; do
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4
-dPDFSETTINGS=/printer -dNOPAUSE -dQUIET
-dBATCH -sOutputFile="opt-$pdf" "$pdf"
done Best Practices Summary
Do’s
- ✓ Use vector formats for diagrams
- ✓ Include descriptive captions
- ✓ Label all figures for referencing
- ✓ Maintain consistent style
- ✓ Optimize file sizes
- ✓ Test figure placement
Don’ts
- ✗ Use screenshots of text
- ✗ Include figures without captions
- ✗ Ignore aspect ratios
- ✗ Use low-resolution images
- ✗ Hardcode absolute paths
- ✗ Forget alternative text
Future-Proofing Your Figures
Sustainable Practices
% Use relative sizes
\includegraphics[width=0.8\linewidth]{figure.png}
% Store source files
figures/
├── figure1.tex % TikZ source
├── figure1.pdf % Compiled output
├── data/
│ └── figure1.csv % Raw data
└── scripts/
└── generate.py % Generation script Documentation
% Document figure sources
\begin{figure}[htbp]
\includegraphics{results.png}
\caption[Short caption for list]{
Detailed caption.
Data source: experiment-2024-01-30.csv.
Generated using: matplotlib v3.5.1.
}
\label{fig:documented}
\end{figure} Wrapping Up
Most figure problems come down to two things: choosing the right format (vector for diagrams, raster for photos) and trusting the float system instead of fighting it. The rest is captions, labels, and consistent sizing. Get those habits down and your figures stop being a source of compile-day stress.
If you want to draft and compile heavy graphics in the browser, inscrive.io runs LaTeX with no install, a free tier, and EU-hosted storage. It is built for exactly the slow-compiling, TikZ-heavy documents this guide covers.




