6

What's the best way to place a page-sized figure including the correct caption numbering on the facing page of a chapter opening page?

Correct numbering means: if I put the figure before the chapter, the numbering of the previous chapter is continued and the list of figures shows it belonging to the previous chapter. But I want to have it labeled 6.1 if the new chapter will be chapter 6.

Now I was thinking: Is there a way to use a caption(command) that will only be defined later? Is there a package that does something like this already?

In essence, something like this:

\cleartoevenpage{\thispagestyle{empty}}
\begin{figure}[p]
    \begin{sidecaption}{\theCaption}  % TODO: how?
        \includegraphics{image.jpg}
    \end{sidecaption}
\end{figure}

\chapter{Chapter Title}

\defineTheCaption

Or, if that is not possible, how can I manually label the figure as if belonging to the next chapter, with the correct entry in the lof file?

PS: I am using memoir. The kind of opposite thing seems possible with \newfixedcaption: it allows to place a caption on a page preceding a figure.

MiB
  • 837
  • 4
  • 10

2 Answers2

7

You can (and should) define a command doing the work, rather than explicitly set all those commands for each chapter.

My idea is to define a \chapterfigure command that has one optional argument and two mandatory ones; the optional argument and the first mandatory one are used for \includegraphics, while the final argument contains the caption.

The command steps the chapter counter, so the number for the figure will be correct; after the figure the counter is stepped back, so when \chapter is processed, the chapter number will be right; then we patch \memendofchapterhook so that it steps the figure counter (that would have been reset to zero by \chapter) and redefines itself to its previous value (usually nothing, but one never knows). Similarly, we issue \insertchapterspace, then redefine it to simply redefine itself to its previous value, so when the command is called by \chapter it does nothing else than putting us back to the original situation.

For a chapter without a facing figure, just issue \chapter by itself. A label for \chapterfigure should be in a trailing optional argument, to reflect the syntax of sidecaption; so

\chapterfigure[<options for includegraphics>] % optional
              {<graphic file name>}           % mandatory
              {<caption>}                     % mandatory
              [<label>]                       % optional

Here's a complete example

\documentclass{memoir}
\usepackage{xparse}
\usepackage[demo]{graphicx}

