summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex/cbx/numeric-comp.cbx
blob: d1f9cd8e111556345b965aa00cc71fd9af63c09c (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
% $Id: numeric-comp.cbx,v 0.9 2010/02/14 15:42:33 lehman beta $

\ProvidesFile{numeric-comp.cbx}
[\abx@cbxid $Id: numeric-comp.cbx,v 0.9 2010/02/14 15:42:33 lehman beta $]

\ExecuteBibliographyOptions{labelnumber,sortcites,autocite=inline}
\renewcommand*{\multicitedelim}{\addcomma\space}
\providebool{bbx:subentry}
\newcounter{cbx@tempcnta}
\newcounter{cbx@tempcntb}

\DeclareFieldFormat{entrysetcount}{\mknumalph{#1}}

\newbibmacro*{cite:init}{%
  \let\cbx@tempa=\empty
  \undef\cbx@lasthash
  \defcounter{cbx@tempcnta}{0}%
  \defcounter{cbx@tempcntb}{-2}}

\newbibmacro*{cite:comp}{%
  \global\defcounter{cbx@tempcntb}{\value{cbx@tempcntb}+1}%
  \iffieldundef{shorthand}
    {\ifbool{bbx:subentry}
       {\iffieldundef{entrysetcount}
	  {\usebibmacro{cite:comp:comp}}
          {\usebibmacro{cite:comp:inset}}}
       {\usebibmacro{cite:comp:comp}}}
    {\usebibmacro{cite:comp:shand}}}

\newbibmacro*{cite:comp:comp}{%
  \ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}}
    {\savefield{entrykey}{\cbx@lastkey}%
     \savefield{labelnumber}{\cbx@lastnumber}%
     \global\defcounter{cbx@tempcnta}{\value{cbx@tempcnta}+1}}
    {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}-1}
       {}
       {\usebibmacro{cite:dump}%
	\ifnumgreater{\value{cbx@tempcntb}}{-1}
	  {\multicitedelim}
	  {}%
	\printtext[bibhyperref]{\printfield{labelnumber}}}}%
  \global\defcounter{cbx@tempcntb}{\thefield{labelnumber}}}

\newbibmacro*{cite:comp:inset}{%
  \usebibmacro{cite:dump}%
  \ifnumgreater{\value{cbx@tempcntb}}{-1}
    {\multicitedelim}
    {}%
  \printtext[bibhyperref]{%
    \printfield{labelnumber}%
    \printfield{entrysetcount}}%
  \global\defcounter{cbx@tempcntb}{-1}}

\newbibmacro*{cite:comp:shand}{%
  \usebibmacro{cite:dump}%
  \ifnumgreater{\value{cbx@tempcntb}}{-1}
    {\multicitedelim}
    {}%
  \printtext[bibhyperref]{\printfield{shorthand}}%
  \global\defcounter{cbx@tempcntb}{-1}}

\newbibmacro*{cite:dump}{%
  \ifnumgreater{\value{cbx@tempcnta}}{0}
    {\ifnumgreater{\value{cbx@tempcnta}}{1}
       {\bibrangedash}
       {\multicitedelim}%
     \bibhyperref[\cbx@lastkey]{%
       \printtext[labelnumber]{\cbx@lastnumber}}%
     \global\defcounter{cbx@tempcnta}{0}}
    {}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}%
   \bibleftbracket}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \bibrightbracket}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}}

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

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

\DeclareCiteCommand{\textcite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {\usebibmacro{cite:comp}}
     {\usebibmacro{cite:dump}\cbx@tempa
      \usebibmacro{cite:init}%
      \ifnameundef{labelname}
        {\printfield[citetitle]{labeltitle}}
        {\printnames{labelname}}%
      \addspace\bibleftbracket
      \usebibmacro{cite:comp}}%
   \savefield{namehash}{\cbx@lasthash}%
   \gdef\cbx@tempa{\bibrightbracket\multicitedelim}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}\bibrightbracket}

\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\DeclareMultiCiteCommand{\cites}[\mkbibbrackets]{\parencite}{\multicitedelim}
\DeclareMultiCiteCommand{\parencites}[\mkbibbrackets]{\parencite}{\multicitedelim}

\endinput