Debian Codegraph @

texmf-dist/doc/latex/biblatex-ms/examples/93-nameparts-ms.tex

raw
1 \documentclass[a4paper]{article}
2 \usepackage{fontspec}
3 \usepackage{libertine}
4 \usepackage[fallback]{xeCJK}
5 %\setCJKmainfont{Malgun Gothic}
6 \setCJKmainfont{PingFang TC}% OSX
7
8 \usepackage[english]{babel}
9 \usepackage{csquotes}
10 \begin{filecontents}[force]{\jobname.bib}
11 @book{tolstoy,
12 author = {given=Лев, patronymic=Николаевич, family=Толстой, nametemplates=russian},
13 title = {Война и мир},
14 date = {1877},
15 langid = {russian},
16 }
17 @book{bulgakov,
18 author = {given=Михаил, patronymic=Афанасьевич, family=Булгаков, nametemplates=russian},
19 title = {Мастер и Маргарита},
20 date = {1966},
21 langid = {russian},
22 }
23 @book{bulgakov:val,
24 author = {given=Валентин, patronymic=Фёдорович, family=Булгаков, nametemplates=russian},
25 title = {Л. Н. Толстой в последний год его жизни},
26 date = {1911},
27 langid = {russian},
28 }
29
30 @book{dosto:1,
31 author = {given=Александр , patronymic=Андреевич, family=Достоевский, nametemplates=russian},
32 title = {О строении телец Грандри},
33 date = {1885},
34 langid = {russian},
35 }
36 @book{dosto:2,
37 author = {given=Андрей , patronymic=Андреевич, family=Достоевский, nametemplates=russian},
38 title = {П. П. Семенов-Тян-Шанский как исследователь, географ и статистик},
39 date = {1914},
40 langid = {russian},
41 }
42
43 @book{demeke,
44 author = {given=Kebede, patronymic=Daniel, papponymic=Demeke, nametemplates=ethiopian},
45 title = {One},
46 date = {1983}
47 }
48 @book{dameke,
49 author = {given=Kebede, patronymic=Daniel, papponymic=Dameke, nametemplates=ethiopian},
50 title = {Two},
51 date = {1983}
52 }
53 @book{james,
54 author = {given=Kebede, patronymic=James, papponymic=Demeke, nametemplates=ethiopian},
55 title = {Three},
56 date = {1983}
57 }
58 @book{jonathan,
59 author = {given=Kebede, patronymic=Jonathan, papponymic=Kebede, nametemplates=ethiopian},
60 title = {Four},
61 date = {1986}
62 }
63 @book{william,
64 author = {given=Kebede, patronymic=William, papponymic=Kebede, nametemplates=ethiopian},
65 title = {Four},
66 date = {1987}
67 }
68
69 @book{zhangx1,
70 title = {Shuming},
71 titleaddon = {書名},
72 author = {family=Zhang, cjk=章學成, given=Xuecheng, nametemplates=cjk},
73 location = {Beijing},
74 publisher = {Zhonghua Shuju},
75 date = {2017},
76 }
77 @book{zhangx2,
78 title = {Shuming er},
79 titleaddon = {書名二},
80 author = {family=Zhang, cjk=張學成, given=Xuecheng, nametemplates=cjk},
81 location = {Shanghai},
82 publisher = {Shangwu Yinshuguan},
83 date = {2016},
84 }
85
86 @book{bronte:c,
87 author = {Charlotte Brontë},
88 date = {1847},
89 title = {Jane Eyre},
90 }
91 @book{bronte:e,
92 author = {Emily Brontë},
93 date = {1847},
94 title = {Wuthering Heights},
95 }
96
97 @book{austen:jane,
98 author = {Jane Austen},
99 date = {1813},
100 title = {Pride and Prejudice},
101 }
102 @collection{austen:john,
103 editor = {John Austen},
104 editortype = {compiler},
105 date = {1924},
106 title = {Rogues in Porcelain: A Miscellany of 18th Poems},
107 }
108 \end{filecontents}
109 \usepackage[style=authoryear,datamodel=93-nameparts,backend=biber, autolang=hyphen]{biblatex-ms}
110 \addbibresource{biblatex-examples.bib}
111 \addbibresource{\jobname.bib}
112
113
114 % Use transliteration to sort Cyrillic among Latin script
115 \DeclareSortTranslit{
116 \translit[russian]{*}{russian}{bgn/pcgn-standard}
117 }
118
119 \makeatletter
120 %% CJK names
121 % the idea is to sort family -> given -> cjk (full name)
122 % and disambiguate in the same manner using only full
123 % forms of the name, no initials
124 % the order should always be family -> given -> cjk
125 % names are not reversed
126 \DeclareSortingNamekeyTemplate[cjk]{
127 \keypart{
128 \namepart{family}
129 }
130 \keypart{
131 \namepart{given}
132 }
133 \keypart{
134 \namepart{cjk}
135 }
136 }
137
138 \DeclareUniquenameTemplate[cjk]{
139 \namepart[base=true]{family}
140 \namepart[disambiguation=full]{given}
141 \namepart[disambiguation=full]{cjk}
142 }
143
144 \newbibmacro*{name:cjk}[3]{%
145 \usebibmacro{name:delim}{#2#3#1}%
146 \usebibmacro{name:hook}{#2#3#1}%
147 \mkbibnamefamily{#1}%
148 \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}%
149 \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnamecjk{#3}}}
150
151 %% Ethiopian names
152 % Ethiopian names are given -> patronymic -> papponymic
153 % the latter two are only needed for disambiguation
154 % names order is never reversed
155 \DeclareSortingNamekeyTemplate[ethiopian]{
156 \keypart{
157 \namepart{given}
158 }
159 \keypart{
160 \namepart{patronymic}
161 }
162 \keypart{
163 \namepart{papponymic}
164 }
165 }
166
167 \DeclareUniquenameTemplate[ethiopian]{
168 \namepart[base=true]{given}
169 \namepart[disambiguation=full]{patronymic}
170 \namepart[disambiguation=full]{papponymic}
171 }
172
173 \newbibmacro*{name:ethiopian}[3]{%
174 \usebibmacro{name:delim}{#1#2#3}%
175 \usebibmacro{name:hook}{#1#2#3}%
176 \mkbibethgiven{#1}%
177 \ifdefvoid{#2}{}{\bibnamedelimd\mkbibethpat{#2}\isdot}%
178 \ifdefvoid{#3}{}{\bibnamedelimd\mkbibethpap{#3}\isdot}}
179
180 \let\mkbibethgiven\mkbibnamefamily
181 \let\mkbibethpat\mkbibnamegiven
182 \let\mkbibethpap\mkbibnamegiven
183
184 %% Russian names
185 % family -> given -> patronymic
186 % we never show the given name alone, it is always accompanied
187 % by the patronymic
188 % (patronymic could just be treated as another given name)
189 % reversed name order is 'family, given patronymic'
190 \DeclareSortingNamekeyTemplate[russian]{
191 \keypart{
192 \namepart{family}
193 }
194 \keypart{
195 \namepart{given}
196 }
197 \keypart{
198 \namepart{patronymic}
199 }
200 }
201
202 \DeclareUniquenameTemplate[russian]{
203 \namepart[base=true]{family}
204 \namepart{given}
205 \namepart{patronymic}
206 }
207
208 \newbibmacro*{name:russian}[3]{%
209 \usebibmacro{name:delim}{#1#2#3}%
210 \usebibmacro{name:hook}{#1#2#3}%
211 \ifdefvoid{#2}
212 {}
213 {\mkbibnamegiven{#2}\isdot\bibnamedelimd
214 \ifdefvoid{#3}
215 {}
216 {\mkbibnamepatronymic{#3}\isdot\bibnamedelimd}}%
217 \mkbibnamefamily{#1}}
218
219 \newbibmacro*{name:russian-rev}[3]{%
220 \usebibmacro{name:delim}{#1#2#3}%
221 \usebibmacro{name:hook}{#1#2#3}%
222 \mkbibnamefamily{#1}%
223 \ifdefvoid{#2}
224 {}
225 {\revsdnamepunct\bibnamedelimd
226 \mkbibnamegiven{#2}\isdot
227 \ifdefvoid{#3}
228 {}
229 {\bibnamedelimd\mkbibnamepatronymic{#3}\isdot}}}
230
231 %% sortname
232 % helper to select the sorting template in \ifcase
233 \newcommand*{\abx@sortingnamekeytemplate}{0}
234 \newcommand*{\abx@getsortingnamekeytemplate}{%
235 \ifsortingnamekeytemplatename{cjk}
236 {\def\abx@sortingnamekeytemplate{1}}
237 {\ifsortingnamekeytemplatename{ethiopian}
238 {\def\abx@sortingnamekeytemplate{2}}
239 {\ifsortingnamekeytemplatename{russian}
240 {\def\abx@sortingnamekeytemplate{3}}
241 {}}}}
242
243 % show fullest version of names,
244 % reverse Russian and western names for sorting
245 % all other names are always in the correct order for sorting
246 \DeclareNameFormat{sortname}{%
247 \abx@getsortingnamekeytemplate
248 \ifcase\abx@sortingnamekeytemplate\relax
249 \usebibmacro{name:family-given}
250 {\namepartfamily}
251 {\namepartgiven}
252 {\namepartprefix}
253 {\namepartsuffix}%
254 \or
255 \usebibmacro{name:cjk}
256 {\namepartfamily}
257 {\namepartgiven}
258 {\namepartcjk}%
259 \or
260 \usebibmacro{name:ethiopian}
261 {\namepartgiven}
262 {\namepartpatronymic}
263 {\namepartpapponymic}%
264 \or
265 \usebibmacro{name:russian-rev}
266 {\namepartfamily}
267 {\namepartgiven}
268 {\namepartpatronymic}%
269 \fi
270 \usebibmacro{name:andothers}}
271
272 %% labelname
273 % copy of the standard definition in biblatex.def
274 % uses the 'old way' of finding the disambiguating name part
275 \newbibmacro{labelname:western}{%
276 \ifcase\value{uniquename}%
277 \usebibmacro{name:family}
278 {\namepartfamily}
279 {\namepartgiven}
280 {\namepartprefix}
281 {\namepartsuffix}%
282 \or
283 \ifuseprefix
284 {\usebibmacro{name:given-family}
285 {\namepartfamily}
286 {\namepartgiveni}
287 {\namepartprefix}
288 {\namepartsuffixi}}
289 {\usebibmacro{name:given-family}
290 {\namepartfamily}
291 {\namepartgiveni}
292 {\namepartprefixi}
293 {\namepartsuffixi}}%
294 \or
295 \usebibmacro{name:given-family}
296 {\namepartfamily}
297 {\namepartgiven}
298 {\namepartprefix}
299 {\namepartsuffix}%
300 \fi
301 \usebibmacro{name:andothers}}
302
303 % Uses \iffieldequalstr{uniquepart} to find the disambiguating
304 % name part.
305 % If neither base (i.e. family) nor given name are enough,
306 % go with the full name.
307 % Uses \empty for suppressed name parts, so we don't have to define
308 % dedicated macros for the shorter name forms.
309 \newbibmacro{labelname:cjk}{%
310 \iffieldequalstr{uniquepart}{base}%
311 {\usebibmacro{name:cjk}
312 {\namepartfamily}
313 {\empty}
314 {\empty}}
315 {\iffieldequalstr{uniquepart}{given}%
316 {\usebibmacro{name:cjk}
317 {\namepartfamily}
318 {\namepartgiven}
319 {\empty}}
320 {\usebibmacro{name:cjk}
321 {\namepartfamily}
322 {\namepartgiven}
323 {\namepartcjk}}}}
324
325 % similar to the CJK format
326 \newbibmacro{labelname:ethiopian}{%
327 \iffieldequalstr{uniquepart}{base}%
328 {\usebibmacro{name:ethiopian}
329 {\namepartgiven}
330 {\empty}
331 {\empty}}
332 {\iffieldequalstr{uniquepart}{patronymic}%
333 {\usebibmacro{name:ethiopian}
334 {\namepartgiven}
335 {\namepartpatronymic}
336 {\empty}}
337 {\usebibmacro{name:ethiopian}
338 {\namepartgiven}
339 {\namepartpatronymic}
340 {\namepartpapponymic}}}}
341
342 % Uses \iffieldequalstr{uniquepart} to get the disambiguating
343 % name part.
344 % We only choose between 'Given Patronymic Family' and
345 % 'G. P. Family', the decision whether or not to use
346 % initials is for the given name to decide.
347 % If the given initial is enough to disambiguate the name,
348 % the given name and patronymic become initials.
349 % Even if the initial of the patronymic would make the name
350 % unique we go with the full name instead.
351 % There is no 'Given P. Family' format.
352 % \namepart<>un=1 says initials are enough
353 % 2 means the full name is required
354 % 0 means not used
355 \newbibmacro{labelname:russian}{%
356 \iffieldequalstr{uniquepart}{base}%
357 {\usebibmacro{name:russian}
358 {\namepartfamily}
359 {\empty}
360 {\empty}}
361 {\ifnum\namepartgivenun=1\relax
362 \usebibmacro{name:russian}
363 {\namepartfamily}
364 {\namepartgiveni}
365 {\namepartpatronymici}%
366 \else
367 \usebibmacro{name:russian}
368 {\namepartfamily}
369 {\namepartgiven}
370 {\namepartpatronymic}%
371 \fi}}
372
373 % helper to select the uniquename template in \ifcase
374 \newcommand*{\abx@uniquenametemplatename}{0}
375 \newcommand*{\abx@getuniquenametemplatename}{%
376 \ifuniquenametemplatename{cjk}
377 {\def\abx@uniquenametemplatename{1}}
378 {\ifuniquenametemplatename{ethiopian}
379 {\def\abx@uniquenametemplatename{2}}
380 {\ifuniquenametemplatename{russian}
381 {\def\abx@uniquenametemplatename{3}}
382 {}}}}
383
384 \DeclareNameFormat{labelname}{%
385 \abx@getuniquenametemplatename
386 \ifcase\abx@uniquenametemplatename\relax
387 \usebibmacro{labelname:western}%
388 \or
389 \usebibmacro{labelname:cjk}%
390 \or
391 \usebibmacro{labelname:ethiopian}%
392 \or
393 \usebibmacro{labelname:russian}%
394 \fi
395 \usebibmacro{name:andothers}}
396 \makeatother
397
398 \begin{document}
399 % Historically, name handling in latex bibliographies has been determined by
400 % the name parsing rules of bibtex. In a modern context, this name handling
401 % is rather archaic, restricted to Western names with the four parts
402 % "family", "given", "prefix", "suffix" (often referred to in bibtex
403 % documentation as "last", "first", "von" and "Jr" parts). When using biber,
404 % it is possible to define arbitrary name parts since the allowable name
405 % parts are defined in the data model (see accompanying file 93-nameparts.dbx).
406
407 % Here we demonstrate the possibility of adding a new name parts to the
408 % datamodel and then using it in formatting, sorting etc.
409 % Notice that we can use the new name part types in the datasource
410 % which is now allowable due to the enhanced datamodel constant definition.
411 % We have also defined a new name format and method of sorting names which
412 % are aware of the new name parts.
413 %
414 \textcite{tolstoy,bulgakov,bulgakov:val}
415
416 \textcite{dosto:1}
417
418 \textcite{dosto:2}
419
420 \textcite{demeke,dameke,james,jonathan,william}
421
422 \textcite{sigfridsson,worman,geer,knuth:ct:a,cicero,companion,vangennep}
423
424 \textcite{bronte:c,bronte:e,austen:jane,austen:john}
425
426 \textcite{zhangx1,zhangx2}
427
428 \printbibliography
429 \end{document}