-
Notifications
You must be signed in to change notification settings - Fork 31
/
iso-authoryear.bbx
129 lines (116 loc) · 4.32 KB
/
iso-authoryear.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
\ProvidesFile{iso-authoryear.bbx}
[2022/03/20 v0.4.1 ISO 690 biblatex bibliography style]
\RequireBibliographyStyle{iso}
\ExecuteBibliographyOptions{%
sorting=nyt,
}
% The separator between 'titles' and the numeration section.
% Overrides the command in 'iso.bbx'.
\renewcommand{\numerationpunct}{\newunitpunct}
% Delimiter between creator name and year in bibliography
\DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addcomma\space}
% Delimiter between substitution of creator name (if any)
% and year in bibliography
\DeclareDelimFormat[bib,biblist]{nonameyeardelim}{\addcomma\space}
% a)
% The field extradate turns from integer type to a letter
% after year to distinguish more works of the author
% from the same year, e.g. 1994a, 1994b.
% We use 'labeldate' as it is also used in standard styles.
% b)
% Moreover we print additional date information (dateaddon).
\newbibmacro*{date+extradate}{%
\printlabeldateextra
\setunit{\dateaddonpunct}%
\iffieldequalstr{labeldatesource}{dateaddon}
{}% Do not print dateaddon twice
{\printfield{dateaddon}}%
}
% Check if 'date' or 'origdate' field holds only year or a more specific date.
% Inspired by \ifdatehasyearonlyprecision from 'biblatex.sty',
% but the test date==year is left out, because we use date=year
% in package options so it turned always true.
\newcommand{\ifdatehasyearonly}{%
\ifboolexpr{not test {\iffieldundef{year}}
and (test {\iffieldundef{month}}
and test {\iffieldundef{season}})}
}
\newcommand{\iforigdatehasyearonly}{%
\ifboolexpr{not test {\iffieldundef{origyear}}
and (test {\iffieldundef{origmonth}}
and test {\iffieldundef{origseason}})}
}
% If there is no more specific date available, we shouldn't repeat
% the year in publication info section.
% Overrides macro 'fulldate' in 'iso.bbx'.
\renewbibmacro*{fulldate}{%
\iffieldundef{origyear}
{\ifdatehasyearonly%
{}% Print nothing (only year is available)
{\mkdaterangeiso{}}}
{\iforigdatehasyearonly
{}% Print nothing (only origyear is available)
{\mkdaterangeiso{orig}}}%
}
% Remove second appearance of year in a reference
\renewbibmacro*{date}{}%
% Overwrite names:primary to print year right after:
% 0) holder (only for patents)
% 1) author
% 2) editor
% 3) label/title
% Need to handle not to print editor twice (primary
% and subsidiary names): editor macro includes \clearname{editor}
\renewbibmacro*{names:primary}{%
% If we have a patent with holder field, we will use that.
\ifboolexpr{test \ifuseholder and test {\ifentrytype{patent}}
and not test {\ifnameundef{holder}}}
{\usebibmacro{byholder}%
\setunit{\addspace}%
\printfield{nameaddon}%
\setunit{\printdelim{nameyeardelim}}}%
{% Otherwise, first check if we have author(s) available
\ifboolexpr{test \ifuseauthor and not test {\ifnameundef{author}}}
{\usebibmacro{author}%
\setunit{\addspace}%
\printfield{nameaddon}%
\setunit{\printdelim{nameyeardelim}}}%
{% If no author(s) is available, check for editor(s)
\ifboolexpr{test \ifuseeditor and not test {\ifnameundef{editor}}}
{\usebibmacro{editor}%
\setunit{\printdelim{nameyeardelim}}}%
{% If no editor(s) is available, use label/title
\usebibmacro{labeltitle}%
\setunit{\printdelim{nonameyeardelim}}}}}%
% And finally print date
\usebibmacro{date+extradate}%
}
% Print label or title in place of names if they are not available
\newbibmacro*{labeltitle}{%
\iffieldundef{label}
{\iffieldundef{shorttitle}
{\usebibmacro{titles}{}{emph}%
\clearfield{title}%
\clearfield{subtitle}%
\clearfield{titleaddon}}
{\printfield[title]{shorttitle}}}
{\printfield{label}}}
\renewbibmacro*{urldate-space}{%
% if there is no publisher specified in the bib file, set unit to dot,
% so there is a separation between previous block
% this version doesn't check date, as it isn't printed in the publisher block
\ifboolexpr{%
test {\iflistundef{publisher}}%
and test {\iflistundef{location}}%
and test {\iffieldundef{version}}%
}{\setunit{\adddot\addspace}}%
{\setunit{\addspace}}%
}
\newbool{bbx@inset}
\DeclareBibliographyDriver{set}{%
\booltrue{bbx@inset}%
\entryset{}{}%
\newunit\newblock
\usebibmacro{setpageref}%
\finentry}
\endinput