\listoffigures 不能与 \subfig 一起使用

\listoffigures 不能与 \subfig 一起使用

\listoffigures 似乎不能与 \subfig 一起使用。我没有收到错误,但编译停止并显示消息...amsfonts/umsb.fd。如何修复它?

\documentclass[12pt,twoside]{report} 
\usepackage{graphicx,subfig}    
\begin{document}

\listoffigures

\begin{figure}
\centering
\subfloat[sample A]{\includegraphics[width=0.48\textwidth]{./figure/a.png}}
\subfloat[sample B]{\includegraphics[width=0.48\textwidth]{./figure/n.png}}\\
\caption{Sample.}
\label{fig:sample}
\end{figure}

\end{document}

答案1

通常,图表列表中不包含子标题。

\documentclass[12pt,twoside]{report} 
\usepackage{graphicx,subfig}    
\begin{document}

\setcounter{lofdepth}{2}% include subcaptions
\listoffigures

\begin{figure}
\centering
\subfloat[sample A]{\includegraphics[width=0.48\textwidth]{example-image-a}}\hfil
\subfloat[sample B]{\includegraphics[width=0.48\textwidth]{example-image-b}}% automatic \par from \caption
\caption{Sample.}
\label{fig:sample}
\end{figure}

\end{document}

演示

答案2

我知道你已经有答案了,但你知道,{subfig} 现在并不是最好的方法。最好用 {subcaption} 代替它。举个例子,我经常使用:

\documentclass{scrreprt}%

\RequirePackage{graphicx}%
\RequirePackage[hypcap=true]{caption}%
\RequirePackage[list=true,hypcap=true]{subcaption}% list=true ... print in List of Figures
\RequirePackage{hyperref}%

\captionsetup{hypcap=true}% -- hyperref
\captionsetup{rule=false}% reset make@caption to KOMA-Script,%
\captionsetup[subtable]{labelformat=simple,labelsep=period,listformat=simple}%
\captionsetup[subfigure]{labelformat=simple,labelsep=period,listformat=simple}%
\captionsetup{format=plain}%
\makeatletter%
\renewcommand\p@subfigure{\thefigure.}%
\renewcommand\p@subtable{\thetable.}%
\makeatother%

\begin{document}%
    \chapter{Sample}%
    \label{chap:Sample}%
    \section{Sample section}%
    \label{sec:Sample:Sample section}%
    \begin{figure}[h]%
        \captionsetup{justification=centering}% raggedright, justified, ...
        \subcaptionbox{sample A\label{subfig:Sample:sample A}}{\includegraphics[width=0.48\textwidth]{example-image-a}}%
        \hfill%
        \subcaptionbox{sample B\label{subfig:Sample:sample B}}{\includegraphics[width=0.48\textwidth]{example-image-b}}%
        \caption{Sample}%
        \label{fig:Sample}%
    \end{figure}%
    \listoffigures%
\end{document}

这会产生类似的结果(如果您不想用 scrreprt-class 替换它,则可以将它与 report-class 一起使用。):在此处输入图片描述

相关内容