如何将子图重叠成多行

如何将子图重叠成多行

我正在尝试制作 3x2 图案的图形,右侧还有另一个图形与两行重叠。我能够在 beamer 中制作它,它看起来像这样:

投影仪数字

我使用了列环境,下面是代码:

\documentclass{beamer}
    \usetheme{Madrid}
    
    \begin{document}
    
    \begin{frame}{Results}
    \setbeamertemplate{caption}{\raggedright\insertcaption\par}
    
    \vspace{-1em}
    \begin{columns}
    \hspace{-2.5em}
    \begin{column}{0.5\textwidth}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=0).png}
            \vspace{-1.1em}
            \caption{time = 0}
        \end{figure}
        \vspace{-1em}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=15).png}
            \vspace{-1.1em}
            \caption{time = 15 mins}
        \end{figure}
    \end{column}
        \hspace{-2.5cm}
    \begin{column}{0.5\textwidth}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=5).png}
            \vspace{-1.1em}
            \caption{time = 5 mins}
        \end{figure}
        \vspace{-1em}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=20).png}
            \vspace{-1.1em}
            \caption{time = 20 mins}
        \end{figure}
    \end{column}
        \hspace{-2.5cm}
    \begin{column}{0.5\textwidth}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=10).png}
            \vspace{-1.1em}
            \caption{time = 10 mins}
        \end{figure}
        \vspace{-1em}
        \begin{figure}
            \centering
            \includegraphics[width=3.5cm]{Figures/u(t=25).png}
            \vspace{-1.1em}
            \caption{time = 25 mins}
        \end{figure}
    \end{column}
    \hspace{-3.5cm}
    \begin{column}{0.5\textwidth}
        \begin{figure}
            \centering
            \vspace{-1cm}
            \includegraphics[width=1.3cm, height=4.5cm]{Figures/colorbar.png}
        \end{figure}
    \end{column}
    \end{columns}
    
    \end{frame}
    
    \end{document}

我想在文章文档类中复制此内容。据我所知,文章类不支持使用列,因此我尝试使用子图来重现此内容。但是我无法让最右边的图形与两行重叠。它看起来像这样:

文章图

这是我的代码:

    \documentclass{article}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption}
    
    \begin{document}
    
    \begin{figure}
    \centering
        \begin{subfigure}{0.28\textwidth}
            \includegraphics[width=3.5cm]{Figures/u(t=0).png}
            \caption{time = 0}
            \label{fig:subfig1}
        \end{subfigure}
        \begin{subfigure}{0.28\textwidth}
            \includegraphics[width=3.5cm]{Figures/u(t=5).png}
            \caption{time = 5 minutes}
            \label{fig:subfig2}
        \end{subfigure}
        \begin{subfigure}{0.28\textwidth}
            \includegraphics[width=3.5cm]{Figures/u(t=10).png}
            \caption{time = 10 minutes}
            \label{fig:subfig3}
        \end{subfigure}
    \vfill
         \begin{subfigure}{0.28\textwidth}
             \includegraphics[width=3.5cm]{Figures/u(t=15).png}
             \caption{time = 15 minutes}
             \label{fig:subfig4}
        \end{subfigure}
        \begin{subfigure}{0.28\textwidth}
              \includegraphics[width=3.5cm]{Figures/u(t=20).png}
              \caption{time = 20 minutes}
              \label{fig:subfig5}
        \end{subfigure}
        \begin{subfigure}{0.28\textwidth}
            \includegraphics[width=3.5cm]{Figures/u(t=25).png}
            \caption{time = 25 minutes}
            \label{fig:subfig6}
        \end{subfigure}
        \begin{subfigure}{0.1\textwidth}
            \includegraphics[width=1cm]{Figures/colorbar.png}
        \end{subfigure}
    \caption{Heat diffusion over time}
    \label{fig:subfigures4}
    \end{figure}
    
    \end{document}

答案1

环境subfigure就是minipage在遇到语句时被告知要做什么的环境\caption。我建议你将前六个subfigure环境放在一个单独的minipage环境中,然后将最后一个环境放在subfigure旁边minipage

哦,不要为图表设置绝对宽度,如\includegraphics[width=3.5cm]{...}。相反,使用\includegraphics[width=\linewidth]{...},其中\linewidth是封闭环境的(相对)宽度subfigure

在此处输入图片描述

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx}
%\usepackage{caption} % caption is loaded automatically by subcaption
\usepackage{subcaption}
   
\begin{document}
   
\begin{figure}
   
   \begin{minipage}[c]{0.86\textwidth} % start an "outer" minipage
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=0).png}
        \caption{time = 0}
        \label{fig:subfig1}
      \end{subfigure}%
      \hspace{0.01\textwidth}%
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=5).png}
        \caption{time = 5 min}
        \label{fig:subfig2}
      \end{subfigure}%
      \hspace{0.01\textwidth}%
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=10).png}
        \caption{time = 10 min}
        \label{fig:subfig3}
      \end{subfigure}% leave a blank line to create a line break
   
      \medskip
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=15).png}
        \caption{time = 15 min}
        \label{fig:subfig4}
      \end{subfigure}%
      \hspace{0.01\textwidth}%
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=20).png}
        \caption{time = 20 min}
        \label{fig:subfig5}
      \end{subfigure}%
      \hspace{0.01\textwidth}%
      \begin{subfigure}{0.28\textwidth}
        \includegraphics[width=\linewidth]{Figures/u(t=25).png}
        \caption{time = 25 min}
        \label{fig:subfig6}
      \end{subfigure}%
      \end{minipage}%
      \hspace{0.01\textwidth}%
      \begin{minipage}[c]{0.13\textwidth}
        \includegraphics[width=\linewidth,
                         height=7cm] % set height as needed
                        {Figures/colorbar.png}
      \end{minipage}
      
\caption{Heat diffusion over time}
\label{fig:subfigures4}
   
\end{figure}
   
\end{document}

答案2

不错的 @Mico 答案的一个小变化(+1)。如果您安装了subcaption软件包版本 3.1 或更新版本,那么您可以使用sublot(如subfig软件包中定义)和\setkeys{Gin}{...}宏,两者都有助于缩短代码:

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx}
\usepackage{subcaption} % version 3.1 or newer

\begin{document}
    \begin{figure}
\begin{minipage}{0.86\textwidth} % start an "outer" minipage
\setkeys{Gin}{width=0.33\linewidth}
%
\subfloat[time = 0 min \label{fig:subfig1}]{\includegraphics{Figures/u(t=0).png}}%
\hfill
\subfloat[time = 5min  \label{fig:subfig2}]{\includegraphics{Figures/u(t=5).png}}%
\hfill
\subfloat[time = 10min \label{fig:subfig3}]{\includegraphics{Figures/u(t=10).png}}%

\medskip
 \subfloat[time = 15 min \label{fig:subfig4}]{\includegraphics{Figures/u(t=15).png}}%
\hfill
\subfloat[time = 20min  \label{fig:subfig5}]{\includegraphics{Figures/u(t=20).png}}%
\hfill
\subfloat[time = 25min \label{fig:subfig6}]{\includegraphics{Figures/u(t=25).png}}
\end{minipage}%
\hfill
\begin{minipage}{0.12\textwidth}
\includegraphics[width=\linewidth, height=7cm]{Figures/colorbar.png}
\end{minipage}

\caption{Heat diffusion over time}
\label{fig:subfigures4}
    \end{figure}
\end{document}

在此处输入图片描述

相关内容