为什么我想将子图并排放置,但它们却是堆叠在一起的?

为什么我想将子图并排放置,但它们却是堆叠在一起的?

我想要两张并排的图像,目前正在使用以下代码:

\begin{figure}[!h]
\centering
\begin{subfigure}[t]{.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{./0_intro/img/cost_breakdown.png}
    \caption{}
    \label{fig:cost_breakdown} 
\end{subfigure}
\begin{subfigure}[t]{.45\textwidth}
   \centering
   \includegraphics[width=\textwidth]{./0_intro/img/cost_breakdown_forecast.png}
   \caption{}
   \label{fig:cost_breakdown_forecast}
\end{subfigure}
\caption{\emph{Source: DOE SSL Roundtable and Workshop attendees}}
\label{fig:costs_BD_FC}
\end{figure}

图像按组进行放置。

我尝试改变图像的宽度,但没有效果。

有什么想法吗?谢谢!

答案1

副标题

\documentclass{article}
\usepackage{subcaption,mwe}
\begin{document}
\begin{figure}[!h]
\centering
\begin{subfigure}[t]{.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-a}
    \caption{}
    \label{fig:cost_breakdown} 
\end{subfigure}
\begin{subfigure}[t]{.45\textwidth}
   \centering
   \includegraphics[width=.45\textwidth]{example-image-b}
   \includegraphics[width=.45\textwidth]{example-image-a}
   \caption{}
   \label{fig:cost_breakdown_forecast}
\end{subfigure}
\caption{\emph{Source: DOE SSL Roundtable and Workshop attendees}}
\label{fig:costs_BD_FC}
\end{figure}

\begin{figure}[!h]
\centering
\begin{subfigure}[t]{.45\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-a}
    \caption{}
    \label{fig:cost_breakdown} 
\end{subfigure}
\begin{subfigure}[t]{.45\textwidth}
   \centering
   \includegraphics[width=\textwidth]{example-image-b}
   \caption{}
   \label{fig:cost_breakdown_forecast}
\end{subfigure}
\caption{\emph{Source: DOE SSL Roundtable and Workshop attendees}}
\label{fig:costs_BD_FC}
\end{figure}
\end{document}

在此处输入图片描述

相关内容