-
Notifications
You must be signed in to change notification settings - Fork 3
/
aglc2.cbx
424 lines (382 loc) · 12.4 KB
/
aglc2.cbx
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
% AGLC2 citation style for Biblatex
% This file was created by editing the standard biblatex style
\ProvidesFile{verbose-ibid.cbx}
\ExecuteBibliographyOptions{citetracker=context,ibidtracker=constrict,
pagetracker,autocite=footnote}
\providecommand*{\mkibid}[1]{#1}
\newbool{cbx@loccit}
\setlength\bibhang{0pt}
\renewcommand\bibfont{\small}
\defbibheading{articles}{\subsection*{Articles/Books/Reports}}
\defbibheading{cases}{\subsection*{Case Law}}
\defbibheading{legislation}{\subsection*{Legislation}}
\defbibheading{treaties}{\subsection*{Treaties}}
\defbibheading{other}{\subsection*{Other Sources}}
\defbibfilter{articles}{\not \keyword{citeonly} \and \( \type{book} \or \type{inbook} \or \type{incollection} \or \type{article} \or \type{report} \)}
\defbibfilter{cases}{\not \keyword{citeonly} \and \type{jurisdiction}}
\defbibfilter{legislation}{\not \keyword{citeonly} \and \type{legislation}}
\defbibfilter{treaties}{\not \keyword{citeonly} \and \type{legal}}
\defbibfilter{other}{\not\keyword{citeonly} \and \not \( \type{book} \or \type{inbook} \or \type{incollection}
\or \type{article} \or \type{jurisdiction} \or
\type{legislation} \or \type{legal} \or \type{report} \)}
\DefineBibliographyStrings{english}{%
andothers = {et al},
editor = {\addspace{}(ed)},
editors = {\addspace{}(eds)},
edition = {ed},
january = {January},
february = {February},
march = {March},
april = {April},
may = {May},
june = {June},
july = {July},
august = {August},
september = {September},
october = {October},
november = {November},
december = {December},
}
\DeclareListFormat{endash}{%
#1%
\ifthenelse{\value{listcount}<\value{liststop}}
{--}
{}}
\renewcommand*{\UrlFont}{\normalfont}
\newrobustcmd{\mkbibangle}[1]{%
\begingroup%
\let\mkbibangle\blx@nobrackets%
$<$#1$>$%
\endgroup}
\DeclareFieldFormat{angle}{\mkbibangle{#1}}
\DeclareFieldFormat{url}{\mkbibangle{\url{#1}}}
\def\wmkbibordinal#1{%
\@tempcnta0#1 \the\@tempcnta
\ifthenelse{\@tempcnta>1000}{\hspace{0.2em}}{%
\@whilenum\@tempcnta>100\do{\advance\@tempcnta-100}%
\ifnum\@tempcnta>20
\@whilenum\@tempcnta>9\do{\advance\@tempcnta-10}%
\fi
$^{\ifcase\@tempcnta th\or st\or nd\or rd\else th\fi}$}}%
\DeclareFieldFormat{edition}{\wmkbibordinal{#1}\hspace{0.1em}\bibstring{edition}}
% Used in the bibliography, first name displayed as last-first and subsequent names
% displayed as first-last. If too many names show the first with "et al"
\DeclareNameFormat{sortname}{%
\ifthenelse{\value{listcount}=1}
{%
\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
\usebibmacro{name:andothers}%
} {%
\ifthenelse{\value{listcount}>1\and\value{listtotal}>\value{liststop}}
{}%
{\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}%
}%
}
% Used in all citations, always first-last, if too many names show the first with "et al"
\DeclareNameFormat{default}{%
\ifthenelse{\value{listcount}>1\and\value{listtotal}>\value{liststop}}{}{%
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}%
\usebibmacro{name:andothers}}
% Print "et al" with only the first author
%\renewbibmacro*{name:andothers}{%
% \ifthenelse{\value{listtotal}>\value{liststop}\AND\value{listcount}=2\AND\ifmorenames}%
% {\addspace\bibstring{andothers}}%
% {}}
\DeclareBibliographyOption{ibidpage}[true]{%
\ifstrequal{#1}{true}
{\ExecuteBibliographyOptions{loccittracker=constrict}}%
{\ExecuteBibliographyOptions{loccittracker=false}}}%
% Redefine how backref works, to use footnotes, not pages.
\def\blx@backref@global{%
\iffootnote{%
\blx@leavevmode%
\if@filesw%
\protected@write\@mainaux{}{\string\abx@aux@backref%
{\the\c@instcount}{\abx@field@entrykey}%
{\the\c@refsection}{\thefootnote}}%
\fi}{}}
\DeclareListFormat{last}{\ifthenelse{\value{listcount}=1}{#1}{}}
\DeclareNameFormat{surname}{\ifthenelse{\value{listcount}=1}{#1}{}}
\DeclareNameFormat{firstname}{\ifthenelse{\value{listcount}=1}{#3}{}}
\newbibmacro{author/editor:surname}{%
\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
{\ifuseauthor{\printnames[surname]{author}}{}}%
{\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}{\printnames[surname]{editor}}{}}}
\newbibmacro{author/editor:firstname}{%
\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
{\ifuseauthor{\printnames[firstname]{author}}{}}%
{\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}{\printnames[firstname]{editor}}{}}}
\newbibmacro*{author/editor:lastnamefirst}{%
\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
{\ifuseauthor{\printnames[sortname]{author}}{}}%
{\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}{\printnames[sortname]{editor}}{}}}
\newbibmacro*{cite:save}{%
\csxdef{cbx@\thefield{entrykey}}{\the\value{instcount}}%
\label{cbx@\the\value{instcount}}%
}
\newbibmacro*{cite}{%
\global\boolfalse{cbx@loccit}%
\ifciteseen
{%
\iffieldundef{shorthand}
{%
\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{%
% citeibid is true and this citation has been seen on this page previously
% and citation is in a footnote
\usebibmacro{cite:ibid}%
\setunit{\space}\newblock\printfield{prenote}\setunit{}%
} {%else
% either citeibid is false or this is the first time the citation appears
% on this page
\ifthenelse{\(\equal{\thefield{entrytype}}{jurisdiction}\or%
\equal{\thefield{entrytype}}{legislation}\or%
\equal{\thefield{entrytype}}{legal}\)%
\or\not\ifciteseen}%
{%
% If the entry is a jurisdiction or legislation or legal
% or if the citation has not been seen before
% ie: this is how to print a first citation. Legislation, legal and
% jurisdictions are always printed as though they were a first citation.
\usebibmacro{cite:short}%
} {% else
% Must be something else or a subsequent citation
\usebibmacro{author/editor:surname}\addnbspace%
above n\addnbspace\ref{cbx@\csuse{cbx@\thefield{entrykey}}}%
\iffieldundef{postnote}{.\nopunct}{\nopunct\finentry}%
}%
} {%
% shorthand field is defined
\usebibmacro{cite:shorthand}%
}%
}%
}{%
% citation has not been seen before
\usebibmacro{cite:full}%
\usebibmacro{cite:save}%
}%
}
\newbibmacro*{cite:full}{%
\printtext[bibhypertarget]{%
\usedriver%
{\DeclareNameAlias{sortname}{default}}%
{\thefield{entrytype}}}%
\usebibmacro{shorthandintro}}
% Display the shorthand, for AGLC2 rules 2.1.8 and 2.1.9. eg (`Mabo')
% This can be overridden by the field "shorthandintro" eg (I will sometimes refer to this case as Mabo)
\renewbibmacro*{shorthandintro}{%
\iffieldundef{shorthandintro}
{\ifthenelse{\iffieldundef{shorttitle} \and \iffieldundef{shorthand}}
{}
{\setunit{\addspace}%
\printtext[parens]{%
`{\it \usebibmacro{shorthand-or-title}'\hspace{0.15em}}}}}
{\setunit{\addspace}%
\printtext[parens]{\printfield{shorthandintro}}}}
% Pick either the shorthand or the shorttitle, if there is no shorthand.
\newbibmacro*{shorthand-or-title}{%
{\it \iffieldundef{shorthand}%
{\iffieldundef{shorttitle}%
{\thefield{title}}%
{\thefield{shorttitle}}}%
{\thefield{shorthand}}%
}}
\newbibmacro*{cite:short}{%
%\printnames{labelname}%
%\setunit*{\addcomma\space}%
%\printtext[bibhyperlink]{%
%\printfield[citetitle]{labeltitle}}}
\printtext[bibhypertarget]{%
\usedriver{}{short:\thefield{entrytype}}}}%
\newbibmacro*{cite:shorthand}{%
\printtext[bibhyperlink]{%
\printfield{shorthand}}}
\newbibmacro*{cite:ibid}{%
\printtext[bibhyperref]{Ibid}%
\ifloccit
{\global\booltrue{cbx@loccit}}
{}\iffieldundef{postnote}{.\nopunct}{\nopunct}}
\newbibmacro*{cite:postnote}{%
\ifbool{cbx@loccit}%
{}%
{\usebibmacro{postnote}}%
}
\renewbibmacro*{postnote}{%
\setunit{}\newblock\printfield{postnote}\setunit{}
}
\DeclareCiteCommand{\casename}
{\citetrackerfalse
\pagetrackerfalse
\usebibmacro{prenote}}
{\iffieldundef{shorttitle}{\printfield{title}}{\ifciteseen{\printfield{shorttitle}}{\printfield{title}\addspace\mkbibparens{`\printfield{shorttitle}'}}}}
{\multicitedelim}
{\usebibmacro{postnote}}
% This command prints only the citation for a given case, eg [2006] HCA 14
\DeclareCiteCommand{\citecase}
{\citetrackerfalse
\pagetrackerfalse
\usebibmacro{prenote}}
{%\indexfield{indextitle}%
\printfield[citecase]{note}}
{\multicitedelim}
{\usebibmacro{postnote}}
% TODO: Allow cases to be cited in footnotes (inline citation).
% TODO: Ibid should be allowed for \case but not above n.
% TODO: Also seem the note, pinpoint format of the footnote is no longer valid.
\DeclareCiteCommand{\case}
{}
{%
\ifciteseen {%
% First print the mainline title and a postnote if it exists
\iffieldundef{shorttitle}
{%
\printfield{title}%
} {%
\printfield{shorttitle}%
}%
% Now print the footnote but only if the postnote exists.
% Note the trailin full-stop at the end.
\iffieldundef{postnote}%
{} % No need to print anything if there's no postnote
{%
%Manage ibids
\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
{%
\mkbibfootnote{%
\usebibmacro{cite:ibid}%
}%
} {%
% Print a footnote with the note field and then the postnote
% as a pinpoint afterwards. Note the trailing full-stop
\mkbibfootnote{%
\printfield[citecase]{note}%
\setunit{\addcomma\space}\newblock\printfield{postnote}\setunit{}.%
}%
}%
}%
\iffieldundef{postnote}%
{}% Do nothing if the postnote is not defined
{%
% Otherwise print a space and the postnote
\setunit{\space}\newblock\printfield{postnote}\setunit{}%
}%
}%
{% Print the first citation
\printfield{title}%
%
% Print the footnote. No need to manage ibids as this is the first
% occurrence of the citation
\mkbibfootnote{%
\printfield[citecase]{note}%
% Print the prenote if it exists
\iffieldundef{postnote}
{}
{%
\setunit{\space}\newblock%
\printfield{postnote}%
\setunit{}.%
}%
}%
%
% Print a postnote if it exists
% a prenote is where we keep comments to print after the case.
\iffieldundef{prenote}
{} % Do nothing if the postnote is not defined
{%
% Print a space and the postnote
\setunit{\space}\newblock\printfield{prenote}\setunit{}%
}%
%
% Print the short title if it exists
\iffieldundef{shorttitle}
{}
{%
\addspace%
\mkbibparens{`\printfield{shorttitle}'}%
}%
}%
}
{}
{}
{}
\DeclareCiteCommand{\footcase}[\mkbibfootnote]
{}
{%
\ifciteseen
{%
\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{%
\usebibmacro{cite:ibid}%
\iffieldundef{postnote}
{} {%
\setunit{\space}\newblock\printfield{postnote}\setunit{}.%
}%
} {%
% First print the title or the shorttitle
\iffieldundef{shorttitle}
{%
\printfield{title}%
} {%
\printfield{shorttitle}%
}%
%
% Always print the note
\addspace\printfield[citecase]{note}%
%
% Print the pinpoint if it exists
\iffieldundef{postnote}
{}%
{%
\setunit{\space}\newblock\printfield{postnote}\setunit{}.%
}%
}%
} {%
% If the citation is not seen always print the title first
\printfield{title}%
%
% Always print the note
\addspace\printfield[citecase]{note}%
%
% Print the pinpoint if it exists
\iffieldundef{postnote}
{} {%
\setunit{\space}\newblock\printfield{postnote}\setunit{}.%
}%
% Print the shorttitle at the end if it exists
\iffieldundef{shorttitle}
{}%
{%
\addspace%
\mkbibparens{`\printfield{shorttitle}'}%
}%
}%
}
{}
{}
{}
\DeclareCiteCommand{\cite}
{%
\iffootnote
{}
{\citetrackerfalse}\usebibmacro{prenote}%
}
{%
\usebibmacro{citeindex}%
\usebibmacro{cite}%
}
{\multicitedelim}
{\usebibmacro{cite:postnote}}
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{cite:postnote}}
\DeclareCiteCommand{\footcite}[\mkbibfootnote]
{\bibsentence
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{cite:postnote}}
\endinput