我最近改用 BibLaTeX 来实现多语言书目。一切都很顺利——但是当我使用命令\DeclareLanguageMapping{english}{english-apa}
将相应的 apa 文件声明为英语语言文件时,我收到错误“只能在序言中使用”。奇怪的是,如果我编译没有相关行的文件,然后使用该命令再次编译它,它就会起作用。有人知道如何解决这个问题吗?
这是我的 MWE:
\begin{filecontents}{\jobname.bib}
@article{Grimberg.2012,
author = {Grimberg, Steffen},
year = {2012},
title = "{Sherlock Holmes in der ARD: Gefährliche Gefühle}",
journal = {taz.de \textnormal{am 17.05.2012}},
url = {http://www.taz.de/!5093806/},
urldate = {2015-06-06},
hyphenation = {english}
}
@book{Weller.1994,
author = {Philip Weller},
year = {1994},
title = "{Alphabetically, My Dear Watson. A Compilation of Canonical Characters. Sherlock Holmes from A to Z}",
edition = {3},
address = {Portsmouth},
publisher = {Sherlock Publications},
}
@incollection{Moriarty.2011,
author = {Moriarty, James},
title = "{The Role of Supervillains in Modern Democracy.}",
pages = {79-107},
publisher = {{Villainy Press}},
editor = {Moriarty, James},
booktitle = {Supervillainy in the 21st Century},
volume = {5},
edition = {3},
year = {2011},
address = {London},
hyphenation = {english},
}
\end{filecontents}
\documentclass[12pt,parskip=half]{scrartcl}
\usepackage[english,ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{csquotes}
\usepackage[
backend=biber,
style=apa,
natbib=true,
autolang=other]{biblatex}
\DeclareLanguageMapping{ngerman}{ngerman-apa}
\DeclareLanguageMapping{english}{english-apa}
\addbibresource{\jobname.bib}
\begin{document}
\citet{Grimberg.2012, Weller.1994, Moriarty.2011}
\printbibliography
\end{document}
答案1
语言文件在第一次“需要”时加载。第一次编译时,命令就会\cite
出现,因此位于文档中间。如果\DefineBibliographyExtras
使用“仅前言”命令,则会出错。
在下一次编译时,辅助文件将调用英语,因此语言文件会更早加载。
您可以使用以下方式强制提前加载语言文件
\AtBeginDocument{\selectlanguage{english}\selectlanguage{ngerman}}
编辑
我认为这是 apa 文件中的一个错误。它使用DefineBibliographyExtras
而不是\DeclareBibliographyExtras
。我提交了一个错误报告:https://github.com/plk/biblatex-apa/issues/12