[Tex/LaTex] Reduction of Space between two Sub-figures

spacingsubfloats

I want to reduce the space between two subfigures and use that space to make those subfigures large. How to do that? My code is as follows:

\begin{figure}[htp]
  \centering
  \subfigure[1a]{\label{fig1:a}\includegraphics[width=1.6in]{./fig1a.eps}}\hfill
  \subfigure[1b]{\label{fig1:b}\includegraphics[width=1.6in]{./fig1b.eps}}
  \label{fig1}
\end{figure}

Best Answer

Consider the following minimal example that shows three different ways of spacing sub-figures:

  1. Maximum length
  2. Equal lengths
  3. Fixed length

Different lengths separating subfigures

\documentclass{article}
\usepackage{showframe,subcaption,graphicx}
\begin{document}
\begin{figure}[htp]
  % Maximum length
  \subcaptionbox{1a\label{fig1:a}}{\includegraphics[width=1.6in]{example-image-a}}\hfill%
  \subcaptionbox{1b\label{fig1:b}}{\includegraphics[width=1.6in]{example-image-a}}%

  \bigskip

  % Equal length
  \hspace*{\fill}%
  \subcaptionbox{2a\label{fig2:a}}{\includegraphics[width=1.6in]{example-image-b}}\hfill%
  \subcaptionbox{2b\label{fig2:b}}{\includegraphics[width=1.6in]{example-image-b}}%
  \hspace*{\fill}%

  \bigskip

  % Fixed length
  \centering
  \subcaptionbox{3a\label{fig3:a}}{\includegraphics[width=1.6in]{example-image-c}}\hspace{1em}%
  \subcaptionbox{3b\label{fig3:b}}{\includegraphics[width=1.6in]{example-image-c}}
\end{figure}

\end{document}‚Äč

The showframe package was loaded to highlight the text block boundaries. Note the use of % for precise spacing. See What is the use of percent signs (%) at the end of lines? for more on this.

  1. Maximum length: Here a stretchable length of \hfill is used to push both subfigures to the edges of the text block. Note the % at the end of the second subfigure, if you're placing content on the following line.

  2. Equal lengths: A stretchable length is placed on either side of the subfigures to equalize the length from the text block boundary as well as between the subfigures. Note the use of \hspace*{\fill} on either side of the subfigures, while \hfill suffices between them.

  3. Fixed length: Use a fixed \hspace{<len>} between the subfigures, together with \centering to centre and separate the subfigures by a fixed distance <len> (1em in my example).

Some comments:

  • Note the use of % at the end of lines. They do add spurious spaces in your output. While it may not be visible, you may not get exact lengths otherwise. See What is the use of percent signs (%) at the end of lines? for more on this.

  • Only method 3 (fixed length) requires \centering, unless you're also providing a figure caption (which you didn't in your code snippet. Moreover, using \label without a \caption does not help here. It works within \subcaptionbox (from subcaption), since it writes a caption, but you would still need a separate \caption for your figure environment for \label{fig1} to yield anything.