我想知道如何将图像并排放置,例如这里如图 4 所示。图像连接得非常紧密。从我的互联网搜索中,我只找到了将图像并排放置但中间有一些小间隙的解决方案,这是我不想要的。以下是我尝试过的 MWE:
\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage[style=base]{caption}
\usepackage{subcaption}
\begin{figure*}[tp]
% \centering
\begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig1.jpg}\label{fig:fig1}
\end{subfigure}
\begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig2.jpg}\label{fig:fig2}
\end{subfigure}\\
\begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig3.jpg}\label{fig:fig3}
\end{subfigure}
\begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig4.jpg}\label{fig:fig4}
\end{subfigure}
\end{figure*}
\end{document}
答案1
此解决方案使用 测量图像\sbox
,并将该宽度用作子图的宽度。更简单的解决方案是不使用子图。
注意:(几乎)每次用括号结束一行时都会添加一个空格。
\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage[draft]{graphicx}
\usepackage[style=base]{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure*}[tp]
% \centering
\sbox0{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig1.jpg}}%
\sbox1{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig2.jpg}}%
\begin{subfigure}{\wd0}\usebox0\end{subfigure}%
\begin{subfigure}{\wd1}\usebox1\end{subfigure}\\
\sbox0{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig3.jpg}}%
\sbox1{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig4.jpg}}%
\begin{subfigure}{\wd0}\usebox0\end{subfigure}%
\begin{subfigure}{\wd1}\usebox1\end{subfigure}
\end{figure*}
\end{document}