forked from marcusbjoerkqvist/LaTeX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaglc2.cbx
More file actions
238 lines (198 loc) · 8.23 KB
/
aglc2.cbx
File metadata and controls
238 lines (198 loc) · 8.23 KB
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
% AGLC2 citation style for Biblatex
% This file was created by editing the standard biblatex style
% Credits: will@willhardy.com.au http://willhardy.com.au/files/lawessay/aglc2.cbx
\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} \)}
\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} \)}
\DefineBibliographyStrings{english}{%
andothers = {et al},
typeeditor = {\addspace{}(ed)},
typeeditors = {\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}}
{--}
{}}
\newrobustcmd{\mkbibangle}[1]{%
\begingroup%
\let\mkbibangle\blx@nobrackets%
$<$#1$>$%
\endgroup}
\DeclareFieldFormat{angle}{\mkbibangle{#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, always last-first, if too many names show the first with "et al"
\DeclareNameFormat{sortname}{%
\ifthenelse{\value{listcount}>1\and\value{listtotal}>\value{liststop}}{}%
{\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}%
\usebibmacro{name:andothers}}
% 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\bib@aux@backref%
{\the\c@instcount}{\bib@field@entrykey}%
{\the\c@refsection}{\thefootnote}}%
\fi}{}}
\DeclareListFormat{last}{\ifthenelse{\value{listcount}=1}{#1}{}}
\DeclareNameFormat{surname}{\ifthenelse{\value{listcount}=1}{#1}{}}
\newbibmacro{author/editor:surname}{%
\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
{\ifuseauthor{\printnames[surname]{author}}{}}%
{\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}{\printnames[surname]{editor}}{}}}
\newbibmacro*{cite}{%
\global\boolfalse{cbx@loccit}%
\ifciteseen{%
\iffieldundef{shorthand}%
{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
{\usebibmacro{cite:ibid}}%
{\ifthenelse{\(\equal{\thefield{entrytype}}{jurisdiction}\or\equal{\thefield{entrytype}}{legislation}%
\or\equal{\thefield{entrytype}}{legal}\)\or\not\ifciteseen}%
{\usebibmacro{cite:short}}%
{\usebibmacro{author/editor:surname}\addcomma\addspace above n~\printlist[last]{pageref}}}%
{\usebibmacro{cite:shorthand}}}}%
{\usebibmacro{cite:full}}}
\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}}
\newbibmacro*{cite:postnote}{%
\ifbool{cbx@loccit}
{}
{\usebibmacro{postnote}}}
\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).
\DeclareCiteCommand{\case}
{}
{\iffieldundef{shorttitle}%
% Not sure whether I want to footnote every time a case is mentioned... (to do: maybe just the first time?)
% If the subsequent text is punctuation, include it before the footnote as per AGLC2.
{\printfield{title}\printfield{postnote}{\mkbibfootnote{\printfield[citecase]{note}\iffieldundef{prenote}{}{\setunit{\addcomma\space}\newblock\printfield{prenote}\setunit{}}}}}
% If a short name is provided this should be shown in brackets after the case name, before the punctuation
{\ifciteseen{\printfield{shorttitle}}{\printfield{title}\printfield{postnote}\mkbibfootnote{\printfield[citecase]{note}\iffieldundef{prenote}{}{\setunit{\addcomma\space}\newblock\printfield{prenote}\setunit{}}.}\addspace\mkbibparens{`\printfield{shorttitle}'}}}%
}
{}
{}
\DeclareCiteCommand{\cite}
{\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