前言
latex是有自己的一套引用系统的。
如果我们仔细看一下project里面的文件,我们在编写的是.tex
文件,其中的.bbl
和.bib
文件就是引用相关的文件了。
倘若你还不知道什么是latex,转移到我的这篇博客,对他有个基本的认识 :https://blog.csdn.net/Yonggie/article/details/97965554。
我自己是使用miktex和texstudio / mactex和texstudio,但是其他的工具都大同小异,可参考。
2022.04.08日更新:vscode+latex可以只关心.bib文件,bbl文件直接被代理了,不需要自己动手写和创建。
2023.04.12日更新:推荐使用overleaf,直接在线编辑,都不需要自己弄这些shit!还可以多人共享项目合作,妈妈再也不用担心我的latex!
理解我们在做什么
.bib
文件里面要写每个文章的bib引用格式。如果在arxiv上点击Export Bibtex Citation,那么会有很多引用格式让你复制,其中就有bib格式。一个文章的格式长这样:
@misc{wang2020survey,
title={A Survey on Heterogeneous Graph Embedding: Methods, Techniques, Applications and Sources},
author={Xiao Wang and Deyu Bo and Chuan Shi and Shaohua Fan and Yanfang Ye and Philip S. Yu},
year={2020},
eprint={2011.14867},
archivePrefix={arXiv},
primaryClass={cs.SI}
}
有些misc开头,有些article开头还有inproceedings等等,都是可以的。
bib文件里面把所有的引用文献做集合,所以我们需要编写bib文件,把引用的latex的引用文章都一股脑塞到这里面。
.bbl
文件就是挑选具体需要引用的文章了。想引用那个就把他写上。当然编译之后会发现这个文件变了,不过他变不变我们也不用管了,我们只需做好前面的写好对应关系就行了。
对应的在.tex
里面引用\bibliography{bbl文件名}
加上。
具体做法
-
新建文本文件,复制进去要引的bibtex内容,并改后缀名为.bib。例如我要使用这些内容作为bibtex,我命名为hgsurvey.bib:
@misc{wang2020survey, title={A Survey on Heterogeneous Graph Embedding: Methods, Techniques, Applications and Sources}, author={Xiao Wang and Deyu Bo and Chuan Shi and Shaohua Fan and Yanfang Ye and Philip S. Yu}, year={2020}, eprint={2011.14867}, archivePrefix={arXiv}, primaryClass={cs.SI} }
注意下第一行的
wang2020survey
就是你bbl中的引用名字。 -
我们还有个
.bbl
文件要编辑(当然如果此时你直接点编译,他也会提示你bbl文件是空的)。你可以自己直接新建一个文件,改后缀成.bbl。
这个文件格式是这个样子,把自己想引用的文件用\bibitem{xxx}都写上:\begin{thebibliography}{1} % 这个数字如果填少或填多,编译的时候会被改过来。我这里只有1个引用 ,所以是1 % 这里bibitem就把自己的引用文件统统写上。注意这里的名字,要写.bib文件里面的名字 \bibitem{wang2020survey} \end{thebibliography}
我稍微解释下bibitem后面的名字。\bibitem里写引用名字,引用名字是bib中每个paper citation的第一行的名字。举个例子:
@misc{wang2020survey, title={A Survey on Heterogeneous Graph Embedding: Methods, Techniques, Applications and Sources}, author={Xiao Wang and Deyu Bo and Chuan Shi and Shaohua Fan and Yanfang Ye and Philip S. Yu}, year={2020}, eprint={2011.14867}, archivePrefix={arXiv}, primaryClass={cs.SI} }
这个的引用名字是wang2020survey,是可以自己在bib文件里改名的。
-
刚刚写好了bbl和bib文件,现在tex中就能引用了。编写tex:
在tex里面,先加入使用cite相关的package,有如下:\bibliographystyle{plain} %引入bib后的格式 \bibliography{ref} %ref是你要引入的bib的名字,我的例子这里是hgsurvey \usepackage{cite} %cite 需要的
为了给新手看的更清楚,你的tex应该长成这样(按需删减哈):
\documentclass{article} \usepackage{cite} \title{A Test for TeXstudio} \author{Dale} \begin{document} \maketitle \tableofcontents \section{Hello China} China is in East Asia. \subsection{Hello Beijing} Beijing is the capital of China. \subsubsection{Hello Dongcheng District} \paragraph{Hello Tian'anmen Square}is in the center of Beijing \subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square \cite{wang2020survey} % 下面这两个只要在begin document里面就可以 \bibliographystyle{plain} \bibliography{hgsurvey} % 写.bib的文件名。 \end{document}
若要引多个,在\cite里面加逗号就可以了
\cite{2019arXiv191108538R,velickovic2018deep}
-
ok,这样你点击编译就可以出来结果了。此时如果你再回头看你的.bbl文件,他会变样子,以我的举例,他变成了这个样:
\begin{thebibliography}{1} \bibitem{wang2020survey} Xiao Wang, Deyu Bo, Chuan Shi, Shaohua Fan, Yanfang Ye, and Philip~S. Yu. \newblock A survey on heterogeneous graph embedding: Methods, techniques, applications and sources, 2020. \end{thebibliography}
当然,他变不变的,我们也不管了,我们只管用就好。
编译的pdf结果如下:
进阶
下面的对于上面的结果就ok的人来说,就不必看了。
cite样式:
- plain,按字母的顺序排列,比较次序为作者、年度和标题
- unsrt,样式同plain,只是按照引用的先后排序
- alpha,用作者名首字母+年份后两位作标号,以字母顺序排序
- abbrv,类似plain,将月份全拼改为缩写,更显紧凑
- ieeetr,国际电气电子工程师协会期刊样式
- acm,美国计算机学会期刊样式