summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.bbx
blob: a20c39a86ea179466a1a139d2864b28d4a751f5f (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
% Copyright (c) 2020 Agnibho Mondal
% All rights reserved
%
% This file is part of BibLaTex Vancouver.
%
% BibLaTex Vancouver is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your option) any
% later version.
%
% BibLaTex Vancouver is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public License along with
% BibLaTex Vancouver.  If not, see <http://www.gnu.org/licenses/>.
%
% Agnibho Mondal
% contact@agnibho.com
% www.agnibho.com

\ProvidesFile{vancouver.bbx}[2020/05/20 v0.1 biblatex vancouver]

\RequireBiber[2]
\RequireBibliographyStyle{numeric}

\RequirePackage{ifthen}

% Set default bibliography options
\ExecuteBibliographyOptions{
	sorting=none,
	giveninits=true,
	terseinits=true,
	isbn=false,
	maxbibnames=99
}

% Remove unwanted punctuations
\renewcommand*{\revsdnamepunct}{}
\renewcommand*{\finentrypunct}{}
\renewcommand*{\bibpagespunct}{}

% Remove 'in:' string
\renewbibmacro{in:}{}

% Provide three letter month names
\newcommand*{\shortmonth}[1]{
	\ifthenelse{\NOT\equal{#1}{}}{
		\ifcase#1\relax
		\or Jan
		\or Feb
		\or Mar
		\or Apr
		\or May
		\or Jun
		\or Jul
		\or Aug
		\or Sep
		\or Oct
		\or Nov
		\or Dec
		\fi
	}
}

% Family name first
\DeclareNameAlias{default}{family-given}

% Remove unwanted formatting
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat*{journaltitle}{#1}
\DeclareFieldFormat*{labelnumberwidth}{#1\adddot}
\DeclareFieldFormat*{pages}{:\mkcomprange{#1}}
\DeclareFieldFormat*{url}{Available from: \url{#1}}
\DeclareFieldFormat*[article]{issue}{(#1)}
\DeclareFieldFormat*{date}{
	\thefield{year}%
	\shortmonth{\thefield{month}}\addspace
	\thefield{day}\isdot
}
\DeclareFieldFormat*{urldate}{
	{[}Accessed on:
		\thefield{urlyear}%
		\shortmonth{\thefield{urlmonth}}\addspace
	\thefield{urlday}{]}
}

% Some string replacements
\DeclareSourcemap{
	\maps[datatype=bibtex]{
		\map[overwrite=true]{
			\step[fieldsource=journaltitle, match=\regexp{(\.)}, replace={}]
			\step[fieldsource=journaltitle, match=\regexp{($)}, replace={.}]
		}
	}
}

% Code adapted from biblatex-nejm package

\renewbibmacro*{volume+number+eid}{
	\printfield{volume}%
	\printfield{issue}%
	\printfield{eid}%
}

%Order year;volume:page
\renewbibmacro*{issue+date}{
	\setunit*{\addspace}%
	\usebibmacro{date}%
	\newunit%
}

\renewbibmacro*{journal+issuetitle}{
	\usebibmacro{journal}%
	\iffieldundef{series}
	{}
	{\newunit
	\printfield{series}}%
	\setunit*{\addspace}%
	\usebibmacro{issue+date}%
	\setunit*{\addsemicolon\addspace}%
	\usebibmacro{volume+number+eid}%
	\usebibmacro{issue}%
\newunit}