7

I have 6 images, and I want to align them in this way

(a)image1 (c)image3 (e)image5

(b)image2 (d)image4 (f)image6

Any one know how to do that? The problem for me is how to make (a), (b),..., (f) in vertical direction.

  • 1
    Welcome to TeX.SE! Please edit your posting to provide (lots more) information about the document class you use, the width and height of the text block of your document, and any LaTeX packages you may be using that affect the appearance of figures and subfigures. – Mico Jun 20 '13 at 14:54

2 Answers2

6

If I understand your requirements correctly, you could achieve your objective by using three separate subfigure environments in the main figure environment, with each containing two vertically stacked graphs and associated captions (and, if needed, labels for cross-referencing purposes). If you want to use the example code below, be sure to (a) leave off the 'demo' option of the graphicx package and (b) specify real file names for the actual graphics rather than figa, figb, etc.

enter image description here

\documentclass{article}
\usepackage{subcaption} % provides 'subfigure' environment
\usepackage[margin=1in]{geometry} % set margins as required
\usepackage[demo]{graphicx} % omit 'demo' option in real doc
\begin{document}
\begin{figure}
\begin{subfigure}{0.3\textwidth}
  \includegraphics{figa}
  \caption{First subfigure} \label{fig:1a}
  \par\medskip % if more vertical separation needed, use \bigskip
  \includegraphics{figb}
  \caption{Second subfigure} \label{fig:1b}
\end{subfigure}
\hspace*{\fill}
\begin{subfigure}{0.3\textwidth}
  \includegraphics{figc}
  \caption{Third subfigure} \label{fig:1c}
  \par\medskip % if more vertical separation needed, use \bigskip
  \includegraphics{figd}
  \caption{Fourth subfigure} \label{fig:1d}
\end{subfigure}
\hspace*{\fill}
\begin{subfigure}{0.3\textwidth}
  \includegraphics{fige}
  \caption{Fifth subfigure} \label{fig:1e}
  \par\medskip % if more vertical separation needed, use \bigskip
  \includegraphics{figf}
  \caption{Sixth subfigure} \label{fig:1f}
\end{subfigure}
\caption{This is a figure with six subfigures}\label{fig:1}
\end{figure}
\end{document}
Mico
  • 506,678
  • Ah, perhaps I misunderstood the question? With the description given I assumed labels should appear to the left of the images, but now that I see you're answer perhaps this wasn't required. – Gonzalo Medina Jun 20 '13 at 15:32
  • @GonzaloMedina - I wasn't sure either how exactly to interpret the OP's requirements; that's why I prefaced my answer with a "If I understand ..." disclaimer. :-) – Mico Jun 20 '13 at 15:41
  • The answer is good. It is easy to put the labels to the left of the image. – user32558 Jun 20 '13 at 16:54
  • 3
    Since the subfigure environment is in fact a minipage extra minipage environments are IMHO not needed. Just put two images + captions within one subfigure environment should be sufficient. –  Jun 20 '13 at 18:08
  • @AxelSommerfeldt - Many thanks for this excellent suggestion; I've modified the code to incorporate it. – Mico Jun 20 '13 at 18:53
  • 1
    One of those rare occasions that I had a not so very straightforward Latex question and got an answer that worked easily and smoothly! Thanks a lot @Mico! – Vahid S. Bokharaie Jan 04 '21 at 19:18
  • @CrossEntropy - Many thanks for the compliment! Good to know that this answer is still useful, eeven though it's more than seven years old by now. :-) The lack of built-in obsolescence in TeX and LaTeX is one of the main reasons I never regret having taken the time to learn LaTeX. – Mico Jan 05 '21 at 17:39
4

One option is to manually control the counter:

\documentclass{article}
\usepackage{graphicx}
\usepackage{floatrow}
\usepackage{subfig}

\floatsetup[figure]{style=plain,subcapbesideposition=top}

\begin{document}

\begin{figure}
\ffigbox
{\begin{subfloatrow}[3]
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-a}\label{sfig:i-i}}%
\setcounter{subfigure}{2}%
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-b}\label{sfig:i-ii}}%
\setcounter{subfigure}{4}%
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-c}\label{sfig:i-iii}}%
\end{subfloatrow}\par\bigskip
\begin{subfloatrow}[3]
\setcounter{subfigure}{1}%
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-a}\label{sfig:ii-i}}%
\setcounter{subfigure}{3}%
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-b}\label{sfig:ii-ii}}%
\setcounter{subfigure}{5}%
\sidesubfloat[]{\includegraphics[width=3cm]{example-image-c}\label{sfig:ii-iii}}%
\end{subfloatrow}}
{\setcounter{figure}{1}\caption{A figure with subfigures}\label{fig:test}}
\end{figure}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128