
我正在嘗試居中並減少屬於一個圖形的四張圖像之間的空間。命令類似於hspace
但\captionsetup[sub]{skip=0mm}
不執行任何操作。移動我的中心,使其位於 \begin{figure} 下方,也只會使所有內容都成為一條長線。
這是我的相關部分:
\begin{center}
\begin{figure}[b]
\vspace{-45mm}
\begin{subfigure}[b]{0.6\textwidth}
\centering
\includegraphics[width=\textwidth]{Plot M37 with parameters to see more stars.png}
\vspace{-10mm}
\caption{Image of Open Cluster Messier 37}
\vspace{-1mm}
\label{fig:0}
\end{subfigure}
\begin{subfigure}[b]{0.6\textwidth}
\centering
\includegraphics[width=\textwidth]{HD23190.png}
\vspace{-10mm}
\caption{Image of Star HD23190}
\vspace{-1mm}
\label{fig:1}
\end{subfigure}
\vspace{-10mm}
\begin{subfigure}[b]{0.6\textwidth}
\centering
\includegraphics[width=\textwidth]{HD40649.png}
\vspace{-10mm}
\caption{Image of Star HD40649}
\label{fig:2}
\end{subfigure}
\vspace{-10mm}
\begin{subfigure}[b]{0.6\textwidth}
\centering
\includegraphics[width=\textwidth]{HD280264.png}
\vspace{-10mm}
\caption{Image of Star HD280264}
\label{fig:3}
\end{subfigure}
\end{figure}
\end{center}
答案1
在此範例中,您可以看到類似的內容: https://www.latextemplates.com/template/arsclassica-article
如果你嘗試轉置,它可能是這樣的程式碼:
\begin{figure}[tb]
\centering
\subfloat[Image of Open Cluster Messier 37.]{\includegraphics[width=.45\columnwidth]{Plot M37 with parameters to see more stars.png}}\label{fig:0} \quad
\subfloat[Image of Star HD23190.]{\includegraphics[width=.45\columnwidth]{HD23190.png}\label{fig:1}\\
\subfloat[Image of Star HD40649.]{\includegraphics[width=.45\columnwidth]{HD40649.png}}\label{fig:2} \quad
\subfloat[Image of Star HD280264.]{\includegraphics[width=.45\columnwidth]{HD280264.png}}\label{fig:3}
\caption[Stars.]{Stars.}
\label{fig:PicturesOfStars}
\end{figure}
答案2
- 在修復環境中較新的插入浮動環境(如
minipage
等center
) - 一行中子圖形寬度總和應小於文字寬度。如果不是,則子圖像會溢出到右邊框
- 在某些情況下,當圖像與子圖具有相同的寬度時,在子圖中使用
\centering
命令沒有任何意義,因此您可以刪除它們 - 由於所有影像具有相同的寬度,因此可以方便地使用
Gin
key 來確定它們的寬度, - 使用選項子圖垂直
[b]
對齊子圖標題的底部,如果其中一個標題的行數多於其他標題,則會導致圖像頂部未對齊 - 如果您使用
\hfill
圖像之間的水平空間,則圖像將位於文字的左右邊框上
考慮到上述情況,帶有圖像代碼的 MWE 可以是:
\documentclass{article}
\usepackage{graphicx}
\usepackage[skip=0.5ex, belowskip=1ex]{subcaption}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\begin{figure}[htb]
\setkeys{Gin}{width=\linewidth}
\begin{subfigure}[t]{0.48\textwidth}
\includegraphics{example-image-duck}%{Plot M37 with parameters to see more stars.png}
\caption{Image of Open Cluster Messier 37}
\label{fig:0}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.48\textwidth}
\includegraphics{example-image-duck}%{HD23190.png}
\caption{Image of Star HD23190}
\label{fig:1}
\end{subfigure}
\begin{subfigure}[t]{0.48\textwidth}
\includegraphics{example-image-duck}%{HD40649.png}
\caption{Image of Star HD40649}
\label{fig:2}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.48\textwidth}
\includegraphics{example-image-duck}%{HD280264.png}
\caption{Image of Star HD280264}
\label{fig:3}
\end{subfigure}
\end{figure}
\end{document}
(紅線顯示部分頁面佈局)