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

如何在XeLaTeX编译的R Markdown中设置参考文献双行间距?

解决R Markdown中参考文献双行间距的问题

问题原因

你之前尝试的方法无效或报错,核心原因有两点:

  1. 当使用CSL格式生成Harvard参考文献时,pandoc通过自身的citeproc工具处理参考文献,而非依赖LaTeX的biblatex宏包。强行引入biblatex会和pandoc默认的处理流程冲突,导致编译失败。
  2. \setlength\bibitemsep{\baselineskip}是biblatex专属命令,对pandoc生成的thebibliography环境完全不起作用。

解决方案

通过LaTeX的setspace包,直接针对参考文献环境设置双行间距,不会干扰现有功能。修改后的完整R Markdown头部如下:

---
title: "My Title"
geometry: "left=1.2cm,right=1.2cm,top=1.5cm,bottom=1.5cm"
output:
  pdf_document: 
    latex_engine: xelatex
    fig_caption: yes
#    toc: yes
header-includes:
# Use the packages
  - \usepackage{lastpage}
  - \usepackage{fontspec}
  - \usepackage{placeins}
  - \usepackage{fancyhdr}
  - \usepackage{setspace}  # 加载行间距控制包
  - \AtBeginEnvironment{thebibliography}{\doublespacing}  # 对参考文献环境启用双行间距
# Set the font
  - \setmainfont{Calibri}
# Header and Footer Settings
  - \fancyhf{}
  - \pagestyle{fancy}
# References and bibliography settings
csl: */UoL_Harvard.csl
bibliography: references.bib
---

额外调整

如果需要自定义行间距(比如不是标准双行),可以将\doublespacing替换为\setstretch{2},其中2代表行间距是基线高度的2倍,你可以根据需求修改这个数值(比如1.8表示1.8倍行间距)。

内容的提问来源于stack exchange,提问作者JMW

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 07:13:23