\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 一起使用。):在此輸入影像描述

相關內容