LaTeX Guide

Side-by-Side Figures in LaTeX

Use subcaption for figures with their own captions (a)/(b)/(c). Use minipage for figures sharing one caption. Don't use the deprecated subfigure/subfig packages.

Recommended pattern: subcaption

\usepackage{graphicx}
\usepackage{subcaption}

\begin{figure}[t]
  \centering
  \begin{subfigure}{0.48\textwidth}
    \includegraphics[width=\linewidth]{first.png}
    \caption{First subfigure caption.}
    \label{fig:first}
  \end{subfigure}
  \hfill
  \begin{subfigure}{0.48\textwidth}
    \includegraphics[width=\linewidth]{second.png}
    \caption{Second subfigure caption.}
    \label{fig:second}
  \end{subfigure}
  \caption{Shared overall caption.}
  \label{fig:both}
\end{figure}

Reference them: see Figures~\ref{fig:first}, \ref{fig:second}
or both with~\ref{fig:both}.

Three figures in one row

\begin{figure}[t]
  \centering
  \begin{subfigure}{0.32\textwidth}
    \includegraphics[width=\linewidth]{a.png}
    \caption{First.}
  \end{subfigure}\hfill
  \begin{subfigure}{0.32\textwidth}
    \includegraphics[width=\linewidth]{b.png}
    \caption{Second.}
  \end{subfigure}\hfill
  \begin{subfigure}{0.32\textwidth}
    \includegraphics[width=\linewidth]{c.png}
    \caption{Third.}
  \end{subfigure}
  \caption{Three figures side by side.}
\end{figure}

Shared caption (no sub-labels): minipage

\begin{figure}[t]
  \centering
  \begin{minipage}{0.48\textwidth}
    \includegraphics[width=\linewidth]{first.png}
  \end{minipage}
  \hfill
  \begin{minipage}{0.48\textwidth}
    \includegraphics[width=\linewidth]{second.png}
  \end{minipage}
  \caption{One caption for both figures.}
  \label{fig:pair}
\end{figure}

Width math

  • Two figures: 0.48 + 0.48 = 0.96 (4% gap with \hfill)
  • Three figures: 0.32 + 0.32 + 0.32 = 0.96
  • Four figures: 0.24 + 0.24 + 0.24 + 0.24 = 0.96
  • Two unequal: 0.65 + 0.30 = 0.95 (large + small)

Always leave 3-4% slack for \hfill spacing. Going over 1.0 causes overfull warnings.

Common mistakes

  • Using \textwidth inside a subfigure. Use \linewidth instead — it's the subfigure's width, not the page's.
  • Loading the deprecated subfigure package. Use subcaption.
  • Total widths summing to 1.0 or more. Causes overfull \hbox. Stay below 0.97.
  • Forgetting \hfill. Without it, figures stack against each other instead of distributing space.
Typst grids handle this trivially
#figure(
  grid(
    columns: (1fr, 1fr),
    column-gutter: 1em,
    image("first.png"), image("second.png"),
    [(a) First], [(b) Second],
  ),
  caption: [Two figures side by side.]
)

First-class grid layout, no package juggling. Try TypeTeX free.

Try TypeTeX free

Frequently Asked Questions

How do I put two figures side by side in LaTeX?

Use the subcaption package: \usepackage{subcaption}, then inside a figure environment use \begin{subfigure}{0.48\textwidth} ... \end{subfigure} twice. Each subfigure gets its own caption (a), (b). The 0.48\textwidth leaves a small gap between them.

What's the difference between subcaption and subfigure?

subcaption is the modern recommended package (replaces the older subfigure and subfig). subcaption is more flexible, integrates better with hyperref, and is actively maintained. Don't use the deprecated subfigure or subfig packages for new documents.

How do I make figures share one caption (no sub-captions)?

Use minipage instead of subfigure: \begin{minipage}{0.48\textwidth} \includegraphics[width=\linewidth]{a.png} \end{minipage} \hfill \begin{minipage}{0.48\textwidth} ... \end{minipage}. Then one \caption at the figure environment level.

How do I add captions like (a), (b), (c) to subfigures?

Inside each \begin{subfigure}: place a \caption{...} after the \includegraphics. The subcaption package automatically labels them (a), (b), (c). Reference them with \ref{fig:sub} after \label{}.

How do I reference subfigures by letter?

Add \label{fig:sub-a} inside the subfigure (after the caption). Then \ref{fig:sub-a} produces '1a'. Or use \subref{fig:sub-a} for just the 'a' part. The subcaption package handles the formatting automatically.

What width should I use for two side-by-side figures?

0.48\textwidth for each leaves a 4% gap between them. For three figures, use 0.32\textwidth. For tighter layouts use 0.49\textwidth (with \hfill between). Inside a subfigure, use \linewidth (not \textwidth) for \includegraphics width.

How do I put figures side by side without the subcaption package?

Use minipage: each figure goes in its own \begin{minipage}{0.48\textwidth} ... \end{minipage} with \hfill between them, all inside one figure environment. Add captions inside each minipage for individual labels, or one \caption at the end for shared.

How do I make sure figures stay on the same line and don't overflow?

Three rules: (1) widths sum to less than \textwidth (use 0.48 + 0.48 = 0.96, not 0.5 + 0.5); (2) use \hfill between minipages, not space; (3) use \linewidth (not \textwidth) for \includegraphics inside the minipage/subfigure.

Can I put a figure and a table side by side?

Yes — wrap each in a minipage at the same nesting level: \begin{minipage}{0.48\textwidth} \includegraphics{...} \captionof{figure}{...} \end{minipage} \hfill \begin{minipage}{0.48\textwidth} \begin{tabular}{...} ... \end{tabular} \captionof{table}{...} \end{minipage}. Use \captionof from the caption package for cross-environment captions.

More LaTeX guides