summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dk-bib/dk-bib.sty
blob: b5d61f468fb246d401a738767308b27dada3061d (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
% Copyright (C) 2004, 2005, 2006 Arne Jorgensen

% This file is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.

% This file is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.

% You should have received a copy of the GNU General Public License
% along with this file; if not, write to the Free Software Foundation,
% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

\NeedsTeXFormat{LaTeX2e}[1995/12/01]

% subversion date and revision
\def\dkbib@svn $#1 #2 #3 #4-#5-#6 #7 #8 ${%
  \def\dkbib@sty@revision{#3}
  \def\dkbib@sty@date{#4/#5/#6}
}
\dkbib@svn $Id: dk-bib.sty 92 2006-05-21 21:18:10Z arne $
\def\dkbib@version{0.6}

\ProvidesPackage{dk-bib}[\dkbib@sty@date\space v\dkbib@version\space(r\dkbib@sty@revision) Danish variants of the standard BibTeX styles]

\RequirePackage{xkeyval}

\newif\ifdkbib@url
\dkbib@urlfalse
\DeclareOptionX{url}[true]{%
  \csname dkbib@url#1\endcsname}

\newif\ifdkbib@isbn
\dkbib@isbnfalse
\DeclareOptionX{isbn}[true]{%
  \csname dkbib@isbn#1\endcsname}

\newif\ifdkbib@issn
\dkbib@issnfalse
\DeclareOptionX{issn}[true]{%
  \csname dkbib@issn#1\endcsname}

\newif\ifdkbib@annote
\dkbib@annotefalse
\DeclareOptionX{annote}[true]{%
  \csname dkbib@annote#1\endcsname}

\newif\ifdkbib@printing
\dkbib@printingfalse
\DeclareOptionX{printing}[true]{%
  \csname dkbib@printing#1\endcsname}

\newif\ifdkbib@apalike
\dkbib@apalikefalse
\DeclareOptionX{apalike}[true]{%
  \csname dkbib@apalike#1\endcsname}

\newif\ifdkbib@fixcitedash
\dkbib@fixcitedashtrue
\DeclareOptionX{fixcitedash}[true]{%
  \csname dkbib@fixcitedash#1\endcsname}

\newcount\dkbib@maxordinaldepth
\dkbib@maxordinaldepth0
\newcommand*\dkbib@DeclareOrdinalWord[2]{
  \ifnum#1>\dkbib@maxordinaldepth
    \dkbib@maxordinaldepth#1
  \fi
  \@namedef{dkbib@word#1}{#2}%
}
\dkbib@DeclareOrdinalWord{1}{f\o rste}
\dkbib@DeclareOrdinalWord{2}{anden}
\dkbib@DeclareOrdinalWord{3}{tredje}
\dkbib@DeclareOrdinalWord{4}{fjerde}
\dkbib@DeclareOrdinalWord{5}{femte}
\dkbib@DeclareOrdinalWord{6}{sjette}
\dkbib@DeclareOrdinalWord{7}{syvende}
\dkbib@DeclareOrdinalWord{8}{ottende}
\dkbib@DeclareOrdinalWord{9}{niende}
\dkbib@DeclareOrdinalWord{10}{tiende}
\dkbib@DeclareOrdinalWord{11}{elvte}
\dkbib@DeclareOrdinalWord{12}{tolvte}
\dkbib@DeclareOrdinalWord{13}{trettende}
\dkbib@DeclareOrdinalWord{14}{fjortende}
\dkbib@DeclareOrdinalWord{15}{femtende}
\dkbib@DeclareOrdinalWord{16}{sekstende}
\dkbib@DeclareOrdinalWord{17}{syttende}
\dkbib@DeclareOrdinalWord{18}{attende}
\dkbib@DeclareOrdinalWord{19}{nittende}
\dkbib@DeclareOrdinalWord{20}{tyvende}

\newcount\dkbib@ordinaldepth
\dkbib@ordinaldepth\dkbib@maxordinaldepth
\DeclareOptionX{ordinaldepth}{%
  \dkbib@ordinaldepth#1}

\ifnum\dkbib@ordinaldepth>\dkbib@maxordinaldepth
  \PackageWarningNoLine{dk-bib}{Ordinal depth set to
    \the\dkbib@ordinaldepth, but maximum is \the\dkbib@maxordinaldepth}
\fi

\newif\ifdkbib@ordinalstoword
\dkbib@ordinalstowordfalse
\DeclareOptionX{ordinals2word}[true]{%
  \csname dkbib@ordinalstoword#1\endcsname}

\ProcessOptionsX

% Work around a wrong implementation  of \MakeUppercase (according to
% Morten H\o gholm who also provided this implementation)
\DeclareRobustCommand\dkbib@MakeUppercase[1]{%
  \begingroup
  \def\i{I}\def\j{J}%
  \def\dkbib@reserved@a##1##2{\let##1##2\dkbib@reserved@a}%
  \expandafter\dkbib@reserved@a\@uclclist\dkbib@reserved@b{\dkbib@reserved@b\@gobble}%
  \protected@edef\dkbib@reserved@a{\endgroup\uppercase{#1}}%
  \dkbib@reserved@a
}
\protected@edef\dkbib@MakeUppercase#1{\dkbib@MakeUppercase{#1}}

\AtBeginDocument{%
  %%% fixcitedash
  \@ifpackageloaded{cite}%
    {\ifdkbib@fixcitedash%
        \providecommand{\dkbibdash}{\hbox{-}\penalty\@m}%
        \renewcommand{\citedash}{\dkbibdash}%
      \fi}%
    {\relax}%
  %%% apalike
  \ifdkbib@apalike%
    \RequirePackage{dk-apali}%
  \fi%
  %%% url
  \ifdkbib@url%
    \RequirePackage{url}%
    \providecommand{\dkbiburl}[1]{URL \url{#1}}%
  \else%
    \def\dkbiburl#1{\unskip\@gobble}%
  \fi%
  %%% isbn
  \ifdkbib@isbn%
    \providecommand{\dkbibisbn}[1]{ISBN #1}%
  \else%
    \def\dkbibisbn#1{\unskip\@gobble}%
  \fi%
  %%% issn
  \ifdkbib@issn%
    \providecommand{\dkbibissn}[1]{ISSN #1}%
  \else%
    \def\dkbibissn#1{\unskip\@gobble}%
  \fi%
  %%% annote
  \ifdkbib@annote%
    \providecommand{\dkbibannote}[2]{%
      \begin{quotation}\noindent
        \dkbib@MakeUppercase #2
      \end{quotation}
    }%
  \else%
    \def\dkbibannote#1#2{\unskip}%
  \fi%    
  %%% edition/printing
  \DeclareRobustCommand{\dkbibedition}[2]{%
    \ifx\@empty#1\@empty\else%
      \ifdkbib@ordinalstoword%
        \@ifundefined{dkbib@word#1}%
          {#1\dkbib@addperiod~udgave}%
          {\ifnum#1>\dkbib@ordinaldepth
             #1\dkbib@addperiod~udgave%
           \else
             \@nameuse{dkbib@word#1}~udgave%
           \fi}%
      \else
        #1\dkbib@addperiod~udgave%
      \fi
      \ifdkbib@printing
        \ifx\@empty#2\@empty\else, \fi
      \fi
    \fi
    \ifdkbib@printing
      \ifx\@empty#2\@empty\else
        \ifdkbib@ordinalstoword%
          \@ifundefined{dkbib@word#2}%
            {#2\dkbib@addperiod~oplag}%
            {\ifnum#2>\dkbib@ordinaldepth
               #2\dkbib@addperiod~oplag%
             \else
               \@nameuse{dkbib@word#2}~oplag%
             \fi}%
        \else
          #2\dkbib@addperiod~oplag%
        \fi
      \fi
    \fi
  }
  \DeclareRobustCommand\dkbibEdition[2]{%
    \protected@edef\reserved@a{\csname dkbibedition \endcsname{#1}{#2}}%
    \expandafter\dkbib@MakeUppercase\reserved@a}
}