Graphics, Figures & Tables2*2 subfigure - how to?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
jiapei100
Posts: 28
Joined: Sat Jan 12, 2008 7:23 pm

2*2 subfigure - how to?

Post by jiapei100 »

Hi, all:

I'm trying to arrange 8 figures into 2 subfigures, each of size 2*2.
Namely, I would like to arrange two groups of figures with only 2 captions,
each group has 4 figures. But, to arrange 4 figures in a row will be out of the range. And I've got to arrange 4 figures in the form of 2*2.

So the question could be, how to "change lines" in a subfigure??
Adding "\\" at the end of the 2nd figure doesn't help at all.
My current code for one group of images is like:

Code: Select all

\subfigure[caption 1]{
\mbox{\includegraphics[scale=0.8]{./figures/subfigure1}}
\mbox{\includegraphics[scale=0.8]{./figures/subfigure2}}
\mbox{\includegraphics[scale=0.8]{./figures/subfigure3}}
\mbox{\includegraphics[scale=0.8]{./figures/subfigure4}}
}
Please can anybody help?

Cheers
JIA

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

2*2 subfigure - how to?

Post by gmedina »

Hi,

the following example shows how to proceed using the subfig package:

Code: Select all

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}

\begin{document}

\begin{figure}[!ht]
  \centering
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure1}}\quad
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure2}}\\
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure3}}\quad
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure4}}
  \caption{First group of subfigures.}
  \label{fig:sub1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure5}}\quad
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure6}}\\
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure7}}\quad
  \subfloat[][]{\includegraphics[width=.4\textwidth]{figure8}}
  \caption{Second group of subfigures.}
  \label{fig:sub2}
\end{figure}

\end{document}
Note that I used the demo package option for graphicx to render my example compilable for everyone; do not include that option in your actual code. Of course, use the options for the figures according to your needs.

Another approach could be to use the subcaption package.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
jiapei100
Posts: 28
Joined: Sat Jan 12, 2008 7:23 pm

2*2 subfigure - how to?

Post by jiapei100 »

Thank you very much for your prompt reply.

1) What is the relationship between these two packages subfigure and subfig?
Are they compatible? I mean, can I use both packages at the same time?
like:

Code: Select all

\usepackage{subfigure}
\usepackage{subfig}
2) It looks you created two figures, rather than two subfigures embedded in a single figure.
What I need is something like

Code: Select all

figure
subfigure1
\includegraphics11
\includegraphics12 \\ change line here
\includegraphics13
\includegraphics14
subfigure2
\includegraphics21
\includegraphics22 \\ change line here
\includegraphics23
\includegraphics24
Can you please help to just use subfigure package to realize the above required figures?

Thank you ...
Best Regards
JIA
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

2*2 subfigure - how to?

Post by gmedina »

jiapei100 wrote:Thank you very much for your prompt reply...
You're welcome.
jiapei100 wrote:...What is the relationship between these two packages subfigure and subfig?...
subfigure is an obsolete package and it shouldn't be used anymore.
jiapei100 wrote:...What I need is something like...
The quickest solution then is to use the subcaption package that I suggested before:

Code: Select all

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

\begin{document}

\begin{figure}[!ht]
  \begin{minipage}{\textwidth}
    \centering
    \includegraphics[width=.4\textwidth]{figure1}\quad
    \includegraphics[width=.4\textwidth]{figure2}\\
    \includegraphics[width=.4\textwidth]{figure3}\quad
    \includegraphics[width=.4\textwidth]{figure4}
    \subcaption{First subfigure.}
    \label{fig:sub1}
  \end{minipage}\\[1em]
  \begin{minipage}{\textwidth}
    \centering
    \includegraphics[width=.4\textwidth]{figure5}\quad
    \includegraphics[width=.4\textwidth]{figure6}\\
    \includegraphics[width=.4\textwidth]{figure7}\quad
    \includegraphics[width=.4\textwidth]{figure8}
    \subcaption{Second subfigure.}
    \label{fig:sub2}
  \end{minipage}
\end{figure}

\end{document}
jiapei100 wrote:...Can you please help to just use subfigure package to realize the above required figures?...
I guess I could, but I won't; as I explained before, the subfigure package shouldn't be used anymore.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

2*2 subfigure - how to?

Post by localghost »

Perhaps I missed something. But didn't you ask similar questions before [1,2]? If the answers have not been satisfying, you could have posted your queries there. Nevertheless these topics are still awaiting your feedback.

[1] View topic: Group 12 subfigures in 2 groups, 2 captions....
[2] View topic: Align subfigures by columns...


Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply