Graphics, Figures & Tableslof doesn't like subfig captions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
poormans
Posts: 3
Joined: Sun Sep 12, 2010 10:18 pm

lof doesn't like subfig captions

Post by poormans »

I am compiling my thesis using latex/bibtex/latex/latex and all the subfigures return this error:

Code: Select all

! Package caption Error: No float type 'subfloat' defined.
See the caption package documentation for explanation.
Type H <return> for immediate help.
...
l.54 ...{\ignorespaces Programmable counter.}}{28}
If you do not understand this error, please take a closer look
at the documentation of the `caption' package, especially the
section about errors.
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
I have the subfig and caption packages included. I use TexMaker in Windows XP with MiKTeX (latest versions of both). When I check the .lof file the offending lines all start with \contentsline {subfigure} instead of \contentsline {figure}. I don't know how to debug or workaround this error, other than compiling in terminal and pressing Enter at each error. Any advice? Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

lof doesn't like subfig captions

Post by gmedina »

Hi,

without the actual code it's hard to guess what the problem could be. Reduce your code to a minimal working example allowing us to reproduce the error.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
poormans
Posts: 3
Joined: Sun Sep 12, 2010 10:18 pm

Re: lof doesn't like subfig captions

Post by poormans »

Example uploaded here: https://www.yousendit.com/dl?phi_action ... NVZjR0E9PQ . Compile using

latex ryesample.tex
bibtex ryesample
latex ryesample
latex ryesample
dvipdfm ryesample.dvi

The error occurs at the second latex command. When 'nolof' is added to the documentclass argument, the document compiles fine.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: lof doesn't like subfig captions

Post by gmedina »

You are using a custom made document class. In this cases the best thing to do is to contact the class author.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

lof doesn't like subfig captions

Post by sommerfee »

I got this minimal working example by reducing your code:

Code: Select all

\documentclass{ryethesis}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subfig}

\author{Norm Macdonald}
\title{Sample}
\degreeName{Doctor of Philosophy}
\degreeYear{1847}
\program{Degree Name}
\partnerUniversity{Hogwarts University}

\begin{document}

    \chapter{Norm Macdonald}
        \label{CHAPTER_3}

\begin{figure}[!h]
  \centering
  \subfloat[Norm Macdonald 1.]{\label{norm1}\includegraphics[width=0.25\textwidth]{norm1}}\hfill
  \subfloat[Norm Macdonald 2.]{\label{norm2}\includegraphics[width=0.25\textwidth]{norm2}}  \\
  \subfloat[Norm Macdonald 3.]{\label{norm3}\includegraphics[width=0.35\textwidth]{norm3}}  
  \caption{Norm Macdonald.}
  \label{vco}
\end{figure}

\end{document}
By inserting the code of ryethesis.cls into the document and doing further reduction I was able to remove the usage of the ryethesis class but still producing the error:

Code: Select all

\documentclass{book}
\AtBeginDocument{\listoffigures}

\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subfig}

\author{Norm Macdonald}
\title{Sample}

\begin{document}

    \chapter{Norm Macdonald}
        \label{CHAPTER_3}

\begin{figure}[!h]
  \centering
  \subfloat[Norm Macdonald 1.]{\label{norm1}\includegraphics[width=0.25\textwidth]{norm1}}\hfill
  \subfloat[Norm Macdonald 2.]{\label{norm2}\includegraphics[width=0.25\textwidth]{norm2}}  \\
  \subfloat[Norm Macdonald 3.]{\label{norm3}\includegraphics[width=0.35\textwidth]{norm3}}  
  \caption{Norm Macdonald.}
  \label{vco}
\end{figure}

\end{document}
It seems that the subfig package does not like the \listoffigures inside \AtBeginDocument prior loading the subfig package, but this is what the ryethesis document class does. Since this is totally legal code it looks like a bug in the subfig package for me.

The only workaround which comes into my mind is replacing the subfig package with my subcaption package:

Code: Select all

\documentclass{ryethesis}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\author{Norm Macdonald}
\title{Sample}
\degreeName{Doctor of Philosophy}
\degreeYear{1847}
\program{Degree Name}
\partnerUniversity{Hogwarts University}

\begin{document}

    \chapter{Norm Macdonald}
        \label{CHAPTER_3}

\begin{figure}[!h]
  \centering
  \subfloat[Norm Macdonald 1.\label{norm1}]{\includegraphics[width=0.25\textwidth]{norm1}}\hfill
  \subfloat[Norm Macdonald 2.\label{norm2}]{\includegraphics[width=0.25\textwidth]{norm2}}  \\
  \subfloat[Norm Macdonald 3.\label{norm3}]{\includegraphics[width=0.35\textwidth]{norm3}}  
  \caption{Norm Macdonald.}
  \label{vco}
\end{figure}

\end{document}
(Please note the different \label placement inside the subfigures.)

This seems to work without problems.

Axel
poormans
Posts: 3
Joined: Sun Sep 12, 2010 10:18 pm

Re: lof doesn't like subfig captions

Post by poormans »

Thanks for looking into this Axel, I will try as you suggested.
Post Reply