阶段 5 · 图表、表格与文献 39 / 48 ≈ 17 分钟读完

LaTeX 参考文献:biblatex 与 biber 一次跑通的配置

参考书目是一条小型构建流水线:你的源码写下引用键,biber 读一份控制文件和 .bib 数据库,排好的结果以一份 .bbl 交回给 LaTeX 去读。这一页先把它配成一次就能跑通,再逐项讲清 biblatex 的选项各自改了什么、姓名与排序键是怎么生成的,以及期刊样式提出古怪要求时那份驱动(driver)该怎么写。

    一条引用命令到纸上那一行之间发生了什么

    一条引用是在索取本次编译还不具备的信息。LaTeX 读到 \autocite{einstein1916},只是把这个键写进 .aux,并且——在 biblatex 之下——把这条引用记进 .bcf,也就是 biblatex control file:一份 XML,逐条描述你设的每个选项、你引的每个条目、你的样式需要哪些字段,以及数据模型的版本号。这一整套能像一个系统那样工作、而不是三个程序互相讨价还价,靠的就是这个 .bcf。

    接着 biber 对着 .bcf 跑一遍。它读你的 .bib 文件、套用数据模型、拆分并排序姓名列表、解算 crossref 的父条目、分配标签姓名、执行消歧(uniquename、uniquelist)、按你的 sorting= 选项所选的模板给条目排序,最后写出一个 .bbl。在 biblatex 的世界里,.bbl 已经不是「一段参考文献文本」——它是机器生成的 LaTeX:每个条目一条 \bibitem,外加 \refsection 骨架和已经排好序、打好标签的字段数据。

    然后 LaTeX 把这个 .bbl 读回来。biber 之后的第一遍确定编号、标签和页码位置;还需要第二遍,因为文献表本身会改动分页,而每一条指向条目的 \ref 都是拿上一遍写下的东西来解析的。所以一篇带引用的文档,光命令行就是四遍:pdflatex、biber thesis、pdflatex、pdflatex。latexmk 会从依赖文件里自己把这件事推算出来,并用最少步数走完。

    两个实用推论,绝大多数惊慌提问都出自这里。其一,改 .bib 文件在 biber 重新跑过之前不会有任何可见变化——这套方案里 LaTeX 根本不读 .bib。其二,一旦 biber 失败,上一遍留下的旧 .bbl 还躺在那里,照样排出一份看着正确、其实悄悄错了的文献表;输出说不通时,删掉 .bbl 重建一次。

    The biblatex and biber pipeline: thesis.tex plus refs.bib produce a .bcf control file, biber writes a .bbl, and two further runs resolve labels and page numbers RUN 1 RUN 1 WRITES BIBER RUNS 2 AND 3 thesis.tex \autocite{einstein1916} \addbibresource{refs.bib} the .bib file is never opened here thesis.bcf XML: every option you set, every key you cited, the data model version, the sort spec biber thesis reads .bcf plus refs.bib, parses names, sorts labels, applies uniquelist rules thesis.bbl machine-generated LaTeX: \bibitem{einstein1916} plus the sorted field data run 2 reads the .bbl and prints the list; run 3 fixes the page numbers the list moved latexmk -pdf thesis.tex reads the backend from your \usepackage line, reruns until nothing changes pdflatex → biber thesis → pdflatex → pdflatex the same thing by hand: four commands, and biber takes the job name, not refs.bib WHAT GOES WRONG, AND WHERE empty list or [??] = biber never ran, or ran before the .bcf existed. stale list after editing the .bib = the .bbl is from the old run. "found biblatex 3.19, biber 3.18" = the pair was updated only halfway.
    .bcf 是给 biber 读的,.bbl 是 biber 写出来的;LaTeX 自始至终没看过 .bib 文件本身。

    biblatex 还是 bibtex:这是一个后端抉择

    两套系统从源码看长得差不多,底下毫无关系。经典的 bibtex 是一个独立程序,自带 1985 年那套语言(.bst 样式文件,写的是 PostScript 风味的栈代码),输入按 8 位编码假设,数据模型则是一组钉死的条目类型与字段。用它的方式是 \bibliographystyle{plainnat} 配 \bibliography{refs},作者-日期那类命令再交给 natbib 宏包。

    biblatex 加 biber 把这些整个换掉了:一份写明在文档里的数据模型,按类型区分必填与可选字段;Unicode 原生的输入;更多的条目类型(@online、@report、@dataset、@software、@unpublished);姓名列表能被正确地排序与消歧;排序模板、过滤器、分节与分段;带字段继承的交叉引用;样式用 LaTeX 写,而不是用栈语言写。往输出里加一个字段是十几行读得懂的代码,而不是在 .bst 里耗掉一整个下午。

    biblatex 确实接受 backend=bibtex,那是为还没移植过来的样式包留的兼容模式:它会静默关掉那些离不开 biber 的功能(排序、过滤器、扩展数据模型、姓名消歧),并不是「不用学 biber」的捷径。反过来的情形倒是正当的:许多期刊至今只发一份 .bst 并且强制使用,那时你该用 bibtex 或某个转换工具,而不是自己写的样式。

    按事实选,别按潮流选:样式由你或合作者掌控时,就用 biblatex 加 backend=biber。投稿对象发了 .bst 就照它办——同时给同一份 .bib 留一个 biblatex 版本用在学位论文里,因为 biblatex 需要的条目类型与额外字段是 bibtex 所能读的东西的超集,而一份朴素的 .bib 文件在两个世界里都能用。

    一遍就能过的最小配置

    五行就是能跑起来的核心。导言区写 \usepackage[backend=biber,style=numeric]{biblatex};用 \addbibresource{refs.bib} 声明数据库;正文里 \autocite{key};要放文献表的地方写 \printbibliography;再加一条会跑 biber 的构建命令。下面这份清单里其余的部分,属于口味、稳健性或期刊规范。

    这个内核里有三处细节,第一次尝试就死在它们身上。\addbibresource 要的是含扩展名的文件名——\addbibresource{refs} 并不是「一样的写法」,在旧版本里它会安静地什么也找不到。\addbibresource 也是 biblatex 的命令;\bibliography{refs} 是 bibtex 那一条,两者混用就得到那份经典的「一半管用」文档。还有,csquotes 是 biblatex 的硬依赖:不装它,加载时就会收到一条叫你去安装它的报错——这几乎是整个领域里唯一一条诚实说明成因的提示。

    然后是构建。用 latexmk 就一条命令:latexmk -pdf thesis.tex。较新的 latexmk 会从你的 \usepackage[backend=...]{biblatex} 那行读出后端,相应地去跑 biber 或 bibtex,并反复重跑引擎直到 .aux 不再变化;在 .latexmkrc 里写 $bibtex_use = 2,它还会顺手清理过期文件。手动跑的话,记住 biber 的参数是任务名而不是数据库名:biber thesis,不是 biber refs。要是你在第一遍 LaTeX 之前跑 biber,它会抱怨找不到 thesis.bcf——字面上完全属实,但第一次见都很费解。

    在 Overleaf 和多数编辑器里,引擎与文献处理器是个菜单选项;菜单写着 bibtex 而源码写着 biber 时,日志里出现的是 "Cannot find control file",或者一份每个条目都是 [??] 的文献表。在项目设置里定一次,并把它记进那份你声称永远不需要写的 README。

    P = p_{\mathrm{latex}} + b_{\mathrm{biber}} + p_{\mathrm{latex}} + p_{\mathrm{latex}} \qquad (\text{four runs, or one of latexmk})
    P = p_{\mathrm{latex}} + b_{\mathrm{biber}} + p_{\mathrm{latex}} + p_{\mathrm{latex}} \qquad (\text{four runs, or one of latexmk})
    \documentclass[a4paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{babel}
    \usepackage{csquotes}          % required by biblatex for quoted strings
    \usepackage[backend=biber,style=authoryear,
                giveninits=true,maxcitenames=2,maxbibnames=99,
                uniquename=init,doi=false,url=false,
                sorting=nyt]{biblatex}
    
    \begin{filecontents*}{refs.bib}
    @article{einstein1916,
      author  = {Einstein, Albert},
      title   = {Die Grundlage der allgemeinen Relativit{\"a}tstheorie},
      journal = {Annalen der Physik},
      volume  = {354},
      number  = {7},
      pages   = {769--822},
      date    = {1916},
      doi     = {10.1002/andp.19163540702},
    }
    @inproceedings{lambda2020,
      author    = {van der Waals, Johannes D. and Oseen, Carl W.},
      title     = {On the continuity of the gaseous state},
      booktitle = {Proceedings of the Section of Sciences},
      publisher = {KNAW},
      volume    = {23},
      pages     = {1--15},
      date      = {1920},
      options   = {useprefix=false},
    }
    @report{thesis2023,
      author      = {Doe, A. N.},
      title       = {A thesis with a very long subtitle},
      type        = {mastersthesis},
      institution = {University of Somewhere},
      date        = {2023},
      url         = {https://example.org/thesis},
    }
    \end{filecontents*}
    \addbibresource{refs.bib}       % the extension is part of the name
    
    \begin{document}
    As shown by \textcite{einstein1916}, the field equations follow from a
    variational principle \autocite[see][§~4]{lambda2020}. Later treatments
    \autocite{thesis2023,einstein1916} simplified the derivation.
    
    \printbibliography[heading=bibintoc]
    \end{document}

    样式选项:哪一个改的是哪一块

    style= 一次选定整副外观;发行版里的那四个是 numeric(编号,输出接近 IEEE 风味)、alphabetic(标签由姓名加年份数字拼出)、authoryear(正文里作者-日期、文献表悬挂缩进),以及面向人文学引用习惯的 authortitle 与 verbose 系列。CTAN 上的样式包还会追加:style=apa 来自 biblatex-apa,还有 style=ieee、style=nature、biblatex-chem 的 chem-angew、biblatex-chicago 的 Chicago 样式。安装宏包不是可选项——样式名本身就是一次文件查找。

    citestyle= 和 bibstyle= 把这个选择拆成两半:前者管正文里一条引用长什么样,后者管文献表长什么样。citestyle=authoryear,bibstyle=numeric 是一个真实存在、偶尔还被要求的组合,而且它比自己去写引用宏包改动小得多。

    姓名缩写是一族选项,值得一次学透:maxcitenames 与 mincitenames 决定引用里何时出现「以及他人」(排成 et~al.),maxbibnames 与 minbibnames 在文献表里干同样的事,giveninits=true 把名缩成首字母(更早那对 firstinits/giveninits 已经废弃,统一用 giveninits 这个拼法),而 uniquename 加 uniquelist 会把原本让两部不同作品撞脸的姓名重新展开。后一对就是「为什么这一条印 J. Smith、那一条印 John Smith」的原因,而且它是功能不是缺陷——想让文献表里的姓名保持固定,就设 uniquelist=false。

    再往后是决定这份文档能不能交印的那些开关:doi=false,url=false,eprint=false 砍掉链接噪声,urldate=comp 管访问日期,date=short 或 date=comp 管日期样式,defernumbers=true 让编号表被过滤之后不必重新编号,backref=true 给「被引页码回指」(那就别再向 hyperref 另要一份 backref),sortcites=true 让同一条引用里的多个键先排序,以及 sorting=nty(默认顺序:姓名、标题、年份)、ynt(年份打头,用于按时间排的表)与 none(按引用次序,配 style=numeric 的常规选择)之间的差别。留意 sorting 属于引用上下文这一层:有多个文献表的文档要逐上下文设它,光靠宏包选项不够。

    \documentclass[a4paper]{book}
    \usepackage{babel,csquotes}
    \usepackage[backend=biber,style=numeric,
                sorting=none,            % order of appearance, not alphabetical
                defernumbers=true,       % numbers assigned when the bib is printed
                maxbibnames=4,uniquelist=false,
                pagetitle=false]{biblatex}
    \usepackage{hyperref}          % biblatex first, hyperref after it
    \addbibresource{sources.bib}
    \addbibresource{more-sources.bib}    % several files are fine, order matters
    
    \DefineBibliographyStrings{english}{%
      bibliography = {Sources and further reading},
      andothers  = {et al\adddot},
    }
    
    \begin{document}
    \chapter{Introduction}
    Text \cite{a1} then \cite{b7} then \cite{c3}.
    
    % Two lists, filtered by keyword, each with its own heading.
    \printbibliography[heading=subbibliography,title={Primary sources},
                       keyword=primary]
    \printbibliography[heading=subbibliography,title={Methods},
                       keyword=method,notkeyword=primary]
    
    % One list for the whole book, put it at the end instead of per chapter:
    % \backmatter \printbibliography[heading=bibintoc]
    \end{document}

    引用命令家族,各自印出什么

    \textcite{einstein1916} 把作者嵌进句子的语法里——「Einstein (1916) 指出……」;\parencite{...} 给括号形式,\footcite{...} 给脚注形式,\supercite{...} 给物理学里常见的上标编号。通用命令是 \autocite{...},它的具体行为由 autocite= 映射而来:autocite=inline 让它成为括号引用,autocite=footnote 让它进脚注,autocite=superscript 让它成为上标数字。通篇只写 \autocite、要换风格时改一次映射,代价是两分钟;否则就是一次全局查找替换。

    两个可选参数每条引用命令都支持,而它们的顺序常出人意料:\autocite[see also][§~4]{lambda2020} 会把第一个方括号印在引用之前、第二个印在之后。前者是 prenote、后者是 postnote,这也是「把页码写进错的那一格」成为高频错误的原因。

    一条引用可以同时点多个键——\autocite{a1,b7,c3}——结果取决于 sortcites 与 nameyeardelim;在 style=numeric 下你会拿到一个压缩过的编号列表。要让某个条目进表却不必真去引它,用 \nocite{key},或者用 \nocite{*} 一次全取——这是通读一份文献库最快的办法,也是一不小心排出十四页参考书目最快的办法。

    还有一类「同一作者」的行为,人人见过却叫不出名字:dashed=true 会在文献表里把重复出现的作者换成一条破折号(它还会与 uniquelist 相互作用),ibidtracker、pagetracker 与 labeldate 管的则是人文学「紧凑地重复同一条引用」的惯例。在 verbose 样式里这些是承重的;在 authoryear 里你多半希望它们关掉,而样式本来就已经替你关好了。

    \mathrm{authors}(e) > m_{\mathrm{cite}} \;\Longleftrightarrow\; \text{et al.}, \qquad m_{\mathrm{cite}} = 3
    \mathrm{authors}(e) > m_{\mathrm{cite}} \;\Longleftrightarrow\; \text{et al.}, \qquad m_{\mathrm{cite}} = 3

    .bib 文件、姓名,以及排序键是怎么生成的

    数据模型才是它与 bibtex 真正的分水岭:每种条目类型都有必填、可选与禁止的字段,而 biber 会照着它做校验。日期是一个 date={1916-07} 字段,不再是 year 加 month,而且可以写成区间(date={2019-03/2019-05})或残缺日期。@online 要的是 url 和 urldate;@report、@thesis、@dataset 都是正经存在的类型,学位论文的文献表该用它们,而不是把 @misc 用到烂。条目级的 langid 能让一份多语种文献表排得对、断字也断得对。

    姓名按 and 这个词切分,每个姓名在两逗号形式里是 Last, First, Junior, von,在直接形式里是 First Last。小写的介词被当作姓的一部分,而且默认不参与排序:「van der Waals」排在 W 下面。控制手段有两个:全局选项 useprefix,以及条目级的 options = {useprefix},它会让这条排到 van 底下;花括号则钉住解析——{van der Waals}, J. 把整串当作一个完整姓氏,J. {van der Waals} 把介词留在名的那一半。花括号写一次,biber 就不必再猜。

    排序时 biber 造的姓名列表与用于打印的是分开的:sortname、sortkey、sortyear、sorttitle 都能在条目里显式给出,用来覆盖打印字段所暗示的顺序——笔名作品按真实作者排序就是这么做的——而生成它们的模板可以用 \DeclareSortingTemplate 和 \DeclareSortingNamekeyTemplate 重定义。presort 字段是个值得知道的便宜招:它排在一切之前,所以一个以 zz 打头的值就能把条目推到它所在分组的最末尾。

    有一件常被用错名字去找的事:biblatex 里没有 dataauthor-raw 这个开关。姓名数据会被归一化成一串列表分量;真正存在的「原始值与显示值」之分是按字段的——urlraw 存的是未编码的 URL,用于「印出来的文字」与「可点击的目标」必须不同那一例;fullhash 连同 fullhashraw(以及各姓名列表自己的 <namelist>fullhashraw 变体)才是 uniquelist 与 uniquename 算法实际比对的那些哈希。如果你的问题是「作者列表印出来的和文件里不一样」,该拧的扳手是 uniquelist、uniquename、dashed 和那几个姓名格式声明,而不是某个原始数据选项。

    \mathrm{sortkey}(e) = \bigl(\rho_{\mathrm{sort}}(e),\; y(e),\; \tau(e)\bigr) \quad \mathrm{nty} \ne \mathrm{ynt}
    \mathrm{sortkey}(e) = \bigl(\rho_{\mathrm{sort}}(e),\; y(e),\; \tau(e)\bigr) \quad \mathrm{nty} \ne \mathrm{ynt}
    From one .bib entry to one printed line: the data model, biber sorting keys and label allocation, the entry type driver, and the field formats and delimiters that produce the text ONE ENTRY, FIVE STAGES @article in refs.bib author = {van der Waals, J. and Oseen, C}, title = {On the continuity ...}, date = {1920-06}, volume = {23}, options = {useprefix} one date field, names split on "and" biber: parse and normalise name list into parts: prefix={van der} last={Waals} sortname, sortkey, presort built; labelname allocated, uniquelist and uniquename compared the .bbl it writes sorted, labelled, and already filtered to what you cited \bibitem{waals1920} \name{author}{2}{...}{...} LaTeX reads this, never the .bib the driver for this entry type \DeclareBibliographyDriver{article}{ ... } \usebibmacro{author}\newunit\newblock \usebibmacro{title} ... \finentry what the driver is allowed to call \DeclareNameAlias{sortname}{family-given} \DeclareFieldFormat[article]{title}{\mkbibemph{#1}} \DeclareDelimFormat[bib]{finalnamedelim}{\addspace\&\space} name formats, field formats, delimiters, bibstrings printed result van der Waals, J. and C. Oseen (1920). “On the continuity of the gaseous state”. In: 23, pp. 1–15. sorted under V because useprefix is on; quotes from the title field format; the ampersand from the delimiter declaration.
    从一条记录到印出来的一行:解析、排序键、分配标签,最后由条目类型驱动把字段排成版式。
    \documentclass[a4paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{babel}
    \usepackage{csquotes}          % required by biblatex for quoted strings
    \usepackage[backend=biber,style=authoryear,
                giveninits=true,maxcitenames=2,maxbibnames=99,
                uniquename=init,doi=false,url=false,
                sorting=nyt]{biblatex}
    
    \begin{filecontents*}{refs.bib}
    @article{einstein1916,
      author  = {Einstein, Albert},
      title   = {Die Grundlage der allgemeinen Relativit{\"a}tstheorie},
      journal = {Annalen der Physik},
      volume  = {354},
      number  = {7},
      pages   = {769--822},
      date    = {1916},
      doi     = {10.1002/andp.19163540702},
    }
    @inproceedings{lambda2020,
      author    = {van der Waals, Johannes D. and Oseen, Carl W.},
      title     = {On the continuity of the gaseous state},
      booktitle = {Proceedings of the Section of Sciences},
      publisher = {KNAW},
      volume    = {23},
      pages     = {1--15},
      date      = {1920},
      options   = {useprefix=false},
    }
    @report{thesis2023,
      author      = {Doe, A. N.},
      title       = {A thesis with a very long subtitle},
      type        = {mastersthesis},
      institution = {University of Somewhere},
      date        = {2023},
      url         = {https://example.org/thesis},
    }
    \end{filecontents*}
    \addbibresource{refs.bib}       % the extension is part of the name
    
    \begin{document}
    As shown by \textcite{einstein1916}, the field equations follow from a
    variational principle \autocite[see][§~4]{lambda2020}. Later treatments
    \autocite{thesis2023,einstein1916} simplified the derivation.
    
    \printbibliography[heading=bibintoc]
    \end{document}

    多个文献表、过滤器与分节文献表

    学位论文常常不止需要一份表:资料来源与延伸阅读、已引与未引、按章节排的论著清单。biblatex 为此给了三种机制。引用分段(宏包选项 refsection=section,或者 \newrefsegment)在大家共用一个数据库的前提下把文档切开,于是每一段得到属于自己的那份子集。引用分节(\newrefsection,或者 env/type 那套机制)则是一个真正独立的上下文,有自己的 .bbl 片段、自己的排序与编号环境——附录里那份规则不同的文献表要的就是它。

    过滤是在 \printbibliography 的选项上完成的:keyword=primary、notkeyword=...、category=...、type=book,或者用 \defbibcheck{mine}{...} 再加一个 check=mine 选项手工圈一份。关键词来自条目本身(keywords = {primary, method}),类别则用 \DeclareBibliographyCategory 声明、在正文里用 \addbibcategory 指派——想让「本章引到的软件」那张表始终准确而又不必去编辑数据库,走的正是后面这条路。

    每份印出来的表还能各自带自己的选项:先 \printbibheading,再反复调用 \printbibliography[segment=...,heading=subbibliography,title=...];标题的处理也能选:heading=none、heading=bibintoc(把它写进目录)、heading=bibnumbered,或者干脆用你自己拟的标题。表上方的引语与表下方的说明来自 \defbibnote{⟨name⟩}{⟨text⟩},配上 prenote= 和 postnote=——「下列清单不含专利」这句话该待在这儿,而不是随手一段正文,等表挪去下一页时它就被孤儿地留下了。

    如果某个编号样式在两表之间看着不对劲,那就是 defernumbers 的事:设成 false 时,编号按引用次序全局分配;设成 true 时,编号在文献表被印出那一刻才分配——条目要过滤进好几份表时,你要的就是它。再叠上按节编号与 labelprefix,结果的区别就是「1–47 接着 48–52」与「两份表各自从 1 数起」。

    \rho_{i} \equiv \rho_{j} \;\Longleftrightarrow\; \text{uniquename widens one of the two labels}
    \rho_{i} \equiv \rho_{j} \;\Longleftrightarrow\; \text{uniquename widens one of the two labels}

    文献表空着、过期或者错了的时候

    "There were undefined references" 再配正文里的 [??]:biber 没跑、没跑成,或者跑在了 .bcf 存在之前。按上面的顺序构建,然后把 .bbl 与 .bcf 删掉重建一次,免得你对着一个过期产物讲道理。"Citation 'key' on page 1 undefined":键拼错了,或者那份 .bib 不是你添加的那份——核对 \addbibresource 给出的文件是否是相对主文档存在的路径;数据库放在子目录里时,本地构建与 Overleaf 构建的差别恰恰就在这儿。

    "XML schema validation failed: found biblatex 3.19, this provides no support for biber with version 3.18" 是版本不匹配,而它几乎总来自一次半截更新:biblatex(一个 LaTeX 宏包)与 biber(一个程序)是同步发布的,只升其中一个就会把这一对拆散。TeX Live 上要把整个发行集合一起升,MiKTeX 上则要把安装的两半都升,共享服务器上则用 which biber 和 kpsewhich biblatex.sty 确认你的 PATH 找到的到底是哪一个。

    biber 关于某个字段发来的警告——Cannot use style…、labelname missing、Duplicate keys、Bad year——才是有用的那批,它们指向的是数据库而不是你的源码。重复键是按「后来者胜」安静解决的,于是两条同键记录只会产出一条文献表条目,而引用会落到你并不想要的那一条上。对可疑文件跑一次 biber --tool:工具模式会把整份库重新输出一遍,排序、去重、姓名归一化全都做完,一小时的瞎猜就此变成一份可以逐行对照的差异输出。

    条目印出来了、某个字段却不见了,说的是数据模型而不是你的语法:一个字段能被印出来,得同时满足「样式的驱动问了它」和「这个类型允许有它」。先确认样式是否为该类型打印该字段(许多样式在文章条目里会忽略 note),然后加一个自己的驱动或字段格式,而不是把条目改成 @misc 去硬逼它现身。这一块最后一个咬人的是陈旧的 .run.xml 配上 latexmk:改过 backend 之后,把辅助文件清掉一次,因为 latexmk 还记得上一回的构建图。

    本课速查

    每节抽一行关键代码:点小节名跳到对应位置,代码一键复制。

    小节 关键代码
    \documentclass[a4paper]{article}
    \documentclass[a4paper]{book}
    \mathrm{authors}(e) > m_{\mathrm{cite}} \;\Longleftrightarrow\; \text{et al.}, \qquad m_{\mathrm{cite}} = 3
    \rho_{i} \equiv \rho_{j} \;\Longleftrightarrow\; \text{uniquename widens one of the two labels}

    常见错误

    • 跑 biber refs.bib。参数给的是任务名(biber thesis),因为 biber 读的是 thesis.bcf,它从不直接读数据库。
    • \addbibresource{refs} 少写了扩展名,或者把 bibtex 的 \bibliography{...} 混进一份 biblatex 文档,然后纳闷为什么只出现一半条目。
    • 改了 .bib 就只重编译一遍:LaTeX 从不读 .bib 文件,所以在 biber 跑过、引擎把新的 .bbl 读满两遍之前,什么都不会变。
    • 把输出里的 [??] 当成样式问题,其实它是构建顺序问题;或者一次半截 TeX 更新之后,biber 与 biblatex 的版本已经对不上。
    • 让「van der Waals」排在 W 下面,再用把姓名改写成 Waals, J. van der 的法子去「修」它:真正的开关是 useprefix 和花括号,而这个土办法会毁掉印出来的形式。
    • 过滤出多个编号文献表时却留着 defernumbers=false,于是第二个表从 48 开始。
    • 把文档发给一个不跑 biber 的期刊却没带上 .bbl,然后和排版编辑争辩这份「在我机器上明明是好的」参考书目。

    关于本课的常见问题

    一定要 biber 吗,bibtex 够不够用?
    只要你用 biblatex 挑样式,就该用 biber:它跑在 backend=bibtex 下时会悄悄丢掉排序、过滤器、扩展数据模型和姓名消歧。期刊给了 .bst 文件,那是 bibtex 的流程,你照它办就行。两者能读同一份 .bib,所以数据库按超集那套写,换后端而不是改条目。
    我明明引了,为什么 LaTeX 的参考文献是空的?
    几乎总是构建顺序,或者 biber 那一步失败了:LaTeX 要的是 biber 写出的 .bbl,而 biber 要的是第一遍 LaTeX 写出的 .bcf。跑一遍编译、再跑 biber、再连跑两遍编译,或者整件事交给 latexmk 去做。还不行就删掉 .bbl、.bcf、.aux 再重建一次,别让过期文件误导你。
    addbibresource 和 bibliography 有什么区别?
    它们分属两套系统。\bibliography{refs} 是经典的 bibtex 命令,收的是不带扩展名的名字;\addbibresource{refs.bib} 是 biblatex 命令,必须要扩展名,可以重复给出,还能带 location=remote 这样的选项。用错那一条,你会得到一份编译通过、却印出错表或者干脆不印的文档。
    biblatex 怎么从 numeric 换成作者-年份?
    改宏包选项:用 style=authoryear 取代 style=numeric;若只想改一半,就用 citestyle= 和 bibstyle= 把它拆开。然后用 latexmk 重跑构建,因为标签是在 biber 里分配的,旧的 .bbl 里还留着编号标签。
    biber 为什么报版本不匹配?
    biblatex 和 biber 是一起发布、并且互相校验的。发行版半截更新、编辑器指向一个旧二进制、或者 Overleaf 的编译版本被冻结,都会让这一对脱节。把两半都更新,再用 which biber 和 kpsewhich biblatex.sty 确认它们出自同一份安装。
    投稿时要不要连 .bbl 一起交?
    对方不跑 biber 时就要,而多数期刊仍然不跑。.bbl 是机器生成的 LaTeX,里面就是那份成形的参考书目,有了它,编辑看到的正是你的文献表,也不必再运行任何文献处理程序。最后一次引用改动之后再重新生成它。

    实时演示:直接编辑 LaTeX,立刻看渲染结果

    预览随输入实时更新——不妨故意写坏一次,看看报错长什么样。

    KaTeX 错误
    试一个例子

    继续读

    同一个东西的三个入口:记法本身、讲它的那一课、以及真正用它写东西的一篇文章。