你好,我想知道是否可以添加/增加一些之间的空间subfloat
captions
?
这是我的代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure} [h]
\centering
\subfloat[text1 text1 text1 text1 text1 text1 text1 text1 text1 ]{
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}
\subfloat[text2 text2 text2 text2 text2 text2 text2 text2 text2 ]{
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}
\subfloat[text3 text3 text3 text3 text3 text3 text3 text3 text3 ]{
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}
\subfloat[]{
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image}}}
\subfloat[]{
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image}}}
\captionof{figure}{Overall Text}
\end{figure}
\end{document}
答案1
您在图像前面的 内添加了一个空格\subfloat
,因此标题会扩展以填充整个空间。您没有在\subfloat
s 之间添加空格(可能以\subfloat
结尾\ignorespaces
)。
我想补充一点,subcaption 包是首选。另外,添加一个 也没什么坏处\raggedright
。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{showframe}% debugging tool
\begin{document}
\begin{figure} [h]
\centering
\subfloat[text1 text1 text1 text1 text1 text1 text1 text1 text1 ]{%
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}\hfil
\subfloat[\sloppy text2 text2 text2 text2 text2 text2 text2 text2 text2 ]{%
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}\hfil
\subfloat[\sloppy text3 text3 text3 text3 text3 text3 text3 text3 text3 ]{%
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image-golden}}}
\subfloat[]{%
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image}}}\hfil
\subfloat[]{%
\fbox{\includegraphics[width={0.30\textwidth}]
{example-image}}}
\captionof{figure}{Overall Text}
\end{figure}
\end{document}
此解决方案使用 subcaption 包。每个子图实际上只是一个小页面。因此,\textwidth
在子图内部重新定义,因此有了新的长度\imagewidth=0.3\textwidth
。该[t]
选项对齐第一行的基线,在本例中指的是图像。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% debugging tool
\newlength{\imagewidth}
\begin{document}
\begin{figure} [h]
\centering
\imagewidth=0.30\textwidth
\captionsetup[subfigure]{width=0.8\imagewidth,justification=raggedright}%
\begin{subfigure}[t]{\dimexpr \imagewidth+2\fboxsep+2\fboxrule}
\fbox{\includegraphics[width=\imagewidth]{example-image-golden}}
\caption{text1 text1 text1 text1 text1 text1 text1 text1 text1}
\end{subfigure}\hfil
\begin{subfigure}[t]{\dimexpr \imagewidth+2\fboxsep+2\fboxrule}
\fbox{\includegraphics[width=\imagewidth]{example-image-golden}}
\caption{text2 text2 text2 text2 text2 text2 text2 text2 text2}
\end{subfigure}\hfil
\begin{subfigure}[t]{\dimexpr \imagewidth+2\fboxsep+2\fboxrule}
\fbox{\includegraphics[width=\imagewidth]{example-image-golden}}
\caption{text3 text3 text3 text3 text3 text3 text3 text3 text3}
\end{subfigure}
\medskip
\begin{subfigure}[t]{\dimexpr \imagewidth+2\fboxsep+2\fboxrule}
\fbox{\includegraphics[width=\imagewidth]{example-image}}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{\dimexpr \imagewidth+2\fboxsep+2\fboxrule}
\fbox{\includegraphics[width=\imagewidth]{example-image}}
\caption{}
\end{subfigure}
\caption{Overall Text}
\end{figure}
\end{document}