Debian Codegraph @

texmf-dist/source/latex/endheads/endheads.dtx

raw
1 % \iffalse meta-comment
2 % !TEX TS-program = dtxmk
3 %
4 % Copyright (C) 2005 by John Burt <[email protected]>
5 % --------------------------------------------------
6 %
7 % This file may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.2
9 % of this license or (at your option) any later version.
10 % The latest version of this license is in:
11 %
12 % http://www.latex-project.org/lppl.txt
13 %
14 % and version 1.2 or later is part of all distributions of LaTeX
15 % version 1999-12-01 or later.
16 %
17 % \fi
18 %
19 % \iffalse
20 %<package>\NeedsTeXFormat{LaTeX2e}[1997-12-01]
21 %<package>\ProvidesPackage{endheads}
22 %<package> [2025-02-12 v1.7 endheads file]
23 %
24 %<*driver>
25 \documentclass{ltxdoc}
26 \usepackage{makeidx,multicol,keyval,ifthen}
27 \EnableCrossrefs
28 \CodelineIndex
29 \RecordChanges
30 \begin{document}
31 \DocInput{endheads.dtx}
32 \end{document}
33 %</driver>
34 % \fi
35 %
36 % \CheckSum{514}
37 %
38 % \CharacterTable
39 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
40 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
41 % Digits \0\1\2\3\4\5\6\7\8\9
42 % Exclamation \! Double quote \" Hash (number) \#
43 % Dollar \$ Percent \% Ampersand \&
44 % Acute accent \' Left paren \( Right paren \)
45 % Asterisk \* Plus \+ Comma \,
46 % Minus \- Point \. Solidus \/
47 % Colon \: Semicolon \; Less than \<
48 % Equals \= Greater than \> Question mark \?
49 % Commercial at \@ Left bracket \[ Backslash \\
50 % Right bracket \] Circumflex \^ Underscore \_
51 % Grave accent \` Left brace \{ Vertical bar \|
52 % Right brace \} Tilde \~}
53 %
54 %
55 % \changes{v1.0}{2005-08-21}{Initial version}
56 % \changes{v1.1}{2005-09-25}{uses needspace prevent orphan chapter
57 % beginnings in notes}
58 % \changes{v1.15}{2005-09-25}{uses titleref to capture chapter titles for
59 % notes}
60 % \changes{v1.151}{2005-09-25}{Corrections to user's guide}
61 % \changes{v1.152}{2006-11-10}{Fixed strange white space error}
62 % \changes{v1.2}{2006-11-10}{Added commands for multilingual use}
63 % \changes{v1.3}{2007-12-12}{Added commands for multilingual use}
64 % \changes{v1.4}{2008-04-12}{Added compatibility with memoir class. Added
65 % commands for multilingual use}
66 %\changes{v1.45}{2008-04-14}{Corrected problem with putting entry for
67 %endnotes in table of contents}
68 %\changes{v1.5}{2011-12-29}{Corrected problem with page styles for
69 %first pages of chapters}
70 %\changes{v1.51}{2012-09-03}{Corrected problem with page page headings in memoir style}
71 %\changes{v1.55}{2013-10-13}{Corrected conflict with biblatex}
72 %\changes{v1.6}{2017-04-06}{Warnings about known issues}
73 %\changes{v1.7}{2025-024-06}{Correct date format in style file}
74 % \GetFileInfo{endheads.sty}
75 %
76 % \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\else,\renewcommand,\makeatletter,\makeatother}
77 % \DoNotIndex{\abovedisplayskip,\belowdisplayskip,\abovedisplayshortskip,\belowdisplayshortskip}
78 % \DoNotIndex{\newcommand, \section, \subsection, \subsubsection,
79 % \fileversion,} \DoNotIndex{\filedate, \docdate, \leavevmode,
80 % \vspace, \small, \normalsize, \fontsize,} \DoNotIndex{\newcommand,
81 % \section, \subsection, \subsubsection, \fileversion}
82 % \DoNotIndex{\filedate, \docdate, \leavevmode, \vspace, \small,
83 % \normalsize, \fontsize} \DoNotIndex{\selectfont, \abovedisplayskip,
84 % \belowdisplayskip, \setlength, \item} \DoNotIndex{\global, \input,
85 % \def, \edef, \texttt, \textsf, \setcounter}
86 % \DoNotIndex{\pagenumbering, \oddsidemargin, \evensidemargin,
87 % \newdimen, \renewcommand} \DoNotIndex{\makeatletter, \let, \@listi,
88 % \@listl, \z@, \@xpt, \@xipt, \p@ , \@plus2} \DoNotIndex{\@minus5,
89 % \@minus3, \@plus3, \makeatother, \@minus4, \relax, \pagestyle}
90 % \DoNotIndex{\fancyhead, \fancyfoot, \thepage, \@ixp}
91 % \DoNotIndex{\begin \botmark, \botmark, \catcode, \croppadbot,
92 % \croppadtop} \DoNotIndex{\croppagewidth, \endverse, \equal,
93 % \fancyfoot, \fancyhead, \fancyhf} \DoNotIndex{\fancypagestyle,
94 % \firstmark, \footrulewidth, \hbox, \hbox, \headrulewidth}
95 % \DoNotIndex{\hfil, \hspace, \ifthenelse, \immediate, \itemindent,
96 % \listparindent} \DoNotIndex{\makeatletter, \nolinebreak, \openout,
97 % \raggedbottom, \setcounter, \textrm} \DoNotIndex{\value, \vspace,
98 % \write}
99 % \DoNotIndex{\afterpoemtitleskip, \addtocounter, \advance,
100 % \begin, \bf, \bigskip}
101 % \DoNotIndex{\bigskipamount, \fi, \@fulltitle, \label, \large, \leftheader}
102 % \DoNotIndex{\leftheadervalue, \leftmargin, \leftmargini}
103 % \DoNotIndex{\medskip, \newcounter, \nobreak, \par, \textbf}
104 % \DoNotIndex{\closeout,\em,\emph,\expandafter,\Huge,\it,\jobname,\kern,\newif,
105 % \newwrite,\p@,\pageref,\renewenvironment,\rm,\scriptsize,\string,
106 % \textsc, \unskip}
107 % \setcounter{IndexColumns}{2}
108 % \MakeShortVerb{|}
109 % \def\fileversion{1.7}
110 % \def\filedate{12 February 2025}
111 % \def\docdate{12 February 2025}
112 % \title{Running Headers for Endnotes\thanks{This document
113 % corresponds to \textsf{endheads}~\fileversion, dated \filedate.}}
114 % \author{John Burt \\ \texttt{[email protected]}}
115 % \date{February 12, 2025}
116 % \maketitle
117 % \begin{abstract}
118 % \textsf{endheads} provides running headers of the form ``Notes to
119 % pp.~xx--yy'' for endnotes. \textsf{endheads} is designed to work
120 % with \textsf{endnotes}.
121 % \end{abstract}
122 % \tableofcontents
123 % \hfuzz=50pt
124 % \section{Introduction} It is a convenience, if you are
125 % flipping though the endnotes of a book, to be able to find the
126 % endnote you are looking for by looking at the running header.
127 % \textsf{endheads} uses the |\mark| mechanism to update the running
128 % header continuously, so that it always indicates to what pages in
129 % the main text the notes on a particular page refer.
130 % \textsf{endheads} also enables one to reset endnote numbering at
131 % the beginning of each chapter.
132 %
133 % \textsf{endheads} requires the following packages to work correctly:
134 % with the standard document classes, or the komascript classes:
135 % \textsf{endnotes} (obviously), \textsf{fancyhdr} (also obviously),
136 % \textsf{ifthen} (for comparing page numbers), \textsf{needspace} (to
137 % prevent widowed chapter titles in notes sections when resetting
138 % notes by chapter using either |\notesbychapter| or
139 % |\resetendnotes|), and \textsf{titleref} (to send the chapter titles
140 % to the notes section).
141 %
142 %With \textsf{memoir} class, \textsf{endheads} requires fewer packages,
143 % since many of the package functions are built into \textsf{memoir} and some,
144 % \textsf{fancyhdr} most especially, conflict with it. Minimally, you will need \textsf{endnotes}
145 % and \textsf{ifthen}. You might wish to call \textsf{memoir} with the oldfontcommands
146 % option.
147 %
148 % \section{Setup} \DescribeMacro{\setupendnoteheaders} This is the
149 % only macro you need to call to use this package. If you use
150 % |\setupendnoteheaders| you should remember to start your endnotes on
151 % a new page. |\setupendnoteheaders| sets the first page of the notes
152 % section to the |empty| pagestyle, since you normally don't have
153 % running headers on the first page of a section. And it changes the
154 % pagestyle for subsequent pages to have a running header of the form
155 % ``Notes to pages xx--yy.'' This header will appear in the center of
156 % each header. Then it modifies the |\endnote| command, having it
157 % increment a counter that keeps track of all the endnotes (even if
158 % you are resetting the number by chapter), and defines a label for
159 % that note. Finally, it writes on the external file for the endnotes
160 % a command to set the |\mark| for that page of the endnotes using a
161 % |\pageref| to the label it has just defined. \textsf{endheads}
162 % creates a label and a pageref for every note.
163 %
164 % \DescribeMacro{\notesbychapter} |\notesbychapter| resets the note
165 % counter every time you issue a |\chapter| command, and it puts a
166 % centered line reading ``Chapter \textless\emph{chapter
167 % number}\textgreater ~ \textless\emph{chapter title}\textgreater'' in the
168 % notes at that point. If you want only the chapter number, not its
169 % title, issue |\titleinnotesfalse| in your preamble. Please note
170 % that with the standard classes
171 % \textsf{endheads} modifies |\@chapter|, adding a few lines on
172 % to the end of the command. If some other package does the same, you
173 % may need to reconcile them. With \textsf{memoir} class, |\chapter| is modified
174 % only if |\notesbychapter| is issued.
175 %
176 % \begin{sloppypar}
177 % \DescribeMacro{\setstyleforchapternotebegin}
178 % \DescribeMacro{\setstyleforchapternoteend}
179 % |\setstyleforchapternotebegin| and |\setstyleforchapternoteend|
180 % allows you to customize the appearance of the line that separates
181 % chapters in the endnotes. If, for instance, rather having a
182 % centered line in the small font size, you want a flushleft line in
183 % the large fontsize, issue
184 % |\setstyleforchapternotebegin{\begin{flushleft}\large}| and
185 % |\setstyleforchapternoteend{\end{flushleft}}| in your preamble.
186 % To set these lines in italic or bold, issue
187 % |\setstyleforchapternotebegin{\em}| or
188 % |\setstyleforchapternotebegin{\bf}| in your preamble. (It's safe,
189 % indeed required, to use the old style font commands here, since the
190 % chapter title line in the notes is confined to a group, which
191 % restricts the scope of the font style command to the line. If you are
192 % using \textsf{memoir} class, you should use the oldfontcommands option if you
193 % plan on issuing |\setstyleforchatpernotebegin| and |\setstyleforchapternoteend|.)
194 % Remember that if you open an environment with
195 % |\setstyleforchapternotebegin| you must close it in
196 % |\setstyleforchapternoteend|. So, for instance, if you wish the
197 % chapter line to be set flushleft, in boldface, in normal font size,
198 % you would issue
199 % |\setstyleforchapternotebegin{\begin{flushleft}\begin{bf}\normalsize}| and
200 % |\setstyleforchapternoteend{\end{bf}\end{flushleft}}| in your
201 % preamble.
202 % \end{sloppypar}
203 %
204 % \DescribeMacro{\resetendnotes} Conceivably you might wish to do what
205 % |\notesbychapter| does for each chapter individually. For instance,
206 % there may be a chapter without endnotes, in which case
207 % |\notesbychapter| would issue the centered line for that chapter,
208 % but no notes would follow, which is ugly. Also, since the
209 % Bibliography is, as far as \LaTeX\ is concerned, a chapter, you must
210 % use |\resetendnotes| before each chapter rather issuing
211 % |\notesbychapter| in the preamble if you have a bibliography, or odd
212 % results will follow.
213 %
214 % \section{Using \textsf{endheads} in a Multilingual World}
215 %
216 % \begin{sloppypar}
217 % By default, \textsf{endheads} uses English language running headers.
218 % As of version 1.2 these
219 % are easily changed. \end{sloppypar}
220 %
221 %
222 % \DescribeMacro{\changenotesname} To change the name for the endnote
223 % section for notes (the default is Notes), issue
224 % |\changenotesname{your version}|. To change the running header (by
225 % default ``Notes to'') issue |\changenotesheader{your version}|.
226 %
227 % \DescribeMacro{\changenotescontentsname}
228 %To
229 % change the name for the notes in the table of contents ( by
230 % default ``Notes'') issue |\changenotescontentsname{your version}|.
231 %
232 % \DescribeMacro{\notesincontents} If you do not wish to include a line for the endnotes
233 % in the table of contents, issue |\notesincontentsonfalse| (This is the default). To include a line
234 % for the endnotes in the table of contents, issue |\notesincontents|
235 % or (toggling the boolean) |\notesincontentsontrue|. If you wish to
236 % rethink how to present the notes in the table of contents, include
237 % an |\addtocontents| line just before you issue |\theendnotes|, the command which
238 % will read all of your endnotes into your document at that point. For instance, I set the
239 % word ``Notes'' in the table of contents flush with the left margin, just where the numbers
240 % in the preceding chapters are. You might, however, wish to indent that word just a bit, so
241 % that it will be flush with the chapter titles above, rather than with the chapter numbers.
242 % If you wish to do this, just before issuing |\theendnotes|, issue
243 % |\addcontentsline{toc}{chapter}{\protect\numberline{} \the\notescontentsname}|.
244 %
245 % \begin{sloppypar}
246 % \DescribeMacro{\changesinglepageabbrev}
247 % \DescribeMacro{\changemultiplepageabbrev} Running headers refer to
248 % single pages with the English abbreviation ``p.'' and to multiple
249 % pages with the English abbreviation ``pp.'' To change these issue
250 % |\changesinglepageabbrev{new abbrev}| or
251 % |\changemultiplepageabbrev{new abbrev}| respectively. The ultimate
252 % outcome is to translate a header of the form ``Notes to
253 % pp.~xx-yy'' to the form appropriate for your
254 % language. \end{sloppypar}
255 %
256 % \begin{sloppypar}
257 % \DescribeMacro{\changechapternotesline}If you are using |\resetendnotes|
258 % or |\setnotesbychapter| you may also want to
259 % change the text of the line those commands add to the endnotes so as to use some
260 % other word than ``Chapter.'' To change this,
261 % issue |\changechapternotesline{your version}|.\end{sloppypar}
262 %
263 % \section{Using \textsf{endheads} with \textsf{biblatex}}
264 % If you use \textsf{biblatex} you might get an error message
265 % that reads ``Package biblatex Error: Patching 'endnotes' package failed.''
266 % What is happening here is that \textsf{biblatex} and \textsf{endheads} are both
267 % trying to modify the |\theendnotes| command from \textsf{endnotes}. If
268 % \textsf{endheads} goes first, \textsf{biblatex} can't find the portion of the command
269 % it is trying to modify. Now
270 % \textsf{biblatex} redefines |\theendnotes| at |\begin{document}|,
271 % and \textsf{endheads }redefines |\theendnotes| when |\setupendnoteheaders|
272 % is issued, so issue |\setupdendnoteheaders|
273 % after |\begin{document}| and everything should be OK.
274 % \section{Known Issues}
275 % The running headers in \textsf{endheads} will only work correctly if all endnotes are issued on pages
276 % with arabic numbering. Endnotes issued on pages with roman numbering will break
277 % \textsf{endheads}, because the calculations required to update the headers
278 % require arabic numbers.
279 %
280 % Normally if you are using |\footnote| in the body of the text you can issue
281 % |\let\footnote=\endnote| to get endnotes with \textsf{endnote}. This will break
282 % \textsf{endheads}, however, (the running headers will all have your final
283 % chapter title, not the proper page numbers) so all of your endnotes must be made with
284 % |\endnote|.
285 % \StopEventually{\PrintChanges\PrintIndex}
286 % \section{Implementation}
287 % \subsection{General Purpose Routines}
288 % Essentially these routines are code posted by Heiko Oberdiek to
289 % comp.text.tex. If you set a counter from a |\pageref|, that
290 % |\pageref| is undefined on the first run, and \TeX\ will not only
291 % complain about the undefined reference, but give a ``missing
292 % number'' error if you try to do anything with that reference, such
293 % as compare one page number to another. These commands enable one to
294 % use the |\pageref| without generating the missing number error on
295 % the first run.
296 % \begin{macrocode}
297 \providecommand*{\ifrefundefined}[1]{%
298 \expandafter\ifx\csname r@#1\endcsname\relax
299 \expandafter\@firstoftwo
300 \else
301 \expandafter\@secondoftwo
302 \fi
303 }
304 \providecommand*{\@extract@ref}[2]{%
305 \expandafter\expandafter\expandafter#1\csname
306 r@#2\endcsname{}{}\@nil
307 }
308
309 \providecommand*{\@extractref}{%
310 \@extract@ref\@car
311 }
312
313 \providecommand*{\@extractpageref}{%
314 \@extract@ref\@secondcar
315 }
316
317 \long\def\@secondcar#1#2#3\@nil{#2}
318
319 \providecommand*{\setcounterfromref}[2]{%
320 \ifrefundefined{#2}{%
321 \protect\G@refundefinedtrue
322 \@latex@warning{Reference `#2' on page \thepage \space
323 undefined}%
324 \setcounter{#1}{0}%
325 }{%
326 \setcounter{#1}{\@extractref{#2}}%
327 }%
328 }
329 \providecommand*{\setcounterfrompageref}[2]{%
330 \ifrefundefined{#2}{%
331 \protect\G@refundefinedtrue
332 \@latex@warning{Reference `#2' on page \thepage \space
333 undefined}%
334 \setcounter{#1}{0}%
335 }{%
336 \setcounter{#1}{\@extractpageref{#2}}%
337 }%
338 }
339 \long\def\appendtomacro#1#2{%
340 \begingroup
341 \toks@\expandafter{#1#2}%
342 \xdef#1{\the\toks@}%
343 \endgroup}
344 % \end{macrocode}
345 % \subsection{Building Blocks}
346 % First, define some counters:
347 % \begin{macrocode}
348 \newcounter{allendnotes}
349 \setcounter{allendnotes}{1}
350 \newcounter{notepageholder}
351 % \end{macrocode}
352 % \begin{macro}{\mymarks}
353 % A command to set the marks. This will be called by the page style.
354 % \begin{macrocode}
355 \newtoks{\singlepageabbrev}
356 \singlepageabbrev={p.}
357 \newcommand{\changesinglepageabbrev}[1]{\singlepageabbrev={#1}}
358 \newtoks{\multiplepageabbrev}
359 \newcommand{\changemultiplepageabbrev}[1]{\multiplepageabbrev={#1}}
360 \multiplepageabbrev{pp.}
361 \@ifclassloaded{memoir}{\newcommand{\mymarks}{%
362 \ifthenelse{\equal{\rightmark}{\leftmark}}%
363 {\unskip ~\the\singlepageabbrev~\rightmark}% if equal
364 {\unskip ~\the\multiplepageabbrev~\rightmark--\leftmark}}%if not equal
365 }
366 {\newcommand{\mymarks}{%
367 \ifthenelse{\equal{\firstmark}{\botmark}}%
368 {\unskip ~\the\singlepageabbrev~\firstmark}% if equal
369 {\unskip ~\the\multiplepageabbrev~\firstmark--\botmark}}%if not equal
370 }
371 % \end{macrocode}
372 % \end{macro}
373 % \begin{macro}{\endnotespagestyle}
374 % A command to set the page style in \textsf{fancyhdr}. You might
375 % want to change some aspects of this, such as where to put the page
376 % number, to make it consistent with the rest of your document.
377 % \begin{macrocode}
378
379 \newtoks{\endnotesname}
380 \endnotesname={Notes}
381 \newcommand{\changenotesname}[1]{\def\notesname{#1}}
382 \newtoks{\notesheadername}
383 \notesheadername={Notes to}
384 \newcommand{\changenotesheader}[1]{\notesheadername={#1}}
385 \newtoks{\notescontentsname}
386 \notescontentsname={Notes}
387 \newcommand{\changenotescontentsname}[1]{\notescontentsname={#1}}
388 \newtoks{\chapternoteslinename}
389 \chapternoteslinename={Chapter}
390 \newcommand{\changechapternotesline}[1]{\chapternoteslinename={#1}}
391 \@ifclassloaded{memoir}{
392 \makepagestyle{endnotesstyle}
393 \makeevenhead{endnotesstyle}{{\small\textrm{\thepage}}}{{\small{\em \the\notesheadername~\mymarks}}}{}
394 \makeoddhead{endnotesstyle}{}{{\small{\em \the\notesheadername~\mymarks}}}{{\small\textrm{\thepage}}}
395 \makeevenfoot{endnotesstyle}{}{}{}
396 \makeoddfoot{endnotesstyle}{}{}{}
397 }{
398 \fancypagestyle{endnotesstyle}{%
399 \fancyhf{}
400 \fancyhead[CO]{{\small{\em \the\notesheadername~\mymarks}}}
401 \fancyhead[CE]{{\small{\em \the\notesheadername~\mymarks}}}
402 \renewcommand{\headrulewidth}{0pt}
403 \renewcommand{\footrulewidth}{0pt}
404 \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
405 }
406 }
407
408 % \end{macrocode}
409 % \end{macro}
410 % \begin{macro}{\checknoteheaders}
411 % This macro sets the counter notepageholder to the value given by
412 % the pageref of the note that is being output. All that strange
413 % business with |\string| is there because I want to use the
414 % |\immediate\write| mechanism to control what gets expanded and what
415 % doesn't get expanded on the external file for the endnotes, |\jobname.ent|.
416 % Everything except the actual number of the endnote is written to
417 % the external file as unexpanded tokens. When, after you call
418 % |\theendnotes|, you read in the external file for the endnotes,
419 % |\jobname.ent|, all these tokens become a command to set the |\mark|.
420 % \begin{macrocode}
421 \@ifclassloaded{memoir}{\newcommand{\checknoteheaders}{%
422 \string\setcounterfrompageref\string{notepageholder\string}%
423 \string{notl\theallendnotes\string}%
424 \string\markboth\string{\string\thenotepageholder\string}\string{\string\thenotepageholder\string}%
425 }
426 }{\newcommand{\checknoteheaders}{%
427 \string\setcounterfrompageref\string{notepageholder\string}%
428 \string{notl\theallendnotes\string}%
429 \string\mark\string{\string\thenotepageholder\string}%
430 }
431 }
432
433 % \end{macrocode}
434 % \end{macro}
435 % \subsection{User Code}
436 % \begin{macro}{\notesincontents}
437 % \begin{macrocode}
438 \newif\ifnotesincontentson \notesincontentsonfalse
439 \newcommand{\notesincontents}{\notesincontentsontrue}
440 % \end{macrocode}
441 % \end{macro}
442 % \begin{macro}{\setupendnoteheaders}
443 % |\setupendnoteheaders| turns on processing of running headers, and
444 % adds two lines to the definition of |\endnote|
445 % \begin{macrocode}
446 \newif\ifendnoteheaderson \endnoteheadersonfalse
447 \newcommand{\setupendnoteheaders}{%
448 \endnoteheadersontrue
449 \if@enotesopen \else \@openenotes \fi
450 \immediate\write\@enotes{%
451 \string\thispagestyle\string{empty\string}
452 \string\pagestyle\string{endnotesstyle\string}}
453 \immediate\write\@enotes{\string\ifnotesincontentson}%
454 \immediate\write\@enotes{\string\addcontentsline\string{toc\string}
455 \string{chapter\string}\string{\string\the\string\notescontentsname\string}}%
456 %\immediate\write\@enotes{\string{\string\notescontentsname\string}}%
457 %\string{\string\protect\string\numberline
458 %\string{\string} \string\notescontentsname \string}
459 \immediate\write\@enotes{\string\fi}
460 \def\endnote{\@ifnextchar[\@xendnote{\stepcounter{endnote}%
461 % my addition begins
462 \stepcounter{allendnotes}\label{notl\theallendnotes}%
463 \immediate\write\@enotes{\checknoteheaders}%
464 % my addition ends
465 \protected@xdef\@theenmark{\theendnote}%
466 \@endnotemark\@endnotetext}}
467 \let\oldtheendnotes=\theendnotes
468 \renewcommand{\theendnotes}{%
469 \immediate\write\@enotes{\string\thispagestyle\string{endnotesstyle\string}}
470 \oldtheendnotes}
471 }
472 % \end{macrocode}
473 % \end{macro}
474 % \begin{macro}{\resetendnotes}
475 % Tells the |\chapter| macro to reset the note counter and to
476 % put a line with the chapter number in the endnotes.
477 % \begin{macrocode}
478 \def\strip#1>{}
479 \newcommand{\literalendnote}[1]{\if@enotesopen \else
480 \@openenotes\setupendnoteheaders \fi
481 \begingroup
482 \def\next{#1}%
483 \newlinechar='40
484 \immediate\write\@enotes{\expandafter\strip\meaning\next}%
485 \endgroup%
486 }
487 \newif\iftitleinnotes \titleinnotestrue
488 \newcommand{\styleforchapternotebegin}{%
489 }
490 \newcommand{\styleforchapternoteend}{%
491 }
492 \newcommand{\setstyleforchapternotebegin}[1]{%
493 \renewcommand{\styleforchapternotebegin}{#1}}
494 \newcommand{\setstyleforchapternoteend}[1]{%
495 \renewcommand{\styleforchapternoteend}{#1}}%
496 \setstyleforchapternotebegin{\begin{center}}
497 \setstyleforchapternoteend{\end{center}}
498 \newcommand{\resetendnotes}{%
499 \label{chapter\thechapter}%
500 \setcounter{endnote}{0}%
501 \if@enotesopen \else \@openenotes \fi
502 \immediate\write\@enotes{\string\begingroup}
503 \immediate\write\@enotes{\string\goodbreak}
504 \immediate\write\@enotes{\string\Needspace\string{5\string\baselineskip\string}}
505 \immediate\write\@enotes{\string\styleforchapternotebegin}
506 % \immediate\write\@enotes{\string\begin\string{center\string}}
507 %\immediate\write\@enotes{\string{}
508 \immediate\write\@enotes{\the\chapternoteslinename\string\ \thechapter\string~}
509 \iftitleinnotes
510 \immediate\write\@enotes{\string\titleref\string{chapter\thechapter\string}}
511 \fi
512 %\immediate\write\@enotes{\string}}
513 \immediate\write\@enotes{\string\styleforchapternoteend}
514 % \immediate\write\@enotes{\string\end\string{center\string}}
515 \immediate\write\@enotes{\string\nopagebreak}
516 \immediate\write\@enotes{\string\endgroup}
517 }
518 % \end{macrocode}
519 % \end{macro}
520 % \begin{macro}{\notesbychapter}
521 % \begin{macrocode}
522 % \newcommand{\notesbychapter}{%
523 % \appendtomacro{\chapter}{%
524 % \relax
525 % \resetendnotes}%
526 % }
527 \newif\ifnotesbychapteron \notesbychapteronfalse
528 \@ifclassloaded{memoir}{\newcommand{\notesbychapter}{\notesbychapterontrue
529 \addtoiargdef{\chapter}{}{ \iftitleinnotes%
530 % \label{chapter\thechapter}%
531 \fi%
532 \ifnotesbychapteron%
533 \relax%
534 \resetendnotes%
535 \fi}}
536 }{\newcommand{\notesbychapter}{\notesbychapterontrue}
537 \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
538 \if@mainmatter
539 \refstepcounter{chapter}%
540 \typeout{\@chapapp\space\thechapter.}%
541 \addcontentsline{toc}{chapter}%
542 {\protect\numberline{\thechapter}#1}%
543 \else
544 \addcontentsline{toc}{chapter}{#1}%
545 \fi
546 \else
547 \addcontentsline{toc}{chapter}{#1}%
548 \fi
549 \chaptermark{#1}%
550 \addtocontents{lof}{\protect\addvspace{10\p@}}%
551 \addtocontents{lot}{\protect\addvspace{10\p@}}%
552 \if@twocolumn
553 \@topnewpage[\@makechapterhead{#2}]%
554 \else
555 \@makechapterhead{#2}%
556 \@afterheading
557 \fi
558 \iftitleinnotes%
559 % \label{chapter\thechapter}%
560 \fi%
561 \ifnotesbychapteron%
562 \relax%
563 \resetendnotes%
564 \fi}
565 }
566
567 % \end{macrocode}
568 % \end{macro}
569 % \Finale
570 \endinput