blob: 1675c333083cfd5027ee7c67e2b2035b70f25e9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
%%
%% This is file `pagenote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pagenote.dtx (with options: `usc')
%%
%% -----------------------------------------------------------------
%% Author: Peter Wilson (The Herries Press)
%% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
%% Copyright 2004 Peter R. Wilson
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any
%% later version: <http://www.latex-project.org/lppl.txt>
%%
%% This work has the LPPL maintenance status "maintained".
%% The Current Maintainer of this work is Will Robertson.
%%
%% This work consists of the files listed in the README file.
%% -----------------------------------------------------------------
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pagenote}[2009/09/03 v1.1a page/end notes]
\@ifclassloaded{memoir}{}{\RequirePackage{ifmtarg}}
\newif\ifpnhaschapter
\@ifundefined{chapter}{\pnhaschapterfalse}{\pnhaschaptertrue}
\providecommand{\f@rtoc}{}
\newif\ifpnpageopt
\pnpageoptfalse
\newif\ifpncontopt
\pncontoptfalse
\DeclareOption{page}{\pnpageopttrue}
\DeclareOption{continuous}{\pncontopttrue}
\ProcessOptions
\ifpncontopt
\newcounter{pagenote}
\else
\ifpnhaschapter
\newcounter{pagenote}[chapter]
\else
\newcounter{pagenote}[section]
\fi
\fi
\renewcommand{\thepagenote}{\arabic{pagenote}}
\setcounter{pagenote}{0}
\newcounter{pnotesavechap}
\setcounter{pnotesavechap}{-1000}
\newif\ifmakingpagenotes
\makingpagenotesfalse
\newcommand*{\makepagenote}{%
\newwrite\@notefile
\immediate\openout\@notefile=\jobname.ent
\makingpagenotestrue
\def\pagenote{\@bsphack\begingroup
\@sanitize
\@wrpnote}%
\typeout{Writing note file \jobname.ent}%
\let\makepagenote\@empty}
\newcommand{\immediate@protected@write}[3]{%
\begingroup
#2%
\let\protect\@unexpandable@protect
\edef\reserved@a{\immediate\write#1{#3}}%
\reserved@a
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
\ifpnpageopt
\let\@pnwrite\protected@write
\else
\let\@pnwrite\immediate@protected@write
\fi
\newcommand{\@wrpnote}[2][]{%
\refstepcounter{pagenote}%
\notenumintext{\thepagenote}%
\ifpnhaschapter
\ifnum\value{pnotesavechap}=\value{chapter}\else
\setcounter{pnotesavechap}{\value{chapter}}%
\addtonotes{\pagenotesubhead{\thechapter}{\f@rtoc}}%
\fi
\else
\ifnum\value{pnotesavechap}=\value{section}\else
\setcounter{pnotesavechap}{\value{section}}%
\addtonotes{\pagenotesubhead{\thesection}{}}%
\fi
\fi
\@pnwrite\@notefile{}
{\string\noteentry{\thepagenote}{#1}{#2}{\thepage}}%
\endgroup
\@esphack}
\def\pagenote{\@bsphack\begingroup \@sanitize\@pagenote}
\newcommand{\@pagenote}[2][]{\endgroup\@esphack}
\newcommand{\addtonotes}[1]{%
\ifmakingpagenotes
\IfFileExists{\jobname.ent}{\@pnwrite\@notefile{}{#1}}{\pnofilewarn}%
\fi}
\newcommand{\notenumintext}[1]{%
\textsuperscript{#1}}
\newcommand{\notenuminnotes}[1]{%
{\normalfont #1.} }
\newcommand{\noteentry}[4]{%
\prenoteinnotes
\noteidinnotes{#1}{#2}\pageinnotes{#4}\noteinnotes{#3}%
\postnoteinnotes}
\newcommand{\textinnotes}[1]{%
[#1] }
\newcommand{\noteidinnotes}[2]{%
\@ifmtarg{#2}{%
\notenuminnotes{#1}}{\textinnotes{#2}}}
\providecommand*{\pagename}{page}
\newcommand{\pageinnotes}[1]{%
\ifpnpageopt (\pagename\ #1) \fi}
\newcommand{\noteinnotes}[1]{#1}
\newcommand{\prenoteinnotes}{\par\noindent}
\newcommand{\postnoteinnotes}{\par}
\providecommand*{\notesname}{Notes}
\ifpnhaschapter
\newcommand*{\notedivision}{\chapter{\notesname}}
\else
\newcommand*{\notedivision}{\section{\notesname}}
\fi
\newcommand*{\printnotes}{\@ifstar{\@sprintnotes}{\@printnotes}}
\newcommand*{\pnofilewarn}{%
\PackageWarning{pagenote}{There is no .ent file}}
\newcommand*{\@sprintnotes}{%
\ifmakingpagenotes
\notedivision
\IfFileExists{\jobname.ent}{%
\immediate\closeout\@notefile
\input{\jobname.ent}%
\immediate\openout\@notefile=\jobname.ent%
}{%
\pnofilewarn
}%
\fi}
\newcommand*{\@printnotes}{%
\ifmakingpagenotes
\notedivision
\IfFileExists{\jobname.ent}{%
\immediate\closeout\@notefile
\input{\jobname.ent}%
}{%
\pnofilewarn
}
\fi}
\providecommand*{\chaptername}{Chapter}
\providecommand*{\sectionname}{Section}
\ifpnhaschapter
\DeclareRobustCommand{\pagenotesubhead}[2]{%
\subsection*{\chaptername\ #1 #2}}
\else
\DeclareRobustCommand{\pagenotesubhead}[2]{%
\subsection*{\sectionname\ #1}}
\fi
\endinput
%%
%% End of file `pagenote.sty'.
|