-
Notifications
You must be signed in to change notification settings - Fork 1
/
sorting.tex
267 lines (243 loc) · 11 KB
/
sorting.tex
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
%\chapter{Sorting}
\chapter{排序}\label{ch:sorting}
\indexstart{sorting!general}
A bibliography style will usually define a sorting scheme which is
appropriate for that style. For instance, consider the following works:
\medskip
\colorbox{red!40}%
{Smith, J. (2000) Zoology for the Amateur. Oxbridge: Pubco.}\\
\colorbox{green!40}%
{Smith, J. (1999) Professional Zoology. Yarvard: Aldus.}\\
\colorbox{blue!40}%
{Smith, J. (2010) Amateur Zoology. Camford: Otherco.}
\medskip
In an author/year system, it would make sense to put the works in that
order. On the other hand, in an author/title system, it would probably
make sense to list them as
\medskip
\colorbox{blue!40}%
{Smith, J. \emph{Amateur Zoology}. Camford: Otherco 2010.}\\
\colorbox{green!40}%
{Smith, J. \emph{Professional Zoology}. Yarvard: Aldus 1999.}\\
\colorbox{red!40}%
{Smith, J. \emph{Zoology for the Amateur}. Oxbridge: Pubco 2000.}
\medskip
In an alphanumeric system, the correct order will normally be one
that make sense of the labels.
\medskip
\colorbox{red!40}
{{[}Smi00{]} Smith J. \emph{Zoology for the Amateur} \ldots{}}\\
\colorbox{blue!40}
{{[}Smi10{]} Smith J. \emph{Amateur Zoology} \ldots{}}\\
\colorbox{green!40}
{{[}Smi99{]} Smith J. \emph{Professional Zoology} \ldots{}}
\medskip
A numeric system may either sort its bibliography in some way (usually
along the lines of the author/title system) or print the bibliography in
the order of citation in the text -- a system that is conveniently and
inaccurately described as involving an \emph{unsorted} bibliography, and
which one achieves by loading \biblatex\ with the option
\texttt{sorting=none}.
\biblatex\ allows for a wide variety of sorting schemes, and there is
considerable flexibility to define new schemes. But that largely lies
outside the scope of this book, which is aimed at the ordinary user. So
what we are going to do is to describe the common schemes, explain how
you can make simple and reasonable changes to them, and pay a bit of
attention to some special fields in the \texttt{.bib} file that can be
used to influence sorting.
\indexstop{sorting!general}
%\section{The built-in schemes}
\section{biblatex 提供的排序格式}
\indexstart{sorting!predefined schemes}
The following are the basic schemes,\manref{\S\S\ 3.1.2.1, 3.5} and a
basic definition of what they are intended to achieve. (Note that
individual bibliography styles may produce their own schemes.)
\begin{itemize}
\item
\emph{Unsorted.} (\texttt{sorting=none}) --- a misnomer, really, in so far as
it suggests that the bibliography might appear in some sort of random
order. The bibliography will be printed in the order the works are
first cited in the text.\index{sorting!citation order}\index{sorting!none}
\item
\emph{Name/Title/Year} (\texttt{sorting=nty}). Works are first sorted by the
name of the author (or editor), so all works by Albert Aardvark appear
before anything written by Benjamin Badger. Within each name, the
works are sorted by title. And if titles are identical, then the
earlier in time is placed first.\index{sorting!name/title/year}
\begin{marginfigure}[-20ex]
\fbox{
\begin{minipage}{0.95\marginparwidth}
\colorbox{red!50}{\strut Aardvark, A.} My life. 1999.\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!60}{\strut Memoirs.}%
\colorbox{blue!50}{\strut 2005.}\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!60}{\strut Memoirs}(2nd ed).%
\colorbox{blue!30}{\strut 2010.}\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!40}{\strut Memories.} 1999.\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!30}{\strut Recollection.} 2005.
\end{minipage}}
\vspace{3pt}
\caption{\texttt{nty} sorting}
\end{marginfigure}
\item \emph{Name/Year/Title} (\texttt{sorting=nyt} or \texttt{sorting=nyvt}).
Works are first sorted by the name of the author (or editor), so
that all works by Albert Aardvark appear before anything written by
Benjamin Badger. Within each name, the works are sorted first by
year and then, if there is more than one work in any given year,
alphabetically by title. Name/Year/Volume/Title
(\texttt{sorting=nyvt}) is the same as Name/Year/Title, except that
the volume is considered before title.\index{sorting!name/year/title}
\begin{marginfigure}[-15ex]
\fbox{
\begin{minipage}{0.95\marginparwidth}
\colorbox{red!50}{\strut Aardvark, A.} (1999) My life.\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!60}{\strut(1999)} Memories.\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!40}{\strut(2005)}%
\colorbox{blue!50}{Memoirs.}\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!40}{\strut(2005)}%
\colorbox{blue!30}{Recollection.}\\
%
\colorbox{red!30}{\strut Badger, B.}%
\colorbox{green!20}{\strut(2010)} Memoirs (2nd ed)
\end{minipage}}
\vspace{3pt}
\caption{\texttt{nyt} sorting}
\end{marginfigure}
\item
\emph{Year/Name/Title} (\texttt{sorting=ynt} or \texttt{sorting=ydnt}). Sorts
by the year first, then the name, then the title (can be useful for
producing a chronologically organized bibliography). The difference
between \texttt{ynt} and \texttt{ydng} is that \texttt{ynt} works
upwards (2013 comes after 2000), whereas \texttt{ydnt} works downwards
(2000 comes after 2013).\index{sorting!year/name/title}
\begin{marginfigure}[1ex]
\fbox{
\begin{minipage}{0.95\marginparwidth}
\colorbox{red!50}{\strut 1999.}%
\colorbox{green!50}{\strut Aardvark, A.}My Life.\\
%
\colorbox{red!50}{\strut1999.}%
\colorbox{green!30}{\strut Badger, B.}Memories.\\
%
\colorbox{red!40}{\strut 2001.}Badger, B. Memoirs.\\
%
\colorbox{red!30}{\strut 2002.}Badger, B. Recollection.\\
%
\colorbox{red!20}{\strut 2003.}Badger, B. Memoirs (2nd ed).
\end{minipage}}
\vspace{3pt}
\caption{\texttt{ynt} sorting}
\end{marginfigure}
\item
\emph{Alphabetic Label/Name/Year/Title} (\texttt{sorting=anyt}). Sorts
principally by the alphabetic label --- and obviously therefore
intended only for alphabetic styles. The \biblatex~manual says that it
then sorts by name, year and title: but so long as the labels are
unique, as would usually be the case, these will never need to be
consulted. There is also a style \texttt{anyvt} which
considers volume information.\index{sorting!alphanumeric labels}
\begin{marginfigure}[1ex]
\fbox{
\begin{minipage}{0.95\marginparwidth}
\colorbox{red!50}{\strut[Aar00]}A.\,Aardvark.\,My Life.\.2000. \\
\colorbox{red!40}{\strut[Bad05a]}B.\,Badger.\,Memoirs.\,2005.\\
\colorbox{red!30}{\strut[Bad05b]}B.\,Badger.\,Recollection.\,2005. \\
\colorbox{red!20}{\strut[Bad10]}B.\,Badger.\,Memoirs.\,2010. \\
\colorbox{red!10}{\strut[Bad99]}B.\,Badger.\,Memories.\,1999.
\end{minipage}}
\vspace{3pt}
\caption{\texttt{anyt} sorting}
\end{marginfigure}
\item \emph{By order in the \texttt{.bib} file}
(\texttt{sorting=debug}) this order citations by their \emph{key},
and is (as its name suggests) exclusively intended for styles which
are used for debugging \texttt{.bib} files.\index{sorting!debug}\index{sorting!in .bib file order@in \texttt{.bib} file order}
\end{itemize}
\indexstop{sorting!predefined schemes}
\section{\texttt{.bib} 文件内的特殊操作}
%\section{Ad hoc manipulations in the \texttt{.bib} file.}
\index{sorting!special cases}
Most of the time, \biblatex\ and \package{biber} will sort quite well,
but there are occasions when you may need to intervene.\marginpar{\footnotesize 可以在 bib 文件内,设置 sortname,sorttitle,sortyear 以实现根据给出的域信息进行排序。可以指定 presort 域提供更早的排序信息。也可以指定 sortkey 来明确可以参与排序的域。
}
\index{sorting!sortname@texttt{sortname}}\index{database!sortname
field@\texttt{sortname} field}
\paragraph{Helping out the sorting}\label{sorting:sortname} The first,
and most common, is when for some reason the name field that should be
printed is inappropriate for sorting, and you need to specify a
slightly different version for sorting purposes only. This can happen
for two main reasons.
You may just want a different name. For instance, suppose you have an
`institutional' author:
\begin{Verbatim}
author = {{The Magoo Trust}}
\end{Verbatim}
\biblatex\ is going to try to sort this under T for `The' --- but you
might think it better to have it sorted under M. In such a case, you
can specify a \texttt{sortname}
\begin{Verbatim}
sortname = {{Magoo Trust The}}
\end{Verbatim}
\index{sorting!sorttitle@texttt{sorttitle}}\index{database!sorttitle
field@\texttt{sorttitle} field}
Similar things can happen with titles (indeed, it's more common
there)\label{sorting:sorttitle}
\begin{Verbatim}
title = {The General Principles of EC Law}
sortitle = {General Principles of EC Law The}
\end{Verbatim}
\index{database!latex in@\LaTeX\ in}
If you have used a \LaTeX\ command in a field this may confuse the
sorting, and you can use an `unvarnished' version for sorting
\begin{Verbatim}
title = {\TeX\}ing,
sortitle = {Texing}
\end{Verbatim}
You can set \texttt{sortname}, \texttt{sorttitle}, and \texttt{sortyear}
fields for these purposes.
\index{sorting!altering order}
\paragraph{Fiddling with the order} The second change you might sometimes
want to make is something which more drastically manipulates the order.
Take, for instance a book with no author or one with no date. In a
name/title/year system, the authorless book gravitates to the top of
the list, and in a year/name/title system, the dateless work ends up
at the end of the list. Suppose you want the reverse?
\index{database!presort field@\texttt{presort} field}\index{sorting!pre-sorting}
The trick is this. Every entry in your \texttt{.bib} file is assumed
to have a field called \texttt{presort} magically set to
\texttt{mm}. And, as the name suggests, that is the first field that
gets sorted. So if you set \texttt{presort} to something higher in the
alphabet than \texttt{mm} (like, say, \texttt{aa}) the work in
question will magically appear (alongside everything else with the
same presort code) above the rest of the list; and if you set it to
something lower in the alphabet than \texttt{mm} (like, say,
\texttt{zz}) it will drop to the bottom.
The \texttt{presort} field could be used --- and in the past sometimes
was --- for other purposes, and in particular for producing
topic-based bibliographies (for instance by giving all primary sources
a presort of \texttt{aa}, to move them to the top of the list). With
\biblatex\ there are better ways of achieving that sort of
result.
\index{database!sortkey@\texttt{sortkey}}\index{sorting!sortkey as last resort@\texttt{sortkey} as last resort}
In desperation you can also use \texttt{sortkey} to fix absolutely and
unequivocally the `key' by which a work will be sorted. Generally
speaking, though, this is a counsel of desperation, and it is hard to
think of a real-life situation in which it would be advised.
%%% Local Variables:
%%% coding: utf-8
%%% mode: LaTeX
%%% TeX-master: "biblatex-tutorial"
%%% End: