我使用\usepackage[english]{babel}
,但一直收到错误:
Package babel Error: You haven't defined the language EN yet.
在解析参考书目时\bibliographystyle{apsrev4-1}
(奇怪的是,对于一些其他参考书目样式,我没有遇到这个问题)。
我发现有些bib
条目中有几行
language = {en},
更改en
为english
确实解决了问题。但是,当我bib
从其他工具(Mendeley)获取文件时,这会很烦人。
有没有办法将语言定义en
为的同义词english
?
笔记:
有一个类似的问题无法摆脱错误 babel:您尚未定义语言 en?,但由于不清楚而被关闭。
例子:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{natbib}
\bibliographystyle{apsrev4-1}
\usepackage{doi}
\begin{document}
\cite{Renyi1961}
\bibliography{notwrk}
\end{document}
和notwrk.bib
@inproceedings{Renyi1961,
author = {R\'{e}nyi, Alfr\'{e}d},
booktitle = {Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Contributions to the Theory of Statistics},
issn = {0097-0433},
language = {en},
publisher = {The Regents of the University of California},
title = {{On Measures of Entropy and Information}},
url = {http://projecteuclid.org/euclid.bsmsp/1200512181},
year = {1961}
}
答案1
这不是一个完整的混叠系统,因为它只对 起作用\selectlanguage
,但它应该足以满足您的目的。完整的系统需要对 进行深入的改造babel
。
\begin{filecontents*}{\jobname.bib}
@inproceedings{Renyi1961,
author = {R\'{e}nyi, Alfr\'{e}d},
booktitle = {Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics
and Probability, Volume 1: Contributions to the Theory of Statistics},
issn = {0097-0433},
language = {en},
publisher = {The Regents of the University of California},
title = {{On Measures of Entropy and Information}},
url = {http://projecteuclid.org/euclid.bsmsp/1200512181},
year = {1961}
}
\end{filecontents*}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{natbib}
\bibliographystyle{apsrev4-1}
\usepackage{doi}
\usepackage{letltxmacro}
\LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
\makeatletter
\DeclareRobustCommand{\selectlanguage}[1]{%
\@ifundefined{alias@\string#1}
{\ORIGselectlanguage{#1}}
{\begingroup\edef\x{\endgroup
\noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
}
\newcommand{\definelanguagealias}[2]{%
\@namedef{alias@#1}{#2}%
}
\makeatother
\definelanguagealias{en}{english}
\begin{document}
\cite{Renyi1961}
\bibliography{\jobname}
\end{document}
诀窍filecontents*
只是使示例自成一体,您不需要它,而可以使用.bib
您已有的普通文件。
根据 Javier Bezos 的建议,修补\bbl@fixname
似乎更好,因为它也适用于所有语言更改命令。
\begin{filecontents*}{\jobname.bib}
@inproceedings{Renyi1961,
author = {R{\'{e}}nyi, Alfr{\'{e}}d},
booktitle = {Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics
and Probability, Volume 1: Contributions to the Theory of Statistics},
issn = {0097-0433},
language = {en},
publisher = {The Regents of the University of California},
title = {{On Measures of Entropy and Information}},
url = {http://projecteuclid.org/euclid.bsmsp/1200512181},
year = {1961}
}
\end{filecontents*}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{natbib}
\usepackage{doi}
\usepackage{hyperref}
\bibliographystyle{apsrev4-1}
\makeatletter
\let\ORIbbl@fixname\bbl@fixname
\def\bbl@fixname#1{%
\@ifundefined{languagealias@\expandafter\string#1}
{\ORIbbl@fixname#1}
{\edef\languagename{\@nameuse{languagealias@#1}}}%
}
\newcommand{\definelanguagealias}[2]{%
\@namedef{languagealias@#1}{#2}%
}
\makeatother
\definelanguagealias{en}{english}
\begin{document}
\cite{Renyi1961}
\bibliography{\jobname}
\end{document}