Tengo este código para colocar seis imágenes en dos filas (3 imágenes para cada fila):
\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}
Pero se muestran en posiciones verticales.
Respuesta1
Esto funciona bien. Tenga cuidado con las líneas en blanco, que comienzan un nuevo párrafo, por lo que no deberían estar ahí para las líneas que terminan con \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}