summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex/doc/examples/97-annotations.tex
blob: 03be50f142cd6f35e29a6ba8ebd07d2014178463 (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
%
% This file demonstrates the data annotation feature
%
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@MISC{ann1,
  AUTHOR           = {Last1, First1 and Last2, First2 and Last3, First3},
  AUTHOR+an        = {1:family=student;2=corresponding},
  TITLE            = {The Title},
  TITLE+an:default = {=titleannotation},
  TITLE+an:french  = {="Le titre"},
  TITLE+an:german  = {="Der Titel"}
}
\end{filecontents}
\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{corresponding}
    {\textbf{#1}}
    {#1}%
  \ifpartannotation{family}{student}
    {\textsuperscript{*}}
    {}}

% Default for numeric style so we are overriding the active format for titles
\DeclareFieldFormat{titlecase}{
  \iffieldannotation{titleannotation}{\textsc{#1}}{#1}%
  \hasfieldannotation[][french]{\mkbibparens{\getfieldannotation[][french]}}{}%
  \hasfieldannotation[][german]{\mkbibparens{\getfieldannotation[][german]}}{}}

\begin{document}
The annotation feature allows the user to attache metadata, either in the
form of strings to be tested for in formatting commands, or in the form of
strings to be printed as-is. This example demonstrates all aspects of the
annotation feature:

\begin{itemize}
\item Metadata attaching to fields, items in a list or parts of an item in
  a list (e.g. name parts)
\item Literal annotations where the annotation is a string to be printed
  rather than used as a metadata test for other formatting.
\item Multiple named annotations for the same data field.
\item The ``default'' name for annotations with no explicit name.
\end{itemize}

\cite{ann1}
\printbibliography
\end{document}