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.

I am using the \ContinuedFloat command of the subfig package to print a series of figures in more than one page. I would like to have one caption in the List of Figures and "compress" the pages so that only the first and the last are shown.

EDIT: Since I am using also the cleveref package, I would like to have a link for both the pages. So it should be 2 --> links to page 2, 3 --> links to page 3, and the hyphen that is a "neutral" symbol.

For example, what I get now is:

List of Figures

  1. A result that requires two pages. (cont.) 2
  2. A result that requires two pages 3

while I would like to have:

List of Figures

  1. A result that requires two pages 2-3

Here is the MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}

\listoffigures

\clearpage

\begin{figure}
\centering
\subfloat[][]{\includegraphics[scale=.9]{fig1}}
\\
\subfloat[][]{\includegraphics[scale=.9]{fig2}}
\caption{A result that requires two pages. \emph{(cont.)}}
\end{figure}

\begin{figure}
\ContinuedFloat
\centering
\subfloat[][]{\includegraphics[scale=.9]{fig3}}
\\
\subfloat[][]{\includegraphics[scale=.9]{fig4}}
\caption{A result that requires two pages.}
\end{figure}
\end{document}
share|improve this question
    
I think you meant hyperref and not cleveref? After all, hyperlinks are created by the former. –  Gonzalo Medina Apr 7 '12 at 3:46

2 Answers 2

up vote 7 down vote accepted

Simply use an empty optional argument for \caption in the continuation (and the optional argument in the first \caption if you want to get rid of "(cont)" in the list of figures):

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}

\listoffigures

\begin{figure}[!ht]
\centering
\subfloat[][]{\includegraphics[height=1cm]{fig1}}
\\
\subfloat[][]{\includegraphics[height=1cm]{fig2}}
\caption[A result that requires two pages.]{A result that requires two pages. \emph{(cont.)}}
\end{figure}

\begin{figure}
\ContinuedFloat
\centering
\subfloat[][]{\includegraphics[height=1cm]{fig3}}
\\
\subfloat[][]{\includegraphics[height=1cm]{fig4}}
\caption[]{A result that requires two pages.}
\end{figure}
\end{document}

enter image description here

I changed some of the settings so that the example will fit in just one page.

I originally didn't see the requirement concerning the page numbering in the LoF; here's now a solution:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subfig}

\def\myaddcontentsline#1#2#3{%
\addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage--\finalpage}}}

\gdef\finalatpage#1{\global\def\finalpage{#1}}
\finalatpage{0}
\makeatletter
\newcommand\MyCaption[1]{%
  \myaddcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}}
  \newcommand\savefinalpage{\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother}
\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \MyCaption{A result that requires two pages}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{A result that requires two pages.}
  \savefinalpage
\end{figure}

\end{document}

enter image description here

Now another version with the new requirements; in particular, it requires loading hyperref:

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

\makeatletter
\def\myaddcontentsline#1#2#3{%
\addtocontents{#1}{\protect\contentsline{#2}{#3}%
    {\protect\hyperlink{xyzs}{\thepage}--\protect\hyperlink{xyzf}{\finalpage}}{}}%
}%

\gdef\finalatpage#1{\gdef\finalpage{#1}}
\finalatpage{0}

\def\MyCaption#1{\hypertarget{xyzs}{}%
  \myaddcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}%
}

\def\savefinalpage{\hypertarget{xyzf}{}\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother
}
\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \MyCaption{A result that requires two pages}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{A result that requires two pages.}
  \savefinalpage
\end{figure}

\end{document}

A new version that improves the anchoring of the hyperlink for the continuation:

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

\makeatletter
\def\myaddcontentsline#1#2#3{%
\addtocontents{#1}{\protect\contentsline{#2}{\ignorespaces #3}%
    {\protect\hyperlink{xyzs}{\thepage}--\protect\hyperlink{xyzf}{\finalpage}}{}}%
}%

\gdef\finalatpage#1{\gdef\finalpage{#1}}
\finalatpage{0}

\def\MyCaption#1{\hypertarget{xyzs}{}%
  \myaddcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}%
}

\def\savefinalpage{\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother
}

\def\MyCaptionE#1{\caption[#1]{\hypertarget{xyzf}{#1}}%
  \savefinalpage
}

\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \MyCaption{A result that requires two pages}
\end{figure}

\clearpage\mbox{}\clearpage
\begin{figure}
  \caption{test}
\end{figure}
\begin{figure}[!b]
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \MyCaptionE{A result that requires two pages.}
\end{figure}

\end{document}

Remark:

These last two codes deserve some explanation but unfortunately right now I won't be able to provide it. As soon as I can I will do so.

share|improve this answer
    
Hi @Gonzalo, thanks for your reply. Unfortunately, your solution doesn't fulfill completely my request. If the first subfigure starts, say, at page 5 and the last one is at page 8, I want the List of Figures to explicitly report "5-8". With the code you proposed, it would write only the page of the first subfigure, that is "5". –  mp87 Apr 6 '12 at 18:16
    
@mp87: I am working on it. I'll let you know when I post an update. –  Gonzalo Medina Apr 6 '12 at 18:20
    
@mp87:please see my updated answer. –  Gonzalo Medina Apr 6 '12 at 19:34
    
