BibLaTeX 无法与 Biber 2.8 配合使用 - 读取 ascii 格式的 .bib 文件时出错

BibLaTeX 无法与 Biber 2.8 配合使用 - 读取 ascii 格式的 .bib 文件时出错

当我尝试执行 BibTeX 时,收到以下错误消息:

INFO - This is Biber 2.8
INFO - Logfile is 'test.blg'
INFO - Reading 'test.bcf'
INFO - Found 1 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex format file 'H:/PhD/Work/Papers/library.bib' for section 0
ERROR - Data file 'H:/PhD/Work/Papers/library.bib' cannot be read in encoding 'ascii': ascii "\xE2" does not map to Unicode at C:\Users\rp1513\AppData\Local\Temp\par-727031353133\cache-72ca3f5324b5c5d2fae0b0f98af3c6b7e3920161\inc\lib/File/Slurper.pm line 63.
INFO - ERRORS: 1

library.bib 文件是 Mendeley 自动生成的。如果我将后端改为“bibtex”,然后将 bibtex 执行也改为 bibtex,就没有问题了。

这是使用我的文件的 MWE library.bib

% preamble to define document settings
% basic page setup
\documentclass[a4paper,12pt,oneside]{book}

% bibliography settings
\usepackage[backend=biber, style=authoryear, citestyle=authoryear]{biblatex}
\bibliography{H:/PhD/Work/Papers/library}

\begin{document}

\tableofcontents

Here is a reference to one of the papers in my Mendeley library (\cite{Cancer2011}).

\printbibliography[heading=bibintoc]

\end{document}

.bib文件由 Mendeley 自动生成,但其头部如下:

Automatically generated by Mendeley Desktop 1.17.11
Any changes to this file will be lost if it is regenerated by Mendeley.

BibTeX export options can be customized via Options -> BibTeX in Mendeley Desktop

@article{Kim2013,
abstract = {Despite the advances in biomedical research and clinical applications, cancer remains a leading cause of death worldwide. Given the limitations of conventional chemotherapeutics, including serious toxicities and reduced quality of life for patients, the development of safe and efficacious alternatives with known mechanism of action is much needed. Prevention of cancer through dietary intervention may hold promise and has been investigated extensively in the recent years. AMP-activated protein kinase (AMPK) is an energy sensor that plays a key role in the regulation of protein and lipid metabolism in response to changes in fuel availability. When activated, AMPK promotes energy-producing catabolic pathways while inhibiting anabolic pathways, such as cell growth and proliferation - thereby antagonizing carcinogenesis. Other anti-cancer effects of AMPK may include promoting autophagy and DNA repair upon UVB damage. In the last decade, interest in AMPK has grown extensively as it emerged as an attractive target molecule for cancer prevention and treatment. Among the latest developments is the activation of AMPK by naturally occurring dietary constituents and plant products - termed phytochemicals. Owing to their efficacy and safety, phytochemicals are considered as an alternative to the conventional harmful chemotherapy. The rising popularity of using phytochemicals for cancer prevention and therapy is supported by a substantial progress in identifying the molecular pathways involved, including AMPK. In this article, we review the recent progress in this budding field that suggests AMPK as a new molecular target in the prevention and treatment of cancer by phytochemicals.},
author = {Kim, Inyoung and He, Yu-Ying},
doi = {10.3389/fonc.2013.00175},
file = {:C$\backslash$:/Users/rp1513/AppData/Local/Mendeley Ltd./Mendeley Desktop/Downloaded/Kim, He - 2013 - Targeting the AMP-Activated Protein Kinase for Cancer Prevention and Therapy.pdf:pdf},
issn = {2234-943X},
journal = {Frontiers in oncology},
keywords = {AMPK,DNA repair,ampk,apoptosis,cancer prevention,dna repair,phytochemicals,proliferation},
number = {175},
pages = {1--12},
pmid = {23875169},
title = {{Targeting the AMP-Activated Protein Kinase for Cancer Prevention and Therapy.}},
url = {http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=3711071{\&}tool=pmcentrez{\&}rendertype=abstract},
volume = {3},
year = {2013}
}
@article{Ostrom2014,
abstract = {Gliomas are the most common primary intracranial tumor, representing 81{\%} of malignant brain tumors. Although relatively rare, they cause significant mortality and morbidity. Glioblastoma, the most common glioma histology (∼45{\%} of all gliomas), has a 5-year relative survival of ∼5{\%}. A small portion of these tumors are caused by Mendelian disorders, including neurofibromatosis, tuberous sclerosis, and Li-Fraumeni syndrome. Genomic analyses of glioma have also produced new evidence about risk and prognosis. Recently discovered biomarkers that indicate improved survival include O⁶-methylguanine-DNA methyltransferase methylation, isocitrate dehydrogenase mutation, and a glioma cytosine-phosphate-guanine island methylator phenotype. Genome-wide association studies have identified heritable risk alleles within 7 genes that are associated with increased risk of glioma. Many risk factors have been examined as potential contributors to glioma risk. Most significantly, these include an increase in risk by exposure to ionizing radiation and a decrease in risk by history of allergies or atopic disease(s). The potential influence of occupational exposures and cellular phones has also been examined, with inconclusive results. We provide a “state of the science” review of current research into causes and risk factors for gliomas in adults.},
author = {Ostrom, Quinn T. and Bauchet, Luc and Davis, Faith G. and Deltour, Isabelle and Fisher, James L. and Langer, Chelsea Eastman and Pekmezci, Melike and Schwartzbaum, Judith A. and Turner, Michelle C. and Walsh, Kyle M. and Wrensch, Margaret R. and Barnholtz-Sloan, Jill S.},
doi = {10.1093/neuonc/nou087},
file = {:/icnas3.cc.ic.ac.uk/rp1513/PhD/Work/Papers/nou087.pdf:pdf},
isbn = {1523-5866 (Electronic)$\backslash$r1522-8517 (Linking)},
issn = {15235866},
journal = {Neuro-Oncology},
keywords = {brain tumors,epidemiology,genome-wide association studies,glioma,risk factors},
number = {7},
pages = {896--913},
pmid = {24842956},
title = {{The epidemiology of glioma in adults: A state of the science review}},
volume = {16},
year = {2014}
}

