为什么我的图像在乳胶中不能形成一行?

为什么我的图像在乳胶中不能形成一行?

我试图将四张图片加载到一行中,所有图片都以相同的大小对齐,以节省空间。但是,它们都分散在两行中。这是我的代码 -

\begin{figure}
\minipage{0.2\textwidth}
  \centering
  \includegraphics[width=\linewidth]{Environment1.png}
  \caption{}
  \label{fig:env}
\endminipage\hfill
\minipage{0.2\textwidth}
  \centering
  \includegraphics[width=\linewidth]{Environment2.png}
  \caption{}
  \label{fig:galaxy}
\endminipage\hfill

\minipage{0.2\textwidth}%
  \centering
  \includegraphics[width=\linewidth]{Environment3.png}
  \caption{}
  \label{}
\endminipage
\minipage{0.2\textwidth}%
  \centering
  \includegraphics[width=\linewidth]{Environment4.png}
  \caption{}
  \label{}
\endminipage
\caption{Stuff}
\label{Environment_2}
\end{figure}

答案1

原帖代码中间的空白行会产生一个新段落,从而防止四个数字出现在同一行。此外,我还添加了一个\hfill我认为需要的。

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}
\minipage{0.2\textwidth}
  \centering
  \includegraphics[width=\linewidth]{Environment1.png}
  \caption{}
  \label{fig:env}
\endminipage\hfill
\minipage{0.2\textwidth}
  \centering
  \includegraphics[width=\linewidth]{Environment2.png}
  \caption{}
  \label{fig:galaxy}
\endminipage\hfill
% <-- GET RID OF PARAGRAPH BREAK
\minipage{0.2\textwidth}%
  \centering
  \includegraphics[width=\linewidth]{Environment3.png}
  \caption{}
  \label{}
\endminipage\hfill% <--PROBABLY WANT AN \hfill
\minipage{0.2\textwidth}%
  \centering
  \includegraphics[width=\linewidth]{Environment4.png}
  \caption{}
  \label{}
\endminipage
\caption{Stuff}
\label{Environment_2}
\end{figure}

\end{document}

在此处输入图片描述

相关内容