Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following code compiles and acts as you would expect:

\documentclass[12pt]{report}

%\usepackage{hyperref}
\usepackage{subfig}

\begin{document}

\begin{figure}
\centering
\renewcommand{\thefigure}{$\dag$}
\subfloat[Sub-dagger]
{
\label{subfloat:first}
Hello there my good sport
}%
\qquad
\subfloat[Sub-dagger the other]
{
Hello again nice to see you
}
\caption{Daggered figure}
\label{fig:dag}
\end{figure}

Figure \ref{fig:dag} shows two things... one of them is sub-figure \ref{subfloat:first}.

\listoffigures

\end{document}

However, when %\usepackage{hyperref} is uncommented, the following error is given:

! TeX capacity exceeded, sorry [input stack size=5000].
\curr@fontshape ->\f@encoding 
                              /\f@family /\f@series /\f@shape 
l.11 \subfloat
              [Sub-dagger]
!  ==> Fatal error occurred, no output PDF file produced!

No error occurs if no subfloats are in the figure, either. The error occurs even if \listoffigures is commented out.

A remark: if $\dag$ is replaced by $a$, or by ABC, the code compiles fine. It seems like there is some issue with the amount of memory $\dag$ takes, which is strange to me.

share|improve this question
    
Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code as I did in my edit. –  doncherry Jun 11 '12 at 23:11

1 Answer 1

up vote 5 down vote accepted

Instead of using subfig you could use the subcaption package:

\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{hyperref}

\begin{document}

\begin{figure}
\centering
\renewcommand{\thefigure}{$\dag$}
\subcaptionbox{First subfigure\label{subfloat:first}}{Hello there my good sport}\qquad
\subcaptionbox{Second subfigure\label{subfloat:second}}{Hello again nice to see you}
\caption{Daggered figure}
\label{fig:dag}
\end{figure}

Figure \ref{fig:dag} shows two things... one of them is sub-figure \ref{subfloat:first}.

\listoffigures

\end{document}

enter image description here

On a side note, except for some exceptions, hyperref should be the last package to load.

If switching to subcaption is not an option, then you can use the following:

\documentclass[12pt]{report}
\usepackage{subfig}
\usepackage{hyperref}

\makeatletter
\newcommand\specialcaption[1]{%
  \@namedef{the\@captype}{#1}%
  \addtocounter{\@captype}{-1}\caption}
\makeatother

\begin{document}

\begin{figure}
\centering
\makeatletter
\def\p@subfigure{$\dag$} 
\makeatother
\subfloat[Sub-dagger]
{%
\label{subfloat:first}
Hello there my good sport
}%
\qquad
\subfloat[Sub-dagger the other]
{%
Hello again nice to see you
}
\specialcaption{$\dag$}{Daggered figure}
\label{fig:dag}
\end{figure}

Figure \ref{fig:dag} shows two things... one of them is sub-figure \ref{subfloat:first}.

\listoffigures

\end{document}

enter image description here

Notice the spurious blank spaces that I removed by using the % character.

share|improve this answer
    
My whole thesis is already formatted with subfig, and it is a daunting thought to go through and change all of it... do you know why this problem is happening? –  Andrey Jun 11 '12 at 23:22
    
@Andrey I see. Please see my updated answer for a work-around using subfig. –  Gonzalo Medina Jun 11 '12 at 23:27
    
@Andrey I had initially forgotten some code; now I've corrected the example. –  Gonzalo Medina Jun 11 '12 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.