![尽管主文档中有有效字符,但 .bib 文件中仍出现无效的 utf-8 序列错误](https://linux22.com/image/474099/%E5%B0%BD%E7%AE%A1%E4%B8%BB%E6%96%87%E6%A1%A3%E4%B8%AD%E6%9C%89%E6%9C%89%E6%95%88%E5%AD%97%E7%AC%A6%EF%BC%8C%E4%BD%86%20.bib%20%E6%96%87%E4%BB%B6%E4%B8%AD%E4%BB%8D%E5%87%BA%E7%8E%B0%E6%97%A0%E6%95%88%E7%9A%84%20utf-8%20%E5%BA%8F%E5%88%97%E9%94%99%E8%AF%AF.png)
我正在写一篇main.tex
带有单独 Bibtex 文件的论文references.bib
。我使用以下方法进行编译:
lualatex main
bibtex main
lualatex main
(请注意,我必须使用,bibtex
因为日记风格与不兼容biber
)
String contains an invalid utf-8 sequence
在最后一步“lualatex main”中,我收到来自 Bibtex 文件中的引用的错误:其中一位作者的名字以字符开头Á
(如果删除此字符则不会发生错误)。
我很困惑:这个角色似乎有效的 utf-8,并且如果它在主文档中,它会毫无问题地打印。此外,我的 Bibtex 文件包含其他不常见的重音字符,这些字符在 pdf 中正常显示。
我错过了什么?
抱歉,我忘记在 bibtex 文件中显示有问题的条目了:
@book {walsh15,
author = {Walsh, Kieran and Carney, Gemma M. and Ní Léime, Áine},
title = "Ageing through Austerity: Critical Perspectives from Ireland",
year = "2015",
publisher = "Policy Press",
address = "Bristol, UK",
isbn = "9781447316251",
doi = "10.51952/9781447316251",
url = "https://bristoluniversitypressdigital.com/view/book/9781447316251/9781447316251.xml"
}
以及生成的 .bbl 条目:
%Type = Book
\bibitem[{Walsh et~al.(2015)Walsh, Carney and Ní~Léime}]{walsh15}
\bibinfo{author}{Walsh, K.}, \bibinfo{author}{Carney, G.M.},
\bibinfo{author}{Ní~Léime, \C3.}, \bibinfo{year}{2015}.
\newblock \bibinfo{title}{Ageing through Austerity: Critical Perspectives from
Ireland}.
\newblock \bibinfo{publisher}{Policy Press}, \bibinfo{address}{Bristol, UK}.
\newblock \URLprefix
\url{https://bristoluniversitypressdigital.com/view/book/9781447316251/9781447316251.xml},
\DOIprefix\doi{10.51952/9781447316251}.
错误信息如下:
! String contains an invalid utf-8 sequence.
l.362 \bibinfo{author}{Ní~Léime,
�..}, \bibinfo{year}{2015}.
答案1
bibtex 对多字节编码一无所知,因此在尝试查找名称的“首字母”时,它只提取字节中的一个字节,因此Á
最终生成了无效的 latex.bbl
文件。 {\'A}
是记录的 bibtex 语法,并保留所有内容 ascii。
答案2
如果您不想替换参考书目中的重音字符,我建议您运行bibtexu
-- 其中“u”表示unicode或utf8 -- 而不是“plain” bibtex
。
\documentclass{article}
\begin{filecontents}[overwrite]{mwe.bib}
@book{walsh15,
author = {Walsh, Kieran and Carney, Gemma M. and Ní Léime, Áine},
title = "Ageing through Austerity: Critical Perspectives from Ireland",
year = "2015",
publisher = "Policy Press",
address = "Bristol, UK",
isbn = "9781447316251",
doi = "10.51952/9781447316251",
url = "https://bristoluniversitypressdigital.com/view/book/9781447316251/9781447316251.xml"
}
\end{filecontents}
\usepackage[numbers]{natbib}
\bibliographystyle{plainnat}
\usepackage{xurl}
\begin{document}
\cite{walsh15}
\bibliography{mwe}
\end{document}