如何将两个应该并排的(子)图形的迷你页面描述置于中心?

如何将两个应该并排的(子)图形的迷你页面描述置于中心?

我有以下代码

\begin{figure}[h]
\begin{subfigure}[h]{0.4\linewidth}
\includegraphics[width=\linewidth]{Plots/scatterpng.png}
\end{subfigure}
\hfill
\begin{subfigure}[h]{0.65\linewidth}
\includegraphics[width=\linewidth]{Plots/lollipng.png}
\end{subfigure}%
\caption{\textbf{Search trends for cyber insurance in the US and in Germany}}
  \label{fig:1}
    \begin{minipage}{0.87\textwidth}\footnotesize
\emph{Note:} This figure was created scraping data from Google search trends. In the USA, the term cyber insurance was used whereas in Germany, the term cyber versicherung was used. The vertical lines have been added to show the occurence of significant events during that time period.   
\end{minipage}  
\label{f:3}
\end{figure}

我想让两个图并排显示。我还想让小页面/描述整齐地排列在图的标题下方。

如果我保留上述代码,就不可能将小页面文本置于标题下方的中心。

在此处输入图片描述

如果我在代码中添加 \center,小页面的副标题就会完美地与标题对齐。但是,图片不是并排的,而是相互叠置的。

我不知道如何才能找到一个合适的解决方案。

任何帮助都将不胜感激

答案1

在此上下文中,\linewidth等于\textwidth。您将图像大小调整为0.4\linewidth0.65\linewidth,加起来等于1.05\linewidth1.05\textwidth——您的图像超出可用页面宽度 5%。除此之外,LaTeX 会在后面插入一个空格\end{subfigure}(参见此回答)。在这种情况下,第二个子图将移动到下一行。

至于描述,请\centering在您的描述之前添加。

解决这些数字的方法是 (1) 使用总和为1\textwidth或更小的宽度和 (2)%在第一行末尾添加\end{subfigure}%

下面的示例将两个图形以很小的间隙并排放置,并将描述居中。我还添加了\captionsetup更改标题周围的空格。

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


\begin{document}
\begin{figure}[h]
  \captionsetup{position=bottom, aboveskip=3pt,belowskip=3pt}
  \centering
  \begin{subfigure}[h]{0.39\linewidth}
    \includegraphics[width=\linewidth]{Plots/scatterpng.png}
  \end{subfigure}%   <--- keep % here
  \hfill
  \begin{subfigure}[h]{0.59\linewidth}
    \includegraphics[width=\linewidth]{Plots/lollipng.png}
  \end{subfigure}
  \caption{\textbf{Search trends for cyber insurance in the US and in Germany}}\label{fig:1}

  \begin{minipage}{0.87\textwidth}\footnotesize
    \emph{Note:} This figure was created scraping data from Google search trends. In the USA, the term cyber insurance was used whereas in Germany, the term cyber versicherung was used. The vertical lines have been added to show the occurence of significant events during that time period.   
  \end{minipage}  
  \label{f:3}
\end{figure}
\end{document}

在此处输入图片描述

相关内容