-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjbib_links.tex
More file actions
119 lines (109 loc) · 3.09 KB
/
jbib_links.tex
File metadata and controls
119 lines (109 loc) · 3.09 KB
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
\usepackage[dvipsnames]{xcolor}
\usepackage[colorlinks]{hyperref}
\usepackage{mathtools} % imports amsmath
\usepackage{cleveref} % must come after importing hyperref and amsmath
\hypersetup{%
linkcolor=BrickRed,%
citecolor=PineGreen,%
filecolor=Mulberry,%
urlcolor=NavyBlue,%
menucolor=BrickRed,%
runcolor=Mulberry,%
linkbordercolor=BrickRed,%
citebordercolor=PineGreen,%
filebordercolor=Mulberry,%
urlbordercolor=NavyBlue,%
menubordercolor=BrickRed,%
runbordercolor=Mulberry%
}
%% make title hyperlink to DOIs, URL or ISBN
%% For use with biblatex
%% FROM https://tex.stackexchange.com/a/48506/19048
%% START %%
\usepackage{biblatex}
% Define new format that applies a hypertext reference
\DeclareFieldFormat{linked}{%
\ifboolexpr{ test {\ifhyperref} and not test {\ifentrytype{online}} }
{\iffieldundef{doi}
{\iffieldundef{url}
{\iffieldundef{isbn}
{\iffieldundef{issn}
{#1}
{\href{\worldcatsearch\thefield{issn}}{#1}}}
{\href{\worldcatsearch\thefield{isbn}}{#1}}}
{\href{\thefieldfirstword{url}}{#1}}}
{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
{#1}}
% URL prefix for WorldCat query
\def\worldcatsearch{http://www.worldcat.org/search?qt=worldcat_org_all&q=}
% Define new command that returns the first word of a given field
\makeatletter
\def\thefieldfirstword#1{%
\expandafter\expandafter%
\expandafter\firstword%
\expandafter\expandafter%
\expandafter{\csname abx@field@#1\endcsname}}
\def\firstword#1{\firstword@i#1 \@nil}
\def\firstword@i#1 #2\@nil{#1}
\makeatother
% Redefine url format to print only first URL, omit URL prefix
\DeclareFieldFormat{url}{\url{\firstword{#1}}}
\renewbibmacro*{title}{% Based on generic definition from biblatex.def
\ifboolexpr{ test {\iffieldundef{title}} and test {\iffieldundef{subtitle}} }
{}
{\printtext[title]{\printtext[linked]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}}%
\newunit}%
\printfield{titleaddon}}
\renewbibmacro*{periodical}{% Based on generic definition from biblatex.def
\iffieldundef{title}
{}
{\printtext[title]{\printtext[linked]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}}}}
\AtEveryCite{\DeclareFieldAlias{linked}{default}}
%% END %%%
%% START %%
% Make a new sorting template to sort by
% name > year > month > day > title
% baesed on nyt from biblatex.def
% from https://tex.stackexchange.com/a/46879/19048
\DeclareSortingTemplate{nymdt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{00}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{00}
}
\sort{
\field{sorttitle}
}
\sort{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{0000}
}
}
%% END %%