我经常用德语和英语写文章,并使用 JabRef 来整理我的参考文献。引用大量会议论文时,总是根据文档语言更改位置的语言往往很烦人。所以我想知道我是否可以为 biblatex 提供一种词典,这样我就不必每次都调整我的数据库。
例如,我想在序言中定义:
Munich = München
Germany = Deutschland
如果文档或 babel 语言是ngerman
。
这能做到吗?
平均能量损失
\documentclass[ngerman]{article}
\usepackage[ngerman]{babel}
\begin{filecontents}{bla.bib}
@inproceedings{Orwell1984,
author = "George Orwell",
title = "1984",
year = "1948",
booktitle = "Books about big brothers",
location = "Munich, Germany",
}
\end{filecontents}
\RequirePackage[backend=biber,style=ieee-alphabetic]{biblatex}
\addbibresource{bla.bib}
\begin{document}
\cite{Orwell1984}. \\
\printbibliography
\end{document}
答案1
您可以使用biblatex
的 bibstring 来翻译某些短语。问题是什么才是好的界面。如果您希望能够在一个字段中组合任意术语,则必须执行类似以下操作(感觉有点笨拙)。
\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}
\NewBibliographyString{munich,germany}
\DefineBibliographyStrings{german}{
munich = {München},
germany = {Deutschland},
}
\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
author = {George Orwell},
title = {1984},
year = {1948},
booktitle = {Books about big brothers},
location = {\bibstring{munich}, \bibstring{germany}},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\autocite{Orwell1984}
\printbibliography
\end{document}
如果你同意每个字段只使用一个字符串,那么你可以让事情变得更好一点
\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}
\NewBibliographyString{de-munich}
\DefineBibliographyStrings{german}{
de-munich = {München},
}
\DefineBibliographyStrings{english}{
de-munich = {Munich, Germany},
}
\DeclareListFormat{location}{%
\usebibmacro{list:delim}{#1}%
\ifbibstring{#1}{\bibstring{#1}}{#1}\isdot
\usebibmacro{list:andothers}}
\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
author = {George Orwell},
title = {1984},
year = {1948},
booktitle = {Books about big brothers},
location = {de-munich},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\autocite{Orwell1984}
\printbibliography
\end{document}
更像 BibTeX 的解决方案使用@string
s。您可以在不同的文件(每种语言一个)中为每个位置定义字符串.bib
,然后.bib
在文档中选择所需语言的文件。
\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}
\begin{filecontents}{locationstrings-german.bib}
@string{de:munich = "München"}
\end{filecontents}
\begin{filecontents}{locationstrings-english.bib}
@string{de:munich = "Munich, Germany"}
\end{filecontents}
% select the bib file for the language you want
\addbibresource{locationstrings-german.bib}
\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
author = {George Orwell},
title = {1984},
year = {1948},
booktitle = {Books about big brothers},
location = de:munich,
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\autocite{Orwell1984}
\printbibliography
\end{document}
仍处于试验阶段的多文字版本biblatex
可能也会引起人们的兴趣:https://github.com/plk/biblatex/issues/416
答案2
\documentclass[ngerman]{article}
\usepackage[ngerman]{babel}
\begin{filecontents}{german-strings.bib}
@string{muenchen={München}}
@string{germany={Deutschland}}
\end{filecontents}
\begin{filecontents}[overwrite]{bla.bib}
@inproceedings{Orwell1984,
author = "George Orwell",
title = "1984",
year = "1948",
booktitle = "Books about big brothers",
location = muenchen # ", " # germany
}
\end{filecontents}
\RequirePackage[backend=biber,style=ieee-alphabetic]{biblatex}
\addbibresource{german-strings.bib}
\addbibresource{bla.bib}
\begin{document}
\cite{Orwell1984}. \\
\printbibliography
\end{document}