我使用以下头文件。
\usepackage[caption = false]{subfig}
\usepackage{subcaption}
\usepackage{graphicx} % subcaption for subfigure environment
\usepackage{caption}
我想打印子图我使用了下面的代码。
\begin{figure}
\centering
\subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/53.jpg}}
\subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/54.jpg}}
\subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/55.jpg}}
\subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/51.jpg}}
\subfigure{\includegraphics[width=0.47\textwidth]{Chapter-5/figures/52.jpg}}
\caption{(a) Release cost (b) WIP-holding cost (c) Production cost (d) FGI-holding cost (e) FGI-backorder cost}
\label{fig:costbar}
\end{figure}
有人可以协助子图带有单独的图形名称以及为什么我会得到错误?
答案1
这是一个可能的例子:
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{font=small, labelfont=bf}
\captionsetup[sub]{labelsep=period, subrefformat=brace}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.16\textwidth}
\centering
\includegraphics[width=1.8cm]{example-image-a}
\caption{\label{fig:image1}}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.16\textwidth}
\centering
\includegraphics[width=1.8cm]{example-image-b}
\caption{\label{fig:image2}}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.16\textwidth}
\centering
\includegraphics[width=1.8cm]{example-image-c}
\caption{\label{fig:image3}}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.16\textwidth}
\centering
\includegraphics[width=1.8cm]{example-image-a}
\caption{\label{fig:image4}}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.16\textwidth}
\centering
\includegraphics[width=1.8cm]{example-image-b}
\caption{\label{fig:image5}}
\end{subfigure}
\caption{\subref{fig:image1} Picture 1, \subref{fig:image2} picture 2, \subref{fig:image3} picture 3, \subref{fig:image4} picture 4, \subref{fig:image5} picture 5.}
\end{figure}
\end{document}
我把图片并排放置,所以它们很小,但通过调整每张图片的0.16\textwidth
(可用宽度)和width
(实际宽度),您可以根据自己的喜好进行调整。
另外,\quad
用于在每个图像之间添加一些空间,您可以用任何您想要的东西来替换,包括\\
如果您希望图片位于不同的行上。
编辑:添加两\captionsetup
行来调整标题的外观。
答案2
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[t]{0.2\textwidth}
\centering
\includegraphics[width=\linewidth,height=50mm, keepaspectratio]{example-image-a}
\caption{This is a very long caption for such a little figure, will the captions overlap?}
\label{fig:fig-a}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.2\textwidth}
\centering
\includegraphics[width=\linewidth,height=40mm, keepaspectratio]{example-image-b}
\caption{This is a very long caption for such a little figure, will the captions overlap?}
\label{fig:fig-b}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.2\textwidth}
\centering
\includegraphics[width=\linewidth,height=50mm, keepaspectratio]{example-image-a}
\caption{This is a very long caption for such a little figure, will the captions overlap?}
\label{fig:fig-c}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.2\textwidth}
\centering
\includegraphics[width=\linewidth,height=40mm, keepaspectratio]{example-image-b}
\caption{This is a very long caption for such a little figure, will the captions overlap?}
\label{fig:fig-d}
\end{subfigure}
\caption{A lot of subfigures inside one figure}
\label{fig:my-fig}
\end{figure}
\end{document}