以下代码可以按照您期望的方式进行编译和运行:
\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}
但是,当%\usepackage{hyperref}
取消注释时,会出现以下错误:
! 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!
\listoffigures
如果图中没有子浮点数,也不会发生错误。即使注释掉,也会发生错误。
备注:如果$\dag$
将 替换为$a$
,或将 替换为ABC
,则代码可以正常编译。似乎内存$\dag$
占用量存在一些问题,这对我来说很奇怪。
答案1
除了使用,subfig
您还可以使用subcaption
包裹:
\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}
顺便说一下,除了一些例外情况外,hyperref
应该是最后加载的包。
如果subcaption
无法切换到,则可以使用以下方法:
\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}
请注意我通过使用字符删除的虚假空格%
。