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 would like to place two figures, where each figure has subfigures next to each other. I tried with minipage, but tex does not like the \subfigure as Not in outer par mode. Is there any way to place figures with subfigures next to each other?

\begin{figure*}[htbp]


\begin{minipage}[hbt]{0,49\textwidth}

\begin{figure}
\subfigure[Subfigure 1.1]{
\label{fig:subfig1_1}
\includegraphics[scale=0.42]{graphs/sub_1_1.pdf}
}

\subfigure[Sub 1.2] {
\label{fig:subfig1_2}
\includegraphics[scale=0.42]{graphs/sub_1_2.pdf}
}
}
\label{fig:subfigure1} 
\caption{Subfigure 1}
\end{figure}
\end{minipage}




\begin{minipage}[hbt]{0,49\textwidth}
%... as above
\end{minipage}
\end{figure*}
share|improve this question
    
Welcome to TeX.sx! Please change your code snippet to a minimal working example (MWE) that shows your document class and relevant packages. –  lockstep Oct 23 '12 at 10:11
    
Relevant: tex.stackexchange.com/questions/76153/… –  Bart Arondson Oct 23 '12 at 22:50

2 Answers 2

You can't put a floating object inside a minipage, but you can place minipages inside a floating object. I notice that you are using the obsolete subfigure package; you should use subfig or subcaption instead.

Below there are two approaches; the first one using the subfig package, and the other one using the subcaption package:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subfig} % Needs subfig for this example.

\begin{document}

\begin{figure}
\begin{minipage}{.48\textwidth}
\centering
\subfloat[]{\includegraphics[width=.4\linewidth]{fig1}}\quad
\subfloat[]{\includegraphics[width=.4\linewidth]{fig2}}
\caption{First figure with two subfigures}
\label{fig:testa}
\end{minipage}\hfill
\begin{minipage}{.48\textwidth}
\centering
\subfloat[]{\includegraphics[width=.4\linewidth]{fig3}}\quad
\subfloat[]{\includegraphics[width=.4\linewidth]{fig4}}
\caption{Second figure with two subfigures}
\label{fig:testb}
\end{minipage}
\end{figure}

\end{document} 

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{minipage}{.48\textwidth}
\centering
\subcaptionbox{}{\includegraphics[width=.4\linewidth]{fig1}}\quad
\subcaptionbox{}{\includegraphics[width=.4\linewidth]{fig2}}
\caption{First figure with two subfigures}
\label{fig:testa}
\end{minipage}\hfill
\begin{minipage}{.48\textwidth}
\centering
\subcaptionbox{}{\includegraphics[width=.4\linewidth]{fig3}}\quad
\subcaptionbox{}{\includegraphics[width=.4\linewidth]{fig4}}
\caption{Second figure with two subfigures}
\label{fig:testb}
\end{minipage}
\end{figure}

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

share|improve this answer
    
+1 what is the pros and cons betweem both approaches? –  Oh my ghost Oct 23 '12 at 16:49
1  
@ガベージコレクタ this question and its answers give a good comparison. –  Gonzalo Medina Oct 23 '12 at 17:43
    
@Speravir yes it was a typo. I had subcaption in both examples (the problems of copy-paste). –  Gonzalo Medina May 6 '13 at 22:39

Since figure is a floating object and minipages are not, you can't use figures inside minipages. One method is to avoid using figure and use the captionof from caption/subcation (or capt-of) package.

Code:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}


\begin{document}
\noindent
\begin{minipage}[t]{0.49\linewidth}%
\begin{minipage}[t]{0.49\textwidth}%
\includegraphics[width=\textwidth]{example-image-a}%
\captionof{subfigure}{sub figure - 1}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.49\textwidth}%
\includegraphics[width=\linewidth]{example-image-b}
\captionof{subfigure}{sub figure - 2} 
\end{minipage}
\captionof{figure}{figure one}
\end{minipage}%
\setcounter{subfigure}{0}
\hfill
\begin{minipage}[t]{0.49\linewidth}%
\begin{minipage}[t]{0.49\textwidth}%
\includegraphics[width=\textwidth]{example-image-c}%
\captionof{subfigure}{sub figure - 1}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.49\textwidth}%
\includegraphics[width=\linewidth]{example-image}
\captionof{subfigure}{sub figure - 2}
\end{minipage}
\captionof{figure}{figure two}
\end{minipage}%


\end{document} 

enter image description here

share|improve this answer
    
It's not appropriate to use hbt in the optional argument of minipage (you can use t, b, or c). –  Gonzalo Medina Oct 23 '12 at 16:35
    
@GonzaloMedina My bad. I copied it as such from the OP's code and overlooked. Thanks for noting. –  Harish Kumar Oct 23 '12 at 21:40

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.