使用子图将图形放入 2X2 中时出现问题

使用子图将图形放入 2X2 中时出现问题

我用了这个代码:

\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*}

但我不知道为什么

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

并且对于 fig8、fig9 和 fig10 的其他三行我出现了以下错误:

! Missing number, treated as zero

我不知道问题出在哪里。

答案1

我不确定你遇到了什么问题;但是,你应该意识到里面的subfigure\textwidth指的是保留给整个子图的大小,所以你想要width=\textwidth或者图像会进一步减半。

也不要使用\small里面\caption,但最好用改变布局\captionsetup

不要说\vskip\baselineskip,而是\bigskip\vspace{...}在它前面加上一个空行。

\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}

在此处输入图片描述

答案2

我不熟悉subfigure您的 MWE,因此我建议另一种安排方式subfigures。在这种情况下,我宁愿使用subfig包:

documentclass{article}
    \usepackage{graphicx}
    \usepackage[labelsep=space,
                labelfont={sf,bf},
                textfont=sf]{subfig}
    \usepackage[labelsep=colon,
                labelfont={sf,bf},
                textfont=sf]{caption}
%---------------------------------------------------------------%
\usepackage[active,floats,tightpage]{preview}% just for generating 
                                             % provided image
\setlength\PreviewBorder{1em}
%---------------------------------------------------------------%
\begin{document}
    \begin{figure*}\centering
\subfloat[Network 1 \label{fig:mean and std of net14}]
        {\includegraphics[width=0.45\textwidth]{example-image}}
    \hfill
\subfloat[Network 2 \label{fig:mean and std of net24}]
         {\includegraphics[width=0.45\textwidth]{example-image}}

\subfloat[Network 2 \label{fig:mean and std of net34}]
         {\includegraphics[width=0.45\textwidth]{example-image}}
    \hfill
\subfloat[Network 1 \label{fig:mean and std of ne44}]
        {\includegraphics[width=0.45\textwidth]{example-image}}
\caption[The average and standard deviation of critical parameters]
        {The average and standard deviation of critical parameters: Region R4}
    \label{fig:mean and std of nets}
    \end{figure*}
\end{document} 

在此处输入图片描述

相关内容