summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-iso690/iso-authoryear.bbx
blob: 49629ce0ebf38bc1e9b47338c3e278f72c86e1e3 (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
\ProvidesFile{iso-authoryear.bbx}[2016/05/13 v0.3.1 biblatex bibliography style]

\RequireBibliographyStyle{iso}
\ExecuteBibliographyOptions{%
  sorting=nyt
}

\def\printextrayear{%
  \ifentrytype{patent}
    {}
    {\printfield{year}\printfield{extrayear}}%
}

% remove second appearance of year in a reference
\renewbibmacro*{date}{}%

% overwrite names:primary to print year right after
% 1) author
% 2) editor
% 3) label/title
% need to handle not to print editor twice (primary
% and subsidiary names)
\renewbibmacro*{names:primary}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{author}}%
    {\usebibmacro{editor}}%
  \setunit{\addspace}\printfield{nameaddon}%
  \setunit{\addcomma\space}\printextrayear%
}

\InitializeBibliographyStyle{\global\undef\bbx@lasthash}

\newbibmacro*{bbx:savehash}{%
  \savefield{fullhash}{\bbx@lasthash}}

\newbool{bbx@inset}
\DeclareBibliographyDriver{set}{%
  \booltrue{bbx@inset}%
  \entryset{}{}%
  \newunit\newblock
  \usebibmacro{setpageref}%
  \finentry}

\renewbibmacro*{editor}{%
  \usebibmacro{bbx:editor}{editorstrg}}
\newbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \printnames{editor}%
        \addspace%
        \mkbibparens{\usebibmacro{#1}}}%
     \clearname{editor}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}}}%

\newbibmacro*{bbx:dashcheck}[2]{%
  \ifboolexpr{
    test {\iffieldequals{fullhash}{\bbx@lasthash}}
    and
    not test \iffirstonpage
    and
    (
       not bool {bbx@inset}
       or
       test {\iffieldequalstr{entrysetcount}{1}}
    )
  }
    {#1}
    {#2}}

\newbibmacro*{labeltitle}{%
  \iffieldundef{label}
    {\iffieldundef{shorttitle}
       {\usebibmacro{titles}{}{emph}%
        \clearfield{title}%
        \clearfield{subtitle}%
        \clearfield{titleaddon}}
       {\printfield{shorttitle}}}
    {\printfield{label}}}

\endinput