summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-ext/ext-authoryear-common.bbx
blob: cdd9e8602ec2e43fdbf75179d6f5dbb514cb52fb (plain)
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
\ProvidesFile{ext-authoryear-common.bbx}
  [2021/06/08 v0.13 common files for extended biblatex
   authoryear bibliography styles (MW)]

\RequireBibliographyStyle{ext-dashed-common}

\DeclareFieldFormat{biblabeldate}{\mkbibparens{#1}}
\DeclareFieldAlias{biblistlabeldate}{biblabeldate}

\providebibmacro*{bbx:ifmergeddate}{\@secondoftwo}

\renewbibmacro*{date}{%
  \usebibmacro{bbx:ifmergeddate}
    {}
    {\printdate}}

% merge date/issue with date label
\def\bbx@opt@mergedate@maximum{%
  \renewbibmacro*{date+extradate}{%
    \iffieldundef{labelyear}
      {}
      {\printtext[\blx@delimcontext labeldate]{%
         \iflabeldateisdate
           {\printfield{issue}%
            \setunit*{\addspace}%
            \printdateextra}
           {\printlabeldateextra}}}}%
  \renewbibmacro*{bbx:ifmergeddate}{\iflabeldateisdate}%
  \renewbibmacro*{issue+date}{%
    \usebibmacro{bbx:ifmergeddate}
      {}
      {\printtext[issuedate]{%
         \printfield{issue}%
         \setunit*{\addspace}%
         \printdate}}}}

% merge date with date label
\def\bbx@opt@mergedate@compact{%
  \renewbibmacro*{date+extradate}{%
    \iffieldundef{labelyear}
      {}
      {\printtext[\blx@delimcontext labeldate]{%
         \iflabeldateisdate
           {\printdateextra}
           {\printlabeldateextra}}}}%
  \renewbibmacro*{bbx:ifmergeddate}{\iflabeldateisdate}%
  \renewbibmacro*{issue+date}{%
    \ifboolexpr{test {\usebibmacro{bbx:ifmergeddate}}
                and
                test {\iffieldundef{issue}}}
      {}
      {\printtext[issuedate]{%
         \printfield{issue}%
         \setunit*{\addspace}%
         \usebibmacro{bbx:ifmergeddate}
           {}
           {\printdate}}}%
    \newunit}}

% merge year-only date with date label
\def\bbx@opt@mergedate@basic{%
  \renewbibmacro*{date+extradate}{%
    \iffieldundef{labelyear}
      {}
      {\printtext[\blx@delimcontext labeldate]{\printlabeldateextra}}}%
  \renewbibmacro*{bbx:ifmergeddate}{%
    \ifboolexpr{
      test {\iflabeldateisdate}
      and
      not test {\ifdateshavedifferentprecision{label}{}}
    }%
  }%
  \renewbibmacro*{issue+date}{%
    \ifboolexpr{
      test {\usebibmacro{bbx:ifmergeddate}}
      and
      test {\iffieldundef{issue}}
    }
      {}
      {\printtext[issuedate]{%
         \printfield{issue}%
         \setunit*{\addspace}%
         \printdate}}%
    \newunit}}

% merge year-only date with year-only date label
\def\bbx@opt@mergedate@minimum{%
  \renewbibmacro*{date+extradate}{%
    \iffieldundef{labelyear}
      {}
      {\printtext[\blx@delimcontext labeldate]{\printlabeldateextra}}}%
  \renewbibmacro*{bbx:ifmergeddate}{%
    \ifboolexpr{
      test {\iflabeldateisdate}
      and
      not test {\ifdateshavedifferentprecision{label}{}}
      and
      test {\iffieldundef{extradate}}
    }%
  }%
  \renewbibmacro*{issue+date}{%
    \ifboolexpr{
      test {\usebibmacro{bbx:ifmergeddate}}
      and
      test {\iffieldundef{issue}}
    }
      {}
      {\printtext[issuedate]{%
         \printfield{issue}%
         \setunit*{\addspace}%
         \printdate}}%
    \newunit}}

% don't merge date/issue with date label
\def\bbx@opt@mergedate@false{%
  \renewbibmacro*{date+extradate}{%
    \iffieldundef{labelyear}
      {}
      {\printtext[\blx@delimcontext labeldate]{\printlabeldateextra}}}%
  \renewbibmacro*{bbx:ifmergeddate}{\@secondoftwo}%
  \renewbibmacro*{issue+date}{%
    \printtext[issuedate]{%
      \printfield{issue}%
      \setunit*{\addspace}%
      \usebibmacro{date}}%
    \newunit}}

\DeclareFieldAlias{biblabeltitle}{title}
\DeclareFieldAlias{titlecase:biblabeltitle}{tilecase}
\renewbibmacro*{labeltitle}{%
  \iffieldundef{label}
    {\iffieldundef{shorttitle}
       {\iffieldundef{title}
          {\printtext[biblabeltitle]{%
             \printfield[titlecase:biblabeltitle]{maintitle}}%
           \clearfield{maintitle}}
          {\printtext[biblabeltitle]{%
             \printfield[titlecase:biblabeltitle]{title}}%
           \clearfield{title}}}
       {\printtext[biblabeltitle]{%
          \printfield[titlecase:biblabeltitle]{shorttitle}}}}
    {\printfield{label}}}

\defbibenvironment{bibliography}
  {\list
     {\ifcsequal{extblx@introcite}{extblx@opt@introcite@label}
        {\usebibmacro{introcite:typeset}}
        {}}
     {\ifcsequal{extblx@introcite}{extblx@opt@introcite@label}
        {\setlength{\labelwidth}{\introcitewidth}%
         \setlength{\leftmargin}{\labelwidth}%
         \setlength{\labelsep}{\introcitesep}%
         \addtolength{\leftmargin}{\labelsep}%
         \renewcommand*{\makelabel}[1]{##1\hss}}
        {\setlength{\leftmargin}{\bibhang}%
         \setlength{\itemindent}{-\leftmargin}}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item
   \ifcsequal{extblx@introcite}{extblx@opt@introcite@label}
     {\usebibmacro{introcite:break}}
     {}}

% We need to execute some options that were already executed
% by the standard styles again, because we changed the
% underlying definitions.
\ExecuteBibliographyOptions{mergedate=compact, dashed=true}%

\endinput
%
% This file is part of the biblatex-ext bundle.
% biblatex-ext is released under the LaTeX Project Public License v1.3c
% or later.
%
% A complete list of files included in that package can be found in
% README.md or - failing that - in ext-standard.bbx.
%
% Official releases of this package are on CTAN
%   https://www.ctan.org/pkg/biblatex-ext
% development takes place on GitHub
%   https://github.com/moewew/biblatex-ext
%