summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/authoryear-icomp-tt/authoryear-icomp-tt.cbx
blob: 7e404a952918fe785a492d98d78f88dc704085c4 (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
% $Id: authoryear-icomp-tt.cbx, v0.1a 2009/07/17 00:04:00 ttitz $

\ProvidesFile{authoryear-icomp-tt.cbx}
[\abx@cbxid $Id: authoryear-icomp-tt.cbx, v0.1a 2009/07/17 00:04:00 ttitz $]

\ExecuteBibliographyOptions{labelyear,uniquename,ibidtracker=constrict,pagetracker,sortcites,autocite=inline}
\providecommand*{\mkibid}[1]{#1}
\newbool{cbx:parens}
\newbool{cbx:loccit}

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

\newbibmacro*{cite:init}{%
  \global\boolfalse{cbx:parens}%
  \global\let\cbx@tempa=\empty
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear
  \global\boolfalse{cbx:loccit}}

\newbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
      {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{year}}
         {\cbx@tempa
          \usebibmacro{cite:label}%
  	\setunit{\addspace}%
	  \usebibmacro{cite:year+labelyear}%
          \usebibmacro{cite:init}}
         {\iffieldequals{namehash}{\cbx@lasthash}
            {\iffieldequals{year}{\cbx@lastyear}
               {\setunit{\addcomma}%
                \usebibmacro{cite:labelyear}}
               {\setunit{\compcitedelim}%
                \usebibmacro{cite:year+labelyear}%
                \savefield{year}{\cbx@lastyear}}}
            {\cbx@tempa
             \printnames{labelname}%
    	   \setunit{\nameyeardelim}%
             \usebibmacro{cite:year+labelyear}%
             \savefield{namehash}{\cbx@lasthash}%
             \savefield{year}{\cbx@lastyear}}}}}
    {\cbx@tempa
     \usebibmacro{cite:shorthand}%
     \usebibmacro{cite:init}}%
  \global\let\cbx@tempa=\multicitedelim}

\newbibmacro*{citeyear}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
      {\iffieldundef{year}
         {\cbx@tempa
          \usebibmacro{cite:label}%
          \usebibmacro{cite:init}}
         {\iffieldequals{namehash}{\cbx@lasthash}
            {\iffieldequals{year}{\cbx@lastyear}
               {\setunit{\addcomma}%
                \usebibmacro{cite:labelyear}}
               {\setunit{\compcitedelim}%
                \usebibmacro{cite:year+labelyear}%
                \savefield{year}{\cbx@lastyear}}}
            {\cbx@tempa
             \usebibmacro{cite:year+labelyear}%
             \savefield{namehash}{\cbx@lasthash}%
             \savefield{year}{\cbx@lastyear}}}}}
    {\cbx@tempa
     \usebibmacro{cite:shorthand}%
     \usebibmacro{cite:init}}%
  \global\let\cbx@tempa=\multicitedelim}

\newbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\iffieldequals{year}{\cbx@lastyear}
          {\setunit{\addcomma}%
           \usebibmacro{cite:labelyear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:year+labelyear}%
           \savefield{year}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\cbx@tempa
     \ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
	   \setunit{%
	     \global\booltrue{cbx:parens}%
	     \addspace\bibleftparen}%
	   \usebibmacro{cite:year+labelyear}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames{labelname}%
	\setunit{%
	  \global\booltrue{cbx:parens}%
	  \addspace\bibleftparen}%
        \iffieldundef{shorthand}
          {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
             {\usebibmacro{cite:ibid}}
            {\iffieldundef{year}
               {\usebibmacro{cite:label}}
               {\usebibmacro{cite:year+labelyear}}%
             \savefield{year}{\cbx@lastyear}}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}%
        \savefield{namehash}{\cbx@lasthash}}}%
  \gdef\cbx@tempa{%
    \ifbool{cbx:parens}
      {\bibrightparen\global\boolfalse{cbx:parens}}
      {}%
    \multicitedelim}}

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

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

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

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

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

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

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

\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{\textcite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\iffieldundef{postnote}
     {\ifbool{cbx:parens}
        {\bibrightparen}
	{}}
     {\ifbool{cbx:parens}
        {\postnotedelim}
	{\addspace\bibleftparen}%
      \printfield{postnote}\bibrightparen}}

\endinput