-
Notifications
You must be signed in to change notification settings - Fork 0
/
muss.bbx
350 lines (300 loc) · 9.8 KB
/
muss.bbx
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
% File: muss.bbx
% Author: Timm Lichte (http://timm-lichte.de)
% Date: 2023-09-08T09:04:24+0200
% Version: 0.4 (tested with BibLaTeX v3.19)
% License: LPPL Version 1.3c
%
% ----------------------------------------------------------------
% MUSS: Minimal Unified Style Sheet for Computational Linguistics
% ----------------------------------------------------------------
%
% MUSS is a style sheet for BibLaTeX that seeks minimality in different ways:
%
% (1) Minimality of supported entry types: MUSS supports only a small set of entry types and
% fields that I consider most important in my field (natural language processing).
% (2) Minimality of backward compatiblity: MUSS will only be compatible with recent
% versions of BibLaTeX.
% (3) Minimality of code: Because of (1) and (2), MUSS has a very slim codebase and is maximally
% self-contained. In fact, there is only *one* generic driver which is used for articles,
% books, etc.
%
% MUSS was heavily inspired by, but uses only certain characteristics of,
%
% - Unified Style Sheet (USS), a set of general style rules for references
% (see https://www.linguisticsociety.org/resource/unified-style-sheet)
% - langsci-unified.bbx, a BibLaTeX implementation of the USS that is part of the
% langscibook class (see https://github.com/langsci/langscibook),
% and therefore also biblatex-unified.bbx, on which langsci-unified.bbx is based
% (see https://github.com/semprag/biblatex-sp-unified)
%
% MUSS comes with two files:
%
% - muss.bbx (this file) specifies the structure and formatting of entries in a list of references.
% - muss.cbx specifies the look of cite commands in the text.
%
% List of currently supported entry types:
% article, book, collection, incollection, inproceedings, manual, online, phdthesis,
% techreport, thesis
%
% List of currently supported entry fields (depending on the entry type):
% author, booktitle, doi, edition, editor, institution, journal, note, number, pages,
% publisher, school, title, type, url, urldate, volume, year
%
% Yes, there is no address field; this is a deliberate decision.
%
\ProvidesFile{muss.bbx}
% Set general options.
\ExecuteBibliographyOptions{
sorting=nyt, % sorting in list of references: name --> year --> title
abbreviate, % use abbreviated strings in citations and in the bibliography
dateabbrev=false, % do not abbreviate dates
useprefix=true, % use name prefix (von, van, of, da, de, della, etc)
labeldateparts, % provides special fields
maxbibnames=99, % show all authors
}
% MUSS is derived from authoryear.bbx, which extends standard.bbx.
% Note that by default also the definitions in biblatex.def are used.
\RequireBibliographyStyle{authoryear}
% Set options defined in authoryear.
\ExecuteBibliographyOptions{
dashed=false, % do not replace same list of authors with a dash
isbn=false, % do not use the isbn field
eprint=false % do not use the eprint field
}
\AtBeginBibliography{\sloppy} % allow for sloppy line breaking
%%%%%%%%%%%%%%%%%%%%%%%%
% Special strings
%%%%%%%%%%%%%%%%%%%%%%%%
\NewBibliographyString{thesisat}
\NewBibliographyString{reportat}
\DefineBibliographyStrings{english}{%
edition = {edn\adddot},
phdthesis = {doctoral dissertation}, % default string used when type is undefined
techreport = {technical report}, % default string used when type is undefined
thesisat = {at},
reportat = {at},
}
%%%%%%%%%%%%%%%%%%%%%%%%
% Special symbols
%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand*{\intitlepunct}{\addspace} % Remove colon from "In:".
\renewcommand*{\finalnamedelim}{\addspace\&\addspace} % Use ampersand in name lists
\renewcommand*{\finallistdelim}{\addspace\&\addspace} % Use ampersand in name lists
% \renewcommand*{\finentrypunct}{} % Remove period from end of entry.
% \renewcommand*{\finentrypunct}{\addperiod} % Entry should always end with a period.
%%%%%%%%%%%%%%%%%%%%%%%%
% Field formats
%%%%%%%%%%%%%%%%%%%%%%%%
% Display pages without page prefix (p., pp.)
\DeclareFieldFormat{pages}{#1}
% No quotes around titles (drivers have to be specified)
\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,report,unpublished]{title}{#1}
% The titles of books, reports and theses are printed with italics.
\DeclareFieldFormat[book,collection,report,thesis]{title}{\mkbibemph{#1}}
% Put square brackets around note.
\DeclareFieldFormat{note}{\mkbibbrackets{#1}}
% The booktitles are printed with italics.
\DeclareFieldFormat{booktitle}{\mkbibemph{#1}}
\DeclareFieldFormat{doi}{%
\mkbibacro{DOI}\addcolon\space%
\ifhyperref%
{\href{https://doi.org/#1}{\nolinkurl{#1}}}%
{\nolinkurl{#1}}}%
\DeclareFieldFormat{url}{%
% \mkbibacro{URL}\addcolon\space%
\url{#1}}%
%%%%%%%%%%%%%%%%%%%%%%%%
% Macros
%%%%%%%%%%%%%%%%%%%%%%%%
\newbibmacro*{muss:author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:savehash}%
\printnames{author}%
}
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
}%
}
\newbibmacro*{muss:booktitle}{%
\iffieldundef{booktitle}
{}
{\printtext[booktitle]{%
\printfield[titlecase]{booktitle}}%
}%
}
\newbibmacro*{muss:byeditor+others}{%
\ifnameundef{editor}
{}
{\printnames[byeditor]{editor}% don't swap name parts of first editor
\setunit{\addspace}%
\printtext[parens]{\usebibmacro{editor+othersstrg}}% putting (ed.) or (eds.) after editors of books
}%
}
\newbibmacro*{muss:editor+others}{%
\ifnameundef{editor}
{}
{\printnames{editor}% swap name parts of first editor
\setunit{\addspace}%
\printtext[parens]{\usebibmacro{editor+othersstrg}}% putting (ed.) or (eds.) after editors of books
}%
}
\newbibmacro*{muss:date+extradate}{%
\iffieldundef{labelyear}
{}
{\printtext{\printlabeldateextra}}% no parentheses around year
}
\newbibmacro*{muss:doi+url+publisher}{%
\ifboolexpr{
test {\ifentrytype{book}}
or
test {\ifentrytype{collection}}
or
test {\ifentrytype{incollection}}
}
{\printlist{publisher}\newunit}
{}%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\usebibmacro{url+urldate}}}
{\printfield{doi}}%
}
\newbibmacro*{muss:journal+volume+number+eid}{%
\usebibmacro{journal}%
\setunit*{\addspace}%
\printfield{volume}%
\printfield[parens]{number}% parentheses instead of dot before issue number
\setunit{\addcomma\space}%
\printfield{eid}%
}
\newbibmacro*{muss:note}{%
\printfield{note}%
}
\newbibmacro*{muss:pages}{%
\printfield{pages}%
}
\newbibmacro*{muss:partof}{%
\ifentrytype{article}
{\usebibmacro{in:}%
\usebibmacro{muss:journal+volume+number+eid}%
\setunit{\addcomma\space}%
\usebibmacro{muss:pages}}%
{}
\ifentrytype{inproceedings}
{\usebibmacro{in:}%
\usebibmacro{muss:booktitle}%
\setunit{\addcomma\space}%
\usebibmacro{muss:pages}}%
{}
\ifentrytype{incollection}
{\usebibmacro{in:}%
\ifnameundef{editor}
{\setunit{\addspace}}
{\usebibmacro{muss:byeditor+others}
\setunit{\addcomma\space}}%
\usebibmacro{muss:booktitle}%
\setunit{\addcomma\space}%
\printfield{edition}%
\setunit{\addcomma\space}%
\usebibmacro{muss:pages}}%
{}
\ifboolexpr{
test {\ifentrytype{book}}
or
test {\ifentrytype{collection}}
or
test {\ifentrytype{incollection}}
}
{\printfield{edition}}
{}%
}
\newbibmacro*{muss:type+institution}{%
\ifentrytype{report}
{\printfield{type}\addspace\printfield{number}\addspace\bibstring{thesisat}\addspace\printlist{institution}}
{}%
\ifentrytype{thesis}
{\printfield{type}\addspace\bibstring{thesisat}\addspace\printlist{institution}}
{}%
}
\newbibmacro*{muss:title}{%
\iffieldundef{title}
{}
{\printtext[title]{%
\printfield[titlecase]{title}}%
}
}
\newbibmacro*{muss:typeof}{%
\ifboolexpr{%
test {\ifentrytype{report}}
or
test {\ifentrytype{thesis}}
}
{\printtext[parens]{\usebibmacro{muss:type+institution}}}
{}
\ifboolexpr{%
test {\ifentrytype{book}}
or
test {\ifentrytype{collection}}
or
test {\ifentrytype{incollection}}
}
{\iffieldundef{series}
{}
{\printtext[parens]{\usebibmacro{series+number}}}}
{}%
}
% muss:finentry is introduced to have better control.
% BibLaTeX's finentry does not always work as expected, e.g. with \fullcite.
\newbibmacro*{muss:finentry}{%
\addperiod%
}
%%%%%%%%%%%%%%%%%%%%%%%%
% Entry drivers
%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareBibliographyDriver{object}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\ifentrytype{collection}
{\usebibmacro{muss:editor+others}}
{\usebibmacro{muss:author}}%
\newunit%
\usebibmacro{muss:date+extradate}%
\setunit{\printdelim{nametitledelim}}%
\newblock%
\usebibmacro{muss:title}% booktitle is not considered here
\setunit{\addspace}%
\usebibmacro{muss:typeof}%
\newunit%
\usebibmacro{muss:partof}%
\newunit%
\usebibmacro{muss:doi+url+publisher}%
\newunit%
\usebibmacro{muss:finentry}%
\usebibmacro{muss:note}%
}
%%%%%%%%%%%%%%%%%%%%%%%%
% Entry aliases
%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareBibliographyAlias{article}{object}
\DeclareBibliographyAlias{book}{object}
\DeclareBibliographyAlias{collection}{object} % TODO: editors
\DeclareBibliographyAlias{incollection}{object}
\DeclareBibliographyAlias{inproceedings}{object}
\DeclareBibliographyAlias{online}{object}
\DeclareBibliographyAlias{report}{object}
\DeclareBibliographyAlias{thesis}{object}
\DeclareBibliographyAlias{phdthesis}{thesis}
\DeclareBibliographyAlias{techreport}{report}
\DeclareBibliographyAlias{manual}{book}
%%%%%%%%%%%%%%%%%%%%%%%%
% Constraints
%%%%%%%%%%%%%%%%%%%%%%%%
% \DeclareDatamodelConstraints
% Checked with: biber --validate_datamodel file
%%%%%%%%%%%%%%%%%%%%%%%%
% Archive
%%%%%%%%%%%%%%%%%%%%%%%%