
text
我正在嘗試使用 pdflatex (biber) 在書目中獲得語言依賴(定制) 。
我發現至少有 3 種方法可以做到這一點:
\DefineBibliographyStrings{language}{bibfield={formatting}}
\NewBibliographyString
- 建立新的書目字串並像下面一樣使用它這個例子\iffieldequalstr{hyphenation}{language}{true}{false}
然而,第一種方法
\DefineBibliographyStrings{english}{series = {Ser\adddot\addcolon\space{#1}\isdot}}
\DefineBibliographyStrings{russian}{series = {Сер\adddot\addcolon\space{#1}\isdot}}
導致錯誤:
包 keyval 錯誤:系列未定義。 }
第二種方法如果你有很多text tuples
需要客製化的東西,那麼很難實現。
第三種方法
\DeclareFieldFormat{series}{\iffieldequalstr{hyphenation}{russian}{Сер}{Ser}\adddot\addcolon\space{#1}\isdot} %
不適用於任何面向語言的領域,例如hyphenation
.
請幫我解答,它解決了 1 和 3 方法的問題。
微量元素
\documentclass{memoir}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INBOOK{Inbook,
author = {Peter Eston},
title = {The title of the work},
booktitle = {Book title},
chapter = {8},
pages = {201-213},
publisher = {The name of the publisher},
year = {1993},
volume = {4},
series = {5},
address = {The address of the publisher},
edition = {3},
month = {7},
hyphenation = {english}
}
@Book{avtonomova:fya,
author = {Н. С. Автономова},
title = {Философский язык Жака Деррида},
year = 2011,
publisher = {Российская политическая энциклопедия (РОССПЭН)},
location = {М.},
isbn = {978-5-8243-1618-6},
series = {Российские Пропилеи},
pagetotal = 510,
hyphenation =russian,
}
\end{filecontents}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}[2014/04/30] %
\usepackage[english, russian]{babel}[2014/03/24]%
\usepackage[%
backend=biber,
bibencoding=utf8,
style=gost-numeric,
babel=other,
defernumbers=true,
sortcites=true,
doi=true,
]{biblatex}[2016/09/17]
%add Ser.: to series format
%%% First approach
%\DefineBibliographyStrings{english}{series = {Ser\adddot\addcolon\space{#1}\isdot}}
%
%\DefineBibliographyStrings{russian}{series = {Сер\adddot\addcolon\space{#1}\isdot}}
%%% Third approach
\DeclareFieldFormat{series}{\iffieldequalstr{hyphenation}{russian}{Сер}{Ser}\adddot\addcolon\space{#1}\isdot} % do not work
%% Work perfectly
%\DeclareFieldFormat{series}{\iffieldequalstr{pagetotal}{510}{Сер}{Ser}\adddot\addcolon\space{#1}\isdot} %
\addbibresource{\jobname.bib}
\begin{document}
\cite{avtonomova:fya,Inbook}
\printbibliography
\end{document}
所需輸出
答案1
.bib
首先請注意,您必須在文件中使用大括號(或引號)給出非數字值。hyphenation = russian
是錯誤的並產生警告WARN - BibTeX subsystem: <filename>, line 29, warning: undefined macro "russian"
。它應該是
hyphenation = {russian},
不起作用\iffieldequalstr{hyphenation}{russian}
,因為它hyphenation
是舊別名。在內部,該字段現在稱為 langid
.因此,
\iffieldequalstr{langid}{russian}
作品。
然而,我更喜歡使用參考書目字串的方法。由於該字串series
尚未定義,因此您需要先使用 聲明它\NewBibliographyString{series}
。然後你可以在 中給出它的定義\DefineBibliographyStrings
。請注意,此定義應僅包含翻譯後的字串,沒有額外的標點符號,也沒有其他類似巨集的格式。最後你可以使用字串\bibsring
最後,您可以在欄位格式中。這基本上是第二種方法在 bibfile 中建立新命令。
\documentclass{memoir}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}[2014/04/30] %
\usepackage[english, russian]{babel}[2014/03/24]%
\usepackage[%
backend=biber,
style=gost-numeric,
babel=other,
defernumbers=true,
sortcites=true,
doi=true,
]{biblatex}[2016/09/17]
\NewBibliographyString{series}
\DefineBibliographyStrings{english}{series = {Ser\adddot}}
\DefineBibliographyStrings{russian}{series = {Сер\adddot}}
\DeclareFieldFormat{series}{\bibstring{series}\addcolon\space{#1}\isdot}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INBOOK{Inbook,
author = {Peter Eston},
title = {The title of the work},
booktitle = {Book title},
chapter = {8},
pages = {201-213},
publisher = {The name of the publisher},
year = {1993},
volume = {4},
series = {5},
address = {The address of the publisher},
edition = {3},
month = {7},
hyphenation = {english}
}
@Book{avtonomova:fya,
author = {Н. С. Автономова},
title = {Философский язык Жака Деррида},
year = 2011,
publisher = {Российская политическая энциклопедия (РОССПЭН)},
location = {М.},
isbn = {978-5-8243-1618-6},
series = {Российские Пропилеи},
pagetotal = 510,
hyphenation = {russian},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{avtonomova:fya,Inbook}
\printbibliography
\end{document}
請注意,如果您想添加第三種語言,第三種方法很快就會失控。第一種方法根本行不通,因為biblatex
本地化(bibstrings)和通用格式(字段格式等)是分開的。但第二種方法並不比第一種方法多做多少工作。事實上,在此範例中您甚至可以避免程式碼重複。