使用子图并创建两行图形?

使用子图并创建两行图形?

我正在尝试使用子图获取两行,每行有两个数字,但是我一直收到错误。

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx,subcaption}
\begin{document}
\begin{figure}

\begin{subfigure}[0.45\textwidth]
    \includegraphics[width=\textwidth]{long_pneumonic.jpg}
    \caption{Pre-vaccination susceptible and infected 
    population$\alpha=0.000015, \beta=0.0027, \delta=.002, \sigma=1/3, 
    \Delta=3/4, r=1/5$.}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic2.jpg}
    \caption{Transient loops of the infected and susceptible population 
    changes.}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic3.jpg}
    \caption{The population of susceptible individuals and infected 
    individuals over a period of 1500 days post-vaccination.
    $\alpha=0.000015, \beta=0.0027, \delta=.002, \sigma=1/3, \Delta=3/4, 
    r=1/5$.}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic4.jpg}
    \caption{[A graph showing the rise and decrease of pneumonic plague 
    victims leading to increasing amounts of infected with each recurrence 
    post-vaccination.}
\end{subfigure}
\caption{Graphs comparing and contrasting the same parameters examining the 
dynamics of the susceptible and infected populations pre and post 
vaccinations.}
\end{figure}
\end{document}

答案1

你写了,

我一直收到错误

你没有提到哪些错误你得到了,但我只能假设它们是由线引起的

\begin{subfigure}[0.45\textwidth]

在第一个环境的开始处subfigure。将此行更改为

\begin{subfigure}{0.45\textwidth}

即用花括号替换方括号,立即的问题就解决了。(请注意,其他三个\begin{subfigure}{0.45\textwidth}指令已经正确。)顺便说一句,我假设您的文档加载了包subcaption不是过时且弃用的subfigure软件包。

除了修复语法错误之外,您可能还想“美化”图形的外观。例如,增加子图之间的水平间距,增加两行子图之间的空间,并将四个子图的标题从完全对齐切换为居中。

在此处输入图片描述

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx,subcaption,ragged2e}
\begin{document}

\begin{figure}
\captionsetup[subfigure]{justification=Centering}

\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\textwidth]{long_pneumonic.jpg}
    \caption{Pre-vaccination susceptible and infected population. $\alpha=0.000015$, $\beta=0.0027$, $\delta= 0.002$, $\sigma=1/3$, $\Delta=3/4$, $r=1/5$.}
\end{subfigure}\hspace{\fill} % maximize horizontal separation
\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic2.jpg}
    \caption{Transient loops of the infected and susceptible population changes.}
\end{subfigure}

\bigskip % more vertical separation
\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic3.jpg}
    \caption{The population of susceptible individuals and infected individuals over a period of 1500 days post-vaccination.
    $\alpha=0.000015$, $\beta=0.0027$, $\delta=0.002$, $\sigma=1/3$, $\Delta=3/4$, 
    $r=1/5$.}
\end{subfigure}\hspace{\fill} % maximize horizontal separation
\begin{subfigure}[t]{0.45\textwidth}
    \includegraphics[width=\linewidth]{long_pneumonic4.jpg}
    \caption{A graph showing the rise and decrease of pneumonic plague victims leading to increasing amounts of infected with each recurrence post-vaccination.}
\end{subfigure}

\caption{Graphs comparing and contrasting the same parameters examining the  dynamics of the susceptible and infected populations pre and post  vaccinations.}

\end{figure}
\end{document}

相关内容