程式碼

程式碼

我想使用 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,一次就夠了。
  • 我沒有依賴圖中的自動換行,而是使用了顯式的空白行。
  • %行尾的註解符號可以防止文件中出現不必要的空格。
  • 為了使圖中的間距保持一致,我使用 a\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}

結果

結果

相關內容