summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/babelbib/babelbib.sty
blob: 7340e11fc0eaf68952ca1375329380c5deb37630 (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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
%%
%% This is file `babelbib.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% babelbib.dtx  (with options: `latex,package')
%% 
%%   babelbib package
%% 
%%   Copyright  2003--2021 Harald Harders
%%   Copyright  2019--2021 Norbert Preining
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   harald.harders@gmx.de
%%   norbert@preining.info
%% 
\NeedsTeXFormat{LaTeX2e}[1998/06/01]
\ProvidesPackage{babelbib}
  [2021/01/06 v1.34  babelbib: multilingual bibliographies]
\let\bbbbifpackageloaded=\@ifpackageloaded
\newif\ifbbbbfixlanguage
\DeclareOption{fixlanguage}{\bbbbfixlanguagetrue}
\DeclareOption{varlanguage}{\bbbbfixlanguagefalse}
\newif\ifbbbblanguagenames
\DeclareOption{nolanguagenames}{\bbbblanguagenamesfalse}
\DeclareOption{languagenames}{\bbbblanguagenamestrue}
\newif\ifbbbbannotations
\DeclareOption{annote}{\bbbbannotationstrue}
\DeclareOption{noannote}{\bbbbannotationsfalse}
\newif\ifbtx@printISBN
\newif\ifbtx@printISSN
\DeclareOption{isbn}{\btx@printISBNtrue}
\DeclareOption{noisbn}{\btx@printISBNfalse}
\DeclareOption{issn}{\btx@printISSNtrue}
\DeclareOption{noissn}{\btx@printISSNfalse}
\newcommand\btxprintmonthyear[4]{}
\newcommand*\btx@dateasis{%
  \def\btxprintmonthyear##1##2##3##4{##2\ ##3}%
}
\newcommand*\btx@datenumeric{%
  \def\btxprintmonthyear##1##2##3##4{%
    \ifnumber{##2}{\btxprintmonthyearnum{##2}{##3}}{##2\ ##3}}%
}
\newcommand*\btx@datename{%
  \def\btxprintmonthyear##1##2##3##4{%
    \ifnumber{##2}{%
      \ifcase ##2 \or
      \csname btxmonjan##4\endcsname{##1}\or
      \csname btxmonfeb##4\endcsname{##1}\or
      \csname btxmonmar##4\endcsname{##1}\or
      \csname btxmonapr##4\endcsname{##1}\or
      \csname btxmonmay##4\endcsname{##1}\or
      \csname btxmonjun##4\endcsname{##1}\or
      \csname btxmonjul##4\endcsname{##1}\or
      \csname btxmonaug##4\endcsname{##1}\or
      \csname btxmonsep##4\endcsname{##1}\or
      \csname btxmonoct##4\endcsname{##1}\or
      \csname btxmonnov##4\endcsname{##1}\or
      \csname btxmondec##4\endcsname{##1}\or
      \PackageError{babelbib}{%
        Month outside range 1 to 12 used}{%
        Better use the BibTeX names jan, feb, mar, etc.}%
      \fi
      \ ##3%
    }{%
      ##2\ ##3}%
  }%
}
\DeclareOption{dateasis}{\btx@dateasis}
\DeclareOption{datenumeric}{\btx@datenumeric}
\DeclareOption{datename}{\btx@datename}
\DeclareOption*{%
  \InputIfFileExists{\CurrentOption.bdf}{%
    \typeout{babelbib: \CurrentOption.bdf loaded due to explicit package
      option \CurrentOption}%
    \expandafter\def\csname bbbb\CurrentOption loaded\endcsname{\@empty}%
  }{%
    \PackageError{babelbib}{%
      Language definition file \CurrentOption.bdf not found}{%
      Maybe you misspelled the language option?}%
  }%
}
\ExecuteOptions{varlanguage,nolanguagenames,noannote,isbn,issn,datename}
\ProcessOptions*
\newcommand*{\bbbbifundefined}[1]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1\endcsname\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\newcommand\bbbbaddto[2]{%
  \expandafter\bbbbifundefined{extras#1}{}{%
    \expandafter\addto\expandafter{\csname extras#1\endcsname}{%
      \csname #2\endcsname}%
    \typeout{babelbib extension \@backslashchar #2 added to
      \string\extras #1}%
  }%
}
\newcommand\inputbdf[2]{%
  \bbbbifundefined{date#1}{}{%
    \@ifundefined{bbbb#2loaded}{%
      \expandafter\def\csname bbbb#2loaded\endcsname{\@empty}%
      \typeout{babelbib: #2.bdf loaded because language #2 defined.}%
      \input{#2.bdf}%
    }{}%
  }%
}
\ifbbbbfixlanguage
  \newcommand\selectbiblanguage[1]{%
    \AtBeginDocument{\@selectbiblanguage{#1}}%
  }
  \AtBeginDocument{%
    \renewcommand\selectbiblanguage[1]{\@selectbiblanguage{#1}}%
  }
  \newcommand\@selectbiblanguage[1]{%
    \bbbbifundefined{bibs#1}{%
      \bbbbifundefined{date#1}{%
        \PackageError{babelbib}{Language #1 in bibliography not loaded
          by babel}{%
          The language #1 hasn't been loaded by babel.
          Add it to the\MessageBreak
          options of the \string\usepackage{babel} command or to the
          global options.}%
      }{%
        \PackageError{babelbib}{Language #1 in bibliography unknown by
          babelbib}{%
          There are no definitions for #1 available in the
          current\MessageBreak
          version of babelbib. Please contact harald.harders@gmx.de.}%
      }%
    }{%
      \typeout{babelbib: Set language for keywords in the bibliography fixed to #1}%
      \csname bibs#1\endcsname
    }%
  }
\else
  \newcommand\selectbiblanguage[1]{%
    \PackageWarning{babelbib}{Command \string\selectbiblanguage\space
      used without package\MessageBreak
      option fixlanguage. Ignored}%
  }
  \AtBeginDocument{%
    \typeout{babelbib: Use citation-dependent languages in bibliography}%
  }
\fi
\newcommand\btxselectlanguage[1]{%
  \bbbbifundefined{bibs#1}{%
    \bbbbifundefined{date#1}{%
      \PackageError{babelbib}{Language #1 in bibliography not loaded
        by babel}{%
        The language #1 hasn't been loaded by babel.
        Add it to the\MessageBreak
        options of the \string\usepackage{babel} command or to the
        global options.}%
    }{%
      \ifbbbbfixlanguage
        \PackageWarning{babelbib}{Language #1 in bibliography
          unknown\MessageBreak
          by babelbib. Hyphenation will be\MessageBreak
          incorrect}%
      \else
        \PackageError{babelbib}{Language #1 in bibliography unknown by
          babelbib}{%
          There are no definitions for #1 available in the
          current\MessageBreak
          version of babelbib. Please contact harald.harders@gmx.de.}%
      \fi
    }%
  }{%
    \csname extras#1\endcsname
    \selectlanguage{#1}%
  }%
}
\newcommand\biblanguage[1]{{%
    \expandafter\selectlanguage\expandafter{\biblanguagename}#1}}
\newcommand\btxlanguagename[1]{%
  \bbbbifundefined{btxlanguagename#1}{%
    \PackageError{babelbib}{Languagename for #1 not
      defined\MessageBreak
      in \languagename\space language}{%
      Either you have forgotten to specify the option `languagenames'
      when loading\MessageBreak
      babelbib, or the command \string\bibs\languagename\space does
      not contain a definition\MessageBreak
      for the command \string\btxlanguagename#1.
      In the latter case, please\MessageBreak
      contact harald.harders@gmx.de.}%
    #1%
  }{%
    \@nameuse{btxlanguagename#1}%
  }%
}
\newcommand*\setbtxfallbacklanguage[1]{%
  \edef\btxfallbacklanguage{#1}%
  \typeout{babelbib: Set bibliography fall-back language to
    \btxfallbacklanguage}%
}
\AtBeginDocument{%
  \@ifundefined{btxfallbacklanguage}{%
    \edef\btxfallbacklanguage{\languagename}%
  \typeout{babelbib: Set bibliography fall-back language to
    \btxfallbacklanguage}%
  }{%
    \typeout{babelbib: Bibliography fall-back language unchanged
      (\btxfallbacklanguage)}%
  }%
}
\newcommand*\declarebtxcommands[2]{%
  \AtBeginDocument{%
    \typeout{babelbib: Add a command to \string\bibs#1}%
    \expandafter\g@addto@macro\csname bibs#1\endcsname{#2}%
    \ifbbbbfixlanguage
      \selectbiblanguage{\biblanguagename}%
    \fi
  }%
}
\@onlypreamble\declarebtxcommands
\newcommand*\btxifchangecaseon{%
  \def\btxifchangecase{\@firstoftwo}%
}%
\newcommand*\btxifchangecaseoff{%
  \def\btxifchangecase{\@secondoftwo}%
}%
\newcommand\setbibliographyfont{%
  \@ifnextchar*{\@@setbibliographyfont}{\@setbibliographyfont}%
}
\newcommand\@setbibliographyfont[2]{%
  \bbbbifundefined{btx#1font}{%
    \PackageError{babelbib}{Bibliography font `#1' can't be set}{%
      You have tried to define a font for the bibliographic element
      \MessageBreak
      `#1', which is unknown to babelbib}%
  }{%
    \expandafter\renewcommand\csname btx#1font\endcsname{#2}%
    \typeout{babelbib: Bibliography font for `#1' changed.}%
  }%
}
\newcommand\@@setbibliographyfont[3]{%
  \bbbbifundefined{btx#2font}{%
    \expandafter\newcommand\csname btx#2font\endcsname{#3}%
    \typeout{babelbib: Bibliography font for `#2' newly defined.}%
  }{%
    \expandafter\renewcommand\csname btx#2font\endcsname{#3}%
    \typeout{babelbib: Bibliography font for `#2' changed.}%
  }%
}
\newcommand\providebibliographyfont{%
  \@ifnextchar*{\@@providebibliographyfont}{\@providebibliographyfont}%
}
\newcommand\@providebibliographyfont[2]{%
  \bbbbifundefined{btx#1font}{%
    \PackageError{babelbib}{Bibliography font `#1' can't be set}{%
      You have tried to define a font for the bibliographic element
      \MessageBreak
      `#1', which is unknown to babelbib}%
  }{%
    \expandafter\ifx\csname btx#1font\endcsname\@empty
      \expandafter\renewcommand\csname btx#1font\endcsname{#2}%
      \typeout{babelbib: Using the BibTeX style's default font for `#1'.}%
    \else
      \typeout{babelbib: Using user changed font for `#1'.}%
    \fi
  }%
}
\newcommand\@@providebibliographyfont[3]{%
  \bbbbifundefined{btx#2font}{%
    \expandafter\newcommand\csname btx#2font\endcsname{#3}%
    \typeout{babelbib: Using the BibTeX style's default font for `#2'.}%
  }{%
    \expandafter\ifx\csname btx#2font\endcsname\@empty
      \expandafter\renewcommand\csname btx#2font\endcsname{#3}%
      \typeout{babelbib: Using the BibTeX style's default font for `#2'.}%
    \else
      \typeout{babelbib: Using user changed font for `#2'.}%
    \fi
  }%
}
\newcommand*\btxnamefont{}
\let\btxnamefont=\@empty
\newcommand*\btxlastnamefont{}
\let\btxlastnamefont=\@empty
\newcommand\btxtitlefont{}
\let\btxtitlefont=\@empty
\newcommand\btxjtitlefont{}
\let\btxjtitlefont=\@empty
\newcommand\btxetalfont{}
\let\btxetalfont=\@empty
\newcommand\btxjournalfont{}
\let\btxjournalfont=\@empty
\newcommand\btxpublisherfont{}
\let\btxpublisherfont=\@empty
\newcommand\btxvolumefont{}
\let\btxvolumefont=\@empty
\newcommand\btxISBNfont{}
\let\btxISBNfont=\@empty
\newcommand\btxISSNfont{}
\let\btxISSNfont=\@empty
\newcommand\btxurlfont{}
\let\btxurlfont=\@empty
\newcommand\btxurldatefont{}
\let\btxurldatefont=\@empty
\newcommand\btxnumeralfont{}
\let\btxnumeralfont=\@empty
\newcommand\btxauthorcolon{:}
\newcommand\btxISBN{ISBN}
\newcommand\btxISSN{ISSN}
\DeclareRobustCommand\ifbtxprintISBN[1]{\ifbtx@printISBN #1\fi}
\DeclareRobustCommand\ifbtxprintISSN[1]{\ifbtx@printISSN #1\fi}
\newcommand*\btxprintISBN[1]{\csname btx@printISBN#1\endcsname}
\newcommand*\btxprintISSN[1]{\csname btx@printISSN#1\endcsname}
\ifbbbbannotations
  \DeclareRobustCommand\btxannotation[1]{%
    \begin{quotation}%
      \noindent
      #1%
    \end{quotation}%
  }
\else
  \DeclareRobustCommand\btxannotation[1]{}%
\fi
\providecommand\ifnumber[3]{%
 \begingroup\@tempswafalse\let\scr@next\test@number
 \expandafter\scr@next#1\scr@next
 \if@tempswa\endgroup#2\else\endgroup#3\fi
}
\providecommand*\test@number[1]{%
 \ifx \scr@next#1%
  \let\scr@next\relax
 \else
  \@tempcnta=\expandafter\expandafter\expandafter\number
  \expandafter`#1\relax
  \ifnum \@tempcnta>47\relax
   \ifnum \@tempcnta<58\relax
    \@tempswatrue
   \else\@tempswafalse\fi
  \else\@tempswafalse\fi
  \if@tempswa\else\let\scr@next\gobble@till@next\fi\fi
 \scr@next
}
\def\gobble@till@next#1\scr@next{}
\def\btx@parsenum#1#2#3\@empty{%
  #1%
  \edef\btx@digitb{#3}%
  \ifx\@empty\btx@digitb
    #2%
    \edef\btx@digita{#1}%
    \edef\btx@digitb{#2}%
  \else
    \expandafter\btx@parsenum#2#3\@empty
  \fi
}
\DeclareRobustCommand\btxnumeralfallback[2]{%
  \foreignlanguage{#1}{%
    \ifnumber{#2}{%
      \PackageWarning{babelbib}{Handling of numerical editions not
        handled\MessageBreak by language #1 for edition `#2'}%
    }{}%
    #2%
  }%
}%
\DeclareRobustCommand\btxnumeraldot[2]{%
  \foreignlanguage{#1}{\ifnumber{#2}{#2.}{#2}}%
}
\DeclareRobustCommand\btxnumeralenglish[2]{%
  \foreignlanguage{#1}{%
    \ifnumber{#2}{%
      \expandafter\btx@parsenum#2\@empty\@empty\@empty
      \btxnumeralfont{%
        \ifx\btx@digitb\@empty
          \ifcase\btx@digita th\or st\or nd\or rd\else th\fi
        \else
          \ifnum\btx@digita=1
            th%
          \else
            \ifcase\btx@digitb th\or st\or nd\or rd\else th\fi
          \fi
        \fi
        }%
    }{#2}%
  }%
}
\newcounter{btxromaniannumeral}%
\renewcommand\thebtxromaniannumeral{\Roman{btxromaniannumeral}}%
\DeclareRobustCommand\btxnumeralromanian[2]{%
  \foreignlanguage{#1}{%
    \ifnumber{#2}{%
      \setcounter{btxromaniannumeral}{#2}%
      \ifcase#2 0\or \thebtxromaniannumeral\else a \thebtxromaniannumeral-a \fi
    }{#2}%
  }%
}
\DeclareRobustCommand\btxnumeralfrench[2]{%
  \foreignlanguage{#1}{%
    \ifnumber{#2}{%
      \expandafter\btx@parsenum#2\@empty\@empty\@empty
      \btxnumeralfont{%
        \ifx\btx@digitb\@empty
          \ifcase\btx@digita \ieme\or \iere\else \ieme\fi
        \else
          \ifnum\btx@digita=1
            th%
          \else
            \ifcase\btx@digitb \ieme\or \iere\else \ieme\fi
          \fi
        \fi
        }%
    }{#2}%
  }%
}
\DeclareRobustCommand\btxnumeralswedish[2]{%
  \foreignlanguage{#1}{%
    \ifnumber{#2}{%
      \expandafter\btx@parsenum#2\@empty\@empty\@empty
      \btxnumeralfont{%
        \ifx\btx@digitb\@empty
          \ifcase\btx@digita :e\or :a\or :a\or :e\else :e\fi
        \else
          \ifnum\btx@digita=1
            :a%
          \else
            \ifcase\btx@digitb :e\or :a\or :a\or :e\else :e\fi
          \fi
        \fi
        }%
    }{#2}%
  }%
}
\AtBeginDocument{%
  \providecommand\url[1]{%
    \PackageError{babelbib}{No \string\url\space command defined but
      field URL used\MessageBreak
      in bibliography}{%
      Please define a \string\url\space command for printing URLs
      before \string\begin{document}, e.\,g.\MessageBreak
        by loading the package `url.sty'.}%
    \texttt{#1}%
    }%
}
\AtBeginDocument{%
  \RequirePackage{babel}
  \inputbdf{afrikaans}{afrikaans}
  \inputbdf{american}{english}
  \inputbdf{austrian}{german}
  \inputbdf{bahasa}{bahasa}
  \inputbdf{brazil}{portuguese}
  \inputbdf{brazilian}{portuguese}
  \inputbdf{british}{english}
  \inputbdf{canadian}{english}
  \inputbdf{canadien}{french}
  \inputbdf{catalan}{catalan}
  \inputbdf{croatian}{croatian}
  \inputbdf{czech}{czech}
  \inputbdf{danish}{danish}
  \inputbdf{dutch}{dutch}
  \inputbdf{english}{english}
  \inputbdf{esperanto}{esperanto}
  \inputbdf{finnish}{finnish}
  \inputbdf{francais}{french}
  \inputbdf{french}{french}
  \inputbdf{frenchb}{french}
  \inputbdf{galician}{galician}
  \inputbdf{german}{german}
  \inputbdf{germanb}{german}
  \inputbdf{greek}{greek}
  \inputbdf{italian}{italian}
  \inputbdf{norsk}{norsk}
  \inputbdf{mexican}{spanish}
  \inputbdf{naustrian}{german}
  \inputbdf{ngerman}{german}
  \inputbdf{portuges}{portuguese}
  \inputbdf{portuguese}{portuguese}
  \inputbdf{romanian}{romanian}
  \inputbdf{russian}{russian}
  \inputbdf{russianb}{russian}
  \inputbdf{serbian}{serbian}
  \inputbdf{spanish}{spanish}
  \inputbdf{swedish}{swedish}
  \inputbdf{turkish}{turkish}
  \inputbdf{UKenglish}{english}
  \inputbdf{USenglish}{english}
  \ifbbbbfixlanguage
    \typeout{babelbib: Load BibTeX extensions
      \string\bibs\bbl@main@language\space for \bbl@main@language}%
    \selectbiblanguage{\bbl@main@language}%
  \else
    \expandafter\selectlanguage\expandafter{\bbl@main@language}%
  \fi
}

\endinput
%%
%% End of file `babelbib.sty'.