我的数字无法并排放置

我的数字无法并排放置

我有此代码将六幅图像分成两行(每行 3 幅图像):

\begin{figure}[htbp!]   
 \centering
 \begin{subfigure}[b]{0.3 \textwidth}

     \includegraphics[width=\textwidth]{1agw-eva.png}
     \caption{Cec\_2021\_ Function 1}
 \end{subfigure} \hfill
 
 \begin{subfigure}[b]{0.3\textwidth}
     \includegraphics[width=\textwidth]{2agw-eva.png}
     \caption{Cec\_2021\_ Function 2}
 \end{subfigure} \hfill

 \begin{subfigure}[b]{0.3\textwidth}
     \includegraphics[width=\textwidth]{3agw-eva.png}
     \caption{Cec\_2021\_ Function 3}
 \end{subfigure}

 \begin{subfigure}[b]{0.3\textwidth}
     \includegraphics[width=\textwidth]{4agw-eva.png}
     \caption{Cec\_2021\_ Function 5}
 \end{subfigure} \hfill


 \begin{subfigure}[b]{0.3\textwidth}

     \includegraphics[width=\textwidth]{5agw-eva.png}
     \caption{Cec\_2021\_ Function 7}
 \end{subfigure} \hfill


 \begin{subfigure}[b]{0.3\textwidth}
     \centering
     \includegraphics[width=\textwidth]{6agw-eva.png}
     \caption{Cec\_2021\_ Function 8}
 \end{subfigure}
 \hfill

 \begin{subfigure}[t]{0.9\textwidth}
     \centering
     \includegraphics[width=\textwidth]{7agw-eva.png}
     \caption{Cec\_2021\_ Function 3}
 \end{subfigure}

    \caption{caption.}
    \label{fig:fig-evaluation}
\end{figure}

但它们是以垂直位置显示的。

答案1

这很好用。请小心处理空白行,因为它们会开始一个新段落,所以以 结尾的行不应该有空白行\hfill

\documentclass[a4paper]{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp!]
  \centering
  \begin{subfigure}[b]{0.3 \textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \caption{Cec\_2021\_ Function 1}
  \end{subfigure} \hfill
  \begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \caption{Cec\_2021\_ Function 2}
  \end{subfigure} \hfill
  \begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \caption{Cec\_2021\_ Function 3}
  \end{subfigure}

  \medskip
  
 \begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=\textwidth]{example-image}
   \caption{Cec\_2021\_ Function 5}
 \end{subfigure} \hfill
 \begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=\textwidth]{example-image}
   \caption{Cec\_2021\_ Function 7}
 \end{subfigure} \hfill
 \begin{subfigure}[b]{0.3\textwidth}
   \centering \includegraphics[width=\textwidth]{example-image}
   \caption{Cec\_2021\_ Function 8}
 \end{subfigure}

 \medskip
 
 \begin{subfigure}[t]{0.9\textwidth}
   \centering \includegraphics[width=\textwidth]{example-image}
   \caption{Cec\_2021\_ Function 3}
 \end{subfigure}

 \caption{Convergence curves for AGWO and other recent algorithms
   during 2500 iterations.}
 \label{fig:agwo-evaluation}
\end{figure}
\end{document}

相关内容