Overleaf 中一行中有四幅图

Overleaf 中一行中有四幅图

我想将四个数字添加到一行中,但我做不到。我尝试了很多次来找出错误,但仍然失败了。目前,第一行有一个数字,第二行有第二个数字,第四行有第三个数字和第四个数字。

\begin{figure}
%\centering
    %\hfill
    \subfigure[Training         loss]{\includegraphics[width=0.25\linewidth]{images/all_vits.pdf}}

    %\vspace{-4pt}
    %\hfill
    \subfigure[Accuracy]{\includegraphics[width=0.25\linewidth]{images/acc_vit.pdf}}
   %
    %\vspace{-4pt}
    %\hfill
    %\caption{Comparison of pure ViTs and Convolutional ViTs %models.}
    %\vspace{-13pt}
    %\label{fig:ALLVITS}
%\end{figure}
%\begin{figure}

    %\hfill
    \subfigure[Training loss]{\includegraphics[width=0.25\linewidth]{images/ours_loss.pdf}}
    %\vspace{-4pt}
    %\hfill
    \subfigure[Accuracy]{\includegraphics[width=0.25\linewidth]{images/ours_acc.pdf}}
    %\vspace{-4pt}
    %\hfill
    %\caption{Comparison of our module integrates in O-PVT.}
    \label{fig:OPVT}
\end{figure}

答案1

有关详细信息,请参阅图:使用 subfig 或 subfigure 有什么区别。确保宽度总和小于 100%。顺便说一句,您的代码看起来有点乱。我建议保持整洁,请参阅下面的建议。

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}

\begin{figure}
\centering
\subfloat[First.]{\label{4figs-a} \includegraphics[width=0.20\textwidth]{example-image-a}}% The "%" masks the line break.
\hfill
\subfloat[Second.]{\label{4figs-b} \includegraphics[width=0.20\textwidth]{example-image-a}}%
\hfill
\subfloat[Third.]{\label{4figs-c} \includegraphics[width=0.20\textwidth]{example-image-a}}%
\hfill
\subfloat[Forth.]{\label{4figs-d} \includegraphics[width=0.20\textwidth]{example-image-a}}%
\caption{Four sub-floats.}
\label{4figs}
\end{figure}

See \figurename~\ref{4figs-b} and \figurename~\ref{4figs-d}.

\end{document}

在此处输入图片描述

答案2

就我而言,下面的代码运行良好。

\begin{figure}[t]
    \subfigure[Training loss curves]{\includegraphics[width=0.245\linewidth]{images/all.pdf}}
    \subfigure[Accuracy curves]{\includegraphics[width=0.245\linewidth]{images/all.pdf}}
    \label{fig:ALLVITS}
    \subfigure[Training loss curves]{\includegraphics[width=0.245\linewidth]{images/all.pdf}}
    \subfigure[Accuracy curves]{\includegraphics[width=0.245\linewidth]{images/all.pdf}}
    \caption{Comparison of our module integrates in O-PVT.}
    \label{fig:OPVT}
\end{figure}

相关内容