在图中添加多级标题

在图中添加多级标题

我正在使用 overleaf,我需要像这样放置图像标题(下图中用红笔和蓝笔突出显示)每张图片单独放置标题,然后两张图片放置一个标题。代码如下,此代码仅为两个单独的图像放置标题在此处输入图片描述

    \documentclass{IEEEtran}
    \usepackage{graphicx}
    \usepackage{afterpage}
    \usepackage{multicol}
    \usepackage{lipsum}
    
    \usepackage{subcaption}
    
    \newsavebox{\shortpagebox}
    \newsavebox{\shortpagefigure}
    \begin{document}
      \begin{figure*}
        \centering
        \setkeys{Gin}{width=0.48\linewidth} % <---
    \begin{minipage}{0.48\linewidth}
    \includegraphics{example-image}\hfil
    \includegraphics{example-image}
    
    \caption{fffffffffffffffffffffffffffffffff}
    \label{fig:first}
    \end{minipage}
    \hfill
    \begin{minipage}{0.48\linewidth}
    \includegraphics{example-image}\hfil
    \includegraphics{example-image} 
    
    \caption{fffffffffffffffffffffffffffffffff}
    \label{fig:second}
    \end{minipage}
    
    \bigskip
    \begin{minipage}{0.48\linewidth}
    \includegraphics{example-image}\hfil
    \includegraphics{example-image}
    
    \caption{fffffffffffffffffffffffffffffffff}
    \label{fig:third}
    \end{minipage}
    \hfill
    \begin{minipage}{0.48\linewidth}
    \includegraphics{example-image}\hfil
    \includegraphics{example-image}
    
    \caption{fffffffffffffffffffffffffffffffff}
    \label{fig:fourth}
    \end{minipage}
        \end{figure*}
\end{document}

答案1

由于您加载了subcaption包,您可以使用它的subfigure环境机制 -subfigure基本上是一个minipage环境,它被告知如果在其范围内遇到指令该做什么\caption- 来实现您的格式化目标。

两条评论:

  • 您会收到一些警告消息,因为captionsubcaption包不完全了解IEEEtran文档类可以做什么和不能做什么。您可以忽略这些警告消息。

  • 这里提出的方法的输出与Zarko 的回答,这并不奇怪,因为两个答案都使用了该subcaption包。方法中可能有意义的差异可能是使用subfigure环境而不是\subfloat宏在图形的垂直定位方面提供了更多的灵活性。

在此处输入图片描述

\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage[skip=0.33\baselineskip]{subcaption}
\begin{document}
\setcounter{figure}{7} % just for this example

\begin{figure*}
\begin{minipage}[t]{\columnwidth}% 1st minipage
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{CNN with \dots}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{LTSM with \dots}
\end{subfigure}
\caption{The distribution of score}
\label{fig:first}
\end{minipage}%
\hfill
\begin{minipage}[t]{\columnwidth}% 2nd minipage
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{Rounds vs.\ accuracy}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image} 
    \caption{Payment $p$ and score with $N$}
\end{subfigure}
\caption{Training speed and payment with parameter $N$}
\label{fig:second}
\end{minipage}
    
\bigskip\medskip
\begin{minipage}[t]{\columnwidth}% 3rd minipage
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{Rounds vs.\ accuracy}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{Payment $p$ and score with $K$}
\end{subfigure}
\caption{Training speed and payment with parameter $K$}
\label{fig:third}
\end{minipage}%
\hfill
\begin{minipage}[t]{\columnwidth}% 4th minipage
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{Training speed with $p$}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
    \includegraphics[width=\linewidth]{example-image} 
    \caption{Proportion of selected node}
\end{subfigure}
\caption{Performance impact of parameter $\psi$}
\label{fig:fourth}
\end{minipage}
\end{figure*}

\end{document}

答案2

每个图像插入在\subfloat环境中(也在包中定义subcaption。答案假设图中的所有图像都有相同的,因此可以通过键Gin为图中的所有图像定义。

\documentclass{IEEEtran}
\usepackage{graphicx}

\usepackage{subcaption}

\begin{document}
      \begin{figure*}
        \centering
        \setkeys{Gin}{width=0.48\linewidth} % <---
\begin{minipage}{0.48\linewidth}
\subfloat[CNN with CIFAR-10]{\includegraphics{example-image}}\hfill
\subfloat[LSTM with HPNews]{ \includegraphics{example-image}}

    \caption{The distribution of score}
    \label{fig:first}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
\subfloat[caption 2a]{\includegraphics{example-image}}\hfill
\subfloat[caption 2b]{\includegraphics{example-image}}

    \caption{fffffffffffffffffffffffffffffffff}
\label{fig:second}
\end{minipage}

    \bigskip
\begin{minipage}{0.48\linewidth}
\subfloat[caption 3a]{\includegraphics{example-image}}\hfill
\subfloat[caption 3b]{\includegraphics{example-image}}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:third}
\end{minipage}
    \hfill
\begin{minipage}{0.48\linewidth}
\subfloat[caption 4a]{\includegraphics{example-image}}\hfill
\subfloat[caption 4b]{\includegraphics{example-image}}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:fourth}
\end{minipage}
    \end{figure*}
\end{document}

在此处输入图片描述

相关内容