summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-gost/gost-authoryear.cbx
blob: 3546d7a9b5ac14d032b960d9c7402bb4c4b51bfd (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
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
\ProvidesFile{gost-authoryear.cbx}
[2013/07/17\space v0.9\space biblatex-gost styles]

\ExecuteBibliographyOptions{dashed=false,citetracker=constrict,loccittracker=constrict,
                            singletitle=false,labeldate,labeltitleyear,uniquename=init,
                            uniquelist,ibidtracker=constrict,pagetracker,sortcites,autocite=inline,
                            citeisbn,citeurl,citedoi,citeeprint}

\providecommand*{\mkibid}[1]{#1}
\renewcommand*{\iffinalcitedelim}{%
  \ifnumequal{\value{textcitecount}}{\value{textcitetotal}-1}}
\newbool{cbx:parens}
\newbool{cbx:loccit}

\DeclareBibliographyOption{ibidpage}[true]{%
  \ifstrequal{#1}{true}
    {\ExecuteBibliographyOptions{loccittracker=constrict}}
    {\ExecuteBibliographyOptions{loccittracker=false}}}

\renewcommand*{\postnotedelim}{\addcomma\addspace}
\renewcommand*{\nameyeardelim}{\addcomma\addspace}
\renewcommand*{\compcitedelim}{\addsemicolon\space}
\renewcommand*{\bibleftparen}{\blx@postpunct\ifcitation{[\bibsentence}{(}}
\renewcommand*{\bibrightparen}{\blx@postpunct\ifcitation{]}{)}\midsentence}

\DeclareFieldFormat*{citetitle}{\mkbibemph{#1}}
\DeclareFieldFormat{extratitleyear}{%
  \iffieldnums{labelyear}
    {\mknumalph{#1}}
    {\printtext{(}\mknumalph{#1}\printtext{)}}}
\DeclareFieldFormat{citeheading}{#1}

\newbibmacro*{cite:init}{%
  \global\boolfalse{cbx:loccit}%
  \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:parens}%
     \global\undef\cbx@lasthash
     \global\undef\cbx@lastyear}
    {\iffieldundef{prenote}
       {}
       {\global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}}}

\newbibmacro*{cite:reinit}{%
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}

\newbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\iffieldundef{heading}
         {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
            {\ifnameundef{labelname}
                {\usebibmacro{cite:label+volume+parts}{bibhyperref}%
                 \setunit{\nameyeardelim}%
                 \usebibmacro{cite:labelyear+extras}{bibhyperref}}
                {\usebibmacro{cite:labelname+volume+parts}{bibhyperref}}%
             \usebibmacro{cite:reinit}}
            {\iffieldequals{namehash}{\cbx@lasthash}
               {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                        \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
                  {\setunit{\addcomma}%
                   \usebibmacro{cite:extrayear}}
                  {\setunit{\compcitedelim}%
                   \usebibmacro{cite:labelyear+extras}{bibhyperref}%
                   \savefield{labelyear}{\cbx@lastyear}}}
               {\ifsingletitle
                  {\usebibmacro{cite:labelname+volume+parts}{bibhyperref}}
                  {\usebibmacro{cite:labelname+volume+parts}{}%
                   \setunit{\nameyeardelim}%
                   \usebibmacro{cite:labelyear+extras}{bibhyperref}%
                   \savefield{labelyear}{\cbx@lastyear}}%
                \savefield{namehash}{\cbx@lasthash}}}}
         {\usebibmacro{cite:heading}{bibhyperref}%
%          \iffieldundef{labelyear}
%            {}
%            {\setunit{\nameyeardelim}%
%             \usebibmacro{cite:labelyear+extras}{bibhyperref}}
          \usebibmacro{cite:reinit}}}}%
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\newbibmacro*{cite:labelname+volume+parts}[1]{%
  \printtext[#1]{\printnames{labelname}}%
     \setunit*{\addcomma\space}%
     %\usebibmacro{volume+parts}{\setunit*{\addcomma\space}}%
}

\newbibmacro*{cite:label+volume+parts}[1]{%
  \iffieldundef{label}
    {\ifsingletitle
      {\printtext[#1]{\printfield[citetitle]{labeltitle}}}
      {\printfield[citetitle]{labeltitle}}}
    {\printtext[#1]{\printfield{label}}}%
     \setunit*{\addcomma\space}%
     %\usebibmacro{volume+parts}{\setunit*{\addcomma\space}}%
}

\newbibmacro*{cite:labelyear+extras}[1]{%
  \ifsingletitle
    {}
    {\iffieldundef{labelyear}
      {}
      {\printtext[#1]{%
          \printfield{labelyear}%
          \usebibmacro{cite:extras}}}}}

\newbibmacro*{citeyear}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\iffieldundef{labelyear}
    {\usebibmacro{cite:label}%
           \usebibmacro{cite:reinit}}
    {\iffieldequals{namehash}{\cbx@lasthash}
             {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extrayear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{labelyear}{\cbx@lastyear}}}
             {\usebibmacro{cite:labelyear+extrayear}%
              \savefield{namehash}{\cbx@lasthash}%
              \savefield{labelyear}{\cbx@lastyear}}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\newbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extrayear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenparen}%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\usebibmacro{cite:labelyear+extrayear}}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames{labelname}%
  \setunit{%
    \global\booltrue{cbx:parens}%
    \addspace\bibopenparen}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
        \iffieldundef{shorthand}
          {\iffieldundef{labelyear}
             {\usebibmacro{cite:label}}
             {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
    {\usebibmacro{cite:ibid}}
    {\usebibmacro{cite:labelyear+extrayear}}}%
           \savefield{labelyear}{\cbx@lastyear}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}

\newbibmacro*{cite:heading}[1]{%
  \printtext[#1]{\printfield[citeheading]{heading}}}

\newbibmacro*{cite:shorthand}{%
  \printtext[bibhyperref]{\printfield{shorthand}}}

\newbibmacro*{cite:label}{%
  \iffieldundef{label}
    {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
    {\printtext[bibhyperref]{\printfield{label}}}}

\newbibmacro*{cite:labelyear+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{%
       \printfield{labelyear}%
       \printfield{extrayear}}}}

\newbibmacro*{cite:extrayear}{%
  \iffieldundef{extrayear}
    {}
    {\printtext[bibhyperref]{\printfield{extrayear}}}}

\newbibmacro*{cite:ibid}{%
  \printtext[bibhyperref]{\bibstring[\mkibid]{ibidem}}%
  \ifloccit
    {\global\booltrue{cbx:loccit}}
    {}}

\newbibmacro*{cite:postnote}{%
  \ifbool{cbx:loccit}
    {}
    {\usebibmacro{postnote}}}

\newbibmacro*{textcite:postnote}{%
  \ifbool{cbx:loccit}
    {}
    {\usebibmacro{postnote}}%
  \ifthenelse{\value{multicitecount}=\value{multicitetotal}}
    {\setunit{}%
     \printtext{%
       \ifbool{cbx:parens}
   {\bibcloseparen\global\boolfalse{cbx:parens}}
   {}}}
    {\setunit{%
       \ifbool{cbx:parens}
   {\bibcloseparen\global\boolfalse{cbx:parens}}
   {}%
       \textcitedelim}}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibparens\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\cbx@textcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}

\newrobustcmd{\cbx@textcite@init}[2]{%
  \setcounter{textcitetotal}{0}%
  \setcounter{textcitecount}{0}%
  \def\cbx@savedcites{#1}#2\cbx@savedcites\empty}

\DeclareMultiCiteCommand{\cbx@textcites}{\cbx@textcite}{}
\DeclareMultiCiteCommand{\textcites}[\cbx@textcites@init\cbx@textcites]{\textcite}{}

\let\cbx@textcites@init\cbx@textcite@init
\pretocmd{\cbx@textcites@init}{\UseNextMultiCiteHook}{}{}

\DeclareMultiCiteCommand{\cites}{\cite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\parencites}[\mkbibparens]
  {\parencite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\footcites}[\mkbibfootnote]
  {\footcite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\footcitetexts}[\mkbibfootnotetext]
  {\footcitetext}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\smartcites}[\iffootnote\mkbibparens\mkbibfootnote]
  {\smartcite}{\setunit{\multicitedelim}}

\endinput