0

I would like to use the hyperref package to highlight the citations and urls in blue in the text (\usepackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref}), as well as later using hyperref to link Figure citations to the corresponding figure page.

However, I use a custom figure environment to handle captions spanning multiple pages in case of large figures/large captions.

When I set the hyperref package, the captions that spanned multiple pages raise a warning

Package caption warning: The option 'hypcap=true' will be ignored for this particular \caption.

How can I concile large caption spanning multiple pages with package hyperref?

Here is my code:

\documentclass[12pts,openright,twoside]{report}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm, bindingoffset=6mm]{geometry}
\usepackage[font={small,sf}, singlelinecheck=false]{caption}
\usepackage{graphicx}
\graphicspath{{./fig/}}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\usepackage{natbib}
\bibliographystyle{apa}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref}

\begin{document}

\begin{center}
\includegraphics[width=\textwidth]{fig/chap2-workflow.pdf}
\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[My Figure Title.]{Very very large caption}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1
\label{workflow1}
\end{center}

\end{document}
1
  • You could try using \capstart from the hypcap package. Nov 27, 2019 at 16:47

1 Answer 1

1

The warning continues in the log with

See the caption package documentation for explanation.

And if search there for hypcap you will end in the section 6.5 hyperref which describes your options. One for example is to use \captionsetup and \caption instead of \captionof outside of a real float environment:

\documentclass[12pt,openright,twoside]{report}
\usepackage[font={small,sf}, singlelinecheck=false]{caption}
\usepackage{graphicx}
\usepackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref}

\begin{document}

\begin{center}
\captionsetup{type=figure}
\includegraphics[width=\textwidth]{example-image}
\caption[My Figure Title.]{Very very large caption}
\label{workflow1}
\end{center}

\end{document}
4
  • The solution isn't that trivial. Following your suggestion, the whole caption lies appart from the figure, on the next page, although it could have begun just below the figure. Your solution does not allow the caption to span on multiple pages.
    – KevinD
    Nov 27, 2019 at 10:13
  • 1
    Your example didn't compile and doesn't have a long caption. But \captionof{figure} instead of \caption should work too. For other options check the documentation. Nov 27, 2019 at 10:40
  • The issue has been raised in @WillAdler 's comments link but nobody could find a way to bypass this behavior.
    – KevinD
    Nov 27, 2019 at 11:32
  • The other question has nothing to do with the hyperref anchor but only with the question if caption can break over a page or not. Nov 27, 2019 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .