4

This is a follow up to here: https://tex.stackexchange.com/a/130629/32245

When I insert \usepackage{hyperref} as last line of the preamble. The main figure (or the two continued figures) are labeled as "0" but the sub-figures as "1a - 1h". Why is that so?

In the comments on the linked post, it is mentioned, that \usepackage[all]{hypcap} is not needed due to the caption-package loaded by subfig. However, I don't succeed to hyperlink to the top of all sub-figures instead of the caption on the second page. I even tried \usepackage[hypcap=true]{caption} before and after loading subfig.


% arara: pdflatex
% arara: pdflatex

\documentclass{article}
\usepackage[%
    ,demo
    ]{graphicx}
%\usepackage[hypcap=true]{caption}    
\usepackage{subfig}
%\usepackage{hyperref}

\begin{document}
\listoffigures
\begin{figure}[!htb] 
\centering   
\subfloat[][opt. caption]{\includegraphics[width=0.49\linewidth]{a}\label{fig:Figurea}} \hfill
\subfloat[][]{\includegraphics[width=0.49\linewidth]{b}\label{fig:Figureb}} \\
\subfloat[][]{\includegraphics[width=0.49\linewidth]{c}\label{fig:Figurec}} \hfill
\subfloat[][]{\includegraphics[width=0.49\linewidth]{d}\label{fig:Figured}}  \\ 
\subfloat[][]{\includegraphics[width=0.49\linewidth]{e}\label{fig:Figuree}} \hfill
\subfloat[][]{\includegraphics[width=0.49\linewidth]{f}\label{fig:Figuref}}    
\phantomcaption % for caption version 3.2 or higher. Not needed if not used with subfig.  
\end{figure}  
% The figure continues on the next page  
\begin{figure}  
\centering
\ContinuedFloat  
\subfloat[][opt. caption]{\includegraphics[width=0.49\linewidth]{g}\label{fig:Figureg}} \hfill
\subfloat[][]{\includegraphics[width=0.49\linewidth]{h}\label{fig:Figureh}}    
\caption{These are figures 1 a-h}  
\label{fig:fig1}  
\end{figure}  

This is figure \ref{fig:fig1} and its subfigure \ref{fig:Figureh}.
\end{document}
0
4

Your problem can be simplified a lot:

\documentclass{article}
\usepackage{caption}
\usepackage{subfig}
\usepackage{hyperref}

\begin{document}
\begin{figure}
\caption{abc}
\end{figure}

\begin{figure}
\ContinuedFloat
\caption{cde}
\end{figure}
\end{document}

I would put the blame on subfig (it redefines some important commands at the begin of the document and so breaks the \ContinuedFloat command) but probably only the author of caption can do something about it.

I personally would avoid subfig and use the subcaption package instead.

11
  • Thanks. I always do use subcaption. I only tried to help in the linked question where subfig is used and found that error there. I will provide a subcaption-answer now.
    – LaRiFaRi
    Sep 2 '13 at 11:42
  • The hypcap-functionality does not work for me. Maybe you could take a look at tex.stackexchange.com/a/130629/32245 . I would like to jump always to the top of the referenced figure or sub-figure. But it still jumps to the caption.
    – LaRiFaRi
    Sep 2 '13 at 11:54
  • 1
    It is not natural not to use a caption in the first figure. How should the reader know that the explanations will follow later? Sep 2 '13 at 14:07
  • 1
    @UlrikeFischer Unfortunately the way how figure and table counters are treated differs a lot between the caption and subfig package in current versions. (It's a pity that the subfig package is not maintained anymore.) But I'll see if I can do something to get this working again: sourceforge.net/p/latex-caption/tickets/16
    – user2574
    Sep 2 '13 at 18:58
  • 1
    @LaRiFaRi The top of the figure is only linked if a \label is following the \phantomcaption and if you are linking to that label. Why is the label not shared? First of all this would omit the opportunity to create a (hyper)link which is pointing to a specific part of the (continued) float. And second I (and Steven) simply did not thought about this ;-)
    – user2574
    Sep 2 '13 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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