0

It seems \listoffigures does not work with \subfig. I do not receive an error, but compile is stoppped with the message ...amsfonts/umsb.fd. How to fix it?

\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}
Benben
  • 103
  • according to many resources (for instance http://tex.stackexchange.com/questions/13625/subcaption-vs-subfig-best-package-for-referencing-a-subfigure ) it is good practice tu use subcaptions instead of subfig. I personally changed to subcaption and the list of figures works for me. – bene Jan 30 '17 at 14:20
  • 1
    Your example works fine for me and I don't see where amsfonts should enter. Are you really compiling the code you are showing? If yes show the log-file. – Ulrike Fischer Jan 30 '17 at 14:46

2 Answers2

1

Normally one doesn't include subcaptions in the list of figures.

\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}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
0

I know you already got an answer, but {subfig} isn't really the best way nowadays you know. Better to replace it with {subcaption}. To give an example what I always use:

\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}

This gives something like (You can use it with the report-class if you don't want to replace it with scrreprt-class.):enter image description here