我有 5 个子浮点,我想将 3 个分布在顶行,2 个分布在底行,但前 3 个之间间距相等。但\\
它们之间似乎没有任何作用。你有什么建议?
给出这个:
即XXX
X X
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htb]
\centering
\makebox[\textwidth]{
\subfloat[Single window]{\label{fig:wind_single}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_single.png}}\hspace{1em}%
\subfloat[Two openings, same side]{\label{fig:wind_same}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_same.png}}\hspace{1em}%
\subfloat[Two openings, opposite sides]{\label{fig:wind_opposite}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_opposite.png}}\newline%
\subfloat[Two openings, same side with wings]{\label{fig:wind_wings}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_wings.png}}\hspace{1em}%
\subfloat[Two openings, adjacent walls]{\label{fig:wind_adjacent}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_adjacent.png}}%
}
\smallskip
\caption{Passive ventilation examples}
\end{figure}
\end{document}
答案1
只需摆脱该\makebox
命令(在新发行版中它不会执行任何操作)现在您就可以使用标准行更改命令\\
:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
%\makebox[\textwidth]{
\subfloat[Single window]{\label{fig:wind_single}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_single.png}}\hspace{1em}%
\subfloat[Two openings, same side]{\label{fig:wind_same}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_same.png}}\hspace{1em}%
\subfloat[Two openings, opposite sides]{\label{fig:wind_opposite}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_opposite.png}}\\%
\subfloat[Two openings, same side with wings]{\label{fig:wind_wings}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_wings.png}}\hspace{1em}%
\subfloat[Two openings, adjacent walls]{\label{fig:wind_adjacent}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_adjacent.png}}%
%}
\smallskip
\caption{Passive ventilation examples}
\end{figure}
\end{document}
选项demo
只是graphicx
用黑色矩形替换实际图形;不是在实际文档中使用该选项。
我还建议您进行一些其他修改以改善结果:由于您的子图很窄,子标题的文本可能会导致单词间距过大;防止这种情况的一种方法是使用 \raggedright 将它们设置为
\captionsetup[subfigure]{justification=raggedright}
另一个变化是,您不需要手动\smallskip
在对象和标题之间添加一些间距。如果这适用于您的所有图形,您可以使用
\captionsetup[figure]{skip=<lenght>}
以下是经过这些修改的代码:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\captionsetup[figure]{skip=\bigskipamount}
\begin{document}
\begin{figure}
\centering
\captionsetup[subfigure]{justification=raggedright}
\subfloat[Single window]{\label{fig:wind_single}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_single.png}}\hspace{1em}%
\subfloat[Two openings, same side]{\label{fig:wind_same}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_same.png}}\hspace{1em}%
\subfloat[Two openings, opposite sides]{\label{fig:wind_opposite}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_opposite.png}}\\%
\subfloat[Two openings, same side with wings]{\label{fig:wind_wings}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_wings.png}}\hspace{1em}%
\subfloat[Two openings, adjacent walls]{\label{fig:wind_adjacent}\includegraphics[width=3cm, height=2cm]{./Figures/chapter2/wind_adjacent.png}}%
\caption{Passive ventilation examples}
\end{figure}
\end{document}
答案2
如果您愿意使用subcaption
而不是subfig
,那么也许是这样:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htb]
\centering%
\begin{subfigure}{3cm}
\includegraphics[demo,width=3cm, height=2cm]{}
\caption{A}
\label{fig:A}
\end{subfigure}\hspace{1em}%
\begin{subfigure}{3cm}
\includegraphics[demo,width=3cm, height=2cm]{}
\caption{B}
\label{fig:B}
\end{subfigure}\hspace{1em}%
\begin{subfigure}{3cm}
\includegraphics[demo,width=3cm, height=2cm]{}
\caption{C}
\label{fig:C}
\end{subfigure}\vskip 1em%
\begin{subfigure}{3cm}
\includegraphics[demo,width=3cm, height=2cm]{}
\caption{D}
\label{fig:D}
\end{subfigure}\hspace{1em}%
\begin{subfigure}{3cm}
\includegraphics[demo,width=3cm, height=2cm]{}
\caption{E}
\label{fig:E}
\end{subfigure}\hspace{1em}%
\begin{subfigure}{3cm}
\hspace{\fill}
\end{subfigure}\hspace{1em}%
\caption{Passive ventilation examples}
\end{figure}
\end{document}
对我来说,subcaption
比 更好subfig
。否则,您可以使用相同的方法向图形中添加一个空的“子图”:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htb]
\centering%
\subfloat[Single window]{\label{fig:wind_single}\includegraphics[demo,width=3cm, height=2cm]{}}\hspace{1em}%
\subfloat[Two openings, same side]{\label{fig:wind_same}\includegraphics[demo,width=3cm, height=2cm]{}}\hspace{1em}%
\subfloat[Two openings, opposite sides]{\label{fig:wind_opposite}\includegraphics[demo,width=3cm, height=2cm]{}}\vskip 1em%
\subfloat[Two openings, same side with wings]{\label{fig:wind_wings}\includegraphics[demo,width=3cm, height=2cm]{}}\hspace{1em}%
\subfloat[Two openings, adjacent walls]{\label{fig:wind_adjacent}\includegraphics[demo,width=3cm, height=2cm]{}}\hspace{1em}%
\subfloat{\hspace{3cm}}%
\caption{Passive ventilation examples}
\end{figure}
\end{document}