summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-gost/gost-authoryear.cbx
blob: bdf7cc545c963b65df2813e30e22517803089572 (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
336
337
338
\ProvidesFile{gost-authoryear.cbx}
[2021/05/08\space v1.22\space biblatex-gost styles]

\ExecuteBibliographyOptions{dashed=false,citetracker=constrict,loccittracker=constrict,
  dropdates=false,
  labeldateparts,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:gost:parens}
\newbool{cbx:gost: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}
\newcommand{\mkbibbracketssentence}[1]{\bibsentence\mkbibbrackets{#1}\midsentence}

\DeclareFieldFormat*{citetitle}{\mkbibemph{#1}}
\DeclareFieldFormat{extratitleyear}{\mknumalph{#1}}
\DeclareFieldFormat{citeheading}{#1}

\newbibmacro*{cite:init}{%
  \global\boolfalse{cbx:gost:loccit}%
  \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:gost: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}
              {% no labelname
               \iffieldundef{label}
                 {% no label, so print labeltitle (always present)
                  \blx@gost@ifneedsdate
                    {\printtext[citetitle]{\printfield[titlecase]{labeltitle}}
                     \setunit{\nameyeardelim}%
                     \usebibmacro{cite:labelyear+extras}{bibhyperref}}
                    {\printtext[bibhyperref]{%
                        \printtext[citetitle]{\printfield[titlecase]{labeltitle}}}}}
                 {% label exists, print it
                  \usebibmacro{cite:label+volume+parts}}}%
              {% labelname, no labelyear
               \usebibmacro{cite:labelname+volume+parts}{bibhyperref}%
               \usebibmacro{cite:reinit}}}%
           {% both labelname, labelyear exist
            \iffieldequals{namehash}{\cbx@lasthash}
               {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                        \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
                  {\setunit{\addcomma}%
                   \usebibmacro{cite:extradate}}
                  {\setunit{\compcitedelim}%
                   \usebibmacro{cite:labelyear+extras}{bibhyperref}%
                   \savefield{labelyear}{\cbx@lastyear}}}
               {\blx@gost@ifneedsdate
                  {\usebibmacro{cite:labelname+volume+parts}{}%
                   \setunit{\nameyeardelim}%
                   \usebibmacro{cite:labelyear+extras}{bibhyperref}%
                   \savefield{labelyear}{\cbx@lastyear}}%
                  {\usebibmacro{cite:labelname+volume+parts}{bibhyperref}}%
                \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}{%
  \iffieldundef{label}
    {}
    {\printtext[bibhyperref]{\printfield{label}}}%
     \setunit*{\addcomma\space}%
     %\usebibmacro{volume+parts}{\setunit*{\addcomma\space}}%
}

\newbibmacro*{cite:labelyear+extras}[1]{%
  \iffieldundef{labelyear}
    {}
    {\printtext[#1]{%
          \usebibmacro{printyear}{label}% print 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:extradate}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extradate}%
           \savefield{labelyear}{\cbx@lastyear}}}
             {\usebibmacro{cite:labelyear+extradate}%
              \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:extradate}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extradate}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
     \setunit{%
       \global\booltrue{cbx:gost:parens}%
       \addspace\bibopenparen}%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\usebibmacro{cite:labelyear+extradate}}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames{labelname}%
  \setunit{%
    \global\booltrue{cbx:gost: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+extradate}}}%
           \savefield{labelyear}{\cbx@lastyear}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:gost:parens}
      {\bibcloseparen\global\boolfalse{cbx:gost: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]{\printtext[citetitle]{\printfield[titlecase]{labeltitle}}}}
    {\printtext[bibhyperref]{\printfield{label}}}}

\newbibmacro*{cite:labelyear+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{%
       \usebibmacro{printyear}{label}%
       \printfield{extradate}}}}

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

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

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

\newbibmacro*{textcite:postnote}{%
  \ifbool{cbx:gost:loccit}
    {}
    {\usebibmacro{postnote}}%
  \ifthenelse{\value{multicitecount}=\value{multicitetotal}}
    {\setunit{}%
     \printtext{%
       \ifbool{cbx:gost:parens}
   {\bibcloseparen\global\boolfalse{cbx:gost:parens}}
   {}}}
    {\setunit{%
       \ifbool{cbx:gost:parens}
   {\bibcloseparen\global\boolfalse{cbx:gost: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}[\mkbibbracketssentence]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbracketssentence]
  {\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\mkbibbracketssentence\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}[\mkbibbracketssentence]
  {\parencite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\footcites}[\mkbibfootnote]
  {\footcite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\footcitetexts}[\mkbibfootnotetext]
  {\footcitetext}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\smartcites}[\iffootnote\mkbibbracketssentence\mkbibfootnote]
  {\smartcite}{\setunit{\multicitedelim}}

\endinput