6

I use subfigure to implement subfigure and I use \hspace or \vspace. I want very small margin to maximize the size of subfigures but when I set \hspace{0cm} and \vspace{0cm}, there is still large enough margin left between 2 subfigures hence I can not maximize subfigure size. How to solve this problem? My code is like this :

\begin{figure}[t]
\centering

\subfigure[11a's TX rate]{
\includegraphics[scale =0.25] {fig/cdf_rate11a.eps}
\label{cdf_rate11a}
}
\hspace{0cm}
\subfigure[11n's TX rate]{
\includegraphics[scale =0.25] {fig/cdf_rate11n.eps}
\label{cdf_rate11n}
}

\caption{Coverage comparison in various location}
\label{coverage_comparison}
\end{figure}

Jesse
  • 29,686
bnbfreak
  • 183

2 Answers2

4

If I understand your objective correctly, you're looking to place two subfigures side by side. In order to maximize their size, while also maximizing the available distance between them, don't specify a scale option in the \includegraphics instructions. Instead, specify a large value for the width of each subfigure environment -- e.g., 0.48\textwidth -- and use the width=\linewidth option when executing \includegraphics. And, be sure to use an instruction such as \hspace{\fill} to maximize the separation between the subfigures.

The following image shows the resulting look. The thin horizontal line on top is drawn just to illustrate the width of the text block.

enter image description here

\documentclass{report}
\usepackage{subcaption}      % for 'subfigure'  environment
\usepackage[demo]{graphicx}  % omit 'demo' in your real document
\begin{document}
\hrule % just to illustrate the width of the text block
\begin{figure}[h!]
%%\centering  % not needed as the subfigures are maximally separated

\begin{subfigure}{0.48\textwidth}
\includegraphics[width=\linewidth]{fig/cdf_rate11a.eps}
\caption{11a's TX rate}
\label{fig:cdf_rate11a}
\end{subfigure}
\hspace*{\fill}
\begin{subfigure}{0.48\textwidth}
\includegraphics[width=\linewidth]{fig/cdf_rate11n.eps}
\caption{11n's TX rate}
\label{fig:cdf_rate11n}
\end{subfigure}

\caption{Coverage comparison in various locations}
\label{fig:coverage_comparison}
\end{figure}
\end{document}
Mico
  • 506,678
  • I have an error while running that, I just use from \begin{figure} till \end{figure} : ! Missing number, treated as zero. } l.174 \begin{subfigure}{0.48\textwidth}

    ?

    – bnbfreak May 16 '14 at 14:20
  • @user2290560 - Are you maybe also loading either the subfigure or the subfig package, in addition to the subcaption package that's used in the example code above? – Mico May 16 '14 at 15:37
  • 1
    That error is disappeared when I comment subfigure package but another error happens : ! Missing number, treated as zero. \let l.81 } – bnbfreak May 17 '14 at 05:45
  • @user2290560 - I'm afraid this new information isn't sufficient to diagnose what's going on. What's on line 81 (the line that contains the \let statement), and what are the instructions on the couple of lines that immediately precede the line that contain the \let statement? Do consider posting a new query, with a new MWE (minimum working example, starting with \documentclass and ending with \end{document}) that generates the error. – Mico May 17 '14 at 06:00
  • Indeed, it works when I just run your code. maybe the problem is with my additional codes. I will find it again – bnbfreak May 17 '14 at 08:22
2

The subfigures are positioned like a letter X.

If you go

XX

there is no space between them.

If you go

X
X

There is one word space between them.

Your usage is like

X
{}
X

with two word spaces between them

and

X

X

would put them one above the other in separate paragraphs

David Carlisle
  • 757,742