summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-enc/enc.cbx
blob: 4bd759c362d2ac5ab20b5c3f14e170cae4af4616 (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
  %% biblatex-enc v.1.0 (17/06/2017)
  %% enc.cbx
  %% Copyright 2014 J.B. Camps (jbcamps@hotmail.com)
  %
  % This work may be distributed and/or modified under the conditions
  % of the LaTeX Project Public License, either version 1.3 of this 
  % license or (at your option) any later version.
  % The latest version of this license is in
  %   http://www.latex-project.org/lppl.txt
  % and version 1.3 or later is part of all distributions of LaTeX
  % version 2005/12/01 or later.
  %
  % This work has the LPPL maintenance status `maintained'.
  % 
  % The Current Maintainer of this work is J.B. Camps (jbcamps <at> hotmail.com).
  %
  % This work consists of the files enc.cbx and enc.BBX.

\ProvidesFile{enc.cbx}[]

\DeclareBibliographyOption{postnote}{%
  \ifcsdef{hz@opt@postnote@#1}
    {\csuse{hz@opt@postnote@#1}}
    {\PackageError{historische-zeitschrift}
       {Invalid option 'postnote=#1'\MessageBreak
        Valid values are 'afterparen', 'inparen'}}}

\def\hz@opt@postnote@afterparen{%
  \renewbibmacro*{postnote}{%
    %\ifbool{cbx@seenote}
      %{\iffieldundef{postnote}
        %{\printtext{\bibrightparen}}
        %{\printtext{\bibrightparen}%
         %\postnotedelim
         %\printfield{postnote}}}
      {\iffieldundef{postnote}
        {}
        {\postnotedelim
         \printfield{postnote}}}}}

\def\hz@opt@postnote@inparen{%
  \renewbibmacro*{postnote}{%
    \ifbool{cbx@seenote}
      {\iffieldundef{postnote}
        {\printtext{\bibrightparen}}
        {\postnotedelim
         \printfield{postnote}%
         \printtext{\bibrightparen}}}
      {\iffieldundef{postnote}
        {}
        {\postnotedelim
         \printfield{postnote}}}}}

\ExecuteBibliographyOptions{
  citetracker=context,
  ibidtracker=context, %changement de constrict (qui en plus de strict, n'utilise ibid que dans des notes immédiatement consécutives) à strict. Voir si on veut le garder. 20/05/2016: changement ultérieur de strict (qui n'utilise pas ibid lorsque la référence précédente consiste en une série de références) à context
  loccittracker=true, %j'ajoute celui-ci pour, lorsque deux ibid. se suivent, ne préciser les pages que quand elles différent
  idemtracker=true,
  singletitle=false,%
  pagetracker=true,
  autocite=footnote,
  postnote=afterparen,
  uniquename=true
}

\providecommand*{\mkibid}[1]{#1}
\newbool{cbx@loccit}
% to check if a 'see note' phrase is in use:
\newbool{cbx@seenote}

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Macro pour l'itération du nom d'auteur
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Option 'nameseen'
\newcommand*{\cbx@seennames}{}
\newrobustcmd*{\cbx@nameseen}[1]{%
  \listcsxadd{cbx@seennames}{#1}}
\newrobustcmd*{\cbx@ifnameseen}[1]{%
  \xifinlistcs{#1}{cbx@seennames}}


\DeclareNameFormat{citeauthor}{%
  \cbx@ifnameseen{\thefield{hash}}
    {}
    {\setcounter{uniquename}{2}%
     \cbx@nameseen{\thefield{hash}}}%
  \ifcase\value{uniquename}%
    \usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}%
  \or
    \ifuseprefix
      {\usebibmacro{name:given-family}
        {\namepartfamily}
        {\namepartgiveni}
        {\namepartprefix}
        {\namepartsuffixi}}
      {\usebibmacro{name:given-family}
        {\namepartfamily}
        {\namepartgiveni}
        {\namepartprefixi}
        {\namepartsuffixi}}%
  \or
    \usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}%
  \fi
  \usebibmacro{name:andothers}}

%%%%% %%%%% %%%%% %%%%% %%%%% 
%%%%% Reformatting      %%%%% 
%%%%% %%%%% %%%%% %%%%% %%%%% 

%\DeclareFieldFormat{citeauthor}{#3\addspace #1}
\DeclareFieldFormat{citetitle}{#1}
\DeclareFieldFormat[article]{citetitle}{#1}
\DeclareFieldFormat[inbook]{citetitle}{#1}
\DeclareFieldFormat[incollection]{citetitle}{#1}
\DeclareFieldFormat[inproceedings]{citetitle}{#1}
\DeclareFieldFormat[patent]{citetitle}{#1}
\DeclareFieldFormat[thesis]{citetitle}{#1}
\DeclareFieldFormat[unpublished]{citetitle}{#1}

%%%%% Les titres courts. 
%Le seul problème avec l'usage des \dots est que biblatex les considère bien comme des points (abréviatifs, si on précise \isdot), et élimine la ponctuation finale, si rien ne suit, et même s'ils figurent dans les guillemets. Cela n'est gênant que pour les titres abrégés d'article, actes, ... entre guillemets, qui sont bels et bien abrégés (pour lesquels les  points de suspensions se trouvent bien dans les guillemets): pour ce cas limite, il faut préciser au /punctuation tracker/ de BibLaTex que la phrase n'est pas finie, avec \midsentence.
%En outre, il faut ajouter un test pour voir si labeltitle est égal à title, et, dans ce cas, mettre les points à l'extérieur des guillemets pour les articles & co. (fait infra dans la macro footcite:note).
%There is a particularly annoying difference here between pdflatex and xelatex: with pdflatex, \dots are considered a dot, with XeLaTeX, not. So, we need \midsentence with pdflatex to be correct, but, on the other hand, we get an extra dot with xelatex..

%Fix for fontspec suggested by moewe on Stackexchange, http://tex.stackexchange.com/questions/340478/biblatex-equivalent-to-adddot-or-isdot-for-ellipsis/340612?noredirect=1#340612

\protected\def\blx@imc@forceisdot{\spacefactor\blx@sf@dot}
\blx@regimcs{\forceisdot}


\DeclareFieldFormat{shorttitle}{\textit{#1}\printtext{\dots\forceisdot}}
\DeclareFieldFormat[article]{shorttitle}{\mkbibquote{#1\printtext{\dots}\forceisdot}\midsentence}
\DeclareFieldFormat[inbook]{shorttitle}{\mkbibquote{#1\printtext{\dots}\forceisdot}\midsentence}
\DeclareFieldFormat[incollection]{shorttitle}{\mkbibquote{#1\printtext{\dots}\forceisdot}\midsentence}
\DeclareFieldFormat[inproceedings]{shorttitle}{\mkbibquote{#1\printtext{\dots}\forceisdot}\midsentence}
\DeclareFieldFormat[patent]{shorttitle}{\textit{#1}\printtext{\dots}\forceisdot}
\DeclareFieldFormat[thesis]{shorttitle}{\textit{#1}\printtext{\dots}\forceisdot}
\DeclareFieldFormat[unpublished]{shorttitle}{\textit{#1}\printtext{\dots}\forceisdot}

\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}


%%%%% %%%%% %%%%% %%%%% %%%%% 
%%%%% Cite bibmacros    %%%%%
%%%%% %%%%% %%%%% %%%%% %%%%% 

\newbibmacro*{cite}{%
  \global\boolfalse{cbx@seenote}% 
  \iffieldundef{shorthand}
    {\usedriver
       {\DeclareNameAlias{sortname}{default}}
       {\thefield{entrytype}}}
    {\printfield{shorthand}}}	% 

\newbibmacro*{footcite}{%
  \global\boolfalse{cbx@loccit}%
  \global\boolfalse{cbx@seenote}% 
  \ifciteseen
    {\iffieldundef{shorthand}
       {\ifthenelse{\ifciteibid} %\AND\NOT\iffirstonpage} Je retire ce test, pour avoir des ibid. même en référence à une page précédente. À voir
          {\usebibmacro{footcite:ibid}}
          {\usebibmacro{footcite:note}}}
       {\usebibmacro{footcite:shorthand}}}
    {\usebibmacro{footcite:full}%
     \usebibmacro{footcite:save}}}


\newbibmacro*{footcite:save}{%
  \ifundef\@thefnmark
    {\ifundef\@theenmark % endnotes.sty
       {\csgdef{cbx@note@\thefield{entrykey}}{%
          \BibliographyWarning{Missing footnote mark}\textbf{??}}}
       {\global\cslet{cbx@note@\thefield{entrykey}}\@theenmark}}
    {\global\cslet{cbx@note@\thefield{entrykey}}\@thefnmark}%
  \csxdef{cbx@first@\thefield{entrykey}}{\the\value{instcount}}}

\newbibmacro*{footcite:full}{%
  \printtext{%
    \bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{%
      \usedriver % appelle le driver du fichier .bbx, cf. doc. p. 190...
	{\DeclareNameAlias{sortname}{default}}
	{cite:\thefield{entrytype}}}}%
  \usebibmacro{shorthandintro}}

\newbibmacro*{footcite:note}{%
  \global\booltrue{cbx@seenote}%
  \ifnameundef{labelname}%
    {\printfield{label}}%
    {\usebibmacro{author-shortnote}}%
  \ifsingletitle%Expands to true if there is only one work by the labelname name in the bibliography,
    {}%
    {\setunit*{\addcomma\space}%
    \iffieldundef{shorttitle}%
    {\printfield[title]{labeltitle}%
     \printtext{\dots}\forceisdot}%
    {%
     \iffieldsequal{title}{shorttitle}{%
       \printfield[title]{labeltitle}%
       \printtext{\dots\forceisdot}% 
     }{%
       \printfield[shorttitle]{labeltitle}% 
      }%
    }%
  }%
}

\newbibmacro*{footcite:ibid}{%
  \printtext{%
    \bibhyperlink{\thefield{entrykey}:%
                  \@nameuse{cbx@first@\thefield{entrykey}}}{%
      \bibstring[\mkibid]{ibidem}}}%
  \ifloccit
    {\global\booltrue{cbx@loccit}}
    {}}
    
\newbibmacro*{footcite:shorthand}{%
  \printtext{%
    \bibhyperlink{\thefield{entrykey}:%
                  \@nameuse{cbx@first@\thefield{entrykey}}}{%
      \printfield{shorthand}}}}

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

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \iffootnote
     {\usebibmacro{footcite}}
     {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}
  
\DeclareCiteCommand{\textcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
  {\usebibmacro{footcite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \iffootnote
     {\usebibmacro{footcite}}
     {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\bibsentence
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\endinput