代码

代码

我想使用 5 个子图,其中三个排在第一行,两个排在第二行,两行都需要居中排列。但我在第二行遇到了问题,两个图像分别位于两端,而不是朝向中心。有什么办法吗?

\begin{figure*}[!htb]
\centering
\subfloat[Original Depth Image]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure1}
}
\hfill
\subfloat[Plausibility Map]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure2}
}
\hfill
\subfloat [Depth Image of Guided Filter]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure3}
}
\vfill
\centering
\subfloat[Blending Map]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure4}}
\hfill
\centering
\subfloat[Blended Output Depth Image]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure5}}
\caption{Results for Combination1: Plausibility Method-2 and Blending}
\end{figure*}

在此处输入图片描述

答案1

\hfil只需和玩一些游戏\hfill

\documentclass{scrartcl}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure*}[!htb]
\centering
\subfloat[Original Depth Image]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure1}
}
\hfill
\subfloat[Plausibility Map]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure2}
}
\hfill
\subfloat [Depth Image of Guided Filter]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure3}
}
\vfill
\centering
\hfill\hfill\subfloat[Blending Map]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure4}}\hfill
\subfloat[Blended Output Depth Image]{
\includegraphics[width=.3\textwidth,height=4.0cm]{cat.png}
\label{fig:subfigure5}}\hfill\hfill\hfil
\caption{Results for Combination1: Plausibility Method-2 and Blending}
\end{figure*}
\end{document}

在此处输入图片描述

答案2

我对您的示例做了一些修改:

  • 不需要重复\centering,一次就足够了。
  • 我没有依赖图内的自动断线,而是使用了明确的空行。
  • %行末的注释符号可以避免文档中出现不必要的空格。
  • 为了使图中的间距一致,我使用了 来\hspace{.05\textwidth}产生底行中的空白。

代码

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

\begin{document}
\begin{figure*}[!htb]\centering
\subfloat[Original Depth Image]{%
\includegraphics[width=.3\textwidth,height=4.0cm]{example-image}%
\label{fig:subfigure1}%
}%
\hfill
\subfloat[Plausibility Map]{%
\includegraphics[width=.3\textwidth,height=4.0cm]{example-image}%
\label{fig:subfigure2}%
}
\hfill
\subfloat [Depth Image of Guided Filter]{%
\includegraphics[width=.3\textwidth,height=4.0cm]{example-image}%
\label{fig:subfigure3}%
}

\subfloat[Blending Map]{%
\includegraphics[width=.3\textwidth,height=4.0cm]{example-image}%
\label{fig:subfigure4}}%
\hspace{.05\textwidth}%
\subfloat[Blended Output Depth Image]{%
\includegraphics[width=.3\textwidth,height=4.0cm]{example-image}%
\label{fig:subfigure5}}%
\caption{Results for Combination1: Plausibility Method-2 and Blending}
\end{figure*}
\end{document}

结果

结果

相关内容