Your solution is nice, but I need to use it in a document that is more complex than the example I provided. I'll update my first post to add more info. The problem I that your code writes this row inside the .lof file: \contentsline {figure}{\numberline {1}A result that requires two pages.}{2--4} while usually it should be: \contentsline {figure}{\numberline {1}{A result that requires two pages.}{2--4}{figure.caption.1} The second problem is that I would like to have a link to the two pages, that is 2 --> figure.caption.1, 4 --> figure.caption.2. –  mp87 Apr 6 '12 at 23:18
    
@mp87: see my updated answer. –  Gonzalo Medina Apr 7 '12 at 3:45

@Gonzalo: Sorry for the late answer. I hacked a bit your code, and I finally found a satisfying solution. I report it here, in the hope that can be helpful to someone else.

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

\makeatletter
\def\myaddcontentsline#1#2#3#4#5{%
\addtocontents{#1}{\protect\contentsline{#2}{#3}%
    {\protect\hyperref[#4]{\thepage}--\protect\hyperref[#5]{\finalpage}}{}}%
}

\gdef\finalatpage#1{\gdef\finalpage{#1}}
\finalatpage{0}

\def\MyCaption#1#2#3{%
  \myaddcontentsline{lof}{figure}{\protect\numberline{\thefigure}{\ignorespaces #1\relax }}{#2}{#3}%
}

\def\savefinalpage{\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother
}
\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \label{fig:part1}
  \MyCaption{A result that requires two pages}{fig:part1}{fig:part2}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{A result that requires two pages.}
  \label{fig:part2}
  \savefinalpage
\end{figure}

\end{document}

Basically I substituted the hypertarget command with hyperref and introduced the target objects in the definition of myaddcontentsline. I know that this solution is pretty rough, so please let me know if it is possible to improve it.

Edit:

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

\makeatletter
\gdef\finalatpage#1{\gdef\finalpage{#1}}
\finalatpage{0}
\gdef\finalatpagei#1{\gdef\finalpagei{#1}}
\finalatpagei{0}

\def\MyCaption#1#2#3#4{%
\addtocontents{lof}{\protect\contentsline{figure}{#1}%
    {\protect\hyperref[#2]{\thepage}--\protect\hyperref[#3]{#4}}{}}%
}

\def\savefinalpage{\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother
}
\def\savefinalpagei{\makeatletter
  \write\@auxout{\protect\finalatpagei{\arabic{page}}}
  \makeatother
}
\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \label{fig:part1}
  \MyCaption{A result that requires two pages}{fig:part1}{fig:part2}{\finalpage}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{A result that requires two pages.}
  \label{fig:part2}
  \savefinalpage
\end{figure}

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \label{fig:part3}
  \MyCaption{Another result that requires two pages}{fig:part3}{fig:part4}{\finalpagei}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{Another result that requires two pages.}
  \label{fig:part4}
  \savefinalpagei
\end{figure}

\end{document}

Edit:

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

\makeatletter
\gdef\finalatpage#1{\gdef\finalpage{#1}}
\finalatpage{0}
\gdef\finalatpagei#1{\gdef\finalpagei{#1}}
\finalatpagei{0}

\def\MyCaption#1#2#3#4{%
\addtocontents{lof}{\protect\contentsline{figure}{\protect\numberline{\thefigure}{\ignorespaces #1\relax}}%
    {\protect\hyperref[#2]{\thepage}--\protect\hyperref[#3]{#4}}{}}%
}

\def\savefinalpage{\makeatletter
  \write\@auxout{\protect\finalatpage{\arabic{page}}}
  \makeatother
}
\def\savefinalpagei{\makeatletter
  \write\@auxout{\protect\finalatpagei{\arabic{page}}}
  \makeatother
}
\makeatother

\begin{document}

\listoffigures

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \label{fig:part1}
  \MyCaption{A result that requires two pages}{fig:part1}{fig:part2}{\finalpage}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{A result that requires two pages.}
  \label{fig:part2}
  \savefinalpage
\end{figure}

\clearpage

\begin{figure}
  \captionsetup{list=no}
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig1}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig2}}
  \caption{A result that requires two pages. \emph{(cont.)}}
  \label{fig:part3}
  \MyCaption{Another result that requires two pages}{fig:part3}{fig:part4}{\finalpagei}
\end{figure}

\clearpage\mbox{}\clearpage

\begin{figure}
  \captionsetup{list=no}
  \ContinuedFloat
  \centering
  \subfloat[][]{\includegraphics[height=1cm]{fig3}}\\
  \subfloat[][]{\includegraphics[height=1cm]{fig4}}
  \caption{Another result that requires two pages.}
  \label{fig:part4}
  \savefinalpagei
\end{figure}

\end{document}
share|improve this answer
    
I spoke too soon, there is a problem with the counter defined by savefinalpage. Since I am using the code twice, in the second case \finalpage is overwritten, and I find it twice in the List of Figures. So what I find is something like: 1. Figure 1. A results that requires two pages 2-7 2. Figure 2. A results that requires other two pages 6-7 while the Figure 1 is covering pages 2 and 3. –  mp87 Apr 12 '12 at 17:07
    
In the edit to your answer I've provided perhaps not the most elegant solution (it duplicates definitions), but it will produce the desired output. When I have some time I'll try to improve it. –  Gonzalo Medina Apr 16 '12 at 0:34
    
@GonzaloMedina: Thank you! It doesn't matter if it's not elegant, it works like a charm! P.S. I improved slightly the definition of MyCaption. –  mp87 Apr 16 '12 at 15:04

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.