You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rmarkdown编译PDF遇pandoc转换错误25:参考文献读取失败

Pandoc转换错误25:BibTeX条目格式修复方案

问题背景

编译Rmarkdown生成PDF时,引用环节触发pandoc转换错误25,报错指向library.bib文件第1行的下划线问题。已尝试修改.bib文件名、调整括号格式,均未解决。

简化版Rmarkdown文档

---
title: "Title here" 
date: "`r format(Sys.time(), '%d-%B-%Y')`"
author: 
  - Pierre-Alexandre Dumas
output:
  pdf_document:
    fig_caption: yes        
    includes:  
      in_header: my_header.tex
    latex_engine: xelatex
    number_sections: yes
    toc: false
  bookdown::pdf_document2: default
bibliography: library.bib   
header-includes:
- \usepackage{pdflscape}
- \usepackage[french]{babel}
- \usepackage{longtable}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \renewcommand{\and}{\\}
- \usepackage{titling}
- \usepackage{tocloft}
- \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
---
\newpage
\tableofcontents
\listoffigures
\listoftables
\newpage
# Introduction
Bla bla bla (<1%; [@Eadie2020]). 

library.bib原条目

@book_section{Eadie2020,
   author = {John M. Eadie and Jean-Pierre L. Savard and Mark L. Mallory},
   city = {Ithaca},
   doi = {10.2173/bow.bargol.01},
   editor = {Alan F. Poole and Frank B. Gill},
   journal = {Birds of the World},
   month = {3},
   publisher = {Cornell Lab of Ornithology},
   title = {Barrow's Goldeneye (Bucephala islandica)},
   year = {2020},
}

报错信息

Error reading bibliography file library.bib:
(line 1, column 6):
unexpected '_'
Erreur : pandoc document conversion failed with error 25
Exécution arrêtée

解决方案

问题根源是@book_section并非标准BibTeX条目类型,pandoc无法识别带下划线的自定义类型名。需将条目类型替换为标准类型,同时修正对应字段:

  1. 把@book_section改为@incollection(适用于书籍中的章节内容)
  2. 将原journal字段改为booktitle,符合@incollection类型的规范

修改后的library.bib条目:

@incollection{Eadie2020,
   author = {John M. Eadie and Jean-Pierre L. Savard and Mark L. Mallory},
   city = {Ithaca},
   doi = {10.2173/bow.bargol.01},
   editor = {Alan F. Poole and Frank B. Gill},
   booktitle = {Birds of the World},
   month = {3},
   publisher = {Cornell Lab of Ornithology},
   title = {Barrow's Goldeneye (Bucephala islandica)},
   year = {2020},
}

修改完成后重新编译Rmarkdown文档,pandoc即可正常读取参考文献,错误25会消失,引用也能正确渲染。

内容的提问来源于stack exchange,提问作者Pierre-Alexandre Dumas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 10:42:38