转载自:https://www.jianshu.com/p/47c456572e87
TeXLive下载与安装
TeXLive官网传送门
百度云下载链接 bfwp
安装时长20分钟左右
VSCode下载与安装
LaTexWorkshop插件安装
- 打开VSCode
- <Ctrl+Shift+x>打开扩展管理,搜索LaTeX Workshop,点击安装
- 安装完后启动插件,重启VSCode
插件配置及中文支持
- 点击文件->首选项->设置
- 搜索
latex-workshop.latex.recipes
并点击Edit setttings.json
,打开后左边为插件默认配置,无法修改,我们可以在右侧用户设置中定义同样的属性名称,达到修改配置的目的image.png
image.png
所有配置如下
{
"editor.wordWrap": "on",
"workbench.startupEditor": "newUntitledFile",
"latex-workshop.latex.clean.enabled": true,
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk",
"*.gz"
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex",
"xelatex"
]
},
{
"name": "xelatexb",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
]
}
配置解释如下
“latex-workshop.latex.clean.enabled”
是否删除每次编译成pdf时生成得到中间文件"latex-workshop.latex.clean.fileTypes"
删除哪些文件“latex-workshop.latex.tools”
配置排版引擎程序"latex-workshop.latex.recipes"
定义排版引擎程序调用顺序
注意
默认使用排版引擎程序调用顺序配置"latex-workshop.latex.recipes"
中的第一个进行编译排版,上述配置中第一个xelatex
不会对bib形式的参考文献编译排版,如用bib形式的参考文献请把第二个xelatexb
移到第一个,否则会报错
要让LaTeX编译器支持中文,还需在tex文件头部添加如下代码
\documentclass[UTF8]{ctexart} %ctexart是ctex article的缩写
或
\documentclass[UTF8]{article}
\usepackage{ctex}
LaTeX实例
\documentclass[UTF8]{ctexart}
\author{5john}
\title{LaTeX中文支持及字体}
\begin{document}
\maketitle
{\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示},{\lishu 这里是隶书显示},{\youyuan 这里是幼圆显示}
\end{document}
编译结果
经过上述设置,编写好tex文件后,<Ctrl+s>在保存文件的同时进行编译输出
image.png
注意
文件所在路径和文件名不要有中文,不然会编译失败