在中心环境中为包含的 includegraphics 图像添加标题

在中心环境中为包含的 includegraphics 图像添加标题

我已将我的乳胶源代码的一部分复制粘贴到这里。我想在每个图像、和的底部添加一个,但找不到caption简单的方法来做到这一点。我还附上了处理此乳胶代码的输出。load_8.pngload_9.pngload_1.pngload_1.1.png

pdflatex 的输出。有人能告诉我怎么走吗?

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\includegraphics[width=0.49\linewidth]{fig/load_8.png}
\includegraphics[width=0.49\linewidth]{fig/load_9.png}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\includegraphics[width=0.49\linewidth]{fig/load_1.png}
\includegraphics[width=0.49\linewidth]{fig/load_1_1.png}
\captionof{figure}{Probability distribution with loading level of a) 1.0 b) 1.1 }
\end{center}
\end{document}

答案1

您也可以使用minipage

\documentclass{article}
\usepackage[demo]{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\begin{minipage}{0.48\linewidth}
\includegraphics[width=\linewidth]{fig/load_8.png}
\captionof{figure}{Some here}
\end{minipage}%
\hfill
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_9.png}
\captionof{figure}{some more}
\end{minipage}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_1.png}
\captionof{figure}{some more}
\end{minipage}
\hfill
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_1_1.png}
\captionof{figure}{some more}
\end{minipage}
\captionof{figure}{Probability distribution with loading level of a) 1.0 b) 1.1 }
\end{center}
\end{document}

在此处输入图片描述

如果你不想Figure 1.使用这些标题,请\captionof*使用\captionof

答案2

使用您的代码,最简单的选择是使用tabular并手动标记其中的每个图形。

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.49\linewidth]{example-image-a} &
\includegraphics[width=0.49\linewidth]{example-image-b} \\
 a) & b)\\
 \end{tabular}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.49\linewidth]{example-image-a} &
\includegraphics[width=0.49\linewidth]{example-image-b} \\
 a) & b)\\
 \end{tabular}
\captionof{figure}{Probability distribution with loading level of a): 1.0 ; b) 1.1}
\end{center}
\end{document}

在此处输入图片描述

虽然我认为最好使用包subfigure中的环境subcation。它们有助于管理自动引用并更好地对齐子图和标题。

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\usepackage[subrefformat=parens]{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{First}\label{fig1a}
\end{subfigure}\hfill
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Second}\label{fig1b}
\end{subfigure}%
\caption{Probability distribution with loading level of \subref{fig1a}: 0.8 and \subref{fig1b}: 0.9}
\end{figure}

\begin{figure}
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{First}\label{fig2a}
\end{subfigure}\hfill
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Second}\label{fig2b}
\end{subfigure}%
\caption{Probability distribution with loading level of \subref{fig1a}: 1.0 and \subref{fig1b}: 1.1}
\end{figure}
\end{document}

在此处输入图片描述

相关内容