How to put several images in one row in LaTex?

I just prepared a question/answer (see here) and I think that the code is suitable for the question here. I provide different examples that are based on the subcaption package.

\documentclass{article}

\usepackage[
    showframe, % This option shows the margins and so on -- remove it in the final version
]{geometry}

\usepackage{graphicx}

% Here: H option for float placement
\usepackage{float}

% caption and subcaption work together
\usepackage{subcaption} % loads the caption package

\begin{document}

\section{Two Figures}
\subsection{Horizontal}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.45\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.45\textwidth]{example-image-b}}%
\caption{Caption}
\end{figure}

\subsection{Vertical}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.45\textwidth]{example-image-a}}%
\\ % <-- Line break
\subcaptionbox{Subcaption B}{\includegraphics[width=0.45\textwidth]{example-image-b}}%
\caption{Caption}
\end{figure}

\section{Three Figures}
\subsection{Horizontal}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.30\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.30\textwidth]{example-image-b}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption C}{\includegraphics[width=0.30\textwidth]{example-image-C}}%
\caption{Caption}
\end{figure}

\subsection{Vertical}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.30\textwidth]{example-image-a}}%
\\ % <-- Line break
\subcaptionbox{Subcaption B}{\includegraphics[width=0.30\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}{\includegraphics[width=0.30\textwidth]{example-image-C}}%
\caption{Caption}
\end{figure}

\subsection{Mixed}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.30\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.30\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}{\includegraphics[width=0.30\textwidth]{example-image-C}}%
\caption{Caption}
\end{figure}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.45\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.45\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}{\includegraphics[width=0.30\textwidth]{example-image-C}}%
\caption{Caption}
\end{figure}

\section{Four Figures}
\subsection{Horizontal}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.20\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.20\textwidth]{example-image-b}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption C}{\includegraphics[width=0.20\textwidth]{example-image-C}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption D}{\includegraphics[width=0.20\textwidth]{example-image}}%
\caption{Caption}
\end{figure}

\subsection{Mixed}

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.45\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.45\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}{\includegraphics[width=0.45\textwidth]{example-image-C}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption D}{\includegraphics[width=0.45\textwidth]{example-image}}%
\caption{Caption}
\end{figure}

\section{Symmetric Padding}

See the following example with small picture widths.

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}{\includegraphics[width=0.20\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}{\includegraphics[width=0.20\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}{\includegraphics[width=0.20\textwidth]{example-image-C}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption D}{\includegraphics[width=0.20\textwidth]{example-image}}%
\caption{Caption}
\end{figure}

You can use the optional argument of the \texttt{\textbackslash subcaptionbox} in order to define the width of the sub element.

\begin{figure}[H]
\centering
\subcaptionbox{Subcaption A}[0.50\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-a}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption B}[0.50\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-b}}%
\\ % <-- Line break
\subcaptionbox{Subcaption C}[0.50\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-C}}%
\hfill % <-- Seperation
\subcaptionbox{Subcaption D}[0.50\textwidth]{\includegraphics[width=0.20\textwidth]{example-image}}%
\caption{Caption}
\end{figure}

Here I try to illustrate the idea behind the solution -- \textbf{don't use this code}!

\begin{figure}[H]
\centering
\fbox{%
\subcaptionbox{Subcaption A}[0.482\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-a}}%
}%
\hfill % <-- Seperation
\fbox{%
\subcaptionbox{Subcaption B}[0.482\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-b}}%
}%
\\ % <-- Line break
\fbox{%
\subcaptionbox{Subcaption C}[0.482\textwidth]{\includegraphics[width=0.20\textwidth]{example-image-c}}%
}%
\hfill % <-- Seperation
\fbox{%
\subcaptionbox{Subcaption D}[0.482\textwidth]{\includegraphics[width=0.20\textwidth]{example-image}}%
}%
\caption{Caption}
\end{figure}

\end{document}

enter image description here


Here's how to position figures across the columns of multicol:

\documentclass{article}

\usepackage{multicol}
\usepackage{lipsum}
\usepackage{mwe}

\begin{document}
    \begin{multicols}{2}
        \begin{figure*}[ht!]
            \includegraphics[width=.3\textwidth]{example-image-a}\hfill
            \includegraphics[width=.3\textwidth]{example-image-b}\hfill
            \includegraphics[width=.3\textwidth]{example-image-c}
            \caption{Image A.}
            \caption{Image B.}
            \caption{Image C.}
        \end{figure*}
        \lipsum[1-10]
    \end{multicols}
\end{document}

Note that I'm using the starred version of the figure environment. The [ht] tag specifies position, here indicating "at the top of this page." Google "LaTeX Floats" for how to change that and how to adjust the figure environment.

Here: copy\paste only this part:

        \begin{figure*}[ht!]
            \includegraphics[width=.3\textwidth]{example-image-a}\hfill
            \includegraphics[width=.3\textwidth]{example-image-b}\hfill
            \includegraphics[width=.3\textwidth]{example-image-c}
            \caption{Image A.}
            \caption{Image B.}
            \caption{Image C.}
        \end{figure*}

Tags:

Graphics