summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/biblatex/examples/93-nameparts.tex
blob: 46b337c3dd115837afe4bd637b32c95204308b46 (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
\documentclass[a4paper]{article}
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Arial}
\setmonofont{Courier New}
\usepackage[russian]{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{tolstoy,
  author       = {given=Лев, patronymic=Николаевич, family=Толстой},
  title        = {Война и мир},
  date         = {1877}
}
\end{filecontents}
\usepackage[style=authoryear,datamodel=93-nameparts,backend=biber]{biblatex}
\addbibresource[datatype=biblatexml]{biblatex-examples.bltxml}
\addbibresource{\jobname.bib}

% A format using the new name part
\DeclareNameFormat{author}{%
   \usebibmacro{name:delim}{#1}%
   \usebibmacro{name:hook}{#1}%
   \mkbibnamefamily{\namepartfamily}%
   \ifdefvoid\namepartgiven
     {}
     {\revsdnamepunct
      \bibnamedelimd
      \mkbibnamegiven{\namepartgiven}%
      \space
      \mkbibnamepatronymic{\namepartpatronymic}\isdot}
   \usebibmacro{name:andothers}}

% We want to sort names using these name parts in this order
\DeclareSortingNamekeyScheme{
  \keypart{
    \namepart{patronymic}
  }
  \keypart{
    \namepart{family}
  }
  \keypart{
    \namepart{given}
  }
}

\begin{document}
% Historically, name handling in latex bibliographies has been determined by
% the name parsing rules of bibtex. In a modern context, this name handling
% is rather archaic, restricted to Western names with the four parts
% "family", "given", "prefix", "suffix" (often referred to in bibtex
% documentation as "last", "first", "von" and "Jr" parts). When using biber,
% it is possible to define arbitrary name parts since the allowable name
% parts are defined in the data model (see accompanying file 93-nameparts.dbx).

% Here we demonstrate the possibility of adding a new "patronymic" name part to the
% datamodel and then using it in formatting, sorting etc. It requires
% the biblatexml datasource format (see accompanying file biblatex-examples.bltxml)

% Notice that we can use the <patronymic> name part type in the datasource
% which is now allowable due to the enhanced datamodel constant definition.
% We have also defined a new name format and method of sorting names which
% are aware of the new name part.
%
\noindent\textcite{tolstoy}\\
\textcite{bulgakov}

\printbibliography
\end{document}