Generalhyperref causing problems with \subfloat

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Zardoz
Posts: 8
Joined: Tue Apr 22, 2008 6:59 am

hyperref causing problems with \subfloat

Post by Zardoz »

I'm proofreading a large manuscript and to make document navigation easier I'm trying to add pdf bookmarks to the MS using hyperref. But when I add this command:

\usepackage[bookmarks=true,%
bookmarksopen=true,%
bookmarksnumbered=true,%
colorlinks=true,%
linkcolor=blue]{hyperref}


to the document preamble, I get this error:

! Use of \caption@@setkeys doesn't match its definition.
\text@command #1->\def \reserved@a {
#1}\ifx \reserved@a \@empty \let \check@...
l.10768 \subfloat
{


Does anyone have any suggestions?

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

hyperref causing problems with \subfloat

Post by gmedina »

Can you please post a minimal working example showing the undesired behaviour?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Zardoz
Posts: 8
Joined: Tue Apr 22, 2008 6:59 am

hyperref causing problems with \subfloat

Post by Zardoz »

Ok, here it is:
\documentclass[a4paper]{lloydbook}

\usepackage[bookmarks=true,%
bookmarksopen=true,%
bookmarksnumbered=true,%
colorlinks=true,%
linkcolor=blue]{hyperref}

\usepackage{subfig}

\makeatletter
\renewcommand{\thesubsection}{\thesection\@arabic\c@subsection}
\renewcommand{\thefigure}{\thesubsection\textit{\@alph\c@figure}}
\makeatother

\begin{document}

\begin{figure}[htbp]
\begin{center}
\subfloat{
\begin{tabular}[t]{r|ccc}
$\land$ & 1 & 2 & 3\\\hline
*1 & 1 & 2 & 3\\
2 & 2 & 2 & 3\\
3 & 3 & 3 & 3\\
\end{tabular}
}
\end{center}
\caption{{\L}ukasiewicz's 3-Valued Tables}
\label{orig_fig_2.11a}
\end{figure}

\end{document}

The problem disappears if I comment out the command
\renewcommand{\thefigure}{\thesubsection\textit{\@alph\c@figure}}
But what if I don't want to do that?
Zardoz
Posts: 8
Joined: Tue Apr 22, 2008 6:59 am

hyperref causing problems with \subfloat

Post by Zardoz »

Zardoz wrote:Ok, here it is:
\documentclass[a4paper]{lloydbook}
My apologies, I didn't provide the style file lloydbook.cls. But the problem is replicable with the standard book class.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

hyperref causing problems with \subfloat

Post by sommerfee »

The subfig package defines \theHsubfigure (the command which hyperref uses to build anchor names for sub-figures) in an "unlucky" way, because this definition is based upon \thefigure instead of \theHfigure. Since you change \thefigure, you have to adapt \theHsubfigure, too, to get rid of this dependency.

Just add

Code: Select all

\renewcommand\theHsubfigure{\theHfigure.\arabic{subfigure}}
*AFTER* \begin{document}.

(An alternative would be using the subcaption package instead of the subfig package, which hopefully has no problems with hyperref: http://www.ctan.org/tex-archive/macros/ ... b/caption/ . The very recent version 1.0 has also a \subfloat command inside which emulates the \subfloat command of the subfig package.)
Post Reply