跳到主要内容

BibLaTeX 使用指南

BibLaTeX 是现代 LaTeX 文献管理的标准解决方案,配合 Biber 后端使用,提供更强大的功能和更灵活的自定义选项。本章介绍 BibLaTeX 的完整用法。

为什么选择 BibLaTeX?

BibLaTeX vs BibTeX

特性BibTeXBibLaTeX + Biber
后端程序bibtexbiber
文献样式.bst 文件(难修改)LaTeX 宏(易修改)
Unicode 支持有限完整支持
条目类型固定可扩展
字段自定义不支持完全支持
多文献库不支持支持
引用追踪backref
分类筛选不支持支持

基本配置

宏包加载

% 基本配置
\usepackage[
backend=biber, % 使用 Biber 作为后端
style=numeric, % 引用样式
sorting=none, % 排序方式
]{biblatex}

% 添加文献数据库
\addbibresource{references.bib}

完整配置示例

\usepackage[
backend=biber,
style=numeric-comp, % 压缩数字引用 [1-3]
sorting=nyt, % 按姓名-年份-标题排序
sortcites=true, % 引用时排序
maxbibnames=3, % 最多显示3个作者
minbibnames=1, % 最少显示1个作者
giveninits=true, % 名字使用首字母
uniquename=init, % 唯一姓名区分
date=year, % 只显示年份
url=false, % 不显示 URL
doi=true, % 显示 DOI
isbn=true, % 显示 ISBN
backref=true, % 显示引用页码
]{biblatex}

\addbibresource{references.bib}

BIB 文件格式

文件示例

% references.bib

@article{einstein1905,
author = {Einstein, Albert},
title = {On the Electrodynamics of Moving Bodies},
journal = {Annalen der Physik},
year = {1905},
volume = {17},
pages = {891--921},
doi = {10.1002/andp.19053221004},
}

@book{knuth1984,
author = {Knuth, Donald E.},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1984},
isbn = {0-201-13447-0},
}

@inproceedings{vaswani2017,
author = {Vaswani, Ashish and others},
title = {Attention Is All You Need},
booktitle = {Advances in Neural Information Processing Systems},
year = {2017},
volume = {30},
pages = {5998--6008},
}

