2

My code produces a figure which looks like this: enter image description here

How can I make it look like this:

enter image description here

(which I have produced using paint.)

The code

\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
    \centering
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{1}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{2}
        \label{}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{3}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{4}
        \label{}
    \end{subfigure}
        \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{5}
        \label{}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{6}
        \label{}
    \end{subfigure}
        \begin{subfigure}[b]{0.05\textwidth}
        \includegraphics[height=0.35\textheight]{./dct_for_publication_no_legend/legend}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{7}
        \label{}
    \end{subfigure}
    \begin{subfigure}[b]{0.45\textwidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{8}
        \label{}
    \end{subfigure}
    \caption{Pictures}\label{}
\end{figure}
\end{document}
1

You can set the subfigures in a minipage

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\usepackage{showframe} % just for the example

\begin{document}

\begin{figure}[p]
\begin{minipage}{0.9\textwidth}
\centering
\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{1}\label{1}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{2}\label{2}
\end{subfigure}\hspace*{\fill}

\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{3}\label{3}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{4}\label{4}
\end{subfigure}\hspace*{\fill}

\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{5}\label{5}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{6}\label{6}
\end{subfigure}\hspace*{\fill}

\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{7}\label{7}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
  \includegraphics[width=\textwidth]{example-image}
  \caption{8}\label{8}
\end{subfigure}\hspace*{\fill}
\end{minipage}% <--- don't forget
\begin{minipage}{0.1\textwidth}
\includegraphics[width=\textwidth,height=8cm]{example-image}
\end{minipage}

\caption{Global caption}\label{global}

\end{figure}
\end{document}

The showframe package is just for showing the placement with respect to the text block.

enter image description here

2

I tried to maintain the sizes of the images, but change the spacing. Note that the minipage changes the value of \textwidth, hence the use of \mywidth.

Since the actual images have a lot of white space at the top, the subcaptions should be positioned appropriately.

Note that the legend is centered relative to the images AND their captions. That can be fixed, but you need to measure the height of the images sans captions.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% dubugging tool
\newlength{\mywidth}
\begin{document}
\begin{figure}
    \mywidth=0.45\textwidth
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{1}
    \end{subfigure}\hfil
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{2}
        %\label{}
    \end{subfigure}

  \begin{minipage}[c]{.925\textwidth}
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{3}
    \end{subfigure}\hfill
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{4}
        %\label{}
    \end{subfigure}

    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{5}
        %\label{}
    \end{subfigure}\hfill
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{6}
        %\label{}
    \end{subfigure}
  \end{minipage}\hfill
  \raisebox{-0.5\height}{\includegraphics[height=0.35\textheight,width=0.05\textwidth]{./dct_for_publication_no_legend/legend}}

    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{7}
        %\label{}
    \end{subfigure}\hfil
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{8}
        %\label{}
    \end{subfigure}

  \caption{Pictures}\label{}
\end{figure}
\end{document}

demo


This version computes the widths to place a \columnsep gap between the images and use the natural width of the legend. Of course, it looks awful in demo mode.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% dubugging tool
\newlength{\mywidth}
\begin{document}
\begin{figure}
  \sbox0{\includegraphics[height=0.35\textheight]{./dct_for_publication_no_legend/legend}}%
  \setlength{\mywidth}{\dimexpr 0.5\textwidth-\columnsep-0.5\wd0}%
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{1}
    \end{subfigure}\hfil
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{2}
        %\label{}
    \end{subfigure}

  \begin{minipage}[c]{\dimexpr \textwidth-\columnsep-\wd0}
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{3}
    \end{subfigure}\hfill
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{4}
        %\label{}
    \end{subfigure}

    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{5}
        %\label{}
    \end{subfigure}\hfill
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{6}
        %\label{}
    \end{subfigure}
  \end{minipage}\hfill
  \raisebox{-0.5\ht0}{\usebox0}

    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{7}
        %\label{}
    \end{subfigure}\hfil
    \begin{subfigure}[b]{\mywidth}
        \includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
        \caption{8}
        %\label{}
    \end{subfigure}

  \caption{Pictures}\label{}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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