37

I try to put figures in 2X2, but they appear in 4 rows.

\begin{figure*}
\begin{minipage}{\textwidth}
\centering
\begin{subfigure}[b]{1\textwidth}
\centering
    \includegraphics[scale=0.3]{images/mean/N14.png}
    \caption[Network2]%
    {{\small Network 1}}    
\label{fig:mean and std of net14}
\end{subfigure}
\quad
 \begin{subfigure}[b]{1\textwidth}  
 \centering 
        \includegraphics[scale=0.29]{images/mean/N24.png}
        \caption[]%
        {{\small Network 2}}    
        \label{fig:mean and std of net24}
        \end{subfigure}

    \begin{subfigure}[b]{1\textwidth}   
 \centering 
        \includegraphics[scale=0.29]{images/mean/N34.png}
        \caption[]%
        {{\small Network 3}}    
        \label{fig:mean and std of net34}
        \end{subfigure}
        \quad
        \begin{subfigure}[b]{1\textwidth}   
 \centering 
        \includegraphics[scale=0.29]{images/mean/N44.png}
        \caption[]%
        {{\small Network 4}}    
        \label{fig:mean and std of net44}
        \end{subfigure}


        \caption[ The average and standard deviation of critical parameters ]
        {\small The average and standard deviation of critical parameters: Region R4} 
        \label{fig:mean and std of nets}
        \end{minipage}
\end{figure*}

Any suggestion please?

3 Answers 3

67

Each of your \subfigures is 1\textwidth wide - there's no way LaTeX could fit two of these in a row. Also you don't need the minipage there.

Try something like this:

\documentclass{article}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{mwe}

\begin{document}
    \begin{figure*}
        \centering
        \begin{subfigure}[b]{0.475\textwidth}
            \centering
            \includegraphics[width=\textwidth]{Example-Image}
            \caption[Network2]%
            {{\small Network 1}}    
            \label{fig:mean and std of net14}
        \end{subfigure}
        \hfill
        \begin{subfigure}[b]{0.475\textwidth}  
            \centering 
            \includegraphics[width=\textwidth]{Example-Image}
            \caption[]%
            {{\small Network 2}}    
            \label{fig:mean and std of net24}
        \end{subfigure}
        \vskip\baselineskip
        \begin{subfigure}[b]{0.475\textwidth}   
            \centering 
            \includegraphics[width=\textwidth]{Example-Image}
            \caption[]%
            {{\small Network 3}}    
            \label{fig:mean and std of net34}
        \end{subfigure}
        \hfill
        \begin{subfigure}[b]{0.475\textwidth}   
            \centering 
            \includegraphics[width=\textwidth]{Example-Image}
            \caption[]%
            {{\small Network 4}}    
            \label{fig:mean and std of net44}
        \end{subfigure}
        \caption[ The average and standard deviation of critical parameters ]
        {\small The average and standard deviation of critical parameters: Region R4} 
        \label{fig:mean and std of nets}
    \end{figure*}
\end{document}

2x2 output

Of course you would drop the \usepackage{mwe} and substitute your pictures back in at appropriate scaling.

8
  • Thanks, but when I am using these two packages mwe, and subcaption, I get this error: ! LaTeX Error: Can be used only in preamble.Any idea please?
    – Rebecca
    Commented Aug 15, 2014 at 9:11
  • @Maryam did you try running the exact code from my example? That compiles fine for me on a clean TeXLive 2014. Otherwise do make sure all \usepackage are before \begin{document}.
    – greyshade
    Commented Aug 15, 2014 at 9:14
  • @Maryam the mwe package was only to get the sample images..
    – greyshade
    Commented Aug 15, 2014 at 9:18
  • 1
    Turns out that the \hfill is important. Commented Jan 16, 2018 at 0:38
  • 2
    I had to change the \quad after the third subfigure to \hfill, otherwise the lower left figure wouldn't be aligned, but offset to the left.
    – Adriaan
    Commented Jul 6, 2020 at 13:19
1

This also worked for me:

\begin{figure}
\begin{adjustwidth}{-8em}{0em}
  \begin{subfigure}[b]{0.7\textwidth}
    \includegraphics[width=\textwidth]{images/.png}
    \caption{}
    \label{fig:}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.7\textwidth}
    \includegraphics[width=\textwidth]{images/.png}
    \caption{}
    \label{fig:}
  \end{subfigure}
\end{adjustwidth}
\begin{adjustwidth}{-8em}{0em}
  \begin{subfigure}[b]{0.7\textwidth}
    \includegraphics[width=\textwidth]{images/.png}
    \caption{}
    \label{fig:}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.7\textwidth}
    \includegraphics[width=\textwidth]{images/.png}
    \caption{}
    \label{fig:}
  \end{subfigure}
\end{adjustwidth}
\end{figure}
1

your solution was very helpful.

note that it only works with \usepackage{changepage}.

I think you should include it in your answer.

Thanks again, Nadav A

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .