Latex 自定义参考文献格式(配置 bst)

这几天在 Latex 写作过程中遇到了一点困难,源自于 “论文必须和期刊最终排版一模一样” 的需求。按道理讲,我们在提交手稿时只需要照着期刊给定的模板写即可,但有些出版社在初稿提交和终稿出版时会给出不同的模板,这种情况下,论文很难完成一模一样的表现形式。为了克服这一困难,就不得不从 Latex 底层库开始摸索,这篇博客就从参考文献格式将起,我们通过个性化配置 bst 文件来控制参考文献格式

1. 一个简单的例子

在我们使用 Latex 撰写论文的过程中,往往是通过 bib 文件来管理我们的文献。当我们需要在正文中引用某篇文献时,会尝试使用 \cite 或者 \citep 来引用它。一个简单的例子如下所示,

STEP-1: 首先在 bib 文件中贴上我们需要的论文格式(可以在 谷歌学术 或者 dblp 上下载)。

@inproceedings{Ren2018Automated,
author = {Zhilei Ren and
He Jiang and
Jifeng Xuan and
Zijiang Yang},
title = {Automated localization for unreproducible builds},
booktitle = {Proceedings of the 40th International Conference on Software Engineering,
{ICSE} 2018, Gothenburg, Sweden, May 27 - June 03, 2018},
pages = {71--81},
year = {2018},
url = {https://doi.org/10.1145/3180155.3180224},
doi = {10.1145/3180155.3180224},
timestamp = {Mon, 26 Nov 2018 12:14:46 +0100},}

【注意】这里的 @inproceedings 标记的是会议论文,期刊,书籍等其他的元素要标记为 @article 和 @book 等,详情请参见博客 《BibTeX Style Examples》

STEP-2: 在 tex 文件中引入我们的 bib 文件,一般在正文的最末尾,也就是 \end{document} 之前。

\bibliography{references}
\bibliographystyle{ieeetr}

【注意】第一行的 \bibliography{} 指定了 bib 文件,第二行 \bibliographystyle{} 指定了文献引用格式,如 ieeetr 是 IEEE 的文献引用格式。具体的格式可以在我们安装的 CTEX 目录下可以找到,其中有几个基本的引用格式,如打开下面的路径,可以找到 7 个最常见的格式,具体的格式介绍请参考文档 《Bibtex bibliography styles》

> cd C:/CTEX/MiKTeX/bibtex/bst/base/

STEP-3: 在正文中使用 \cite{Ren2018Automated} 来引用,只有引用了这篇文献,在 Reference 中才会出现这篇文献。如下图所示,前面的 39 表示文献的号码。

2. 控制参考文献格式

论文模板中包含多个文件,但是最核心的只有 cls 和 tex 文件。如 IEEE 的模板 中,只有 IEEEtran.clsconference_041818.tex 这两个文件起关键作用,前者规定了论文格式类库,即 \documentclass{} 中规定的东西;后者给出了我们写论文的文档。

这里有一个细节我们容易忽略,那就是引用文献的格式。之前的 cls 文件只能规定我们正文应该长什么样(如图标,标题,单双栏等),但是控制不了我们的参考文献长什么样。如果要更进一步需要控制参考文献的格式,就需要手动配置 bst 文件了。 这里给出另外一篇介绍 bst 文件的博客 《Latex 自定义bst文件》,个人觉得也还不错,以下我同样分三步来介绍 bst 文件的格式配置。

STEP-1: 找到 makebst 文件。makebst 文件位于我们的 CTEX 的目录下 custom-bib 文件夹里,比较难找。

> cd C:/CTEX/MiKTeX/tex/latex/custom-bib/

STEP-2: 命令行执行命令。键盘输入 Win + R,然后键入 cmd 进入到命令行界面。此时输入命令进入交互界面,

> latex makebst

在此界面中,只需要输入 yes 或者 no 来依次完成各种格式设置,如参考文献编号,作者姓名缩写,标题大小写格式,句号冒号的使用等。【注意】这一交互的过程会比较漫长,大概需要我们手动回答 yes 和 no 多达 60-70 次。我暂时也没想到其他比较好的方法。

STEP-3: 回答问题 yes 和 no。这一阶段程序会不断的抛出问题,我们只需要根据需求选择其中的某个选项即可,以下有选择性的介绍几个格式设置,

  1. 是否需要在 bst 文件中增加描述信息?我们选择输入 yes。
It makes up a docstrip batch job to produce 
a customized .bst file for running with BibTeX 
Do you want a description of the usage? (NO) 

\yn=
  1. 此程序会以交互式的方式来对格式进行设定。在每个问题后都有几个选项,* 表示默认选项,直接回车 Enter 也会选择默认选项。此处需要我们输入 MASTER 文件,我们直接回车,选择默认选项。
In the interactive dialogue that follows,
you will be presented with a series of menus.
In each case, one answer is the default, marked as (*),
and a mere carriage-return is sufficient to select it.
(If there is no * choice, then the default is the last choice.)
For the other choices, a letter is indicated
in brackets for selecting that option. If you select
a letter not in the list, default is taken.

The final output is a file containing a batch job
which may be (La)TeXed to produce the desired BibTeX
bibliography style file. The batch job may be edited
to make minor changes, rather than running this program
once again.

Enter the name of the MASTER file (default=merlin.mbs)

\mfile=
  1. 此处我们要输入 bst 文件的名字,如 yongfeng0119.bst。
Name of the final OUTPUT .bst file? (default extension=bst)

\ofile=
  1. 文献引用风格,默认选项表示采用数字标识,其余的 a 表示用“作者-年” 来表示,b 表示“作者年代”来表示,等。我们选择默认选项。
<<STYLE OF CITATIONS:
(*) Numerical as in standard LaTeX
(a) Author-year with some non-standard interface
(b) Alpha style, Jon90 or JWB90 for single or multiple authors
(o) Alpha style, Jon90 even for multiple authors
(f) Alpha style, Jones90 (full name of first author)
(c) Cite key (special for listing contents of bib file)
  Select:

\ans=
  1. 文献引用形式。默认选项表示引用字体为正常字体,b 选项表示 html 超文本链接格式,等。我们选择默认选项。
<<HTML OUTPUT (if non author-year citations)
(*) Normal LaTeX output
(h) Hypertext output, in HTML code, in paragraphs
(n) Hypertext list with sequence numbers
(k) Hypertext with keys for viewing databases
  Select:

\ans=
  1. 设置语言连字模式,我们选择默认选项
<<LANGUAGE FIELD
(*) No language field 
(l) Add language field to switch hyphenation patterns temporarily
  Select:

\ans=
  1. 参考文献顺序,默认选项按照英文字母顺序 a-z 来给参考文献排序,若有中文文献,则将其放到首位;c 选项按照文中引用的次序来给参考文献排序;d 选项首先按照年限,再按照作者名字来排序;f 选项排序顺序与 d 相反。我们选择 c。
<<ORDERING OF REFERENCES (if non-author/year and non-alph)
(*) Alphabetical by all authors 
(c) Citation order (unsorted, like unsrt.bst)
(d) Year ordered and then by authors
(r) Reverse year ordered and then by authors
  Select:

\ans=c
  1. 规定作者名字排序方法,默认选项 von part 貌似是德语,大概意思是将名字分开起来比较,如 “de la Maria” 在 “Defoe” 前面,因为 “de” 后面没东西了;x 选项则是将名字混合比较,如 “de la Maire” 在 “Mahone” 后面,因为 “Mahone” 比 “Maire” 小。这里我们选择默认选项。
<<ORDER ON VON PART (if not citation order)
(*) Sort on von part (de la Maire before Defoe)
(x) Sort without von part (de la Maire after Mahone)
  Select:

\ans=
  1. 规定作者姓名的书写方式。这里有很多种,如名在前,姓在前,名字缩写,缩写打点号,等。这里我们选择 s,即姓在前,名在后,且名字缩写不打点。
<<AUTHOR NAMES:
(*) Full, surname last (John Frederick Smith)
(f) Full, surname first (Smith, John Frederick)
(i) Initials + surname (J. F. Smith)
(r) Surname + initials (Smith, J. F.)
(s) Surname + dotless initials (Smith J F)
(w) Surname + comma + spaceless initials (Smith, J.F.)
(x) Surname + pure initials (Smith JF)
(y) Surname + comma + pure initials (Smith, JF)
(z) Surname + spaceless initials (Smith J.F.)
(a) Only first name reversed, initials (AGU style: Smith, J. F., H. K. Jones)
(b) First name reversed, with full names (Smith, John Fred, Harry Kab Jones)
  Select:

\ans=x
  1. 作者姓名间隔的符号。默认选项表示作者间用逗号 , 间隔,s 表示作者间用分号 ; 间隔,h 表示作者间用反斜杠 / 间隔。这里我们选择默认选项。
<<PUNCTUATION BETWEEN AUTHOR NAMES:
(*) Author names separated by commas
(s) Names separated by semi-colon
(h) Names separated by slash /
  Select:

\ans=
  1. 相邻文献作者的格式。如果相邻的几篇参考文献的作者一模一样,默认选项表示列出全部作者,d 选项表示后续文献用短横线 - 来表示作者,2 和 3 选项表示用 2 个或 3 个短横线来表示作者。这里我们选择默认选项。
<<ADJACENT REFERENCES WITH REPEATED NAMES:
(*) Author/editor names always present 
(d) Repeated author/editor names replaced by dash 
(2) Repeated author/editor names replaced by 2 dashes 
(3) Repeated author/editor names replaced by 3 dashes 
  Select:

\ans=
  1. 规定作者的数目。默认选项表示在参考文献中,出现全部作者列表。l 表示只列出部分作者姓名,其余作者用 et al 符号来代替。这里我们选择 l 选项。
<<NUMBER OF AUTHORS:
(*) All authors included in listing
(l) Limited authors (et al replaces missing names)
  Select:

\ans=
  1. 规定最多和最少的作者个数。直接填数字即可。
>>NUMBER OF AUTHORS IN BIBLIOGRAPHY:
Maximum number of authors (1-99)
\num= 

Minimum number (before et al given) (1-99)
\num=
  1. 规定作者缩列表的缩写格式。默认选项表示只写一个作者,m 选项表示有其他的方案。这里我们选择 m
<<AUTHORS IN CITATIONS:
(*) One author et al for three or more authors
(m) Some other truncation scheme
  Select:
  
\ans
  1. 规定作者列表的缩写格式。默认选项表示在 “et al” 前只写一个作者,2-6 选项分别表示写 2-6 个作者名字。
<<MAX AUTHORS BEFORE ET AL: (if regular cite not selected)
(*) One et al
(2) One, Two et al
(3) One, Two, Three et al
(4) One, Two, Three, Four et al
(5) One, Two, Three, Four, Five et al
(6) One, Two, Three, Four, Five, Six et al
  Select:
  
\ans=
  1. 规定了作者列表的缩写格式。默认选项表示在第 2 个作者处截断,3-6 表示在第 3 - 6 个作者处截断。这里我们选择 3。
MAX AUTHORS WITHOUR ET AL: (if regular cite not selected)
(*) Two authors without truncating
(3) Three authors without truncating
(4) Four authors without truncating
(5) Five authors without truncating
(6) Six authors without truncating
  Select:
  
\ans=
  1. 设置作者字体样式,默认表示正常字体,s 表示小写,i 表示斜体,b 表示粗体,u 表示用户自定义字体。这里我们选择默认选项。
<<TYPEFACE FOR AUTHORS IN LIST OF REFERENCES:
(*) Normal font for author names
(s) Small caps authors (\sc)
(i) Italic authors (\it or \em)
(b) Bold authors (\bf)
(u) User defined author font (\bibnamefont)
  Select:

\ans=

STEP-4: 生成 bst 文件。面对最后的选项,我们输入 dbj 文件的路径,程序即可帮我们生成个性化的 dbj 文件,当我们要引用它时,只需把该 bst 文件放到 tex 目录下,然后在 \bibliographystyle{} 中引用它即可。

\bibliographystyle{yongfeng0119}

  • 46
    点赞
  • 199
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
### 回答1: LaTeX是一种常用于学术论文撰写的排版软件,借助于BibTeX,也可以方便地实现参考文献的管理。下面介绍一下基本的LaTeX参考文献格式。 首先,需要在LaTeX文档开头部分加入以下命令: \bibliographystyle{样式} 其中样式可以根据需要选择,比如最常用的 “plain”、“apalike”、“ieeetr”,也可以自定义样式。然后在需要引用文献的地方,使用以下命令: \cite{文献标识符} 文献标识符是在BibTeX文件中定义的,格式如下: @文献类型{标识符, 作者={作者1, 作者2, ...}, 标题={标题}, 出版社={出版社}, 年份={年份}, ISBN={ISBN号} } 再来看一下常见的文献类型和相应的LaTeX格式: 1. 书籍:@book 格式: 作者. 书名. 版本. 出版地: 出版社, 出版年. 例如: \bibitem{texbook} D. E. Knuth. The \TeX book. Addison-Wesley, 1984. 2. 期刊文章:@article 格式: 作者. 文章标题. 期刊名, 发表年, 卷号(期号): 页码. 例如: \bibitem{greenwade93} G. Greenwade. The comprehensive Tex Archive network (CTAN). TUGBoat, 14(3): 342--351, 1993. 3. 学位论文:@phdthesis 格式: 作者. 论文题目. 学位论文类型, 所在机构, 所在地, 年份. 例如: \bibitem{li2007} Z. Li. Expert-oriented in-depth study on flexible job-shop scheduling problems. 博士学位论文, Huazhong University of Science and Technology, Wuhan, China, 2007. 以上是LaTeX参考文献格式的基本介绍,了解这些基础知识能够让我们更加高效地管理和使用参考文献,提高论文的写作质量。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值