我需要在两列两行中显示 4 幅图像。\hbox 中的文本太长,这就是为什么它会覆盖下一列中的第二幅图像文本。如何让第一幅图像文本在一定宽度后中断,以便它进入新行。我使用过 \linebreak 和 \,但它们都不起作用。
\hbox to\linewidth{%
\hfil%
\vbox{%
\hbox{\includegraphics[scale=0.5]{sampleimage1.png}}%
\hbox to 5cm {Sample text 1}
}%
\hfil%
\vbox{%
\hbox{\includegraphics[scale=0.5]{sampleimage2.png}}%
\hbox{Sample text 2}
}%
\hfil%
}
\hbox to\linewidth{%
\hfil%
\vbox{%
\hbox{\includegraphics[scale=0.5]{sampleimage3.png}}%
\hbox{Sample text 3}
}%
\hfil%
\vbox{%
\hbox{\includegraphics[scale=0.5]{sampleimage4.png}}%
\hbox{Sample text 4}
}%
\hfil%
}
\caption{caption text}
答案1
如果您不知道低级命令的作用,请不要使用它们。
下面的做法不是更简单吗?
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp]
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
p{0.48\textwidth}
p{0.48\textwidth}
@{}
}
\includegraphics[width=\linewidth]{example-image-a} &
\includegraphics[width=\linewidth]{example-image-b} \\
Sample Text 1 Sample Text 1 Sample Text 1 Sample Text 1 &
Sample Text 2 Sample Text 2 Sample Text 2 Sample Text 3 \\[2ex]
\includegraphics[width=\linewidth]{example-image-c} &
\includegraphics[width=\linewidth]{example-image-a} \\
Sample Text 3 Sample Text 3 Sample Text 3 Sample Text 3 &
Sample Text 4 Sample Text 4 Sample Text 4 Sample Text 4
\end{tabular*}
\caption{Caption text Caption text Caption text Caption text Caption text}
\end{figure}
\end{document}