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:
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.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.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.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 afigure
caption (which you didn't in your code snippet. Moreover, using\label
without a\caption
does not help here. It works within\subcaptionbox
(fromsubcaption
), since it writes a caption, but you would still need a separate\caption
for yourfigure
environment for\label{fig1}
to yield anything.