我在 LaTeX 中编写了以下代码,可生成下图所示的内容。我的问题是,如何使两个图形位于同一行,一个挨着一个?我尝试使用 minipage 和 subfigure,但无法解决问题。谢谢!
\begin{figure}
\begin{center}
\minipage{0.1\textwidth}
\includegraphics[trim={0 2 2 2},clip,width=\linewidth]{image1.jpg}
\endminipage
\hspace{1 cm}
\minipage{0.1\textwidth}
\includegraphics[trim={0 2 2 2},clip,width=\linewidth]{image2.jpg}
\endminipage
\caption{1st common caption}
\label{1st label}
\end{center}
\end{figure}
\begin{figure}
\begin{center}
\minipage{0.1\textwidth}
\includegraphics[trim={0 2 2 2},clip,width=\linewidth]{image3.jpg}
\endminipage
\hspace{1 cm}
\minipage{0.1\textwidth}
\includegraphics[trim={0 2 2 2},clip,width=\linewidth]{image4.jpg}
\endminipage
\caption{2nd common caption}
\label{2nd label}
\end{center}
\end{figure}
答案1
切勿在 里面使用\minipage
和。这两个命令可用于定义新环境。\endminipage
document
现在您可以使用 来完成这项工作minipages
,但以不同的方式。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp]
\centering
\begin{minipage}{0.4\textwidth}
\centering
\includegraphics[width=0.25\linewidth]{example-image-9x16}%
\hspace{1cm}%
\includegraphics[width=0.25\linewidth]{example-image-9x16}%
\caption{1st common caption}
\label{1st label}
\end{minipage}%
\hspace{2cm}%
\begin{minipage}{0.4\textwidth}
\centering
\includegraphics[width=0.25\linewidth]{example-image-9x16}%
\hspace{1cm}%
\includegraphics[width=0.25\linewidth]{example-image-9x16}%
\caption{2nd common caption}
\label{2nd label}
\end{minipage}
\end{figure}
\end{document}