赞
踩
之前我是使用TexStudio软件写的,现在想换一个新环境。主要还是TexStudio我用不惯,所以我卸载了电脑上的环境,使用VSCode+WSL搭建了一个新的latex写作环境。这篇博客主要是记录我在搭建这个环境和用IEEE模板写论文这个过程中遇见的一些问题。
其次我还想表达一下我使用latex写论文的一些感悟。缺点很明显,latex语言是有学习成本的。一些标签和一些莫名其妙的问题真的让人心烦。优点也很明显,你不用管参考文献格式,你不用管图片、表格和公式的序号,位置等问题。你不用管正文和标题的格式。
最后我建议大家在写论文的时候先用word写,这样别人也能帮你改改。
VSCode下载地址:https://code.visualstudio.com/Download
WSL安装:https://zhuanlan.zhihu.com/p/146545159
WSL最好用1版本,如果你下载了2版本可以使用wsl --set-default-version 2
切换一下。
安装VSCOde扩展:WSL-remote;LaTex Workshop;
扩展Latex Workshop要安装在wsl中。
安装latex支持:sudo apt install texlive-base
安装latex算法库支持:sudo apt install texlive-science
texlive-science
是algorithm宏包,这是必须的,以后缺什么就去CTAN下载下载你所需要的sty文件手动安装,下面有手动安装IEEE.bib的过程。一般来说这些已经够了。
如果想一劳永逸就使用sudo apt install texlive-full
下载吧。
配置pdflatex、xelatex和bibtex编译器
首先在wsl终端使用pdflatex -version 确定你已经装好这三个工具了。
然后在setting.json中加入以下内容:
"latex-workshop.latex.tools": [ { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%" ] }, { "name": "xelatex", "command": "xelatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOCFILE%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] } ]
工具链就是配置器调用或者其组合调用
"latex-workshop.latex.recipes": [ { "name": "pdf->bib->pdf->pdf", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] }, { "name": "pdflatex", "tools": [ "pdflatex" ] }, { "name": "xelatex", "tools": [ "xelatex" ], }, { "name": "xe->bib->xe->xe", "tools": [ "xelatex", "bibtex", "xelatex", "xelatex" ] } ]
在插件LaTex Workshop的作用下,使用Ctrl+s会自动调用latex-workshop.latex.recipes中第一个编译链编译当前的tex文件。所以,如果你只用到了一个tex文件,就自己调一下顺序,把pdflatex放在第一个。
首先我们需要明白latex中一些概念
bib格式是一种通用参考文献格式,以下是从dblp下载的一个例子:
@inproceedings{b17, author = {Aws Albarghouthi and Arie Gurfinkel and Marsha Chechik}, editor = {Viktor Kuncak and Andrey Rybalchenko}, title = {Whale: An Interpolation-Based Algorithm for Inter-procedural Verification}, booktitle = {Verification, Model Checking, and Abstract Interpretation - 13th International Conference, {VMCAI} 2012, Philadelphia, PA, USA, January 22-24, 2012. Proceedings}, series = {Lecture Notes in Computer Science}, volume = {7148}, pages = {39--55}, publisher = {Springer}, year = {2012}, doi = {10.1007/978-3-642-27940-9\_4}, timestamp = {Mon, 03 Jan 2022 22:36:07 +0100}, biburl = {https://dblp.org/rec/conf/vmcai/AlbarghouthiGC12.bib}, bibsource = {dblp computer science bibliography, https://dblp.org} }
第一行中b17就是该引用文献的名字,在tex文件中使用\cite{b17}就可以完成引用。具体的他是会议还是期刊,他发表在哪里,都不用你管。我推荐大家使用论文的关键字来命名论文名字,这样方便以后的管理。切记,这个名字不能重复。还有一点需要注意,每条文献之间用回车分开即可,我之前见过加逗号的,结果找了半天才找到出错的原因,你说你没得干自己加什么逗号呀。
IEEE模板提供了两个方式来编写论文,其区别在参考文献上。在你下载好的tex模板中你会在末尾看到thebibliography标签,该标签下有官方提供的例子,你照着写就行了。但是,文献的格式着实让人头疼,我个人总是分不清外国人的last name和first name,还有一些其他的格式问题,总之写过的人都知道这其中的痛苦。bib是一种参考文献格式,你可以从dblp、springer或者IEEE上下载bib格式的参考文献,然后无脑的复制到conference.bib文件中,IEEE会自动帮你把格式排好。
如果要使用多文件,就需要将thebibliography标签内容都删除,然后使用以下两句替换之:
\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,reference}
其中IEEEabrv是一个额外宏包,一般需要手动安装。reference就是我们写的bib文件名。
官网下载后找到IEEEabrv.bib和IEEEtran.bst两个文件,然后复制到/usr/share/texlive/texmf-dist/tex/latex/后只用sudo mktexlsr
编译就好了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。