The fnbreak package

Harald Harders

                   h.harders@tu-bs.de

Version v1.10, 2004/04/06, Printed May 9, 2004

Abstract This package detects footnotes that are split over several pages. It writes a warning into the log file.

Contents

1 The user interface 1

2 The implementation 2

Copyright

Copyright 2003, 2004 Harald Harders.

This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives in directory macros/latex/base/lppl.txt; either version 1.3 of the License, or any later version.

1 The user interface

To use this package place

\usepackage{fnbreak}

in the preamble of your document.

If a footnote is split over a page break, a warning like the following is put into the log:

Package fnbreak Warning: Footnote number 1 (label `a')
(fnbreak)                has been split over different pages:
(fnbreak)                page 1 to page 2.

Sometimes, complicated footnote labels are used (for example, when using symbols):

Package fnbreak Warning: Footnote number 1 (label `\ensuremath {*}')
(fnbreak)                has been split over different pages:
(fnbreak)                page 1 to page 2.

In some cases may this even break the function. To avoid these problems, you may give the package option nolabel:

\usepackage[nolabel]{fnbreak}

Then the label is omitted in the warning:

Package fnbreak Warning: Footnote number 1
(fnbreak)                has been split over different pages:
(fnbreak)                page 1 to page 2.

When using the package option verbose the fnbreak package writes a message for every footnote, even if it is completely on one page.

2 The implementation

The approach of this package is very simple: At the begin and the end of each footnote text, the footnote number and current page are written to the aux file. Then, it is tested if both pages are the same for each footnote.

Heading of the package:

 1 ⟨package⟩\ProvidesPackage{fnbreak}
 2 ⟨version⟩\ProvidesFile{fnbreak-v.tex}
 3 ⟨package | version⟩ [2004/04/06  v1.10  Warning for pagebreak in footnote (HH)]

4 ⟨∗package⟩

Declare an option to show not only the footnote number but also the label.

 5 \newif\iffnb@showlabel
 6 \fnb@showlabeltrue
 7 \newif\iffnb@verbose
 8 \DeclareOption{nolabel}{\fnb@showlabelfalse}
 9 \DeclareOption{verbose}{\fnb@verbosetrue}
10 \ProcessOptions\relax

Define default values in order to avoid possible problems:

11 \xdef\fnb@@footnotestartnum{0}
12 \xdef\fnb@@footnotestartpage{0}

When the aux file is read the first time (before \begin{document}, do nothing:

13 \def\fnb@footnotestart#1#2#3{}
14 \def\fnb@footnoteend#1#2#3{}

Define the working commands at \begin{document} in order to activate them when the aux file is read at the end of the document:

15 \AtBeginDocument{%

If the start of a footnote has been found, just define commands containing the footnote number (only for debugging) and the start page:

16 \def\fnb@footnotestart#1#2#3{%
17  \xdef\fnb@@footnotestartnum{#1}%
18  \xdef\fnb@@footnotestartpage{#3}%
19 }%

If the end of a footnote has been found, test wheather the footnote numbers fit and wheather the start and end pages are the same. If one of the tests fails, generate a warning:^{1}

20 \def\fnb@footnoteend#1#2#3{%
21  \xdef\fnb@@footnoteendnum{#1}%
22  \xdef\fnb@@footnoteendpage{#3}%

Test if start and end refer to the same footnote.

23  \ifx\fnb@@footnotestartnum\fnb@@footnoteendnum

Test if the footnote ends on the same page it has started.

24  \ifx\fnb@@footnotestartpage\fnb@@footnoteendpage

Yes, the footnote is completely on one page. Print a message if verbose mode is requested.

25  \iffnb@verbose
26  \message{Package fnbreak: Footnote number #1
27  \iffnb@showlabel(label `#2') \fi^^J%
28  \space\space\space\space\space\space
29  \space\space\space\space\space\space
30  \space\space\space\space\space
31  completely on page #3.}%
32  \fi
33  \else

No, the footnote contains a pagebreak. Print a warning.

34  \PackageWarningNoLine{fnbreak}{Footnote number #1
35  \iffnb@showlabel(label `#2')\fi
36  \MessageBreak
37  has been split over different pages:\MessageBreak
38  page \fnb@@footnotestartpage\space to page #3}%

Redefine the \fnb@globalwarning to print a warning at the end of the log file.

39  \def\fnb@globalwarning{%
40  \PackageWarningNoLine{fnbreak}{There are footnotes with a
41  pagebreak.\MessageBreak
42  Check if they are acceptable}%
43  }%
44  \fi
45  \else

This macro trys to handle different footnotes. This may not happen and is an internal error.

1Thanks to Bastien Roucaries for pointing at a problem with symbol footnote marks.

46  \PackageError{fnbreak}{Internal problem:\MessageBreak
47  Start and stop marker of footnote do not fit:\MessageBreak
48  start: \fnb@@footnotestartnum, page \fnb@@footnotestartpage,
49  end: #1, page #3}{%
50  This error may not happen.
51  Please try to make a short example which shows this behaviour
52  and send a bug report to h.harders@tu-bs.de.}%
53  \fi
54  }%

55 }

Define command that writes the footnote start marker to the aux file:

56 \def\fnb@fnstart{\@bsphack
57  \protected@write\@auxout{}{%
58  \string\fnb@footnotestart{\the\c@footnote}{\thefootnote}{\thepage}%
59  }%
60  \@esphack

61 }

Define command that writes the footnote end marker to the aux file:

62 \def\fnb@fnend{\@bsphack
63  \protected@write\@auxout{}{%
64  \string\fnb@footnoteend{\the\c@footnote}{\thefootnote}{\thepage}%
65  }%
66  \@esphack

67 }

Redefine \@footnotetext by patching the calls \fnb@fnstart and \fnb@fnend

after all other packages have been loaded.^{2}

68 \AtBeginDocument{%
69 \newcommand\fnb@orig@footnotetext{}%
70 \let\fnb@orig@footnotetext\@footnotetext
71 \long\def\@footnotetext#1{\fnb@orig@footnotetext{\fnb@fnstart#1\fnb@fnend}}%

Append \fnb@globalwarning to \@dofilelist in order to print the global warning \fnb@globalwarning after all other messages, e.g., the \listfiles list.

72 \newcommand\fnb@dofilelist{}%
73 \let\fnb@dofilelist\@dofilelist
74 \def\@dofilelist{\fnb@dofilelist\fnb@globalwarning}%

75 }

Initialise \fnb@globalwarning to print no warning by default.

76 \newcommand\fnb@globalwarning{}%
77 \let\fnb@globalwarning\relax

78 ⟨/package⟩

2Thanks to Bastien Roucaries for that patch

Change History

0.01

General: First version . . . . . . . . . 1 1.00

General: Correct some internal macro names . . . . . . . . . . . . . 2 No need to have numerical page numbers anymore . . . . . . . . . . 3

Patch \@footnotetext instead of

re-writing it . . . . . . . . . . . . . . 4 Use the footnote number instead of the label, show both in the warning . . . . . . . . . . . . . . . . . 3

1.10

General: Add option ‘verbose’ … 2 Write a warning at the end of the log file . . . . . . . . . . . . . . . . . . 4

Index

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

Symbols

\@auxout . . . . . . . 57, 63 \@bsphack . . . . . . 56, 62

\@dofilelist . . . . 73, 74

\@esphack . . . . . . 60, 66

\@footnotetext . . 70, 71

A

\AtBeginDocument 15, 68

C

\c@footnote . . . . . 58, 64

D

\DeclareOption . . . 8, 9

E

\else . . . . . . . . . . 33, 45

F

\fi … 27, 32, 35, 44, 53

\fnb@@footnoteendnum

. . . . . . . . . 21, 23

\fnb@@footnoteendpage

. . . . . . . . . 22, 24

\fnb@@footnotestartnum

…. 11, 17, 23, 48

\fnb@@footnotestartpage

. 12, 18, 24, 38, 48

\fnb@dofilelist . 72–74
\fnb@fnend . . . . . 62, 71
\fnb@fnstart . . . . 56, 71
\fnb@footnoteend . .

. . . . . . . 14, 20, 64

\fnb@footnotestart .

. . . . . . . 13, 16, 58

\fnb@globalwarning .

…. 39, 74, 76, 77

\fnb@orig@footnotetext

. . . . . . . . . 69–71

\fnb@showlabelfalse . 8
\fnb@showlabeltrue . . 6
\fnb@verbosetrue . . . 9

I

\iffnb@showlabel . .

. . . . . . . 5, 27, 35

\iffnb@verbose . . . 7, 25

\ifx . . . . . . . . . . . 23, 24

L

\long . . . . . . . . . . . . 71

M

\message . . . . . . . . . 26

                          \MessageBreak . . . . .

. 36, 37, 41, 46, 47

N \newif . . . . . . . . . . 5, 7

P

                          \PackageError . . . . . 46
                          \PackageWarningNoLine

. . . . . . . . . 34, 40

                          \ProcessOptions . . . 10
                          \protected@write 57, 63
                          \ProvidesFile . . . . . . 2
                          \ProvidesPackage . . . 1

R \relax . . . . . . . . . 10, 77

S \string . . . . . . . . 58, 64

T \the . . . . . . . . . . . 58, 64

                          \thefootnote . . . . 58, 64

\thepage . . . . . . . 58, 64

X \xdef 11, 12, 17, 18, 21, 22