我正在尝试text
使用 pdflatex (biber) 在书目中获取一种语言相关(定制)的内容。
我发现至少有 3 种方法可以实现此目的:
\DefineBibliographyStrings{language}{bibfield={formatting}}
\NewBibliographyString
- 创建新的 bistring 并像在这个例子\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)和常规格式(字段格式等)分开。但第二种方法并不比第一种方法多做很多工作。事实上,在这个例子中,您甚至可以避免代码重复。