Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 % !TEX TS-program = dtxmk
3 %
4 % Copyright (C) 2008 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{edmargin}
22 %<package> [2012/09/04 v1.2 edmargin file]
23 %
24 %<*driver>
25 \documentclass{ltxdoc}
26 \usepackage{makeidx,multicol,keyval,ifthen}
27 \EnableCrossrefs
28 \CodelineIndex
29 \RecordChanges
30 \begin{document}
31 \DocInput{edmargin.dtx}
32 \end{document}
33 %</driver>
34 % \fi
35 %
36 % \CheckSum{1970}
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}{2008/04/21}{Initial version}
56 % \changes{v1.01}{2008/04/23}{Bug fix in macro for defining new
57 % endnote kinds.}
58 % \changes{v1.02}{2008/04/28}{Corrections to manual.}
59 % \changes{v1.2}{2012/09/04}{Fixed a bug the interfered with use of memoir class}
60
61
62 % \GetFileInfo{edmargin.sty}
63 %
64 % \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\else,\renewcommand,\makeatletter,\makeatother}
65 % \DoNotIndex{\abovedisplayskip,\belowdisplayskip,\abovedisplayshortskip,\belowdisplayshortskip}
66 % \DoNotIndex{\newcommand, \section, \subsection, \subsubsection,
67 % \fileversion,} \DoNotIndex{\filedate, \docdate, \leavevmode,
68 % \vspace, \small, \normalsize, \fontsize,} \DoNotIndex{\newcommand,
69 % \section, \subsection, \subsubsection, \fileversion}
70 % \DoNotIndex{\filedate, \docdate, \leavevmode, \vspace, \small,
71 % \normalsize, \fontsize} \DoNotIndex{\selectfont, \abovedisplayskip,
72 % \belowdisplayskip, \setlength, \item} \DoNotIndex{\global, \input,
73 % \def, \edef, \texttt, \textsf, \setcounter}
74 % \DoNotIndex{\pagenumbering, \oddsidemargin, \evensidemargin,
75 % \newdimen, \renewcommand} \DoNotIndex{\makeatletter, \let, \@listi,
76 % \@listl, \z@, \@xpt, \@xipt, \p@ , \@plus2} \DoNotIndex{\@minus5,
77 % \@minus3, \@plus3, \makeatother, \@minus4, \relax, \pagestyle}
78 % \DoNotIndex{\fancyhead, \fancyfoot, \thepage, \@ixp}
79 % \DoNotIndex{\begin \botmark, \botmark, \catcode, \croppadbot,
80 % \croppadtop} \DoNotIndex{\croppagewidth, \endverse, \equal,
81 % \fancyfoot, \fancyhead, \fancyhf} \DoNotIndex{\fancypagestyle,
82 % \firstmark, \footrulewidth, \hbox, \hbox, \headrulewidth}
83 % \DoNotIndex{\hfil, \hspace, \ifthenelse, \immediate, \itemindent,
84 % \listparindent} \DoNotIndex{\makeatletter, \nolinebreak, \openout,
85 % \raggedbottom, \setcounter, \textrm} \DoNotIndex{\value, \vspace,
86 % \write}
87 % \DoNotIndex{\afterpoemtitleskip, \addtocounter, \advance,
88 % \begin, \bf, \bigskip}
89 % \DoNotIndex{\bigskipamount, \fi, \@fulltitle, \label, \large, \leftheader}
90 % \DoNotIndex{\leftheadervalue, \leftmargin, \leftmargini}
91 % \DoNotIndex{\medskip, \newcounter, \nobreak, \par, \textbf}
92 % \DoNotIndex{\closeout,\em,\emph,\expandafter,\Huge,\it,\jobname,\kern,\newif,
93 % \newwrite,\p@,\pageref,\renewenvironment,\rm,\scriptsize,\string,
94 % \textsc, \unskip}
95 % \setcounter{IndexColumns}{2}
96 % \MakeShortVerb{|}
97 % \def\fileversion{1.2}
98 % \def\filedate{4 September 2012}
99 % \def\docdate{4 September 2012}
100 % \title{\textsf{Edmargin:} A Simple Design for Critical Editions with Multiple Endnote Series\thanks{This document
101 % corresponds to \textsf{edmargin}~\fileversion, dated \filedate.}}
102 % \author{John Burt \\ \texttt{[email protected]}}
103 % \date{September 4, 2012}
104 % \maketitle
105 % \begin{abstract}
106 % \textsf{edmargin} provides multiple endnotes sections with running
107 % headers of the form ``Notes to pp.~xx--yy'' for critical editions.
108 % Rather than having endnote marks in the text, \textsf{edmargin}
109 % puts markers in the margins referring to the page in the endnotes
110 % sections to which the note refers.
111 % \end{abstract}
112 % \tableofcontents
113 % \hfuzz=50pt
114
115 % \section{Introduction} \textsf{edmargin} provides a simple scheme
116 % for making critical editions. All critical editions provide several
117 % series of notes, such as notes about emendations, explanatory notes,
118 % and notes about the text. It is a common practice to tie these
119 % notes to line numbers in the text, whether typographical lines in
120 % prose text or verse lines in poetry. Some editions of prose works
121 % enumerate sentences and paragraphs rather than lines, as the Bible
122 % does. All of these systems involve considerable amounts of
123 % laborious markup. \textsf{edmargin} provides a different system of
124 % annotation which minimizes markup, and also minimizes the
125 % possibilities of conflicts among commands. In the text, instead of
126 % placing a marker, or remembering the line or sentence number,
127 % \textsf{edmargin} simply places a mark in the margin (as for
128 % instance ``c'' for a commentary, ``t'' for a textual note, or ``e''
129 % for an emendation) followed by the page number in the relevant
130 % endnotes section to which the note refers. So, for instance, if on
131 % page 42 of my text I have the anchor for an explanatory note which
132 % appears on page 563 of the endnotes section for explanatory notes,
133 % \textsf{edmargin} would put \emph{c: p.~563} in the margin on page
134 % 42 of the line where that note occurs, and the text of the note
135 % would appear on p.~563, with a reference to the page in the text to
136 % which it occurs and a lemma drawn from that text. \textsf{edmargin}
137 % comes with three built in categories of endnotes (emendations,
138 % explanatory notes, textual notes), and facilities for easily
139 % constructing other categories of endnote. All of the endnote
140 % sections will have running headers of the form ``Textual Notes to
141 % pp.~xx--yy.''
142 %
143 % This scheme for a critical edition, while considerably simpler than
144 % the traditional schemes, does provide the information a critical
145 % edition requires, and should be easy for readers to use, provided
146 % that there are not many notes on every line. The scheme is modelled
147 % on that used by David V. Erdman and Harold Bloom in their edition of
148 % \emph{The Complete Poetry and Prose of William Blake}. \textsf{edmargin}
149 % can also make notes with markers in the text, in the traditional
150 % fashion.
151 %
152 %
153 % With the standard document classes, or the komascript classes,
154 % \textsf{edmargin} requires the following packages to work correctly:
155 % \textsf{fancyhdr},
156 % \textsf{ifthen} (for comparing page numbers), \textsf{needspace} (to
157 % prevent widowed chapter titles in notes sections when resetting
158 % notes by chapter using either |\notesbychapter| or
159 % |\resetendnotes|), and \textsf{titleref} (to send the chapter titles
160 % to the notes section). Because the marginal references are set with
161 % |\marginpar| you should also call \textsf{mparhack} if you are
162 % setting with the ``twoside'' option. \textsf{edmargin} sets very
163 % narrow margin references (only 2em wide). If you are using
164 % marginpars for any other purpose, you may need to adjust the width,
165 % and monkey with the other parameters to make the marginal
166 % references on both sides look symmetrical. To change the width of
167 % the marginpars to 4em, issue |\setlength{\marginparwidth}{4em}|.
168 %
169 % With \textsf{memoir} class, \textsf{edmargin} requires fewer
170 % packages, since many of the package functions are built into
171 % \textsf{memoir} and some, \textsf{fancyhdr} most especially,
172 % conflict with it. Minimally, you will need
173 % \textsf{ifthen}. You might wish to call \textsf{memoir} with the
174 % oldfontcommands option.
175 %
176 % \section{Setup} \DescribeMacro{\setupendnoteheaders}
177 % |\setupendnoteheaders| opens an external channel to receive each of the
178 % three preset kinds of endnote, opening external
179 % files for emendations, textual collations, and explanatory notes
180 % (with extensions .emd, .ent, and .enx respectively). Then it sets
181 % the first page of each notes section to the |empty| pagestyle, since
182 % you normally don't have running headers on the first page of a
183 % section. And it changes the pagestyle for subsequent pages to have
184 % a running header of the form ``Notes to pages xx--yy.'' This text
185 % will appear in the center of each header. It also writes
186 % information to the external file which will send information to the
187 % table of contents when the external file for the endnotes section is read back into your
188 % document. Each note written to the file increments a counter that
189 % keeps track of all the endnotes (even if you are resetting the
190 % number by chapter). \textsf{edmargin} creates two labels and two
191 % pagerefs for every note, a label and a pageref for each page in the
192 % main text \emph{from} which a note comes, and a label and a pageref
193 % for each page in the notes sections \emph{upon} which the note is
194 % written. Finally \textsf{edmargin} writes on the external file for
195 % the endnotes a command to update the running header for that page of the
196 % endnotes to be sure that it correctly reflects the pages in the
197 % main text from which the notes are drawn.
198 %
199 % \DescribeMacro{\makeemendations} \DescribeMacro{\maketextnotes}
200 % \DescribeMacro{\makeexplanatorynotes} You can use these commands
201 % individually to set up the predefined classes of endnote, rather
202 % than using |\setupendnoteheaders| to have \textsf{edmargin} put all three classes
203 % of notes in the backmatter of your volume. (This would be useful if you are not
204 % intending to make use of all three classes of note.)
205
206 % \DescribeMacro{\putemendations} \DescribeMacro{\puttextnotes}
207 % \DescribeMacro{\putexplanatory} |\puttextnotes|, |\putexplanatory|,
208 % or |\putemendation| read the external files back into your document
209 % at the place you specify. Remember that these commands change the
210 % page style, so if any sections that do not use the same type of running
211 % header follow these sections (the bibliography,
212 % for instance), be sure to restore your prevailing headings style by
213 % issuing, for example, |\pagestyle{headings}|
214 % |\thispagestyle{empty}|.
215 %
216 %
217 % \DescribeMacro{\notesbychapter} |\notesbychapter|
218 % resets the note counters for each kind of endnote and
219 % puts a centered line reading ``Chapter \textless\emph{chapter
220 % number}\textgreater ~ \textless\emph{chapter title}\textgreater'' in
221 % each of the three predefined sections of the the notes whenever
222 % |\chapter| is issued. If you want only the chapter number, not its
223 % title, issue |\titleinnotesfalse| in your preamble. Please note
224 % that with the standard classes \textsf{edmargin} modifies
225 % |\@chapter|, adding a few lines on to the end of the command. If
226 % some other package does the same, you may need to reconcile them.
227 % With \textsf{memoir} class, |\chapter| is modified only if
228 % |\notesbychapter| is issued.
229 %
230 % \begin{sloppypar}
231 % \DescribeMacro{\setstyleforchapternotebegin}
232 % \DescribeMacro{\setstyleforchapternoteend}
233 % |\setstyleforchapternotebegin| and |\setstyleforchapternoteend|
234 % allows you to customize the appearance of the line that separates
235 % chapters in the endnotes. If, for instance, rather having a
236 % centered line in the small font size, you want a flushleft line in
237 % the large fontsize, issue
238 % |\setstyleforchapternotebegin{\begin{flushleft}\large}| and
239 % |\setstyleforchapternoteend{\end{flushleft}}| in your preamble.
240 % To set these lines in italic or bold, issue
241 % |\setstyleforchapternotebegin{\em}| or
242 % |\setstyleforchapternotebegin{\bf}| in your preamble. (It's safe,
243 % indeed required, to use the old style font commands here, since the
244 % chapter title line in the notes is confined to a group, which
245 % restricts the scope of the font style command to the line.) If you are
246 % using \textsf{memoir} class, you should use the oldfontcommands option if you
247 % plan on issuing |\setstyleforchapternotebegin| and |\setstyleforchapternoteend|.
248 % Remember that if you open an environment with
249 % |\setstyleforchapternotebegin| you must close it in
250 % |\setstyleforchapternoteend|. So, for instance, if you wish the
251 % chapter line to be set flushleft, in boldface, in normal font size,
252 % you would issue
253 % |\setstyleforchapternotebegin{\begin{flushleft}\begin{bf}\normalsize}| and
254 % |\setstyleforchapternoteend{\end{bf}\end{flushleft}}| in your
255 % preamble.
256 % \end{sloppypar}
257 %
258 % \DescribeMacro{\resetendnotes} Conceivably you might wish to do what
259 % |\notesbychapter| does for each chapter individually. Issue this
260 % command just after theh |\chapter| command. For instance,
261 % there may be a chapter without endnotes, in which case
262 % |\notesbychapter| would issue the centered line for that chapter,
263 % but no notes would follow, which is ugly. Also, since the
264 % Bibliography is, as far as memoir class is concerned, a chapter, you
265 % must use |\resetendnotes| before each chapter rather issuing
266 % |\notesbychapter| in the preamble if you have a bibliography, or odd
267 % results will follow. |\resetendnotes| will put a divider line (and
268 % give the chapter name) in the endnotes for all three of the preset
269 % endnote sections. It will also put a divider line (and give the
270 % chapter name) for any section you add using |\definenewnotetype|, if
271 % you define new species of note types. This is convenient if you
272 % know that there will be each species of note for a given chapter.
273 % If the chapter does not include one of the species of notes, you
274 % would be wiser to use the individual commands in the next paragraph
275 %
276 % \DescribeMacro{\resettextnotes} \DescribeMacro{\resetemendations}
277 % \DescribeMacro{\resetexplanatory} These commands do what
278 % |\resetendnotes| does, but only for the named section, not for all
279 % three predefined endnote sections. If you used |\definenewnotetype|
280 % to create a new kind of endnote, you will also be able to use the
281 % corresponding ``reset'' command. For instance, if you created an
282 % |\xyznote| command, you can issue |\resetxyznotes|. If you use
283 % these commands, issue |\label{chapter\thechapter}| just after the
284 % |\chapter| command, and then issue the reset commands you plan to
285 % use.
286 %
287 % \section{Predefined Endnote Sections}
288 % \textsf{edmargin} comes with three predefined endnotes sections and
289 % three predefined kinds of endnote, |\textnote{}|, |\emendation{}|,
290 % and |\explanatory{}|.
291 %
292 %
293 % \DescribeMacro{\textnote} \DescribeMacro{\explanatory}
294 % \DescribeMacro{\emendation} Use |\textnote| and its siblings as you
295 % would use an ordinary |\endnote|. The argument of each note can be whatever you
296 % wish, but for clarity it is a good idea to use as a lemma from the
297 % text, since that will make the passage the note refers to clear.
298 % For example: |\textnote{lemma] comment}|.
299 %
300 % \DescribeMacro{\literaltextnote} \DescribeMacro{\literalemendation}
301 % \DescribeMacro{\literalexplanatory} |\literaltextnote| and its
302 % siblings are useful for sending information directly to the
303 % endnotes section to which the command refers. All of these commands
304 % send unexpanded text to the endnote sections, so you use this command
305 % to send to the endnote sections commands which will be executed when the endnote section is
306 % read back into your document. You can send expanded text using
307 % |\immediate\write\textnotes| and its siblings.
308 %
309 % \DescribeMacro{\notesincontents} If you do not wish to include a
310 % line for the endnotes in the table of contents, issue
311 % |\notesincontentsonfalse|. (This is the default). To include a line
312 % for the endnotes in the table of contents, issue |\notesincontents|
313 % or (toggling the boolean) |\notesincontentsontrue|. If you wish to
314 % rethink how to present the notes in the table of contents, rather than
315 % issuing |\notesincontents| include
316 % an |\addtocontents| line in the main text just before you issue |\puttextnotes| or its siblings, the
317 % command which will read all of your endnotes into your document at
318 % that point. For instance, |\notesincontents| sets the word ``Textual Notes'' in the
319 % table of contents flush with the left margin, just where the numbers
320 % in the preceding chapters are. You might, however, wish to indent
321 % that word just a bit, so that it will be flush with the chapter
322 % titles above, rather than with the chapter numbers. If you wish to
323 % do this, just before issuing |\puttextnotes|, issue
324 % |\addcontentsline{toc}{chapter}{\protect\numberline{}\the\textnotescontentsname}|.
325 % Use a similar line for the other endnotes sections, replacing |\textnotescontentsname|
326 % with |\emendationscontentsname| or |\explanationscontentsname| as the case may be.
327 %
328 % \section{Creating New Endnote Sections}
329 % \DescribeMacro{\definenewnotetype} You can create as many new kinds
330 % of endnote sections as you wish, using the |\definenewnotetype|
331 % command. This macro will
332 % \begin{enumerate}
333 % \item Open a new output stream and create a new external file to hold the
334 % notes.
335 % \item Define a ``literalwrite'' command, on the model of
336 % |\literaltextnote| for writing literal text directly to that external file.
337 % \item Send information to that file to set the page style and the
338 % running header
339 % \item Send information to that file to set the title of the endnotes
340 % section, and formatting information for the note text.
341 % \item Sets up an entry for the table of contents for the note section
342 % \item Defines a new ``note'' command, and a new marginal marker for
343 % that note
344 % \item Defines a new ``reset'' command for setting notes by chapter,
345 % and modifies |\resetendnotes| and |\notesbychapter| to include that
346 % new reset command when those two commands are issued
347 % \item Defines a new ``put'' command (on the model of
348 % |\puttextnotes|)
349 % for closing the external file and reading it into the text.
350 % \end{enumerate}
351 %
352 % This monster command takes \emph{six} arguments, which are used for
353 % setting the names of the various files and commands it creates, and
354 % for defining such things as the title of the new notes section and
355 % the marginal mark it places in the main text. These arguments, in
356 % order, specify
357 % \begin{enumerate}
358 % \item The base name used to construct all the commands.
359 % \item The extension used for the external file
360 % \item The section title in the running headers of the note section
361 % \item The section title at the beginning of the note section
362 % \item The name of the section in the table of contents section
363 % \item The marginal mark placed by the note command in the text
364 % \end{enumerate}
365 %
366 % So, for instance,\begin{verbatim}
367 % \definenewnotetype{xyznote}{xyz}{Xyznotes to}{XYZNOTES}{Xyznotes}{x}
368 % \end{verbatim} creates a note command |\xyznote{}|, and a command
369 % for sending literal text to the new note section |\literalxyznote|,
370 % both of which write to an external file |\jobname.xyz|, sets running
371 % headers for the notes sections of the form ``Xyznotes to
372 % pp.~52-60,'' write a title line in the endnotes section giving the
373 % title as XYZNOTES, writes an entry in the table of contents for
374 % Xyznotes, and sets the marginal mark set by an |\xyznote| to be
375 % ``x''. You can read in the xyznotes section into your document with
376 % the command |\putxyznote|. And |\resetendnotes| and
377 % |\notesbychapter| will put chapter titles in the xyznotes section,
378 % just as they do for the textual notes, the explanatory notes, and
379 % the emendations sections. Finally, you can use |\resetxyznotes| to
380 % set a chapter title in only the xyznotes section.
381 %
382 % A trivial use of this commmand would be to make traditional
383 % endnotes, in which case \textsf{edmargin} would merely be a
384 % replacement (with a slightly different command set) for
385 % \textsf{endnote} and \textsf{endheads}. The command for doing this
386 % would be \begin{verbatim} \definenewnotetype{endnote}{enn}{Endnotes
387 % to}{ENDNOTES}{Endnotes}{\relax} \end{verbatim}
388 %
389 % \section{Using \textsf{edmargin} in a Multilingual World}
390 %
391 % By default, \textsf{edmargin} uses English language running
392 % headers, but these are easily changed.
393 %
394 % \begin{sloppypar} \DescribeMacro{\changetextnotesname} To change the
395 % title in the text for the endnote section for textual notes (the
396 % default is TEXTUAL NOTES), issue |\changetextnotesname{yourversion}|. To change the running header (by default ``Textual Notes
397 % to'') issue |\changetextnotesheader{your version}|. To change the
398 % name of the textual notes section in the table of contents (the
399 % default is ``Textual Notes'') issue |\changetextnotescontentsname.|
400 % Equivalent commands for emendations are |\changeemendationsname|
401 % |\changeemendationsheadername| and |\changeemendationscontentsname|.
402 % Equivalent commands for explanatory notes are
403 % |\changeexplanationsname| |\changeexplanationsheader| and
404 % |\changeexplanationscontentsname|. \end{sloppypar}
405 %
406 %
407 % \begin{sloppypar}
408 % \DescribeMacro{\changesinglepageabbrev}
409 % \DescribeMacro{\changemultiplepageabbrev} Running headers refer to
410 % single pages with the English abbreviation ``p.'' and to multiple
411 % pages with the English abbreviation ``pp.'' To change these issue
412 % |\changesinglepageabbrev{new abbrev}| or
413 % |\changemultiplepageabbrev{new abbrev}| respectively. The ultimate
414 % outcome is to translate a header of the form ``Notes to
415 % pp.~xx-yy'' to the form appropriate for your
416 % language. \end{sloppypar}
417 %
418 % \begin{sloppypar}
419 % \DescribeMacro{\changechapternotesline}If you are using |\resetendnotes|
420 % or |\setnotesbychapter| you may also want to
421 % change the text of the line those commands add to the endnotes so as to use some
422 % other word than ``Chapter.'' To change this,
423 % issue |\changechapternotesline{your version}|.\end{sloppypar}
424 %
425 % \DescribeMacro{\backmattertextfont} |\edmargin| sets the endnote
426 % text in the |\small| size. To change it to |\normalsize| issue
427 % |\renewcommand{\backmattertextfont}{\normalsize}|.
428 %
429 % \section{Customization}
430 % \DescribeMacro{\notemarkinmargin}
431 % \DescribeMacro{\notemarkintext}
432 % Rather than using marginal references,
433 % \textsf{edmargin} can be set to put regular endnote markers in the
434 % text and in the endnote sections. The different series of endnotes
435 % will be distinguished by using the same abbrevations that were used
436 % for marginal references. So, for
437 % instance, the third textual note will have a mark that looks
438 % ``t:3'' both in the text and in the textual notes section, and the
439 % fifth explanatory note will have a mark that ``c:5'' both in the
440 % text and in the textual notes section. You can put the endnote
441 % markers in the main text rather than in the margins by issuing
442 % |\notemarkintext| in your preamble. Putting the endnote
443 % markers in the margin is the default, but you can make sure that
444 % they go there by issuing |\notemarkinmargin|.
445 %
446 % \begin{sloppypar}
447 % \DescribeMacro{\textnotesparamode}
448 % \DescribeMacro{\emendationsparamode}
449 % \DescribeMacro{\explanationsparamode} If you wish to print your
450 % endnotes as block paragraphs, rather than giving a paragraph to
451 % each note, issue |\textnotesparamode|, |\emendationsparamode|, or
452 % |\explanationsparamode|, as the case may require. If you have used
453 % |\definenewnotetype| to define a note type called |\xyznote|, you
454 % can set these notes in block paragraphs by issuing
455 % |\xyznotesparamode|. You might consider setting your notes in block
456 % paragraphs if you have very many very short notes. \end{sloppypar}
457 %
458 % \section{Known Issues} Because the marginal references are set with
459 % |\marginpar| some of them will appear on the wrong side in
460 % two-sided printing, unless you include \textsf{mparhack} in your
461 % list of packages. Also, if you have more than one reference on a
462 % line, the second reference will be moved down a line (marginpars
463 % are floats). This may not be an issue if the lemma in the second note
464 % makes it clear what in the text it refers to. This problem can be
465 % remedied by substituting the \textsf{marn} package and using the
466 % |\marn| command in place of |\marginpar|.
467 %
468 % Using |\definenewnotetype| with |\notesbychapter| or
469 % |\resetendnotes| causes a complaint that an |\iftrue| has been left
470 % open whenever a |\chapter| command is written. The origin is
471 % probably a problem with |\appendtomacro|. But the error is
472 % harmless, it turns out, so I haven't tracked it down.
473 %
474 % \StopEventually{\PrintChanges\PrintIndex}
475 % \section{Implementation}
476 % \subsection{General Purpose Routines}
477 % Essentially these routines are code posted by Heiko Oberdiek to
478 % comp.text.tex. If you set a counter from a |\pageref|, that
479 % |\pageref| is undefined on the first run, and \TeX\ will not only
480 % complain about the undefined reference, but give a ``missing
481 % number'' error if you try to do anything with that reference, such
482 % as compare one page number to another. These commands enable one to
483 % use the |\pageref| without generating the missing number error on
484 % the first run.
485 % \begin{macrocode}
486 \providecommand*{\ifrefundefined}[1]{%
487 \expandafter\ifx\csname r@#1\endcsname\relax
488 \expandafter\@firstoftwo
489 \else
490 \expandafter\@secondoftwo
491 \fi
492 }
493 \providecommand*{\@extract@ref}[2]{%
494 \expandafter\expandafter\expandafter#1\csname
495 r@#2\endcsname{}{}\@nil
496 }
497
498 \providecommand*{\@extractref}{%
499 \@extract@ref\@car
500 }
501
502 \providecommand*{\@extractpageref}{%
503 \@extract@ref\@secondcar
504 }
505
506 \long\def\@secondcar#1#2#3\@nil{#2}
507
508 \providecommand*{\setcounterfromref}[2]{%
509 \ifrefundefined{#2}{%
510 \protect\G@refundefinedtrue
511 \@latex@warning{Reference `#2' on page \thepage \space
512 undefined}%
513 \setcounter{#1}{0}%
514 }{%
515 \setcounter{#1}{\@extractref{#2}}%
516 }%
517 }
518 \providecommand*{\setcounterfrompageref}[2]{%
519 \ifrefundefined{#2}{%
520 \protect\G@refundefinedtrue
521 \@latex@warning{Reference `#2' on page \thepage \space
522 undefined}%
523 \setcounter{#1}{0}%
524 }{%
525 \setcounter{#1}{\@extractpageref{#2}}%
526 }%
527 }
528 \long\def\appendtomacro#1#2{%
529 \begingroup
530 \toks@\expandafter{#1#2}%
531 \xdef#1{\the\toks@}%
532 \endgroup}
533 % \end{macrocode}
534 % \subsection{Building Blocks}
535 % First, define some counters:
536 % \begin{macrocode}
537 \newcounter{allendnotes}
538 \setcounter{allendnotes}{1}
539 \newcounter{notepageholder} \setcounter{notepageholder}{1}
540 % \end{macrocode}
541 % \begin{macro}{\mymarks}
542 % A command to set the marks. This will be called by the page style.
543 % Notice that there is a test to see whether \textsf{memoir} class is being
544 % loaded, so that marks will be set using \textsf{memoir} commands if
545 % they are available.
546 % \begin{macrocode}
547 \newtoks{\singlepageabbrev}
548 \singlepageabbrev={p.}
549 \newcommand{\changesinglepageabbrev}[1]{\singlepageabbrev={#1}}
550 \newtoks{\multiplepageabbrev}
551 \newcommand{\changemultiplepageabbrev}[1]{\multiplepageabbrev={#1}}
552 \newtoks{\chapternoteslinename}
553 \chapternoteslinename={Chapter}
554 \newcommand{\changechapternotesline}[1]{\chapternoteslinename={#1}}
555 \multiplepageabbrev{pp.}
556 \@ifclassloaded{memoir}{\newcommand{\mymarks}{%
557 \ifthenelse{\equal{\rightmark}{\leftmark}}%
558 {\unskip ~\the\singlepageabbrev~\rightmark}% if equal
559 {\unskip ~\the\multiplepageabbrev~\rightmark--\leftmark}}%if not equal
560 }
561 {\newcommand{\mymarks}{%
562 \ifthenelse{\equal{\firstmark}{\botmark}}%
563 {\unskip ~\the\singlepageabbrev~\firstmark}% if equal
564 {\unskip ~\the\multiplepageabbrev~\firstmark--\botmark}}%if not equal
565 }
566 % \end{macrocode}
567 % \end{macro}
568 % \begin{macro}{\endnotespagestyle}
569 % A command to set the page style in \textsf{fancyhdr}. You might
570 % want to change some aspects of this, such as where to put the page
571 % number, to make it consistent with the rest of your document.
572 % Notice that there is a test to see whether \textsf{memoir} class is being
573 % loaded, so that the header commands built in to \textsf{memoir} are
574 % used if they are available, and the header commands from
575 % \textsf{fancyhdr} are used if they are not.
576 % \begin{macrocode}
577 \@ifclassloaded{memoir}{\makepagestyle{plain}
578 \makeevenhead{plain}{}{}{{\small\textrm{\thepage}}}
579 \makeoddhead{plain}{{\small\textrm{\thepage}}}{}{}
580 \makeevenfoot{plain}{}{}{}
581 \makeoddfoot{plain}{}{}{}
582 \makepagestyle{endnotesstyle}
583 \makeevenhead{endnotesstyle}{{\small\textrm{\thepage}}}
584 {{\small{\em \the\notesheadername~\mymarks}}}{}
585 \makeoddhead{endnotesstyle}{}{{\small{\em \the\notesheadername~\mymarks}}}
586 {{\small\textrm{\thepage}}}
587 \makeevenfoot{endnotesstyle}{}{}{}
588 \makeoddfoot{endnotesstyle}{}{}{}
589 }{\fancypagestyle{plain}{%
590 \fancyhf{}
591 \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
592 \renewcommand{\headrulewidth}{0pt}
593 \renewcommand{\footrulewidth}{0pt}
594 }
595 \fancypagestyle{endnotesstyle}{%
596 \fancyhf{}
597 \fancyhead[CO]{{\small{\em \the\notesheadername~\mymarks}}}
598 \fancyhead[CE]{{\small{\em \the\notesheadername~\mymarks}}}
599 \renewcommand{\headrulewidth}{0pt}
600 \renewcommand{\footrulewidth}{0pt}
601 \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
602 }
603 }
604 % \end{macrocode}
605 % \end{macro}
606 % \begin{macro}{\checknoteheaders}
607 % This macro sets the counter notepageholder to the value given by the
608 % pageref of the note that is being output. All that strange business
609 % with |\string| is there because I want to use the |\immediate\write|
610 % mechanism to control what gets expanded and what doesn't get
611 % expanded on the external files for the endnotes, |\jobname.ent| and
612 % its friends. Everything except the actual number of the endnote is
613 % written to the external file as unexpanded tokens. When, after you
614 % call |\theendnotes|, you read in the external file for the endnotes,
615 % for example |\jobname.ent|, all these tokens become a command to set
616 % the |\mark|. Notice that there are two forms of this command, one
617 % for the standard document classes, one for memoir class.
618 % \textsf{edmargin} chooses which form depending upon which class is
619 % loaded.
620 % \begin{macrocode}
621 \@ifclassloaded{memoir}{\newcommand{\checknoteheaders}{%
622 \string\setcounterfrompageref\string{notepageholder\string}%
623 \string{notl\theallendnotes\string}%
624 \string\markboth\string{\string\thenotepageholder
625 \string}\string{\string\thenotepageholder\string}%
626 }
627 }{\newcommand{\checknoteheaders}{%
628 \string\setcounterfrompageref\string{notepageholder\string}%
629 \string{notl\theallendnotes\string}%
630 \string\mark\string{\string\thenotepageholder\string}%
631 }
632 }
633
634 % \end{macrocode}
635 % \end{macro}
636 % \subsection{User Code}
637 % \begin{macro}{\notesincontents}
638 % This command just sets a boolean. Later, that boolean will be used
639 % to determine whether you use the default line for the table of
640 % contents for each endnote class, or whether you define one for
641 % yourself using |\addtocontents|.
642 % \begin{macrocode}
643 \newif\ifnotesincontentson \notesincontentsonfalse
644 \newcommand{\notesincontents}{\notesincontentsontrue}
645 % \end{macrocode}
646 % \end{macro}
647 %
648 % \begin{macro}{\maketextnotes}
649 % Next, setting up the textual collations: |\maketextnotes| opens an
650 % external file with the extension .ent. And it sends formatting
651 % information for the first page of the section, as well as
652 % information to send to the table of contents. Also, it sets a label
653 % for sending the page number of the textual notes to the table of
654 % contents.
655 % \begin{macrocode}
656 % Extra white space at the top of the first page
657 \newcommand{\backmatterafterheadersink}{\leavevmode\vspace{11pt}}
658 % Set notes in small type
659 \newcommand{\backmattertextfont}{\small}
660 % writes unexpanded text on the specified external file
661 \def\strip#1>{}
662 \newcommand{\literaltextnote}[1]{%
663 \begingroup%
664 \def\next{#1}%
665 \newlinechar='40%
666 \immediate\write\textnotes{\expandafter\strip\meaning\next}%
667 \endgroup%
668 }
669 \newcommand{\literalemend}[1]{%
670 \begingroup%
671 \def\next{#1}%
672 \newlinechar='40%
673 \immediate\write\emendations{\expandafter\strip\meaning\next}%
674 \endgroup%
675 }
676 \newcommand{\literalexplain}[1]{%
677 \begingroup%
678 \def\next{#1}%
679 \newlinechar='40%
680 \immediate\write\explanations{\expandafter\strip\meaning\next}%
681 \endgroup%
682 }
683 % Nothing happens to textual notes unless you say you want to collect
684 % them.
685 \newif\iftextnoteson \textnotesonfalse
686 \newif\ifexplanon \explanonfalse
687 \newif\ifemendationson \emendationsonfalse
688 % Use tokens rather than hard coded names to make multilingual use easier
689 \newtoks{\notesheadername}
690 \newtoks{\edmrgnotesname}
691 \edmrgnotesname={TEXTUAL NOTES}
692 \newcommand{\changetextnotesname}[1]{\edmrgnotesname={#1}}
693 \newtoks{\textnotesheadername}
694 \textnotesheadername={Textual Notes to}
695 \newcommand{\changetextnotesheader}[1]{\textnotesheadername={#1}}
696 \newtoks{\textnotescontentsname}
697 \textnotescontentsname={Textual Notes}
698 \newcommand{\changetextnotescontentsname}[1]{\textnotescontentsname={#1}}
699 % font size for endnote section titles
700 \newcommand{\backmatterheadingfont}{\fontsize{16}{20}\selectfont}
701 % setting up an empty page
702 \newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
703 % white space at top of back matter sections
704 \newcommand{\backmattersink}{\leavevmode\vspace{21.5pt}}
705 % set up the external file for textual notes
706 \newcommand{\maketextnotes}{\global\textnotesontrue
707 \newwrite\textnotes
708 \immediate\openout\textnotes=\jobname.ent
709 \literaltextnote{{\par\clearpage
710 {\pagestyle{empty}\cleardoublepage}
711 \thispagestyle{empty}}
712 \notesheadername={\the\textnotesheadername}
713 \pagestyle{endnotesstyle}
714 % \fancyhead{}
715 % \fancyfoot{}
716 % \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
717 % \fancyhead[CO]{{\small{\em \the\textnotesheadername~\mymarks}}}
718 % \fancyhead[CE]{{\small{\em \the\textnotesheadername~\mymarks}}}
719 % \fancyfoot[C]{}
720 \mark{3}
721 \backmattersink
722 \begin{center}{\normalfont \backmatterheadingfont \the\edmrgnotesname}\end{center}
723 \label{textualnotes}
724 % \lefthyphenmin=2\backmatterafterheadersink\tolerance=500\language=0
725 \normalfont \backmattertextfont}
726 \immediate\write\textnotes{\string\ifnotesincontentson}%
727 \immediate\write\textnotes{\string\addcontentsline\string{toc\string}
728 \string{chapter\string}\string{\string\the\string\textnotescontentsname\string}}%
729 %\immediate\write\@enotes{\string{\string\notescontentsname\string}}%
730 %\string{\string\protect\string\numberline
731 %\string{\string} \string\notescontentsname \string}
732 \immediate\write\textnotes{\string\fi}
733 }
734 % \end{macrocode}
735 % \end{macro}
736
737 % \begin{macro}{\makeemendations}
738 % Next, the emendations section:
739 % \begin{macrocode}
740 \newtoks{\emendationsname}
741 \emendationsname={EMENDATIONS}
742 \newcommand{\changeemendationsname}[1]{\emendationsname={#1}}
743 \newtoks{\emendationsheadername}
744 \emendationsheadername={Emendations to}
745 \newcommand{\changeemendationsheader}[1]{\emendationsheadername={#1}}
746 \newtoks{\emendationscontentsname}
747 \emendationscontentsname={Emendations}
748 \newcommand{\changeemendationscontentsname}[1]{%
749 \emendationscontentsname={#1}}
750 \newcommand{\makeemendations}{\global\emendationsontrue
751 \newwrite\emendations
752 \immediate\openout\emendations=\jobname.emd
753 \literalemend{{\par\clearpage
754 {\pagestyle{empty}\cleardoublepage}
755 \thispagestyle{empty}}
756 \notesheadername={\the\emendationsheadername}
757 \pagestyle{endnotesstyle}
758 % \fancyhead{}
759 % \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
760 % \fancyhead[CO]{{\small{\em \the\emendationsheadername~\mymarks}}}
761 % \fancyhead[CE]{{\small{\em \the\emendationsheadername~\mymarks}}}
762 % \fancyfoot{}
763 \mark{3}
764 \backmattersink
765 \begin{center}{\normalfont \backmatterheadingfont
766 \the\emendationsname}\end{center}
767 \label{emendationnotes}
768 % \lefthyphenmin=2\backmatterafterheadersink\tolerance=500\language=0
769 \normalfont \backmattertextfont}
770 \immediate\write\emendations{\string\ifnotesincontentson}%
771 \immediate\write\emendations{\string\addcontentsline\string{toc\string}
772 \string{chapter\string}\string{\string\the\string\emendationscontentsname\string}}%
773 %\immediate\write\@enotes{\string{\string\notescontentsname\string}}%
774 %\string{\string\protect\string\numberline
775 %\string{\string} \string\notescontentsname \string}
776 \immediate\write\emendations{\string\fi}
777 }
778 % \end{macrocode}
779 % \end{macro}
780
781 % \begin{macro}{\makeexplanatorynotes}
782 % And the explanatory notes:
783 % \begin{macrocode}
784 \newtoks{\explanationsname}
785 \explanationsname={EXPLANATORY NOTES}
786 \newcommand{\changeexplanationsname}[1]{\explanationsname={#1}}
787 \newtoks{\explanationsheadername}
788 \explanationsheadername={Explanatory Notes to}
789 \newcommand{\changeexplanationsheader}[1]{\explanationsheadername={#1}}
790 \newtoks{\explanationscontentsname}
791 \explanationscontentsname={Explanatory Notes}
792 \newcommand{\changeexplanationscontentsname}[1]{%
793 \explanationscontentsname={#1}}
794 \newcommand{\makeexplanatorynotes}{\global\explanontrue
795 \newwrite\explanations
796 \immediate\openout\explanations=\jobname.enx
797 \literalexplain{{\par\clearpage
798 {\pagestyle{empty}\cleardoublepage}
799 \thispagestyle{empty}}
800 \notesheadername={\the\explanationsheadername}
801 \pagestyle{endnotesstyle}
802 % \fancyhead[RO,LE]{{\small\textrm{\thepage}}}
803 % \fancyhead[CO]{{\small{\em \the\explanationsheadername~\mymarks}}}
804 % \fancyhead[CE]{{\small{\em \the\explanationsheadername~\mymarks}}}
805 % \fancyfoot{}
806 \mark{3}
807 \backmattersink
808 \begin{center}{\normalfont \backmatterheadingfont
809 \the\explanationsname}\end{center}
810 \label{explanatorynotes}
811 % \lefthyphenmin=2\backmatterafterheadersink\tolerance=500\language=0
812 \normalfont \backmattertextfont }
813 \immediate\write\explanations{\string\ifnotesincontentson}%
814 \immediate\write\explanations{\string\addcontentsline\string{toc\string}
815 \string{chapter\string}\string{\string\the\string\explanationscontentsname\string}}%
816 %\immediate\write\@enotes{\string{\string\notescontentsname\string}}%
817 %\string{\string\protect\string\numberline
818 %\string{\string} \string\notescontentsname \string}
819 \immediate\write\explanations{\string\fi}
820 }
821 % \end{macrocode}
822 % \end{macro}
823
824 % Auxiliary commands for note and title sections
825 % \begin{macrocode}
826 %
827 \newcommand{\argpageref}[1]{\pageref{#1}}
828 \newcommand{\@pagemarktotextnotes}[1]{%
829 \immediate\write\textnotes{\string\setcounterfrompageref\string{notepageholdertitle\string}%
830 \string{#1\string}\string\unskip}%
831 \immediate\write\textnotes{\string\mark%
832 \string{\string\thenotepageholdertitle\string}}%
833 }
834 \newcommand{\@poempagetotextnotes}[1]{%
835 \immediate\write\textnotes{\string\par\string\argpageref\string{#1\string}\string\unskip}%
836 \@pagemarktotextnotes{#1}}
837 \newcommand{\@poemtitletotextnotes}[1]{\literaltextnote{\textbf{#1}}}
838 % \end{macrocode}
839 % \begin{macro}{\setupendnoteheaders}
840 % |\setupendnoteheaders| turns on processing of running headers.
841 % \begin{macrocode}
842 \newif\ifendnoteheaderson \endnoteheadersonfalse
843 \newcommand{\setupendnoteheaders}{%
844 \endnoteheadersontrue
845 \maketextnotes
846 \makeexplanatorynotes
847 \makeemendations
848 }
849 % \newcommand{\setupendnoteheaders}{%
850 % \endnoteheadersontrue
851 % \if@enotesopen \else \@openenotes \fi
852 % \immediate\write\@enotes{%
853 % \string\thispagestyle\string{empty\string}
854 % \string\pagestyle\string{endnotesstyle\string}}
855 % \immediate\write\@enotes{\string\ifnotesincontentson}%
856 % \immediate\write\@enotes{\string\addcontentsline\string{toc\string}
857 % \string{chapter\string}\string{\string\the\string\notescontentsname\string}}%
858 % %\immediate\write\@enotes{\string{\string\notescontentsname\string}}%
859 % %\string{\string\protect\string\numberline
860 % %\string{\string} \string\notescontentsname \string}
861 % \immediate\write\@enotes{\string\fi}
862 % \def\endnote{\@ifnextchar[\@xendnote{\stepcounter{endnote}%
863 % % my addition begins
864 % \stepcounter{allendnotes}\label{notl\theallendnotes}%
865 % \immediate\write\@enotes{\checknoteheaders}%
866 % % my addition ends
867 % \protected@xdef\@theenmark{\theendnote}%
868 % \@endnotemark\@endnotetext}}
869 % \let\oldtheendnotes=\theendnotes
870 % \renewcommand{\theendnotes}{%
871 % \immediate\write\@enotes{\string\thispagestyle\string{endnotesstyle\string}}
872 % \oldtheendnotes}
873 % }
874 % \end{macrocode}
875 % \end{macro}
876 % \begin{macro}{\putemendations} This macro closes external file for emendations,
877 % reads it in, and puts an entry for the emendations into the table of contents
878 % file. The macro tests to see whether there is an .aux file from a previous run
879 % before doing this, and complains in the .log file if the .aux file does not
880 % exist.
881 %
882 % \begin{macrocode}
883 % \newcommand{\hyphenationforsmall}{\small\bf \hyphenchar\font=45
884 % \small\it \hyphenchar\font=45
885 % \small\rm \hyphenchar\font=45
886 % }
887 \newcommand{\putemendations}{
888 \ifemendationson
889 \clearemptydoublepage
890 % \hyphenationforsmall
891 \immediate\closeout\emendations
892 \input \jobname.emd
893 % \ifpoemcontentson
894 % \ifemendationson
895 % \immediate\write\poemcontents{\string\contentspoemtitlefont\ \the\emendationscontentsname}
896 % \immediate\write
897 % \poemcontents{\string~ \string\contentsleaders \string~\
898 % \string\pageref{emendationnotes} \string\par}
899 % \immediate\write\poemcontents{\string\par \string\smallskip}
900 % \fi
901 %\fi
902 \else
903 \relax
904 \fi}
905 % \end{macrocode}
906 % \end{macro}
907 % \begin{macro}{\putexplanatory} Does the same for explanatory notes.
908 %
909 % \begin{macrocode}
910 \newcommand{\putexplanatory}{
911 \ifexplanon
912 \clearemptydoublepage
913 % \hyphenationforsmall
914 \immediate\closeout\explanations
915 \input \jobname.enx
916 % \ifpoemcontentson
917 % \ifexplanon
918 % \immediate\write\poemcontents{\string\contentspoemtitlefont\ \the\explanationscontentsname}
919 % \immediate\write
920 % \poemcontents{\string~ \string\contentsleaders \string~\
921 % \string\pageref{explanatorynotes} \string\par}
922 % \immediate\write\poemcontents{\string\par \string\smallskip}
923 % \fi
924 % \fi
925 \else
926 \relax
927 \fi}
928 % \end{macrocode}
929 % \end{macro}
930 % \begin{macro}{\puttextnotes} Does the same for textual notes.
931 %
932 % \begin{macrocode}
933 \newcommand{\puttextnotes}{
934 \iftextnoteson
935 \clearemptydoublepage
936 % \hyphenationforsmall
937 \immediate\closeout\textnotes
938 \input \jobname.ent
939 % \ifpoemcontentson
940 % \iftextnoteson
941 % \immediate\write\poemcontents{\string\contentspoemtitlefont\ \the\textnotescontentsname}
942 % \immediate\write
943 % \poemcontents{\string~ \string\contentsleaders \string~\
944 % \string\pageref{textualnotes} \string\par}
945 % \immediate\write\poemcontents{\string\par \string\smallskip}
946 % \fi
947 % \fi
948 \else
949 \relax
950 \fi}
951 % \end{macrocode}
952 % \end{macro}
953 % \begin{macro}{\margreftextnote} Macros to set marginal page
954 % references showing where in the apparatus a comment upon the
955 % marked line is to be found. |\margrefspecial{}| is for occasions
956 % when you might need to set the label by hand. For instance, suppose
957 % you have several textnotes on a line, and the note you wish to draw
958 % attention to is on a different page from the other notes.
959 % |\margreftextnote| under those circumstances will point only to the
960 % first note. Use |\margrefspecial| to point to the other note,
961 % giving |\margrefspecial| a unique argument, and opening that note
962 % with a \label{} command using the same argument.
963 %
964 % \begin{macrocode}
965 \setlength{\marginparwidth}{2em}
966 \newcounter{margrefnumber}
967 \setcounter{margrefnumber}{1}
968 \newtoks{\margrefmarker}
969 \margrefmarker={\dag}
970 \newcommand{\setmargrefmarker}[1]{\margrefmarker={#1}}%
971 \newcommand{\makemargreflabel}{\string\label\string{margref\themargrefnumber\string}}
972 \newcommand{\setmargref}{%
973 \marginpar{\scriptsize{\the\margrefmarker~\the\singlepageabbrev~\pageref{margref\themargrefnumber}}}%
974 }
975 \newcommand{\margreftextnote}{%
976 \iftextnoteson\addtocounter{margrefnumber}{1}%
977 \immediate\write\textnotes{\makemargreflabel}%
978 \setmargref\else\relax\fi%
979 }
980 \newcommand{\margrefexplanatory}{%
981 \ifexplanon\addtocounter{margrefnumber}{1}%
982 \immediate\write\explanations{\makemargreflabel}%
983 \setmargref\else\relax\fi%
984 }
985 \newcommand{\margrefemendation}{%
986 \ifemendationson\addtocounter{margrefnumber}{1}%
987 \immediate\write\emendations{\makemargreflabel}%
988 \setmargref\else\relax\fi%
989 }
990 \newcommand{\margrefspecial}[1]{%
991 \marginpar{\scriptsize {\the\margrefmarker~\the\singlepageabbrev~\pageref{#1}}}
992 }
993 % or, perhaps the note marker should be in the text rather than in
994 % the margin
995 \newif\ifn@temarkinmargin%
996 \n@temarkinmargintrue%
997 \newif\ifn@temarkintext%
998 \n@temarkintextfalse%
999 \newcommand{\notemarkinmargin}{\n@temarkinmargintrue\n@temarkintextfalse}
1000 \newcommand{\notemarkintext}{\n@temarkinmarginfalse\n@temarkintexttrue}
1001 %\newif\ifnotemarkinmargin \notemarkinmargintrue%
1002 \newcounter{enmrnotescratchcount}%
1003 \setcounter{enmrnotescratchcount}{0}
1004 \newtoks{\enmrendnotemarker}%
1005 \newcommand{\makeenmrendnotemarker}{%
1006 \enmrendnotemarker={\the\margrefmarker\theenmrnotescratchcount}}%
1007 \newcommand{\putenmrnotemarkerintext}{%
1008 \hbox\textsuperscript{\scriptsize{\the\enmrendnotemarker}}}%
1009 % To set notes in as a block paragraph, rather than individually
1010 \newif{\iftextnotespara}{\textnotesparafalse}
1011 \newcommand{\textnotesparamode}{\textnotesparatrue}
1012 \newif{\ifemendationspara}{\emendationsparafalse}
1013 \newcommand{\emendationsparamode}{\emendationsparatrue}
1014 \newif{\ifexplanationspara}{\explanationsparafalse}
1015 \newcommand{\explanationsparamode}{\explanationsparatrue}
1016 % \end{macrocode}
1017 % \end{macro}
1018 % \begin{macro}{\textnote}
1019 % \begin{macrocode}
1020 % \newcommand{\textnote}[1]{%
1021 % \iftextnoteson%
1022 % \margrefmarker={t:}%
1023 % \stepcounter{allendnotes}\label{notl\theallendnotes}%
1024 % \immediate\write\textnotes{\checknoteheaders}%
1025 % \immediate\write\textnotes{\string\par\string{\string\textbf\string{p.\
1026 % \string\pageref\string{notl\theallendnotes\string}\string}\string}}%
1027 % \literaltextnote{~#1}%
1028 % \margreftextnote%
1029 % \fi
1030 % }
1031 \newcounter{enmrtextnotecount}
1032 \newcommand{\textnote}[1]{%
1033 \iftextnoteson%
1034 \margrefmarker={t:}%
1035 \ifn@temarkinmargin%n@temarkinmargin
1036 \margreftextnote%
1037 \else%
1038 \stepcounter{enmrtextnotecount}%
1039 \setcounter{enmrnotescratchcount}{\value{enmrtextnotecount}}%
1040 \makeenmrendnotemarker%
1041 \putenmrnotemarkerintext%
1042 \fi%
1043 \stepcounter{allendnotes}\label{notl\theallendnotes}%
1044 \immediate\write\textnotes{\checknoteheaders}%
1045 \ifn@temarkinmargin%
1046 \iftextnotespara\relax\else%
1047 \immediate\write\textnotes{\string\par}\fi%
1048 \immediate\write\textnotes{\string{\string\textbf\string{\the\singlepageabbrev\
1049 \string\pageref\string{notl\theallendnotes\string}\string}\string}}%
1050 \else
1051 \iftextnotespara\relax\else%
1052 \immediate\write\textnotes{\string\par}\fi%
1053 \immediate\write\textnotes{\string\textsuperscript\string{\theenmrnotescratchcount\string}%
1054 }%
1055 \fi
1056 \literaltextnote{~#1}%
1057 \fi
1058 }
1059 % \end{macrocode}
1060 % \end{macro}
1061 % \begin{macro}{\explanatory}
1062 % \begin{macrocode}
1063 \newcounter{enmrexplanatorycount}
1064 \newcommand{\explanatory}[1]{%
1065 \ifexplanon%
1066 \margrefmarker={c:}%
1067 \ifn@temarkinmargin%
1068 \margrefexplanatory%
1069 \else%
1070 \stepcounter{enmrexplanatorycount}%
1071 \setcounter{enmrnotescratchcount}{\value{enmrexplanatorycount}}%
1072 \makeenmrendnotemarker%
1073 \putenmrnotemarkerintext%
1074 \fi%
1075 \stepcounter{allendnotes}\label{notl\theallendnotes}%
1076 \immediate\write\explanations{\checknoteheaders}%
1077 \ifn@temarkinmargin%
1078 \ifexplanationspara\relax\else%
1079 \immediate\write\explanations{\string\par}\fi%
1080 \immediate\write\explanations{\string{\string\textbf\string{\the\singlepageabbrev\
1081 \string\pageref\string{notl\theallendnotes\string}\string}\string}}%
1082 \else%
1083 \ifexplanationspara\relax\else%
1084 \immediate\write\explanations{\string\par}\fi%
1085 \immediate\write\explanations{\string%
1086 \textsuperscript\string{\theenmrnotescratchcount\string}%
1087 }%
1088 \fi
1089 \literalexplain{~#1}%
1090 \fi}
1091 % \end{macrocode}
1092 % \end{macro}
1093 % \begin{macro}{\emendation}
1094 % \begin{macrocode}
1095 \newcounter{enmremendationcount}
1096 \newcommand{\emendation}[1]{%
1097 \ifemendationson%
1098 \margrefmarker={e:}%
1099 \ifn@temarkinmargin%
1100 \margrefemendation%
1101 \else%
1102 \stepcounter{enmremendationcount}%
1103 \setcounter{enmrnotescratchcount}{\value{enmremendationcount}}%
1104 \makeenmrendnotemarker%
1105 \putenmrnotemarkerintext%
1106 \fi%
1107 \stepcounter{allendnotes}\label{notl\theallendnotes}%
1108 \immediate\write\emendations{\checknoteheaders}%
1109 \ifn@temarkinmargin%
1110 \ifemendationspara\relax\else%
1111 \immediate\write\emendations{\string\par}\fi%
1112 \immediate\write\emendations{\string{\string\textbf\string{\the\singlepageabbrev\
1113 \string\pageref\string{notl\theallendnotes\string}\string}\string}}%
1114 \else%
1115 \ifemendationspara\relax\else%
1116 \immediate\write\emendations{\string\par}\fi%
1117 \immediate\write\emendations{\string\textsuperscript\string{\theenmrnotescratchcount\string}%
1118 }%
1119 \fi
1120 \literalemend{~#1}%
1121 \fi}
1122 % \end{macrocode}
1123 % \end{macro}
1124 % \begin{macro}{\setstyleforchapternotebegin}
1125 % \begin{macrocode}
1126 \newif\iftitleinnotes \titleinnotestrue%
1127 \newcommand{\styleforchapternotebegin}{%
1128 }
1129 \newcommand{\styleforchapternoteend}{%
1130 }
1131 \newcommand{\setstyleforchapternotebegin}[1]{%
1132 \renewcommand{\styleforchapternotebegin}{#1}}
1133 \newcommand{\setstyleforchapternoteend}[1]{%
1134 \renewcommand{\styleforchapternoteend}{#1}}%
1135 \setstyleforchapternotebegin{\begin{center}}
1136 \setstyleforchapternoteend{\end{center}}
1137 \newcommand{\resettextnotes}{%
1138 % \label{chapter\thechapter}%
1139 \immediate\write\textnotes{\string\begingroup}%
1140 \immediate\write\textnotes{\string\goodbreak}%
1141 \immediate\write\textnotes{\string\Needspace\string{5\string\baselineskip\string}}%
1142 \immediate\write\textnotes{\string\styleforchapternotebegin}%
1143 \immediate\write\textnotes{\the\chapternoteslinename\string\ \thechapter\string~}%
1144 \iftitleinnotes%
1145 \immediate\write\textnotes{\string\titleref\string{chapter\thechapter\string}}%
1146 \fi%
1147 %\immediate\write\textnotes{\string}}
1148 \immediate\write\textnotes{\string\styleforchapternoteend}%
1149 % \immediate\write\textnotes{\string\end\string{center\string}}
1150 \immediate\write\textnotes{\string\nopagebreak}%
1151 \immediate\write\textnotes{\string\endgroup}%
1152 }
1153 \newcommand{\resetemendations}{%
1154 % \label{chapter\thechapter}%
1155 \immediate\write\emendations{\string\begingroup}%
1156 \immediate\write\emendations{\string\goodbreak}%
1157 \immediate\write\emendations{\string\Needspace\string{5\string\baselineskip\string}}%
1158 \immediate\write\emendations{\string\styleforchapternotebegin}%
1159 \immediate\write\emendations{\the\chapternoteslinename\string\ \thechapter\string~}%
1160 \iftitleinnotes%
1161 \immediate\write\emendations{\string\titleref\string{chapter\thechapter\string}}%
1162 \fi%
1163 \immediate\write\emendations{\string\styleforchapternoteend}%
1164 \immediate\write\emendations{\string\nopagebreak}%
1165 \immediate\write\emendations{\string\endgroup}%
1166 }
1167 \newcommand{\resetexplanatory}{%
1168 % \label{chapter\thechapter}%
1169 \immediate\write\explanations{\string\begingroup}%
1170 \immediate\write\explanations{\string\goodbreak}%
1171 \immediate\write\explanations{\string\Needspace\string{5\string\baselineskip\string}}%
1172 \immediate\write\explanations{\string\styleforchapternotebegin}%
1173 \immediate\write\explanations{\the\chapternoteslinename\string\ \thechapter\string~}%
1174 \iftitleinnotes%
1175 \immediate\write\explanations{\string\titleref\string{chapter\thechapter\string}}%
1176 \fi%
1177 \immediate\write\explanations{\string\styleforchapternoteend}%
1178 \immediate\write\explanations{\string\nopagebreak}%
1179 \immediate\write\explanations{\string\endgroup}%
1180 }
1181 \newcommand{\resetendnotes}{%
1182 % \label{chapter\thechapter}% removed SEP-04-2012
1183 \resettextnotes%
1184 \resetemendations%
1185 \resetexplanatory}
1186 % \end{macrocode}
1187 % \end{macro}
1188 % \begin{macro}{\notesbychapter}
1189 % \begin{macrocode}
1190 \newif\ifnotesbychapteron \notesbychapteronfalse
1191 \@ifclassloaded{memoir}{\newcommand{\notesbychapter}{\notesbychapterontrue}
1192 \addtoiargdef{\chapter}{}{ \iftitleinnotes%
1193 \label{chapter\thechapter}%
1194 \fi%
1195 \ifnotesbychapteron%
1196 \relax%
1197 \resetendnotes%
1198 \fi}
1199 }{\newcommand{\notesbychapter}{\notesbychapterontrue}
1200 \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
1201 \if@mainmatter
1202 \refstepcounter{chapter}%
1203 \typeout{\@chapapp\space\thechapter.}%
1204 \addcontentsline{toc}{chapter}%
1205 {\protect\numberline{\thechapter}#1}%
1206 \else
1207 \addcontentsline{toc}{chapter}{#1}%
1208 \fi
1209 \else
1210 \addcontentsline{toc}{chapter}{#1}%
1211 \fi
1212 \chaptermark{#1}%
1213 \addtocontents{lof}{\protect\addvspace{10\p@}}%
1214 \addtocontents{lot}{\protect\addvspace{10\p@}}%
1215 \if@twocolumn
1216 \@topnewpage[\@makechapterhead{#2}]%
1217 \else
1218 \@makechapterhead{#2}%
1219 \@afterheading
1220 \fi
1221 \iftitleinnotes%
1222 \label{chapter\thechapter}%
1223 \fi%
1224 \ifnotesbychapteron%
1225 \relax%
1226 \resetendnotes%
1227 \fi}
1228 }
1229 % \end{macrocode}
1230 % \end{macro}
1231 % \begin{macro}{\definenewnotetype}
1232 % \begin{macrocode}
1233 % first, some building block commands
1234 % make some new ifs (Thanks to Igor Pechtchanski and Ulrich Schwarz)
1235 \newcommand{\m@kenewnoteif}[1]{%
1236 \expandafter\newif\csname if#1son\endcsname%
1237 \global\csname #1sontrue\endcsname%
1238 \expandafter\newif\csname ifno#1yet\endcsname%
1239 \csname no#1yettrue\endcsname%
1240 }
1241 % make a new output stream
1242 \newcommand{\n@woutputstream}[2]{%
1243 \expandafter\newwrite\csname #1s\endcsname%
1244 \immediate\expandafter\openout\csname #1s\endcsname=\expandafter\jobname .#2%
1245 }
1246 % set up a new literalwrite command
1247 \newcommand{\n@wliteralwrite}[1]{%
1248 \expandafter\newcommand\csname literal#1\endcsname[1]{%
1249 \begingroup%
1250 \def\next{##1}%
1251 \newlinechar='40
1252 \immediate\write\expandafter\csname #1s\endcsname{\expandafter\strip\meaning\next}%
1253 \endgroup}
1254 }
1255 % heading material for new notes, label, font, par mode default
1256 \newcommand{\n@wnoteheadingmaterial}[3]{%
1257 \csname literal#1\endcsname{%
1258 \par\clearpage%
1259 {\pagestyle{empty}\cleardoublepage}%
1260 \thispagestyle{empty}%
1261 }
1262 \immediate\write\csname #1s\endcsname{%
1263 \string\notesheadername=\string{#2\string}%
1264 \string\pagestyle\string{endnotesstyle\string}%
1265 }
1266 \immediate\write\csname #1s\endcsname{%
1267 \string\mark\string{3\string}%
1268 \string\backmattersink%
1269 \string\begin\string{center\string}%
1270 \string{\string\normalfont \string%
1271 \backmatterheadingfont\ #3\string}\string\end\string{center\string}%
1272 }
1273 \immediate\write\csname #1s\endcsname{\string\label\string{#3\string}}%
1274 \immediate\write\csname #1s\endcsname{\string\normalfont\string\backmattertextfont}%
1275 \immediate\write\csname #1s\endcsname{\string\paramodefalse}%
1276 }
1277 % new entry for table of contents
1278 \newcommand{\n@wentryfortoc}[2]{%
1279 \immediate\write\csname #1s\endcsname{\string\ifnotesincontentson}%
1280 \immediate\write\csname #1s\endcsname{\string\addcontentsline\string{toc\string}%
1281 \string{chapter\string}\string{#2\string}}%
1282 \immediate\write\csname #1s\endcsname{\string\fi}%
1283 }
1284 % new marginal reference kind
1285 \newcommand{\n@wmargrefkind}[1]{%
1286 \expandafter\newcommand\csname margref#1\endcsname[1]{%
1287 \addtocounter{margrefnumber}{1}%
1288 \immediate\write\csname #1s\endcsname{\makemargreflabel}%
1289 \setmargref%
1290 }
1291 }
1292 % new note counter
1293 \newcommand{\n@wnotecounter}[1]{%
1294 \expandafter\newcounter{enmr#1count}%
1295 }
1296 \newcommand{\n@wparaboolean}[1]{%
1297 \expandafter\newif\csname if#1spara\endcsname}%
1298 \newcommand{\n@wputmargref}[1]{%
1299 \expandafter\csname margref#1\endcsname%
1300 }
1301 \newcommand{\n@wputnotenum}[1]{%
1302 \expandafter\stepcounter{enmr#1count}%
1303 \setcounter{enmrnotescratchcount}{\expandafter\value{enmr#1count}}%
1304 \makeenmrendnotemarker%
1305 \putenmrnotemarkerintext%
1306 }
1307 \newif\ifparamode \paramodefalse%
1308 \newcommand{\n@wsetparamode}[1]{%
1309 \expandafter\newcommand\csname #1sparamode\endcsname{%
1310 %\csname #1sparatrue\endcsname
1311 \immediate\write\expandafter\csname #1s\endcsname{\string\paramodetrue}%
1312 }
1313 }
1314 \newcommand{\enmrconditionalpar}{%
1315 \ifparamode%
1316 % \if#1spara
1317 \relax%
1318 \else%
1319 \par%
1320 \fi%
1321 }
1322 \newcommand{\n@wnotecommand}[2]{%
1323 \expandafter\newcommand\csname #1\endcsname[1]{%
1324 \margrefmarker={#2:}%
1325 \ifn@temarkinmargin%
1326 \n@wputmargref{#1}%
1327 \fi%
1328 \ifn@temarkintext%
1329 \n@wputnotenum{#1}%
1330 \fi%
1331 \stepcounter{allendnotes}\label{notl\theallendnotes}%
1332 \immediate\write\expandafter\csname #1s\endcsname{\checknoteheaders}%
1333 \ifn@temarkinmargin%
1334 \immediate\write\expandafter\csname #1s\endcsname{\string\enmrconditionalpar}%
1335 %\immediate\write\expandafter\csname #1s\endcsname{\string\par}
1336 \immediate\write\expandafter\csname #1s\endcsname{\string{\string\textbf\string{\the\singlepageabbrev\
1337 \string\pageref\string{notl\theallendnotes\string}\string}\string}}%
1338 \else%
1339 % \immediate\write\csname #1s\endcsname{\string\par}
1340 \immediate\write\expandafter\csname #1s\endcsname{\string\enmrconditionalpar}%
1341 \immediate\write\csname #1s\endcsname{%
1342 \string\textsuperscript\string{\theenmrnotescratchcount\string}%
1343 }%
1344 \fi
1345 \expandafter\csname literal#1\endcsname{~##1}%
1346 }}
1347 %%%%%%%%%%%%%%
1348 \newcommand{\definenewnotetype}[6]{%
1349 % 1. make new ifs
1350 \m@kenewnoteif{#1}%
1351 % 2 # new output stream and external file
1352 \n@woutputstream{#1}{#2}%
1353 % 4. set up a literalwrite command
1354 \n@wliteralwrite{#1}%
1355 % 5. First a blank page than a page in the empty pagestyle
1356 % set the page style and running header
1357 \n@wnoteheadingmaterial{#1}{#3}{#4}%
1358 % 6. set up entry for table of contents
1359 \n@wentryfortoc{#1}{#5}%
1360 % % 7. set up a command to write the note
1361 \n@wmargrefkind{#1}%
1362 % % then a counter for the note kind
1363 \n@wnotecounter{#1}
1364 % % then a boolean for setting the notes in paragraph format
1365 \n@wparaboolean{#1}
1366 \n@wsetparamode{#1}
1367 % % then the note command
1368 \n@wnotecommand{#1}{#6}
1369 % 8. make a reset command for setting by chapter
1370 \expandafter\newcommand\csname reset#1s\endcsname[1]{%
1371 \immediate\write\csname #1s\endcsname{\string\begingroup}%
1372 \immediate\write\csname #1s\endcsname{\string\goodbreak}%
1373 \immediate\write\csname #1s\endcsname{\string\Needspace\string{5\string\baselineskip\string}}%
1374 \immediate\write\csname #1s\endcsname{\string\styleforchapternotebegin}%
1375 \immediate\write\csname #1s\endcsname{\the\chapternoteslinename\string\ \thechapter\string~}%
1376 \iftitleinnotes%
1377 \immediate\write\csname #1s\endcsname{\string\titleref\string{chapter\thechapter\string}}%
1378 \fi%
1379 \immediate\write\csname #1s\endcsname{\string\styleforchapternoteend}%
1380 \immediate\write\csname #1s\endcsname{\string\nopagebreak}%
1381 \immediate\write\csname #1s\endcsname{\string\endgroup}%
1382 }
1383 % 9. add this to resetchapter and setbychapter
1384 %\appendtomacro{\notesbychapter}{\expandafter\csname reset#1s\endcsname}
1385 \appendtomacro{\resetendnotes}{\expandafter\csname reset#1s\endcsname}%
1386 % 10. command for closing the file and reading in the endnotes section
1387 \expandafter\newcommand\csname put#1s\endcsname{%
1388 \immediate\expandafter\closeout\csname #1s\endcsname%
1389 \expandafter\input \jobname.#2%
1390 }%
1391 }
1392 % \end{macrocode}
1393 % \end{macro}
1394 % \Finale
1395 \endinput