How to adjust the space or gap between subfigures in LaTeX?

Working with subfigures in LaTeX can be a bit tricky sometimes, but I will share some simple tips to adjust the spaces between subfigures properly. Let’s keep it simple and clear.

LaTeX provides several useful commands to control the space between subfigures, such as \hspace, \quad, \qquad, and \hfill.

Using hspace command for customizable space

The \hspace is a command in LaTeX that allows you to create any custom amount of space.

\subfloat[figure A]{\includegraphics[width]{example-image-a}} 
\hspace(lentgh) 
\subfloat[figure B]{\includegraphics[width]{example-image-b}} 
\hspace(length) 
\subfloat[figure C]{\includegraphics[width]{example-image-c}} 

For example, if you want a 1cm gap between two subfigures, you can easily do it with \hspace{1cm}.

\documentclass[12pt]{article}  
\usepackage{graphicx,lipsum}  
\usepackage{subcaption,xcolor}  
\usepackage[top=2cm]{geometry}  
\begin{document}  

\begin{figure}[htb]  
    \centering  
    \subfloat[Symbol A]{\includegraphics[width=0.27\textwidth]{example-image-a}}  
    \hspace{1cm}  
    \subfloat[Symbol B]{\includegraphics[width=0.27\textwidth]{example-image-b}}  
    \hspace{1.5cm}  
    \subfloat[Symbol C]{\includegraphics[width=0.27\textwidth]{example-image-c}}  
    \caption{Two images with gaps using subfloat env}  
\end{figure}  

\noindent\lipsum[3][2-6]  

\pagecolor{olive!15}  
\begin{figure}[htb]  
    \centering  
    \begin{subfigure}{0.25\textwidth}  
        \includegraphics[width=\linewidth]{example-image-a}  
        \caption{Symbol A}  
    \end{subfigure}  
    \hspace{1.5cm}  
    \begin{subfigure}{0.25\textwidth}  
        \includegraphics[width=\linewidth]{example-image-b}  
        \caption{Symbol B}  
    \end{subfigure}  
    \hspace{1.25cm}  
    \begin{subfigure}{.25\textwidth}  
        \includegraphics[width=\linewidth]{example-image-c}  
        \caption{Symbol C}  
    \end{subfigure}  
    \caption{Three images with gaps using subfigure env}  
\end{figure}  

\noindent\lipsum[1][2-6]  

\begin{figure}[htb]  
    \centering  
    \begin{subfigure}{0.3\textwidth}  
        \includegraphics[width=\linewidth]{example-image-a}  
        \caption{Symbol A}  
    \end{subfigure}  
    \hspace{40pt}  
    \begin{subfigure}{0.3\textwidth}  
        \includegraphics[width=\linewidth]{example-image-b}  
        \caption{Symbol B}  
    \end{subfigure}  
    \caption{Two images with gaps using subfigure env}  
\end{figure}  

\end{document}

Output:

With \hspace, you can set any space you like, such as 0.5cm, 2cm, or more. It’s perfect when you want a specific amount of space between subfigures.

Using quad and qquad for fixed space

The \quad and \qquad are easy ways to add fixed spaces without needing to measure. \quad gives a small space, while \qquad is twice as big.

\begin{figure}[htb]
  \centering  
  \subfloat[Symbol A]{\includegraphics[width=0.29\textwidth]{example-image-a}} 
  \qquad  
  \subfloat[Symbol B]{\includegraphics[width=0.29\textwidth]{example-image-b}} 
  \qquad 
  \subfloat[Symbol C]{\includegraphics[width=0.29\textwidth]{example-image-c}}
  \caption{Main figure caption}  
\end{figure}

Here’s an example of how to use \quad to add a small gap between two subfigures.

\documentclass[12pt]{article}
\usepackage{subfig,graphicx,lipsum}
\usepackage[top=2cm]{geometry}
\begin{document}
\noindent\lipsum[1][1-4]
\begin{figure}[htb]
    \centering  
    \subfloat[symbol C]{\includegraphics[width=0.27\textwidth]{example-image-c}} 
    \quad 
    \subfloat[symbol B]{\includegraphics[width=0.27\textwidth]{example-image-b}} 
    \quad \quad 
    \subfloat[symbol A]{\includegraphics[width=0.27\textwidth]{example-image-a}}
    \caption{Main figure caption}  
\end{figure}

\noindent\lipsum[1][1-3]

\begin{figure}[htb]
    \centering  
    \subfloat[Mars 1]{\includegraphics[width=0.29\textwidth]{mars.png}} 
    \qquad  
    \subfloat[Mars 2]{\includegraphics[width=0.29\textwidth]{mars.png}} 
    \qquad 
    \subfloat[Mars 3]{\includegraphics[width=0.29\textwidth]{mars.png}}
    \caption{Mars figure caption}  
\end{figure}
\end{document}

Output:

If you need a larger gap, you can use \qquad to create double the space. These commands are helpful when you need a standard amount of space without specifying exact measurements.

Using hfill command for equal gaps

The \hfill works a little differently by spreading the space evenly between subfigures. It’s great when you want subfigures to be pushed to the sides and the space between them to be equally spread out.

\begin{figure}[htb]
  \centering  
  \subfloat[Symbol A]{\includegraphics[width=0.3\textwidth]{example-image-a}} 
  \hfill 
  \subfloat[Symbol B]{\includegraphics[width=0.3\textwidth]{example-image-b}} 
  \hfill
  \subfloat[Symbol C]{\includegraphics[width=0.3\textwidth]{example-image-c}}
  \caption{Main figure caption}  
\end{figure}

Let’s say you want three subfigures to have equal gaps between them. Here’s how you’d do it with \hfill.

\documentclass[12pt]{article}
\usepackage{subfig,xcolor,graphicx,lipsum}
\usepackage[top=2cm]{geometry}
\begin{document}
\pagecolor{olive!15}
\lipsum[1][1-4]
\begin{figure}[htb]
    \centering  
    \subfloat[symbol A]{\includegraphics[width=0.27\textwidth]{example-image-a}} 
    \hfill  
    \subfloat[Symbol B]{\includegraphics[width=0.27\textwidth]{example-image-b}} 
    \hfill  
    \subfloat[Symbol A]{\includegraphics[width=0.27\textwidth]{example-image-a}}
    \caption{Main figure caption}  
\end{figure}

\lipsum[2][1-3]

\begin{figure}[htb]
    \centering  
    \subfloat[Mars 1]{\includegraphics[width=0.3\textwidth]{mars.png}} 
    \hfill  
    \subfloat[Mars 2]{\includegraphics[width=0.3\textwidth]{mars.png}} 
    \hfill  
    \subfloat[Mars 3]{\includegraphics[width=0.3\textwidth]{mars.png}}
    \caption{Mars figure caption}  
\end{figure}
\end{document}

Output:

Here, \hfill will add equal space between each pair of subfigures, making them look neatly spread out.

Conclusion

So, now you know that LaTeX offers some very handy ways to adjust space between subfigures! Use \hspace for specific spaces, \quad and \qquad for fixed, standard spaces, and \hfill to spread the space evenly.

Each command has its own use, and you can mix and match them as needed. And remember, if you have any questions, I’m here to help!

Share tutorial

Leave a Comment

Your email address will not be published. Required fields are marked *