| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: fnbreak.dtx |
| 4 |
% Copyright © 2003, 2004, 2006, 2010, 2012, 2023 Harald Harders (inactive) |
| 5 |
% (2023-03-18 update done by H.-Martin Münch, Martin.Muench AT Uni-Bonn.de) |
| 6 |
% Info: Warning for pagebreak in footnote (HH) |
| 7 |
% \fi |
| 8 |
% |
| 9 |
% \iffalse |
| 10 |
% |
| 11 |
%<*driver> |
| 12 |
\documentclass{ltxdoc} |
| 13 |
\title{The \texttt{fnbreak} package} |
| 14 |
\author{Harald Harders\\\texttt{[email protected]}\\(inactive)} |
| 15 |
\date{Version \fileversion, \filedate, Printed \today} |
| 16 |
\EnableCrossrefs |
| 17 |
\CodelineIndex |
| 18 |
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter} |
| 19 |
\DoNotIndex{\setcounter,\space,\ifx,\else,\fi} |
| 20 |
\CodelineNumbered |
| 21 |
\RecordChanges |
| 22 |
\IfFileExists{fnbreak-v.tex}{% |
| 23 |
\input{fnbreak-v.tex} |
| 24 |
\GetFileInfo{fnbreak-v.tex} |
| 25 |
}{% |
| 26 |
\PackageError{fnbreak}{File fnbreak-v.tex not found, |
| 27 |
please\MessageBreak |
| 28 |
run `latex fnbreak.ins' first}{No additional help}% |
| 29 |
\def\fileversion{\textbf{??}}% |
| 30 |
\def\filedate{\textbf{??}}% |
| 31 |
} |
| 32 |
\begin{document} |
| 33 |
\DocInput{fnbreak.dtx} |
| 34 |
\end{document} |
| 35 |
%</driver> |
| 36 |
% \fi |
| 37 |
% |
| 38 |
% \changes{0.01}{2003/04/03}{First version} |
| 39 |
% |
| 40 |
% \maketitle |
| 41 |
% \begin{abstract} |
| 42 |
% \noindent This package detects footnotes that are split over several |
| 43 |
% pages. It writes a warning into the log file. |
| 44 |
% \end{abstract} |
| 45 |
% |
| 46 |
% \tableofcontents |
| 47 |
% |
| 48 |
% \section*{Copyright} |
| 49 |
% Copyright 2003, 2004, 2006, 2010, 2012, 2023 Harald Harders. |
| 50 |
% |
| 51 |
% This program can be redistributed and/or modified under the terms |
| 52 |
% of the LaTeX Project Public License Distributed from CTAN |
| 53 |
% archives in directory macros/latex/base/lppl.txt; either |
| 54 |
% version 1.3c of the License, or any later version. |
| 55 |
% |
| 56 |
% \section{The user interface} |
| 57 |
% |
| 58 |
% To use this package place |
| 59 |
%\begin{verbatim} |
| 60 |
%\usepackage{fnbreak} |
| 61 |
%\end{verbatim} |
| 62 |
% in the preamble of your document. |
| 63 |
% |
| 64 |
% If a footnote is split over a page break, a warning like the |
| 65 |
% following is put into the log: |
| 66 |
%\begin{verbatim} |
| 67 |
%Package fnbreak Warning: Footnote number 1 |
| 68 |
%(fnbreak) (label `a') |
| 69 |
%(fnbreak) has been split over different pages: |
| 70 |
%(fnbreak) page 1 to page 2. |
| 71 |
%\end{verbatim} |
| 72 |
% Sometimes, complicated footnote labels are used (for example, when |
| 73 |
% using symbols): |
| 74 |
% \pagebreak |
| 75 |
% |
| 76 |
%\begin{verbatim} |
| 77 |
%Package fnbreak Warning: Footnote number 1 |
| 78 |
%(fnbreak) (label `\ensuremath {*}') |
| 79 |
%(fnbreak) has been split over different pages: |
| 80 |
%(fnbreak) page 1 to page 2. |
| 81 |
%\end{verbatim} |
| 82 |
% In some cases complex footnote labels may prevent |fnbreak| from |
| 83 |
% functioning. |
| 84 |
% \begin{macro}{nolabel} |
| 85 |
% \begin{macro}{label} |
| 86 |
% To avoid these problems, you may give the package option |nolabel|: |
| 87 |
%\begin{verbatim} |
| 88 |
%\usepackage[nolabel]{fnbreak} |
| 89 |
%\end{verbatim} |
| 90 |
% Then the label is omitted in the warning: |
| 91 |
%\begin{verbatim} |
| 92 |
%Package fnbreak Warning: Footnote number 1 |
| 93 |
%(fnbreak) has been split over different pages: |
| 94 |
%(fnbreak) page 1 to page 2. |
| 95 |
%\end{verbatim} |
| 96 |
% \end{macro} |
| 97 |
% \end{macro} |
| 98 |
% |
| 99 |
% \begin{macro}{\fnbreaknolabel} |
| 100 |
% \begin{macro}{\fnbreaklabel} |
| 101 |
% You may switch on and off printing of the footnote label in the |
| 102 |
% warnings also by using the macros \cs{fnbreaknolabel} and \cs{fnbreaklabel}. |
| 103 |
% \end{macro} |
| 104 |
% \end{macro} |
| 105 |
% |
| 106 |
% If the document is set two-sided, fnbreak tries to determine whether |
| 107 |
% the footnote spans over a double page or flipsides. |
| 108 |
% The result is shown in the warning: |
| 109 |
%\begin{verbatim} |
| 110 |
%Package fnbreak Warning: Footnote number 1 |
| 111 |
%(fnbreak) has been split over different pages (flipsides): |
| 112 |
%(fnbreak) page 1 to page 2. |
| 113 |
%\end{verbatim} |
| 114 |
% or: |
| 115 |
%\begin{verbatim} |
| 116 |
%Package fnbreak Warning: Footnote number 1 |
| 117 |
%(fnbreak) has been split over different pages (double page): |
| 118 |
%(fnbreak) page 2 to page 3. |
| 119 |
%\end{verbatim} |
| 120 |
% This only works if the page numbers are (arabic) numerical. |
| 121 |
% |
| 122 |
% \begin{macro}{verbose} |
| 123 |
% \begin{macro}{nonverbose} |
| 124 |
% When using the package option |verbose| the fnbreak package writes a |
| 125 |
% message for every footnote, even if it is completely on one page: |
| 126 |
%\begin{verbatim} |
| 127 |
%\usepackage[verbose]{fnbreak} |
| 128 |
%\end{verbatim} |
| 129 |
% The output looks as follows: |
| 130 |
%\begin{verbatim} |
| 131 |
%Package fnbreak Note: Footnote number 2 |
| 132 |
%(fnbreak) (label `2') |
| 133 |
%(fnbreak) completely on page 3. |
| 134 |
%\end{verbatim} |
| 135 |
% \end{macro} |
| 136 |
% \end{macro} |
| 137 |
% |
| 138 |
% \begin{macro}{\fnbreaknonverbose} |
| 139 |
% \begin{macro}{\fnbreakverbose} |
| 140 |
% You may switch on and off printing footnote information for |
| 141 |
% non-split footnotes using the macros \cs{fnbreaknonverbose} and |
| 142 |
% \cs{fnbreakverbose}. |
| 143 |
% \end{macro} |
| 144 |
% \end{macro} |
| 145 |
% |
| 146 |
% \StopEventually{\PrintChanges \PrintIndex} |
| 147 |
% |
| 148 |
% \pagebreak |
| 149 |
% \section{The implementation} |
| 150 |
% |
| 151 |
% The approach of this package is very simple: |
| 152 |
% At the begin and the end of each footnote text, the footnote number |
| 153 |
% and current page are written to the aux file. Then, it is tested if |
| 154 |
% both pages are the same for each footnote. |
| 155 |
% |
| 156 |
% Heading of the package: |
| 157 |
% \begin{macrocode} |
| 158 |
%<package>\NeedsTeXFormat{LaTeX2e}[2017/04/15] |
| 159 |
%<package>\ProvidesPackage{fnbreak} |
| 160 |
%<version>\ProvidesFile{fnbreak-v.tex} |
| 161 |
%<package|version> [2023-03-18 v1.40 Warning for pagebreak in footnote (HH)] |
| 162 |
%<*package> |
| 163 |
% \end{macrocode} |
| 164 |
% Declare an option to show not only the footnote number but also the |
| 165 |
% label. |
| 166 |
% \changes{1.11}{2006/05/08}{Allow commands in page number}% |
| 167 |
% \begin{macrocode} |
| 168 |
|
| 169 |
\RequirePackage{ifthen} |
| 170 |
|
| 171 |
% \end{macrocode} |
| 172 |
% Declare an option to show not only the footnote number but also the |
| 173 |
% label. |
| 174 |
% \changes{1.10}{2004/04/06}{Add option `verbose'}% |
| 175 |
% \changes{1.30}{2012/01/01}{Add options `nonverbose' and `label'}% |
| 176 |
% \begin{macrocode} |
| 177 |
\newif\iffnb@showlabel |
| 178 |
\newif\iffnb@verbose |
| 179 |
|
| 180 |
\DeclareOption{label}{\fnb@showlabeltrue} |
| 181 |
\DeclareOption{nolabel}{\fnb@showlabelfalse} |
| 182 |
\DeclareOption{verbose}{\fnb@verbosetrue} |
| 183 |
\DeclareOption{nonverbose}{\fnb@verbosefalse} |
| 184 |
\ExecuteOptions{label,nonverbose} |
| 185 |
\ProcessOptions\relax |
| 186 |
|
| 187 |
% \end{macrocode} |
| 188 |
% \begin{macro}{\fnbreakverbose} |
| 189 |
% \begin{macro}{\fnbreaknonverbose} |
| 190 |
% Switch on or off verbose printing of footnotes. |
| 191 |
% \begin{macrocode} |
| 192 |
\newcommand*\fnbreakverbose{\fnb@verbosetrue} |
| 193 |
\newcommand*\fnbreaknonverbose{\fnb@verbosefalse} |
| 194 |
% \end{macrocode} |
| 195 |
% \end{macro} |
| 196 |
% \end{macro} |
| 197 |
% \begin{macro}{\fnbreaklabel} |
| 198 |
% \begin{macro}{\fnbreaknolabel} |
| 199 |
% Switch on or off printing of footnote labels in the warnings. |
| 200 |
% \begin{macrocode} |
| 201 |
\newcommand*\fnbreaklabel{\fnb@showlabeltrue} |
| 202 |
\newcommand*\fnbreaknolabel{\fnb@showlabelfalse} |
| 203 |
|
| 204 |
% \end{macrocode} |
| 205 |
% \end{macro} |
| 206 |
% \end{macro} |
| 207 |
% Define new counter and boolean for determining whether a split |
| 208 |
% footnote spans over a double page or flipsides. |
| 209 |
% \changes{1.20}{2010/08/09}{Distinguish between split over double |
| 210 |
% page or flipsides}% |
| 211 |
% \begin{macrocode} |
| 212 |
\newcounter{fnb@@numberpages} |
| 213 |
|
| 214 |
\newif\iffnb@@isdoublepage |
| 215 |
|
| 216 |
% \end{macrocode} |
| 217 |
% Define default values in order to avoid possible problems: |
| 218 |
% \changes{1.00}{2004/04/01}{Correct some internal macro names}% |
| 219 |
% \begin{macrocode} |
| 220 |
\xdef\fnb@@footnotestartnum{0} |
| 221 |
\xdef\fnb@@footnotestartpage{0} |
| 222 |
\def\fnb@globalwarning{} |
| 223 |
% \end{macrocode} |
| 224 |
% When the aux file is read the first time (before \cs{begin\{document\}}, |
| 225 |
% do nothing: |
| 226 |
% \begin{macrocode} |
| 227 |
\def\fnb@footnotestart#1#2#3{} |
| 228 |
\def\fnb@footnoteend#1#2#3{} |
| 229 |
|
| 230 |
% \end{macrocode} |
| 231 |
% Define command that writes the footnote start marker to the aux |
| 232 |
% file: |
| 233 |
% \begin{macrocode} |
| 234 |
\def\fnb@fnstart{\@bsphack |
| 235 |
\protected@write\@auxout{}{% |
| 236 |
\string\fnb@footnotestart{\the\c@footnote}{\thefootnote}{\thepage}% |
| 237 |
}% |
| 238 |
\@esphack% |
| 239 |
} |
| 240 |
|
| 241 |
% \end{macrocode} |
| 242 |
% Define command that writes the footnote end marker to the aux file: |
| 243 |
% \begin{macrocode} |
| 244 |
\def\fnb@fnend{\@bsphack |
| 245 |
\protected@write\@auxout{}{% |
| 246 |
\string\fnb@footnoteend{\the\c@footnote}{\thefootnote}{\thepage}% |
| 247 |
}% |
| 248 |
\@esphack% |
| 249 |
} |
| 250 |
|
| 251 |
% \end{macrocode} |
| 252 |
% Provide the command \cs{IfFormatAtLeastTF} for old \LaTeX-formats |
| 253 |
% which did not know it yet: |
| 254 |
% |
| 255 |
% \begin{macrocode} |
| 256 |
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} |
| 257 |
|
| 258 |
% \end{macrocode} |
| 259 |
% Define the working commands at \cs{begin\{document\}} in order to |
| 260 |
% activate them when the aux file is read at the end of the document: |
| 261 |
% \begin{macrocode} |
| 262 |
\AtBeginDocument{% = \AddToHook{begindocument} |
| 263 |
% \end{macrocode} |
| 264 |
% If the start of a footnote has been found, just define commands |
| 265 |
% containing the footnote number (only for debugging) and the start page: |
| 266 |
% \changes{1.11}{2006/05/08}{Allow commands in page number}% |
| 267 |
% \begin{macrocode} |
| 268 |
\def\fnb@footnotestart#1#2#3{% |
| 269 |
\xdef\fnb@@footnotestartnum{#1}% |
| 270 |
\gdef\fnb@@footnotestartpage{#3}% |
| 271 |
}% |
| 272 |
% \end{macrocode} |
| 273 |
% \changes{1.00}{2004/04/01}{No need to have numerical page numbers |
| 274 |
% anymore}% |
| 275 |
% \changes{1.00}{2004/04/01}{Use the footnote number instead of the |
| 276 |
% label, show both in the warning}% |
| 277 |
% If the end of a footnote has been found, test whether the footnote |
| 278 |
% numbers fit and whether the start and end pages are the same. If |
| 279 |
% one of the tests fails, generate a warning:\footnote{Thanks to |
| 280 |
% Bastien Roucaries for pointing at a problem with symbol footnote |
| 281 |
% marks.} |
| 282 |
% \begin{macrocode} |
| 283 |
\def\fnb@footnoteend#1#2#3{% |
| 284 |
\xdef\fnb@@footnoteendnum{#1}% |
| 285 |
\def\fnb@@footnoteendpage{#3}% |
| 286 |
% \end{macrocode} |
| 287 |
% Test if start and end refer to the same footnote. |
| 288 |
% \begin{macrocode} |
| 289 |
\ifx\fnb@@footnotestartnum\fnb@@footnoteendnum% |
| 290 |
% \end{macrocode} |
| 291 |
% Test if the footnote ends on the same page it has started. |
| 292 |
% \changes{1.11}{2006/05/08}{Allow commands in page number}% |
| 293 |
% \begin{macrocode} |
| 294 |
\ifthenelse{\equal{\fnb@@footnotestartpage}{\fnb@@footnoteendpage}}{% |
| 295 |
% \end{macrocode} |
| 296 |
% Yes, the footnote is completely on one page. |
| 297 |
% Print a message if |verbose| mode is requested. |
| 298 |
% Simulate a variant of \cs{PackageInfo} which is also written to the |
| 299 |
% output rather than only to the log file. |
| 300 |
% \changes{1.30}{2012/01/01}{Fix verbose mode for non-numeric labels} |
| 301 |
% \pagebreak |
| 302 |
% \begin{macrocode} |
| 303 |
\iffnb@verbose% |
| 304 |
\begingroup% |
| 305 |
\def\MessageBreak{^^J(fnbreak)\@spaces\@spaces\@spaces\@spaces}% |
| 306 |
\set@display@protect% |
| 307 |
\immediate\write\@unused{^^JPackage fnbreak Note:% |
| 308 |
\space\space\space\space Footnote number #1% |
| 309 |
\iffnb@showlabel\MessageBreak (label `#2') \fi% |
| 310 |
\MessageBreak% |
| 311 |
completely on page #3.^^J}% |
| 312 |
\endgroup% |
| 313 |
\fi% |
| 314 |
}{% |
| 315 |
% \end{macrocode} |
| 316 |
% No, the footnote contains a pagebreak. |
| 317 |
% |
| 318 |
% If the page labels are plain (arabic) numbers we can determine whether a |
| 319 |
% footnote spans over a double page or a flipside.\footnote{Thanks to |
| 320 |
% H.-Martin Münch for the idea of determining double pages.} |
| 321 |
% \changes{1.20}{2010/08/09}{Distinguish between split over double |
| 322 |
% page or flipsides}% |
| 323 |
% |fnb@@numberpages = 0| is used if the code cannot find out whether a |
| 324 |
% footnote spans over a double page (i.\,e., for non-integer page |
| 325 |
% numbers or single-sided documents). |
| 326 |
% \begin{macrocode} |
| 327 |
\setcounter{fnb@@numberpages}{0}% |
| 328 |
% \end{macrocode} |
| 329 |
% Do the effort only if the document is two-sided. |
| 330 |
% This code requised the boolean \cs{if@twoside} to be defined. |
| 331 |
% If this is not the case please report to the author including a |
| 332 |
% minimal example file. |
| 333 |
% \begin{macrocode} |
| 334 |
\if@twoside% |
| 335 |
% \end{macrocode} |
| 336 |
% We can find double pages only if the start page as well as the end |
| 337 |
% page are numbers. |
| 338 |
% \begin{macrocode} |
| 339 |
\ifnum\number0<0\fnb@@footnoteendpage{}% |
| 340 |
\ifnum\number0<0\fnb@@footnotestartpage{}% |
| 341 |
% \end{macrocode} |
| 342 |
% Calculate the number of pages covered by the footnote. If it is more |
| 343 |
% than two, a flipside occurs anyways. |
| 344 |
% \begin{macrocode} |
| 345 |
\setcounter{fnb@@numberpages}{\fnb@@footnoteendpage}% |
| 346 |
\addtocounter{fnb@@numberpages}{-\fnb@@footnotestartpage}% |
| 347 |
\addtocounter{fnb@@numberpages}{1}% |
| 348 |
% \end{macrocode} |
| 349 |
% If the footnote starts on an odd page, flipside occurs in any case. |
| 350 |
% \begin{macrocode} |
| 351 |
\ifodd \fnb@@footnotestartpage{}% |
| 352 |
\fnb@@isdoublepagefalse% |
| 353 |
% \end{macrocode} |
| 354 |
% If the footnote starts on an odd page, a double page is found if the |
| 355 |
% number of pages equals two. |
| 356 |
% \begin{macrocode} |
| 357 |
\else% |
| 358 |
\ifnum \thefnb@@numberpages=2{}% |
| 359 |
\fnb@@isdoublepagetrue% |
| 360 |
% \end{macrocode} |
| 361 |
% If the number of pages is larger, flipside. |
| 362 |
% \begin{macrocode} |
| 363 |
\else% |
| 364 |
\fnb@@isdoublepagefalse% |
| 365 |
\fi% |
| 366 |
\fi% |
| 367 |
\fi% |
| 368 |
\fi% |
| 369 |
\fi% |
| 370 |
% \end{macrocode} |
| 371 |
% Print a warning. |
| 372 |
% |
| 373 |
% \noindent If not determined whether a double page occurs: |
| 374 |
% \begin{macrocode} |
| 375 |
\ifnum\thefnb@@numberpages=0% |
| 376 |
\PackageWarningNoLine{fnbreak}{Footnote number #1% |
| 377 |
\iffnb@showlabel\MessageBreak (label `#2')\fi% |
| 378 |
\MessageBreak% |
| 379 |
has been split over different pages:\MessageBreak% |
| 380 |
page \fnb@@footnotestartpage\space to page #3}% |
| 381 |
% \end{macrocode} |
| 382 |
% For a double page: |
| 383 |
% \begin{macrocode} |
| 384 |
\else% |
| 385 |
\iffnb@@isdoublepage% |
| 386 |
\PackageWarningNoLine{fnbreak}{Footnote number #1% |
| 387 |
\iffnb@showlabel\MessageBreak (label `#2')\fi% |
| 388 |
\MessageBreak% |
| 389 |
has been split over different pages (double page):\MessageBreak% |
| 390 |
page \fnb@@footnotestartpage\space to page #3}% |
| 391 |
% \end{macrocode} |
| 392 |
% For a flipside: |
| 393 |
% \begin{macrocode} |
| 394 |
\else% |
| 395 |
\PackageWarningNoLine{fnbreak}{Footnote number #1% |
| 396 |
\iffnb@showlabel\MessageBreak (label `#2')\fi% |
| 397 |
\MessageBreak% |
| 398 |
has been split over different pages (flipside):\MessageBreak% |
| 399 |
page \fnb@@footnotestartpage\space to page #3}% |
| 400 |
\fi% |
| 401 |
\fi% |
| 402 |
% \end{macrocode} |
| 403 |
% Redefine the \cs{fnb@globalwarning} to print a warning at the end of |
| 404 |
% the log file. |
| 405 |
% \begin{macrocode} |
| 406 |
\def\fnb@globalwarning{% |
| 407 |
\PackageWarningNoLine{fnbreak}{There are footnotes with a % |
| 408 |
pagebreak.\MessageBreak% |
| 409 |
Check if they are acceptable}% |
| 410 |
}% |
| 411 |
}% |
| 412 |
\else% |
| 413 |
% \end{macrocode} |
| 414 |
% This macro trys to handle different footnotes. |
| 415 |
% This may not happen and is an internal error. |
| 416 |
% \begin{macrocode} |
| 417 |
\PackageError{fnbreak}{Internal problem:\MessageBreak% |
| 418 |
Start and stop marker of footnote do not fit:\MessageBreak% |
| 419 |
start: \fnb@@footnotestartnum, page \fnb@@footnotestartpage, % |
| 420 |
end: #1, page #3}{% |
| 421 |
This error may not happen. % |
| 422 |
Please try to make a short example which shows this behaviour % |
| 423 |
and send a bug report to [email protected].}% |
| 424 |
\fi% |
| 425 |
}% |
| 426 |
% \end{macrocode} |
| 427 |
% \changes{1.00}{2004/04/01}{Patch \cs{@footnotetext} instead of |
| 428 |
% re-writing it}% |
| 429 |
% Redefine \cs{@footnotetext} by patching the calls \cs{fnb@fnstart} |
| 430 |
% and \cs{fnb@fnend} after all other packages have been |
| 431 |
% loaded.\footnote{Thanks to Bastien Roucaries for that patch.} |
| 432 |
% \begin{macrocode} |
| 433 |
\newcommand\fnb@orig@footnotetext{}% |
| 434 |
\let\fnb@orig@footnotetext\@footnotetext% |
| 435 |
\long\def\@footnotetext#1{\fnb@orig@footnotetext{\fnb@fnstart#1\fnb@fnend}}% |
| 436 |
% \end{macrocode} |
| 437 |
% \changes{1.10}{2004/04/06}{Write a warning at the end of the log file}% |
| 438 |
% \changes{1.40}{2023-03-18}{Do not mess with \cs{@dofilelist}, use \cs{AddToHook{enddocument/info}}}% |
| 439 |
% Add \cs{fnb@globalwarning} to the info/warning messages |
| 440 |
% printed at the end of the .log file after the \cs{listfiles} list. |
| 441 |
% \begin{macrocode} |
| 442 |
\IfFormatAtLeastTF{2021-11-15}{% |
| 443 |
\AddToHook{enddocument/info}{\fnb@globalwarning}% |
| 444 |
}{\newcommand\fnb@dofilelist{}% |
| 445 |
\let\fnb@dofilelist\@dofilelist% |
| 446 |
\def\@dofilelist{\fnb@dofilelist\fnb@globalwarning}% |
| 447 |
}% |
| 448 |
} |
| 449 |
%</package> |
| 450 |
% \end{macrocode} |
| 451 |
% |
| 452 |
% \Finale |
| 453 |
\endinput |