Master figure positioning in LaTeX. Learn about float placement, positioning options, and advanced layout techniques for professional documents.
Controlling where figures appear in your document is crucial for professional layouts. This guide covers float behavior, positioning options, and advanced techniques for precise figure placement.
Key concept: Figures are “floats” in LaTeX - they can move to optimize page layout. Understanding this behavior is essential for controlling positioning.
Floats are elements (figures, tables) that LaTeX can move to avoid awkward page breaks and maintain good typography. LaTeX uses sophisticated algorithms to determine optimal placement.
Copy
Ask AI
\documentclass{article}\usepackage{graphicx}\begin{document}Text before the figure.\begin{figure}[h] % 'h' suggests "here" \centering \includegraphics[width=0.5\textwidth]{example-image} \caption{LaTeX may move this figure} \label{fig:float}\end{figure}Text after the figure definition continues here, but the figure might appear elsewhere in the final document.\end{document}
% Single option\begin{figure}[h] % Here\begin{figure}[t] % Top of page \begin{figure}[b] % Bottom of page\begin{figure}[p] % Page of floats% Multiple options (order matters)\begin{figure}[ht] % Try here, then top\begin{figure}[hb] % Try here, then bottom\begin{figure}[tb] % Try top, then bottom\begin{figure}[htbp] % Try all positions% With override\begin{figure}[!h] % Try harder to place here\begin{figure}[!t] % Override constraints for top
% Control float placement rules\setcounter{topnumber}{2} % Max floats at top of page\setcounter{bottomnumber}{1} % Max floats at bottom\setcounter{totalnumber}{3} % Max floats per page% Fraction of page for floats\renewcommand{\topfraction}{0.8} % Max 80% of page for top floats\renewcommand{\bottomfraction}{0.5} % Max 50% for bottom floats\renewcommand{\textfraction}{0.2} % Min 20% must be text\renewcommand{\floatpagefraction}{0.7} % Min 70% of float page% Vertical spacing\setlength{\floatsep}{12pt} % Between floats\setlength{\textfloatsep}{20pt} % Between text and float\setlength{\intextsep}{12pt} % For wrapfig
% Force all pending floats\clearpage % Start new page after floats% Clear without page break\usepackage{afterpage}\afterpage{\clearpage} % Clear after current page% Clear specific float type\usepackage{placeins}\FloatBarrier % Prevent floats from passing% Section-wise float barriers\usepackage[section]{placeins} % Floats don't cross sections
% Three figures with different sizes\begin{figure}[htbp] \centering % Large figure on left \begin{minipage}{0.5\textwidth} \includegraphics[width=\textwidth]{large} \end{minipage} \hfill % Two small figures on right \begin{minipage}{0.45\textwidth} \includegraphics[width=\textwidth]{small1}\\[0.5cm] \includegraphics[width=\textwidth]{small2} \end{minipage} \caption{Custom arrangement}\end{figure}% L-shaped arrangement\begin{figure}[htbp] \centering \begin{tabular}{cc} \includegraphics[width=0.3\textwidth]{img1} & \includegraphics[width=0.3\textwidth]{img2} \\ \multicolumn{2}{c}{ \includegraphics[width=0.6\textwidth]{img3} } \end{tabular} \caption{L-shaped layout}\end{figure}
\usepackage{tikz}\usepackage{eso-pic}% Place at specific coordinates\AddToShipoutPictureBG{% \AtPageUpperLeft{% \put(2cm,-5cm){% \includegraphics[width=3cm]{logo} }% }%}% Using TikZ\begin{tikzpicture}[remember picture,overlay] \node at (current page.center) { \includegraphics[width=5cm]{watermark} };\end{tikzpicture}
% For books/reports with wide margins\marginpar{ \centering \includegraphics[width=\marginparwidth]{small-image} \captionof{figure}{Margin figure}}% Using marginfigure (tufte-latex)\begin{marginfigure} \includegraphics[width=\textwidth]{image} \caption{In the margin}\end{marginfigure}
% Preamble settings for better float handling% Allow more floats\setcounter{totalnumber}{6}\setcounter{topnumber}{4}\setcounter{bottomnumber}{4}% Relax float constraints\renewcommand{\topfraction}{0.9}\renewcommand{\bottomfraction}{0.8}\renewcommand{\textfraction}{0.1}\renewcommand{\floatpagefraction}{0.8}% Penalties for float placement\setlength{\floatsep}{10pt plus 3pt minus 2pt}\setlength{\textfloatsep}{15pt plus 3pt minus 3pt}\setlength{\intextsep}{10pt plus 3pt minus 2pt}% Stricter float placement\usepackage[section]{placeins} % Floats within sections
Next: Learn about Creating tables to present structured data effectively. Tables use similar positioning concepts to figures. You might also be interested in Cross-referencing to link to your figures and tables.