\NewDocumentCommand{\chapterfigure}{O{} m m o}{%
  \insertchapterspace
  \cleartoevenpage{\thispagestyle{empty}}
  \stepcounter{chapter}
  \begin{figure}[p]
  \IfNoValueTF{#4}
    {\begin{sidecaption}{#3}}
    {\begin{sidecaption}{#3}[#4]}
  \includegraphics[#1]{#2}
  \end{sidecaption}
  \end{figure}
  \addtocounter{chapter}{-1}
  \let\keptmemendofchapterhook\memendofchapterhook
  \renewcommand{\memendofchapterhook}{%
    \stepcounter{figure}%
    \keptmemendofchapterhook
    \let\memendofchapterhook\keptmemendofchapterhook}%
  \let\keptinsertchapterspace\insertchapterspace
  \renewcommand\insertchapterspace{%
    \let\insertchapterspace\keptinsertchapterspace}%
}

\begin{document}
\frontmatter
\tableofcontents
\listoffigures

\mainmatter

\chapterfigure[width=5cm,height=3cm]{somepic}
  {A caption for this figure}
% Here's how to call it if there's a label
%\chapterfigure[width=5cm,height=3cm]{somepic}
%  {A caption for this figure}[chapfig:one]

\chapter{A title for this chapter}

Some text

\begin{figure}[htp]
\centering
\includegraphics{xyz}
\caption{A caption to see it has the correct number}
\end{figure}

Some text

\end{document}

enter image description here

egreg
  • 1,121,712
  • yay, great code! I had to update my texlive because my memoir didn't have the hook yet. But this is very close to my dream solution. \addtocounter{chapter}{-1} is one key I didn't know yet. The second key, still missing in this solution, is how to add the space between figures of different chapters in the lof. memoir adds \addvspace{10pt} to the lof in \@chapter using \insertchapterspace. That is tricky because it has to be executed earlier, but it should not be duplicated. Any idea how to solve this, too? :) – MiB Oct 12 '13 at 23:17
  • no problem, we all have to sleep :) I have a second question for you while you are at it: why did you choose \stepcounter instead of \refstepcounter? I don't understand the difference, I only read that \refstepcounter changes the current \ref value, whatever that means... – MiB Oct 13 '13 at 09:03
  • @MiB Here's the new version. Please test it. With \refstepcounter we also set the current label, which is not needed here. – egreg Oct 13 '13 at 09:38
  • aha! now this is perfection, since you used latex3 and even provided for the optional sidecaption arg. Very smart, thank you very much! I will have to get used to this redefining commands to restore the old command :) – MiB Oct 13 '13 at 09:58
  • @egreg I realize this is a 9 year old question, but I'm trying to solve the same problem with the spacing in the LoF. How did you fix it? Using the code as posted in this answer I'm seeing incorrect spacing between the second figure of a chapter and the first figure of the following chapter. – Caleb George Mar 15 '22 at 21:16
  • @CalebGeorge I'm not sure what you mean. Does it have anything to do with placing a figure in the opposite page of where a chapter starts? There is always vertical space in the LOF for figures in different chapters. – egreg Mar 15 '22 at 21:28
  • @egreg Wish I could attach a screenshot of what I'm seeing. I have a chapter with 2 figures in it: one is a "chapter figure" as defined by your code. The other is at the end of the chapter. The following chapter also has a "chapter figure". The figures are numbered correctly but in the List of Figures, there is no vertical space between the second figure of chapter 1 and the first figure of chapter 2. – Caleb George Mar 15 '22 at 22:11
0

Here is a simple approach that I used (thanks to some hints here) to putting a landscape figure opposite a Chapter page, and numbering it as the first figure in that chapter:

% For viewing in Adobe Reader, don’t forget to set View> Page Display > Show Cover Page in Two-Page View 
\documentclass[draft,12pt,letterpaper,dvipsnames,svgnames,table,openright,twoside]{book} 
\usepackage{pdflscape} % Has landscape environment
\usepackage{graphicx}
\graphicspath{{./images/}}
\usepackage{caption}
\usepackage{lettrine}
\usepackage{calligra} 
\usepackage[nopar]{lipsum}

%
\begin{document} 
\renewcommand{\LettrineFontHook}{\calligra}
% PREFACE
\chapter*{Preface}
\lipsum[2-4]

% CHAPT 1
% \section[shortish TOC entry]{formatted chapter title} \sectionmark{short title for running headers}
\chapter{Dummy Chapter}
\lipsum[2-4]
%

% CHAPT 2
\makeatletter\@openrightfalse  %%%%
\newpage
\cleardoublepage\part[~STONE AGE]{STONE AGE}
%
% The following page is rotated 90-degrees clockwise in the pdf. 
% In the book it appears on the LHS, opposite the section “Chapter 16”
\stepcounter{chapter} 
\begin{landscape}
   \begin{figure}
      \captionsetup{width=1.20\textwidth}
      %\vspace{12pt} % To move picture further away from binding (odd page)
      \vspace{-36pt} % To move picture further away from binding (even page)
      \centering
      \includegraphics[width=6in]{US_Frequency_Allocations_Jan_2016_a.png}
      \caption[U.S. Electromagnetic Spectrum Frequency Allocations, October 2003]{U.S. Electromagnetic Spectrum usage from DC to 300 GHz}
      \scriptsize{\emph{Photo Credit: U.S. Government, Department of Commerce}}
      \label{figure:FCC_EM_Radio_Spectrum}
   \end{figure}
\end{landscape}
\addtocounter{chapter}{-1}
\newpage
% \section[shortish TOC entry]{formatted chapter title} \sectionmark{short title for running headers}
\chapter{2001: Welcome to Space \& Beyond!}
\label{section:DC2Daylight}
\@openrighttrue\makeatother 
% Body Text:
\lettrine[lines=3,lhang=0.33,lraise=0.0,loversize=0.30,slope=-16pt,findent=2.3em,nindent=-0.4em]{U}{\textbf{nknown Origins}} \lipsum[1-5] 
%
\end{document}
\endinput