[Tex/LaTex] Problem in putting figures in 2X2 using subfigure

floats

I used this code:

\begin{figure*}
    \centering
    \begin{subfigure}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.45\textwidth]{Figs/fig7.eps}
        \caption[Network2]%
        {{\small Network 1}}
        \label{fig:mean and std of net14}
    \end{subfigure}
    \hfill
    \begin{subfigure}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.45\textwidth]{Figs/fig8.eps}
        \caption[]%
        {{\small Network 2}}
        \label{fig:mean and std of net24}
    \end{subfigure}
    \vskip\baselineskip
    \begin{subfigure}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.45\textwidth]{Figs/fig9.eps}
        \caption[]%
        {{\small Network 3}}
        \label{fig:mean and std of net34}
    \end{subfigure}
    \quad
    \begin{subfigure}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.45\textwidth]{Figs/fig10.eps}
        \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*}

But I don't know why in the line

\includegraphics[width=0.45\textwidth]{Figs/fig7.eps}

and the other three similar lines for fig8, fig9 and fig10 I have the following error:

! Missing number, treated as zero

I do not know what's the problem.

Best Answer

I'm not sure about the problem you get; however, you should realize that inside subfigure, \textwidth refers to the size reserved for the whole subfigure, so you want width=\textwidth or the image will be further halved down.

Also don't use \small inside \caption, but better change the layout with \captionsetup.

Don't say \vskip\baselineskip, but \bigskip or \vspace{...} preceding it with a blank line.

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

\captionsetup{font=small}
\captionsetup[subfigure]{font=footnotesize}

\begin{document}
\begin{figure*}
\centering

\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/fig7.eps}
\caption{Network 1}
\label{fig:mean and std of net14}
\end{subfigure}%
%
\hfill
%
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/fig8.eps}
\caption{Network 2}
\label{fig:mean and std of net24}
\end{subfigure}

\bigskip 

\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/fig9.eps}
\caption{Network 3}
\label{fig:mean and std of net34}
\end{subfigure}%
%
\hfill
%
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/fig10.eps}
\caption{Network 4}
\label{fig:mean and std of net44}
\end{subfigure}

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

\end{document}

enter image description here

Related Question