任何帮助将不胜感激!

答案1

您可以使用 强制执行 utf8 编码bibencoding=utf8

因此请使用:

\usepackage[backend=biber, bibencoding=utf8, style=authoryear, citestyle=authoryear]{biblatex}

我也有类似的问题。Biber 2.7 自动重新编码有问题的字符并记录警告。看来 Biber 2.8 及更新版本使用了File::Slurper更好的强制ascii编码,但现在不会自动重新编码有问题的字符。

更新:Biber 2.10 开发版本现在包括变化这样它就会默认读取ascii文件utf8并记录相关警告。此行为与 Biber 2.7 及更早版本的行为非常相似。

答案2

问题是雅各布·D指出他的回答Biber 2.8 及更高版本使用较新版本,File::Slurper当读取具有不正确编码的文件时,其容忍度较低。

默认情况下biblatex,Biber 会自动尝试找出.tex.bib文件的编码。它们会假设.tex.bib文件使用相同的编码。如果您加载inputencinputenxluainputenc包,则文件会使用那里的编码集.tex。如果您不使用其中一个包,biblatex则 LuaTeX 或 XeTeX 会使用 UTF-8,其他所有引擎会使用 ASCII。(如果你的 LaTeX 版本是 2018 年 4 月或更高版本,则默认使用 UTF-8即使使用 pdfTeX,也biblatex能识别这一点并假定使用 UTF-8 而不是 US-ASCII。

您的 MWE 不会加载任何inputenc类似软件包,并且如果使用 pdfLaTeX 编译,它将被视为 ASCII(如果你使用 2018 年 4 月之前的旧 LaTeX 格式)。.bib然后,该文件还将被假定为 ASCII 编码(即使它可能是 UTF-8 - 它肯定不是仅限 ASCII 的,因为各个字段中的一些字符abstract不在 ASCII 范围内)。

您现在有几种选择。

  1. inputenc使用正确的编码选项加载(可能是\usepackage[utf8]{inputenc})或直接使用 Unicode 引擎(XeLaTeX、LuaLaTeX)。我认为这是最好的选择,但你必须确保你的.tex.bib文件都使用你传递给的编码inputenc。(这在 LaTeX 2018-04-01 或更高版本中自动发生

  2. 加载.bib时指定文件的编码biblatexbibencoding

    \usepackage[backend=biber, bibencoding=utf8, style=authoryear]{biblatex}
    
  3. 确保您的.bib文件仅包含 ASCII 字符。如果您不需要任何非 ASCII 字符(例如,如果您只在abstract不打印的字段中使用它们),这可能是一种简单的解决方法。

Biber >= 2.10 再次更加宽容。当指示以 ASCII 读取文件时,它会改为以 UTF-8 读取。由于 UTF-8 向后兼容 ASCII,这不会对纯 ASCII 文件造成问题,并且如果您的.bib文件实际上是 UTF-8 编码的(现在通常都是这样),它会提供更好的结果。当然,如果您的文件包含非 ASCII 字符并使用 UTF-8 以外的编码,它仍然会失败,但在这种情况下,如果您一开始没有向 LaTeX 声明正确的编码,您无论如何都是在自找麻烦。

也可以看看https://github.com/plk/biber/issues/201由于错误发生在读取文件的早期阶段,Biber 无法提供更详细的错误消息,以更具体地定位有问题的字符。

还请注意,这适用于.bib文件中的所有字符,甚至适用于被忽略或通常不会打印在参考书目中的注释和字段。该abstract字段经常出现问题。

相关内容