Debian Codegraph @

07p/doc/include/harvard.sty

raw
1 %% harvard.sty - harvard bibliography style Version 2.0.5
2 %% Author: Peter Williams [email protected]
3 %% Copyright: Peter Williams 1994
4 %%
5 %% This work may be distributed and/or modified under the
6 %% conditions of the LaTeX Project Public License, either version 1.3
7 %% of this license or (at your option) any later version.
8 %% The latest version of this license is in
9 %% http://www.latex-project.org/lppl.txt
10 %% and version 1.3 or later is part of all distributions of LaTeX
11 %% version 2005/12/01 or later.
12 %%
13 %% This work has the LPPL maintenance status `maintained'.
14 %%
15 %% The Current Maintainers of this work are Peter Williams and Thorsten Schnier.
16 %%
17 %% This work consists of all files listed in manifest.txt.
18 %%
19 %% Licence notice added on behalf of Peter Williams and Thorsten Schnier
20 %% by Clea F. Rees 2009/01/30.
21
22 \NeedsTeXFormat{LaTeX2e}
23 \ProvidesPackage{include/harvard}
24 \RequirePackage{ifthen}
25 \IfFileExists{html.sty}{\RequirePackage{html}
26 \newcommand{\harvardurl}[1]{\htmladdnormallink*{\textbf{URL:} \textit{##1}}{##1}}
27 }{
28 \newcommand{\harvardurl}[1]{\textbf{URL:} \textit{##1}}
29 }
30 \DeclareOption{full}{\citationmode{full}}
31 \DeclareOption{abbr}{\citationmode{abbr}}
32 \DeclareOption{default}{\citationmode{default}}
33 \DeclareOption{agsmcite}{\citationstyle{agsm}}
34 \DeclareOption{dcucite}{\citationstyle{dcu}}
35 \DeclareOption{round}{\harvardparenthesis{round}\harvardyearparenthesis{round}}
36 \DeclareOption{curly}{\harvardparenthesis{curly}\harvardyearparenthesis{curly}}
37 \DeclareOption{angle}{\harvardparenthesis{angle}\harvardyearparenthesis{angle}}
38 \DeclareOption{square}{\harvardparenthesis{square}\harvardyearparenthesis{square}}
39 \DeclareOption{none}{\harvardparenthesis{none}\harvardyearparenthesis{none}}
40 \DeclareOption*{
41 \global\edef\HAR@tmp{\CurrentOption}
42 %% Berwin A. Turlach <[email protected]>
43 \AtEndDocument{\bibliographystyle{\HAR@tmp}}
44 }
45
46 %% Kristoffer H. Rose <[email protected]> 1995/03/01:
47 %% do not expand macros in citations: put definitions on .aux file instead.
48 {\catcode`\:=12 \catcode`\-=12 \catcode`\>=12 \catcode`\<=12 %
49 \gdef\codeof#1{\expandafter\codeof@\meaning#1<-:}%
50 \gdef\codeof@#1:->#2<-:{#2}}
51
52 \def\harvardpreambletext{\catcode`\#=12 \harvardpreambletext@}
53 \def\harvardpreambletext@#1{\def\next{#1}\catcode`\#=6 %
54 \immediate\write\@auxout{\string\harvardpreambledefs{%
55 \string\AtBeginDocument{\codeof\next}}}}
56
57 \def\harvardpreambledefs#1{#1\gdef\harvardpreambledefs##1{}}
58
59 \newcommand{\harvarditem}[4][\null]{\item[]%
60 \if@filesw{ \def\protect##1{\string ##1\space}%
61 \ifthenelse{\equal{#1}{\null}}
62 {\def\next{{#4}{#2}{#2}{#3}}}
63 {\def\next{{#4}{#2}{#1}{#3}}}
64 \immediate\write\@auxout{\string\harvardcite\codeof\next}%
65 }\fi%
66 \protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces%
67 }
68
69 \newcommand{\harvardcite}[4]{
70 \global\@namedef{HAR@fn@#1}{#2}
71 \global\@namedef{HAR@an@#1}{#3}
72 \global\@namedef{HAR@yr@#1}{#4}
73 \global\@namedef{HAR@df@#1}{\csname HAR@fn@#1\endcsname}
74 }
75
76 \newcommand{\citationmode}[1]{
77 \renewcommand{\HAR@citemode}{\csname HAR@cite@#1\endcsname}
78 }
79
80 \newcommand{\HAR@cite@full}{HAR@fn@}
81 \newcommand{\HAR@cite@abbr}{HAR@an@}
82 \newcommand{\HAR@cite@default}{HAR@df@}
83 \newcommand{\HAR@citemode}{\HAR@cite@default}
84
85 \newcommand{\HAR@citetoaux}[1]{%
86 \if@filesw\immediate\write\@auxout{\string\citation{#1}}\fi%
87 }
88
89 \newcommand{\HAR@checkdef}[2]{\@ifundefined{HAR@df@#1}%
90 {\textbf{?}\@warning{Citation '#1' on page \thepage \space undefined}}%
91 {#2}%
92 }
93
94 \newcommand{\HAR@dolist}[2]{\def\@citea{\null}\@for\@citeb:=#1\do%
95 {\@citea\def\@citea{\HAR@hisep\penalty\@m\ }\HAR@checkdef{\@citeb}%
96 {#2{\@citeb}\HAR@hysep\penalty\@m\ %
97 \HAR@year{\@citeb}\HAR@setd{\@citeb}}}%
98 }
99
100 \def\@enamedef#1{\expandafter\def\csname #1\expandafter\endcsname\expandafter}
101 \newcommand{\HAR@name}[1]{\csname \HAR@citemode#1\endcsname}
102 \newcommand{\HAR@fname}[1]{\csname HAR@fn@#1\endcsname}
103 \newcommand{\HAR@aname}[1]{\csname HAR@an@#1\endcsname}
104 \newcommand{\HAR@year}[1]{\csname HAR@yr@#1\endcsname}
105 \newcommand{\HAR@setd}[1]{%
106 \global\@enamedef{HAR@df@#1}{\csname HAR@an@#1\endcsname}%
107 }
108
109 %% Berwin A. Turlach <[email protected]>
110 \global\@namedef{HAR@df@*}{\csname HAR@fn@*\endcsname}
111 \renewcommand{\nocite}[1]{\HAR@citetoaux{#1}%
112 \@for\@citeb:=#1\do%
113 {\HAR@checkdef{\@citeb}{}}}%
114
115 \renewcommand{\cite}{\@ifstar{\@ifstar{\HAR@acite}{\HAR@fcite}}{\HAR@dcite}}
116
117 \newcommand{\HAR@dcite}[2][\null]{\HAR@citetoaux{#2}%
118 {\harvardleft\HAR@dolist{#2}{\HAR@name}\ifthenelse{\equal{#1}{\null}}%
119 {}{, #1}\harvardright}%
120 }
121
122 \newcommand{\HAR@acite}[2][\null]{\HAR@citetoaux{#2}%
123 {\harvardleft\HAR@dolist{#2}{\HAR@aname}\ifthenelse{\equal{#1}{\null}}%
124 {}{, #1}\harvardright}%
125 }
126
127 \newcommand{\HAR@fcite}[2][\null]{\HAR@citetoaux{#2}%
128 {\harvardleft\HAR@dolist{#2}{\HAR@fname}\ifthenelse{\equal{#1}{\null}}%
129 {}{, #1}\harvardright}%
130 }
131
132 \newcommand{\citeaffixed}{\@ifstar{\@ifstar{\HAR@aciteaff}{\HAR@fciteaff}}%
133 {\HAR@dciteaff}%
134 }
135
136 \newcommand{\HAR@fciteaff}[3][\null]{\HAR@citetoaux{#2}%
137 {\harvardleft#3\ \HAR@dolist{#2}{\HAR@fname}\ifthenelse{\equal{#1}{\null}}%
138 {}{, #1}\harvardright}%
139 }
140
141 \newcommand{\HAR@aciteaff}[3][\null]{\HAR@citetoaux{#2}%
142 {\harvardleft#3\ \HAR@dolist{#2}{\HAR@aname}\ifthenelse{\equal{#1}{\null}}%
143 {}{, #1}\harvardright}%
144 }
145
146 \newcommand{\HAR@dciteaff}[3][\null]{\HAR@citetoaux{#2}%
147 {\harvardleft#3\ \HAR@dolist{#2}{\HAR@name}\ifthenelse{\equal{#1}{\null}}%
148 {}{, #1}\harvardright}%
149 }
150
151 \newcommand{\citeasnoun}{\@ifstar{\@ifstar{\HAR@aciteasn}{\HAR@fciteasn}}%
152 {\HAR@dciteasn}%
153 }
154
155 \newcommand{\HAR@fciteasn}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
156 {\HAR@fname{#2}\ \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
157 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
158 }
159
160 \newcommand{\HAR@aciteasn}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
161 {\HAR@aname{#2}\ \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
162 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
163 }
164
165 \newcommand{\HAR@dciteasn}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
166 {\HAR@name{#2}\ \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
167 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
168 }
169
170 \newcommand{\possessivecite}{\@ifstar{\@ifstar{\HAR@acitepos}{\HAR@fcitepos}}%
171 {\HAR@dcitepos}%
172 }
173
174 \newcommand{\HAR@fcitepos}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
175 {\HAR@fname{#2}'s \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
176 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
177 }
178
179 \newcommand{\HAR@acitepos}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
180 {\HAR@aname{#2}'s \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
181 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
182 }
183
184 \newcommand{\HAR@dcitepos}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
185 {\HAR@name{#2}'s \harvardyearleft\HAR@year{#2}\ifthenelse{\equal{#1}{\null}}
186 {}{, #1}\harvardyearright}\HAR@setd{#2}}%
187 }
188
189 \newcommand{\citename}{\@ifstar{\@ifstar{\HAR@acitenam}\HAR@fcitenam}%
190 {\HAR@dcitenam}%
191 }
192
193 \newcommand{\HAR@fcitenam}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
194 {\HAR@fname{#2}\ifthenelse{\equal{#1}{\null}}
195 {}{\ \harvardleft#1\harvardright}}}%
196 }
197
198 \newcommand{\HAR@acitenam}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
199 {\HAR@aname{#2}\ifthenelse{\equal{#1}{\null}}
200 {}{\ \harvardleft#1\harvardright}}}%
201 }
202
203 \newcommand{\HAR@dcitenam}[2][\null]{\HAR@citetoaux{#2}\HAR@checkdef{#2}{%
204 {\HAR@name{#2}\ifthenelse{\equal{#1}{\null}}
205 {}{\ \harvardleft#1\harvardright}}}%
206 }
207
208 \newcommand{\citeyear}{\@ifstar{\HAR@citeyrnb}{\HAR@citeyr}}
209
210 \newcommand{\HAR@citeyrnb}[2][\null]{\HAR@citetoaux{#2}%
211 {\def\@citea{\null}\@for\@citeb:=#2\do%
212 {\@citea\def\@citea{\HAR@hisep\penalty\@m\ }\HAR@checkdef{\@citeb}%
213 {\HAR@year{\@citeb}}}\ifthenelse{\equal{#1}{\null}}%
214 {}{, #1}}%
215 }
216
217 \newcommand{\HAR@citeyr}[2][\null]{\HAR@citetoaux{#2}%
218 {\harvardleft\def\@citea{\null}\@for\@citeb:=#2\do%
219 {\@citea\def\@citea{\HAR@hisep\penalty\@m\ }\HAR@checkdef{\@citeb}%
220 {\HAR@year{\@citeb}}}\ifthenelse{\equal{#1}{\null}}%
221 {}{, #1}\harvardright}%
222 }
223
224 \newcommand{\HAR@hysep@apsr}{\null}
225 \newcommand{\HAR@hisep@apsr}{;}
226 \newcommand{\HAR@hysep@agsm}{\null}
227 \newcommand{\HAR@hisep@agsm}{,}
228 \newcommand{\HAR@hysep@dcu}{,}
229 \newcommand{\HAR@hisep@dcu}{;}
230 \newcommand{\HAR@and@agsm}{\&}
231 \newcommand{\HAR@and@dcu}{and}
232 \newcommand{\HAR@and@apsr}{and}
233 \newcommand{\HAR@hysep}{\HAR@hysep@agsm}
234 \newcommand{\HAR@hisep}{\HAR@hisep@agsm}
235 \newcommand{\harvardand}{\HAR@and@agsm}
236 \newcommand{\citationstyle}[1]{%
237 \renewcommand{\HAR@hysep}{\csname HAR@hysep@#1\endcsname}
238 \renewcommand{\HAR@hisep}{\csname HAR@hisep@#1\endcsname}
239 \renewcommand{\harvardand}{\csname HAR@and@#1\endcsname}
240 }
241
242 \newcommand{\HAR@bl@round}{(}
243 \newcommand{\HAR@br@round}{)}
244 \newcommand{\HAR@bl@square}{[}
245 \newcommand{\HAR@br@square}{]}
246 \newcommand{\HAR@bl@curly}{\{}
247 \newcommand{\HAR@br@curly}{\}}
248 \newcommand{\HAR@bl@angle}{$<$}
249 \newcommand{\HAR@br@angle}{$>$}
250 \newcommand{\HAR@bl@none}{}
251 \newcommand{\HAR@br@none}{}
252 \newcommand{\harvardleft}{\HAR@bl@round}
253 \newcommand{\harvardright}{\HAR@br@round}
254 \newcommand{\harvardparenthesis}[1]{
255 \renewcommand{\harvardleft}{\csname HAR@bl@#1\endcsname}
256 \renewcommand{\harvardright}{\csname HAR@br@#1\endcsname}
257 \harvardyearparenthesis{#1}
258 }
259
260 \newcommand{\harvardyearleft}{\HAR@bl@round}
261 \newcommand{\harvardyearright}{\HAR@br@round}
262 \newcommand{\harvardyearparenthesis}[1]{
263 \renewcommand{\harvardyearleft}{\csname HAR@bl@#1\endcsname}
264 \renewcommand{\harvardyearright}{\csname HAR@br@#1\endcsname}
265 }
266
267 \newcommand{\HAR@checkcitations}[4]{
268 \def\HAR@tempa{#2}\expandafter
269 \ifx \csname HAR@fn@#1\endcsname \HAR@tempa
270 \def\HAR@tempa{#3}\expandafter
271 \ifx \csname HAR@an@#1\endcsname \HAR@tempa
272 \def\HAR@tempa{#4}\expandafter
273 \ifx \csname HAR@yr@#1\endcsname \HAR@tempa
274 \else
275 \@tempswatrue
276 \fi
277 \else
278 \@tempswatrue
279 \fi
280 \else
281 \@tempswatrue
282 \fi
283 }
284
285 \AtEndDocument{\renewcommand{\harvardcite}{\HAR@checkcitations}}
286
287 \ExecuteOptions{agsm,agsmcite,default,round}
288 \ProcessOptions*