我遇到的问题是,当我编译时,图像标题显示带有括号“[图标题]”......................................................................................................................................
\documentclass{elsarticle}
\usepackage{verbatim}
\usepackage{xcolor}
\usepackage{booktabs} % For professional looking tables
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{framed}
\usepackage{longtable}
\usepackage{lscape}
%\usepackage[ruled,vlined]{algorithm2e}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
%\usepackage[ruled,vlined]{algorithm2e}
\usepackage{slashbox}
\usepackage{caption}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{float}
%\usepackage{subcaption}
\usepackage{subfig}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{algorithmicx}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{lineno,hyperref}
\usepackage{cleveref}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\modulolinenumbers[5]
\journal{Journal of \LaTeX\ Templates}
\usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsthm}
\begin{figure}
\subfigure[]{ \includegraphics[width=0.24\textwidth]{graph1}
}
\subfigure[]{\includegraphics[width=0.24\textwidth]{graph2}%
}
\subfigure[]{\includegraphics[width=0.24\textwidth]{graph3}}%
\caption{Three simple graphs}
\label{fig:three graphs}
\end{figure}
答案1
由于您正在加载caption
包,因此我会使用高度兼容的subcaption
包的机制,而不是仅仅有点兼容的subfig
包的机制。
(下图中的框线表示文本块的边缘。)
\documentclass[demo]{elsarticle} % remove 'demo' option in real doc
%% preamble reduced the bare minimum
\usepackage{graphicx,caption,subcaption}
\captionsetup[subfigure]{labelformat=simple}
\begin{document}
\begin{figure}[ht!]
\centering
\begin{subfigure}{0.24\linewidth}
\includegraphics[width=\textwidth]{graph1}
\caption{}
\end{subfigure}\qquad
\begin{subfigure}{0.24\linewidth}
\includegraphics[width=\textwidth]{graph2}
\caption{}
\end{subfigure}\qquad
\begin{subfigure}{0.24\linewidth}
\includegraphics[width=\textwidth]{graph3}
\caption{}
\end{subfigure}
\caption{Three simple graphs}\label{fig:three graphs}
\end{figure}
\end{document}
答案2
在删除所有不相关的包并使用正确的子图语法(参见@leandriis 评论)后,MWE 是
\documentclass{elsarticle}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[labelformat=simple]{subfig} % <----
\begin{document}
\begin{figure}
\centering
\subfloat[]{\includegraphics[width=0.24\textwidth]{example-image-a}
}\hfil
\subfloat[]{\includegraphics[width=0.24\textwidth]{example-image-b}%
}\hfil
\subfloat[]{\includegraphics[width=0.24\textwidth]{example-image-c}}%
\caption{Three simple graphs}
\label{fig:three graphs}
\end{figure}
\end{document}