
我知道我可以按關鍵字對參考書目進行分組。但這不是情況,因為如果我不使用字母排序和數字樣式,我可以按關鍵字拆分參考書目。但是,如果我想要排序的參考書目和數字編號,並嘗試將其拆分,我將破壞編號。我需要的是某種語言的圍脖項目先於另一種語言的項目。例子:
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english,greek,russian]{babel} % English please
\setmainfont[
BoldFont={DeJavu Serif Bold},
ItalicFont={DeJavu Serif Italic},
BoldItalicFont={DeJavu Serif BoldItalic}
]{DeJavu Serif}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{AlKarapan,
author = {Καραπαναγοπούλου, Αλέξανδρος Κ.},
title = {Η Μεγάλη Σύνοδος της Ορθοδόξου Ανατολικής Εκκλησίας},
publisher = {auto-édition},
date = {1990/1998},
volumes = {6},
address = {Αθήνα},
langid={greek},
}
@Inbook{CypinIstorijaRPC,
author = {Владислав Цыпин},
title = {История Русской Церкви 1917--1997},
chapter = {VIII},
publisher = {Издательство Спасо-Преображенского Валаамского монастыря},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
url = {http://old.pravoslavie.by/podpod.asp?id=135&Session=10},
langid={russian},
}
@Inbook{authorrus,
author = {Другой Автор},
title = {Название},
chapter = {VIII},
publisher = {Издательство},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
langid={russian},
}
@article{baez/article,
author = {Baez, John C. and Lauda, Aaron D.},
title = {Higher-Dimensional Algebra {V}: 2-Groups},
journaltitle = {Theory and Applications of Categories},
date = 2004,
volume = 12,
pages = {423-491},
version = 3,
eprint = {math/0307200v3},
eprinttype = {arxiv},
langid = {english},
langidopts = {variant=american},
annotation = {An \texttt{article} with \texttt{eprint} and
\texttt{eprinttype} fields. Note that the arXiv reference is
transformed into a clickable link if \texttt{hyperref} support
has been enabled. Compare \texttt{baez\slash online}, which
is the same item given as an \texttt{online} entry},
hyphenation={english},
}
@article{another,
author = {Another,Author and One more, Author},
title = {Title},
journaltitle = {Journal},
date = 2004,
volume = 12,
pages = {423-491},
version = 3,
eprint = {math/0307200v3},
eprinttype = {arxiv},
langid = {english},
langidopts = {variant=american},
hyphenation={english},
}
\end{filecontents*}
\usepackage[russian,greek,english]{babel}
\usepackage[natbib=true,
style=numeric,
isbn=true,
url=true,
defernumbers=false,
sorting=nyt,
firstinits=true,
backend=biber,
language=auto,
autolang=other]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\cite{AlKarapan,CypinIstorijaRPC,baez/article}
\nocite{*}
\printbibliography
\end{document}
輸出將是:英語、希臘語和俄語的項目。如果我編輯 bbl 文件,只需移動開頭的俄語條目,然後是希臘語條目和最後一個英語條目,別跑biber只需引用條目並運行 lualatex 或 xelatex 一切都會好起來的。
Biblatex/Biber 對參考書目進行排序,並且我手動移動 bbl 檔案中給定語言的條目。我得到按給定語言和我想要的語言順序排序的條目。
問題:我可以在不編輯 bbl 檔案的情況下進行這種排序嗎
我不能使用多個圍兜,因為我需要連續編號
答案1
當然,可以\sort{\field{langid}}
在排序過程中放入 a ,但這會按字典順序對語言進行排序,因此英語將首先出現,然後是希臘語,然後是俄語,這不完全是您想要的。
但順便說一下,如果我們排序下降按字典順序,我們在 MWE 中得到您想要的順序。
\DeclareSortingScheme{lnyt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=descending]{\field{langid}}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{0000}
}
}
這當然只是因為您想要的排序順序與語言名稱的逆字典順序一致。
現在使用sorting=lnyt
。
一個更可自訂但稍微複雜的解決方案使用presort
欄位和 Biber 的來源映射功能。
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=langid, match=\regexp{\Arussian\Z}, final]
\step[fieldset=presort, fieldvalue=1]
}
\map{
\step[fieldsource=langid, match=\regexp{\Agreek\Z}, final]
\step[fieldset=presort, fieldvalue=2]
}
\map{
\step[fieldsource=langid, match=\regexp{\Aenglish\Z}, final]
\step[fieldset=presort, fieldvalue=3]
}
}
}
每種語言都簡單地映射到寫入該presort
欄位的數字。該presort
字段在其他排序字段之前被考慮。
這允許不遵循任何字典順序的排序順序。
微量元素
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english,greek,russian]{babel} % English please
\setmainfont[
BoldFont={DeJavu Serif Bold},
ItalicFont={DeJavu Serif Italic},
BoldItalicFont={DeJavu Serif BoldItalic}
]{DeJavu Serif}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{AlKarapan,
author = {Καραπαναγοπούλου, Αλέξανδρος Κ.},
title = {Η Μεγάλη Σύνοδος της Ορθοδόξου Ανατολικής Εκκλησίας},
publisher = {auto-édition},
date = {1990/1998},
volumes = {6},
address = {Αθήνα},
langid={greek},
}
@Inbook{CypinIstorijaRPC,
author = {Владислав Цыпин},
title = {История Русской Церкви 1917--1997},
chapter = {VIII},
publisher = {Издательство Спасо-Преображенского Валаамского монастыря},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
url = {http://old.pravoslavie.by/podpod.asp?id=135&Session=10},
langid={russian},
}
@Inbook{authorrus,
author = {Другой Автор},
title = {Название},
chapter = {VIII},
publisher = {Издательство},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
langid={russian},
}
@article{baez/article,
author = {Baez, John C. and Lauda, Aaron D.},
title = {Higher-Dimensional Algebra {V}: 2-Groups},
journaltitle = {Theory and Applications of Categories},
date = 2004,
volume = 12,
pages = {423-491},
version = 3,
eprint = {math/0307200v3},
eprinttype = {arxiv},
langid = {english},
langidopts = {variant=american},
annotation = {An \texttt{article} with \texttt{eprint} and
\texttt{eprinttype} fields. Note that the arXiv reference is
transformed into a clickable link if \texttt{hyperref} support
has been enabled. Compare \texttt{baez\slash online}, which
is the same item given as an \texttt{online} entry},
hyphenation={english},
}
@article{another,
author = {Another,Author and One more, Author},
title = {Title},
journaltitle = {Journal},
date = 2004,
volume = 12,
pages = {423-491},
version = 3,
eprint = {math/0307200v3},
eprinttype = {arxiv},
langid = {english},
langidopts = {variant=american},
hyphenation={english},
}
\end{filecontents*}
\usepackage[russian,greek,english]{babel}
\usepackage[natbib=true,
style=numeric,
isbn=true,
url=true,
defernumbers=false,
sorting=nyt,
firstinits=true,
backend=biber,
language=auto,
autolang=other]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=langid, match=\regexp{\Arussian\Z}, final]
\step[fieldset=presort, fieldvalue=1]
}
\map{
\step[fieldsource=langid, match=\regexp{\Agreek\Z}, final]
\step[fieldset=presort, fieldvalue=2]
}
\map{
\step[fieldsource=langid, match=\regexp{\Aenglish\Z}, final]
\step[fieldset=presort, fieldvalue=3]
}
}
}
\begin{document}
\cite{AlKarapan,CypinIstorijaRPC,baez/article}
\nocite{*}
\printbibliography
\end{document}
答案2
以下是 moewe 答案的簡化版本。
BibTeX 原始檔
以下 BibTeX 檔案保存在~/TestBib.bib
.
@book{shakespeare,
author = {William Shakespeare},
title = {Hamlet},
year = {1600},
langid = {english}
}
@book{homer,
author = {Homer},
title = {Illiad \& Oddysey},
year = {8th century BC},
langid = {greek}
}
@book{tolstoy,
author = {Leo Tolstoy},
title = {War and Peace},
year = {1869},
langid = {russian}
}
一個帶有參考書目的簡單 LaTeX 文檔
\documentclass{article}
\usepackage{biblatex}
\addbibresource{TestBib.bib}
\begin{document}
\cite{shakespeare}\cite{homer}\cite{tolstoy}
\printbibliography
\end{document}
運行結果
> cd ~
> lualatex 測試
> biber 測試
> lualatex 測試
是
英文優先,其他依照預設順序
\documentclass{article}
\usepackage{biblatex}
\DeclareSourcemap {
\maps {
\map {
\step [
fieldsource=langid,
match=english,
fieldset=presort,
fieldvalue=a
]
}
}
}
\addbibresource{TestBib.bib}
\begin{document}
\cite{shakespeare}\cite{homer}\cite{tolstoy}
\printbibliography
\end{document}
英語第一,俄文第二
現在,我們將新增一個來源對應來對書目條目進行排序,使得英文條目在第一,俄語條目在第二。
\documentclass{article}
\usepackage{biblatex}
\DeclareSourcemap {
\maps {
\map {
\step [
fieldsource=langid,
match=english,
fieldset=presort,
fieldvalue=a
]
\step [
fieldsource=langid,
match=russian,
fieldset=presort,
fieldvalue=b
]
}
}
}
\addbibresource{TestBib.bib}
\begin{document}
\cite{shakespeare}\cite{homer}\cite{tolstoy}
\printbibliography
\end{document}
輸出是:
筆記
無需將
datatype=bibtex
選項傳遞給\maps
(如 moewe 的答案中所做的那樣),因為bibtex
是選項的預設值datatype
。請參閱第 17 頁。手冊第 199 節biblatex
,第 3.18b 節,2022 年 7 月 12 日。不需要將正規表示式包裝起來
\regexp
(如 moewe 的答案中所做的那樣),除非它們包含也是有效 TEX 命令的字元序列。請參閱第 17 頁。手冊第 204 條。特殊欄位值的資料類型
presort
被解釋為biblatex
字串,而不是數字。 (請參閱手冊第 31 頁。)因此,適用於其值的順序是字典順序而不是數字順序。因此,在我看來,最好避免為該欄位分配數字(如 moewe 的答案中所做的那樣),以避免非直觀的後果。例如,如果在我的“英語第一,俄語第二”範例中,我為英語條目分配了值presort
,2
為俄語條目分配presort
了值10
,則俄語條目最終會出現在參考書目中的英語條目之前。除非明確指定,否則書目條目的欄位
presort
將自動設定為mm
。 (請參閱手冊第 83 頁第 3.6 節「排序選項」的第二段。)因此,如果langid
您希望排序依據恰好有三個不同的值,則無需明確指定presort
所有三個值其中(正如moewe 的答案中所做的那樣)。只需指定presort
其中兩個的明確值即可,並確保兩者按字典順序都小於mm
。這也是一個有用的信息,可以了解您是否希望某些條目出現在參考書目的頂部,但您不關心指定其餘條目的相對順序,就像我在“英文優先,其他按照預設排序”示例一樣。
請注意,來源映射發生在應用任何排序模板之前,包括預設的內建模板(如手冊附錄 C1-C3 中所述)。 (請參閱手冊第 199 頁第 4.5.3 節「資料的動態修改」的第二段。)因此,如果您使用任何預設排序模板,請說明
nty
使用的預設排序模板(如果您不這樣做)如果明確指定任何排序範本(請參閱手冊第48 頁的第3.1.2.1 節「包選項/前言選項/常規」),每個組內的條目順序presort
將按預期排列,即按照模板所禁止的順序。step
如果安排得當, s和s的數量map
可以大大減少,s的數量final
可以減少甚至消除。將 moewe 的答案與我的“英語第一,俄語第二”示例進行比較。final
關於諮詢的語義moewe 的回答,因為手冊對此不清楚,甚至具有誤導性。