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

如何在Quarto书籍中设置独立的参考文献与书目章节

实现Quarto书籍双章节参考文献/书目方案

Lua过滤器方案完全可行,这是目前实现你需求最直接的方式,具体操作可以按以下步骤来:

1. 基础配置与标记

首先在项目的_book.yml里做好全局配置,指定章节结构和引用规则:

book:
  title: "你的书籍名称"
  chapters:
    - index.qmd
    - 其他章节.qmd
    - references.qmd  # 存放正文实际引用的参考文献
    - bib.qmd          # 独立书目章节
bibliography: main.bib  # 主文献库
csl: 你的样式.csl       # 统一引用格式(比如apa.csl)
citeproc: true

如果你的独立书目条目是单独维护的,也可以给它们加个标记(比如在main.bib里给目标条目加tags: additional),或者直接单独建一个additional.bib文件专门放书目条目。

2. 配置独立书目章节

在bib.qmd里,通过nocite指令指定要纳入书目的条目,同时设置章节标题:

# 书目

---
# 如果用单独的文献库,添加这行
# bibliography: additional.bib
nocite: |
  @source1
  @source2
  # 可以继续添加更多条目ID
---

3. 编写Lua过滤器拆分参考文献

新建一个split-references.lua文件,作用是把正文引用的条目和书目章节的nocite条目拆分,分别输出到对应章节:

-- 记录正文里实际出现的引用ID
local cited_ids = {}

function Cite(cite)
  for _, cit in ipairs(cite.citations) do
    cited_ids[cit.id] = true
  end
  return cite
end

function Pandoc(doc)
  -- 检查citeproc生成的完整参考文献列表
  if not doc.meta.references then return doc end

  local main_refs = {}  -- 正文引用的参考文献
  local extra_refs = {} -- 书目章节的条目

  -- 拆分两类条目
  for _, ref in ipairs(doc.meta.references) do
    if cited_ids[ref.id] then
      table.insert(main_refs, ref)
    else
      table.insert(extra_refs, ref)
    end
  end

  -- 更新全局参考文献为正文引用的部分
  doc.meta.references = main_refs

  -- 找到"书目"章节,插入拆分出的额外条目
  for i, block in ipairs(doc.blocks) do
    if block.t == "Header" and block.level == 1 and block.content[1].text == "书目" then
      -- 生成和默认参考文献格式一致的列表
      local ref_list = pandoc.BulletList()
      for _, ref in ipairs(extra_refs) do
        table.insert(ref_list.content, pandoc.Plain(pandoc.Str(ref.citation)))
      end
      table.insert(doc.blocks, i + 1, ref_list)
    end
  end

  return doc
end

然后把过滤器加入_book.yml:

filters:
  - split-references.lua

关键说明

  • 编译时,Quarto会先通过citeproc处理所有引用(正文+nocite),Lua过滤器再自动拆分两类条目,分别输出到对应章节
  • 两类条目会自动沿用你指定的CSL格式,无需手动编写完整内容
  • 如果某个条目同时在正文引用和nocite里出现,只会出现在“参考文献”章节,不会重复

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 05:05:18