我是 Latex 新手,想制作带有标题的格式良好的图片,就像这样一。
经过一番搜索,我能够生成类似的字幕
\begin{figure}
\begin{minipage}[b]{0.49\linewidth}
\includegraphics{figure1.pdf}
\begin{center} figure1 \end{center}
\end{minipage}
\begin{minipage}[b]{0.49\linewidth}
\includegraphics{figure2.pdf}
\begin{center} figure2 \end{center}
\end{minipage}
\caption{figure1 vs. figure2 }
\end{figure}
但是文本之间的间距很大。一般来说,如何才能更好地控制文本的位置?
答案1
这里有各种各样的选项,其中最简单的是在里面设置“子图”构造tabular
:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\mbox{}\hfill
\begin{tabular}[b]{c}
\includegraphics[width=5em]{example-image-a} \\
figure1
\end{tabular}\hfill
\begin{tabular}[b]{c}
\includegraphics[width=7em]{example-image-b} \\
figure2
\end{tabular}\hfill
\mbox{}
\caption{figure1 vs. figure2}
\end{figure}
\end{document}
由于您正在使用,只需通过向换行符添加tabular
可选参数来更改空格即可。如果您有多行“子图”标题,那么人们可能会发现不同的东西:<len>
tabular
\\[<len>]
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\mbox{}\hfill
\includegraphics[width=5em]{example-image-a}\hfill
\makebox[12em]{\includegraphics[width=7em]{example-image-b}}\hfill
\mbox{}\par
%\vspace{<len>} to increase the space
\mbox{}\hfill
\makebox[5em]{figure1}\hfill
\begin{tabular}[t]{@{}p{12em}@{}}
This is a beautiful figure that needs more descriptive words
\end{tabular}\hfill
\mbox{}
\caption{figure1 vs. figure2}
\end{figure}
\end{document}
当然,在一般情况下,我建议使用subcaption
;你应该在subcaption
文档。
答案2
我将使用包subigure
中定义的subcaption
并在图像中写入文本\caption*{...}
:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption, subcaption}
\captionsetup{skip=1ex, font=small}
\captionsetup[sub]{skip=-1ex}
\begin{document}
\begin{figure}
\centering
\setkeys{Gin}{width=\linewidth}
\begin{subfigure}[b]{0.4\linewidth}
\includegraphics{example-image-a} \\
\caption*{figure 1}
\end{subfigure}%
\hfil
\begin{subfigure}[b]{0.4\linewidth}
\includegraphics{example-image-B} \\
\caption*{figure 2}
\end{subfigure}%
\caption{figure1 vs. figure2}
\label{fig:comparison}
\end{figure}
\end{document}