Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
Assuming that the \hfill is there to place the figures towards either side of the margin, you can just make them bigger. The \hfill should auto adjust. –  Peter Grill Jan 31 '12 at 19:53

4 Answers 4

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.

share|improve this answer

use a relative width:

\documentclass{article}
\usepackage{showframe}% only for demo
\usepackage{subfig}
\usepackage[demo]{graphicx}% [demo] only for demo
\begin{document}
\begin{figure}[!htp]
  % Maximum length
  \subfloat[1a]{\label{fig1:a}\includegraphics[width=0.49\linewidth]{fig1a}}\hfill
  \subfloat[1b]{\label{fig1:b}\includegraphics[width=0.49\linewidth]{fig1b}}%
\end{figure}

\end{document}​

enter image description here

share|improve this answer

To use all the space available remove the hfill (or keep it, it doesn't really change) and set a relative width .49/textwidth. You may actually want to try a slightly lower value to leave some space between them.

\begin{figure}[htp]
  \centering
  \subfigure[1a]{\label{fig1:a}\includegraphics[width=.49/textwidth]{./fig1a.eps}}
  \subfigure[1b]{\label{fig1:b}\includegraphics[width=.49/textwidth]{./fig1b.eps}}
  \label{fig1}
\end{figure}
share|improve this answer

In my case, the subfig package introduces a default space of a little less than 1em between two figures. I still need them tight, as the two figures correspond in major features, so I found it helpful to tweak the spacing with negative horizontal space as well.

\documentclass[draft]{article}
\usepackage{subfig}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
    \centering
    \subfloat[Subfigure caption 1.]{
        \includegraphics[width=0.75\textwidth] {img1.png}
        \label{fig:img1} } \hspace*{-0.9em}
    \subfloat[Subfigure caption 2.]{
        \includegraphics[width=0.25\textwidth] {img2.png}
        \label{fig:img2} } \\
    \caption{Two corresponding images.}
    \label{fig:img}
\end{figure}
\end{document}
share|improve this answer
1  
This could be due to a spurious space within the \subfloat command. See What is the use of percent signs at the end of lines? –  Werner Nov 9 '12 at 22:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.