@online{overleaf2024,
author = {{Overleaf Team}},
title = {Bibliography Management with BibLaTeX},
year = {2024},
url = {https://www.overleaf.com/learn/latex/bibliography_management_with_biblatex},
urldate = {2024-01-15},
}

常用条目类型

类型用途必需字段
@article期刊文章author, title, journal, year
@book书籍author, title, publisher, year
@inproceedings会议论文author, title, booktitle, year
@incollection书籍章节author, title, booktitle, year
@thesis学位论文author, title, type, institution, year
@online网络资源author, title, url, year
@report技术报告author, title, institution, year

引用命令

基本引用

% 标准引用
\cite{einstein1905} % [1]

% 带页码引用
\cite[页~42]{knuth1984} % [2, 页 42]
\cite[见][第~3章]{knuth1984} % [见 2, 第 3章]

% 文本形式引用
\parencite{einstein1905} % (Einstein, 1905)
\textcite{einstein1905} % Einstein [1] 或 Einstein (1905)

% 脚注引用
\footcite{knuth1984} % 在脚注中显示引用

% 完整引用
\fullcite{einstein1905} % 显示完整文献信息

多文献引用

% 多个引用
\cite{einstein1905, knuth1984, vaswani2017} % [1, 2, 3]

% 压缩范围引用(需 style=numeric-comp)
\cite{ref1, ref2, ref3, ref4, ref5} % [1-5]

特殊引用命令

% 作者姓名
\citeauthor{einstein1905} % Einstein
\citeauthor*{einstein1905} % Albert Einstein(全名)

% 年份
\citeyear{einstein1905} % 1905

% 标题
\citetitle{einstein1905} % On the Electrodynamics...

% URL
\citeurl{overleaf2024} % 显示 URL

命令对照表

命令数字样式输出作者-年份样式输出
\cite[1]Einstein, 1905
\parencite[1](Einstein, 1905)
\textciteEinstein [1]Einstein (1905)
\citeauthorEinsteinEinstein
\citeyear19051905
\fullcite完整文献条目完整文献条目

引用样式

内置样式

% 数字样式
\usepackage[style=numeric, backend=biber]{biblatex} % [1]
\usepackage[style=numeric-comp, backend=biber]{biblatex} % [1-3]

% 作者-年份样式
\usepackage[style=authoryear, backend=biber]{biblatex} % (Smith 2020)
\usepackage[style=authoryear-comp, backend=biber]{biblatex}

% 特殊领域样式
\usepackage[style=apa, backend=biber]{biblatex} % APA 格式
\usepackage[style=ieee, backend=biber]{biblatex} % IEEE 格式
\usepackage[style=chicago-authordate, backend=biber]{biblatex}

中文文献样式

% 使用 biblatex-gb7714 样式(推荐)
\usepackage[
backend=biber,
style=gb7714-2015, % GB/T 7714-2015 标准
gbpub=false, % 不显示出版项缺失标记
]{biblatex-gb7714}

样式选项详解

\usepackage[
backend=biber,
style=authoryear,

% 排序选项
sorting=nyt, % name-year-title
sorting=ynt, % 按年份、姓名、标题排序
sorting=none, % 按引用顺序

% 姓名显示
maxbibnames=99, % 参考文献中最大作者数
minbibnames=3, % 截断后显示的作者数

% 日期格式
date=year, % 只显示年份
date=comp, % 完整日期

% 其他选项
backref=true, % 反向引用
]{biblatex}

Biber 编译流程

标准编译流程

# 完整编译流程
xelatex main.tex # 第一次编译,生成 .bcf 文件
biber main # Biber 处理文献(无需扩展名)
xelatex main.tex # 第二次编译,插入文献引用
xelatex main.tex # 第三次编译,更新交叉引用

latexmk 自动编译

# 使用 latexmk 自动处理编译流程
latexmk -xelatex main.tex

# 持续编译模式
latexmk -pvc -xelatex main.tex

编译问题排查

# 查看详细错误信息
biber --debug main

# 检查 Biber 输出
biber main --output-log=biber.log

高级功能

多文献库

\addbibresource{main.bib}
\addbibresource{secondary.bib}
\addbibresource{https://example.org/refs.bib} % 远程文件

文献分类

% 定义分类
\DeclareBibliographyCategory{primary}
\DeclareBibliographyCategory{secondary}

\addtocategory{primary}{einstein1905, knuth1984}

% 分别输出
\printbibliography[category=primary, title={主要参考文献}]
\printbibliography[category=secondary, title={次要参考文献}]

按类型输出

\printbibliography[type=article, title={期刊论文}]
\printbibliography[type=book, title={书籍}]
\printbibliography[type=inproceedings, title={会议论文}]

筛选器

% 定义筛选器
\defbibfilter{online}{type=online}
\defbibfilter{published}{not type=online}

\printbibliography[filter=online, title={网络资源}]

自定义样式

修改分隔符

% 多引用用分号分隔
\renewcommand*{\multicitedelim}{\addsemicolon\space}

% 标题前冒号
\renewcommand*{\intitlepunct}{\addcolon\space}

修改字符串

\DefineBibliographyStrings{english}{
andothers = {et al.}, % 将 "and others" 改为 "et al."
references = {References}, % 标题
}

% 中文字符串
\DefineBibliographyStrings{chinese}{
andothers = {等},
references = {参考文献},
}

自定义字段格式

% 文章标题斜体
\DeclareFieldFormat[article]{title}{\mkbibemph{#1}}

% 书籍标题加粗
\DeclareFieldFormat[book]{title}{\mkbibbold{#1}}

迁移指南

从 BibTeX 迁移到 BibLaTeX:

% 旧代码
% \bibliographystyle{plain}
% \bibliography{references}

% 新代码
\usepackage[backend=biber, style=numeric]{biblatex}
\addbibresource{references.bib}

% 文档末尾
\printbibliography

完整示例

\documentclass[UTF8]{ctexart}

\usepackage[
backend=biber,
style=numeric-comp,
sorting=none,
]{biblatex}
\addbibresource{references.bib}

\title{示例文档}
\author{作者}
\date{\today}

\begin{document}

\maketitle

\section{引言}

这是引用示例 \cite{einstein1905}。
详细的介绍见文献 \cite{knuth1984}。

\printbibliography

\end{document}

编译命令:

xelatex document.tex
biber document
xelatex document.tex
xelatex document.tex

参考资源