当前位置:网站首页>【Latex】TexLive+VScode+SumatraPDF 配置LaTex编辑环境
【Latex】TexLive+VScode+SumatraPDF 配置LaTex编辑环境
2022-07-31 05:17:00 【G_Summer_Song】
前往我的博客阅读体验更佳:本文链接
安装Texlive

- 打开镜像文件,运行install-tl-windows.bat文件。

- 修改安装位置,开始安装。

- 大约三十分钟后,安装完成。

VScode安装和配置
- 打开VScode官网,下载,安装。

- 打开VScode,安装LaTex WorkShop扩展。

- 按快捷键Ctrl+Shift+P,输入settings.json,打开setting.json文件。 输入以下代码:
{
"latex-workshop.latex.autoBuild.run": "onFileChange", //自动编译:onFileChange、onSave 、never
"latex-workshop.showContextMenu": false, //此命令设置是否将编译文档的选项出现在鼠标右键的菜单中
"latex-workshop.intellisense.package.enabled": true, //从使用的宏包中自动提取命令和环境,从而补全正在编写的代码
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false, //设置当文档编译错误时是否弹出显示出错和警告的弹窗
//定义在下文 recipes 编译链中被使用的编译命令,此处为默认配置,不需要进行更改
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
//此串代码是对编译链进行定义,其中name是标签,也就是出现在工具栏中的链名称;tool是name标签所对应的编译顺序,其内部编译命令来自上文latex-workshop.latex.recipes中内容。
"latex-workshop.latex.recipes": [
{
"name": "XeLaTeX",
"tools": [
"xelatex"
]
},
{
"name": "PDFLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "BibTeX",
"tools": [
"bibtex"
]
},
{
"name": "LaTeXmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
],
//设置编译完成后要清除掉的辅助文件类型,若无特殊需求,无需进行更改。
"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"
],
"latex-workshop.latex.autoClean.run": "onFailed", //设置什么时候对上文设置的辅助文件进行清除:onBuilt、onFailed、never
"latex-workshop.latex.recipe.default": "lastUsed", //设置 vscode 编译 tex 文档时的默认编译链:first、lastUsed
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click" //反向同步:ctrl-click、double-click
}
到这里VScode就配置完LaTex环境了,下面是配置一个好用的外部PDF阅读器。
外部PDF阅读器SumatraPDF(可选)
安装与配置
- 下载SumatraPDF,官网
- 在上述setting.json中添加如下代码,注意将路径替换为自己的SumatraPDF路径和VScode路径。
"latex-workshop.view.pdf.viewer": "external", //设置默认的pdf查看器,tab、browser、external
"latex-workshop.view.pdf.ref.viewer": "auto", //设置PDF查看器用于在 \ref 命令上的[View on PDF]链接,此命令作用于 \ref 引用查看
"latex-workshop.view.pdf.external.viewer.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe", //使用外部查看器时要执行的命令,设置外部查看器启动文件SumatraPDF.exe文件所在位置
"latex-workshop.view.pdf.external.viewer.args": [ //此代码是设置使用外部查看器时,latex-workshop.view.pdf.external.view .command的参数。%PDF%是用于生成PDF文件的绝对路径的占位符。
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "D:/Program Files/SumatraPDF/SumatraPDF.exe", //将生成的辅助文件.synctex.gz转发到外部查看器时要执行的命令,设置其位置参数
//当 .synctex.gz 文件同步到外部查看器时latex-workshop.view.pdf.external.synctex的参数设置。%LINE%是行号,%PDF%是生成PDF文件的绝对路径的占位符,%TEX%是当触发syncTeX被触发时,扩展名为 .tex 的 LaTeX 文件路径。
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"D:/Program Files/Microsoft VS Code/Code.exe\" \"D:/Program Files/Microsoft VS Code/resources/app/out/cli.js\" -r -g \"%f:%l\"", // 注意修改路径
"%PDF%"
]
配置正向搜索与反向搜索
正向搜索
即从tex源码界面定位到pdf界面,使用快捷键Ctrl+Alt+J。
反向搜索
从pdf界面定位相应的tex源码界面。
- 打开SumatraPDF,点击选项。

- 在图示位置输入以下代码(注意VScode路径):

"D:/Program Files/Microsoft VS Code/Code.exe" "D:/Program Files/Microsoft VS Code/resources/app/out/cli.js" --ms-enable-electron-run-as-node -r -g "%f:%l"
- 反向搜索配置成功,在pdf界面双击即可跳转。
边栏推荐
- Nmap的下载与安装
- TransactionTemplate transaction programmatic way
- 评估机器学习模型-摘抄
- DSPE-PEG-Biotin,CAS:385437-57-0,磷脂-聚乙二醇-生物素可延长循环半衰期
- 活体检测FaceBagNet阅读笔记
- jenkins +miniprogram-ci upload WeChat applet with one click
- qt:cannot open C:\Users\XX\AppData\Local\Temp\main.obj.15576.16.jom for write
- Tensorflow——演示
- box-shadow相关属性
- CNN的一点理解
猜你喜欢
Rejection sampling note
浏览器中的画中画(Picture-in-Picture)API
CAS: 1403744-37-5 DSPE-PEG-FA Phospholipid-Polyethylene Glycol-Folic Acid for Scientific Research
机器学习和深度学习概述
Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives
This in js points to the prototype object
VS通过ODBC连接MYSQL(一)
2022 SQL big factory high-frequency practical interview questions (detailed analysis)
The browser looks for events bound or listened to by js
Research reagents Cholesterol-PEG-Maleimide, CLS-PEG-MAL, Cholesterol-PEG-Maleimide
随机推荐
CNN的一点理解
人脸识别AdaFace学习笔记
使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)
禅道安装及使用教程
Pytorch常用函数
Attention based ASR(LAS)
词向量——demo
四种常见的POST提交数据方式
Pytorch实现ResNet
机器学习和深度学习概述
OpenCV中的图像数据格式CV_8U定义
DSPE-PEG-Azide DSPE-PED-N3 Phospholipid-Polyethylene Glycol-Azide Lipid PFG
wangeditor富文本编辑器上传图片以及跨域问题解决
Cholesterol-PEG-Amine CLS-PEG-NH2 Cholesterol-Polyethylene Glycol-Amino Research Use
CAS:474922-22-0 Maleimide-PEG-DSPE Phospholipid-Polyethylene Glycol-Maleimide Brief Description
应用usb_cam同时打开多个摄像头方法
pyspark.ml特征变换模块
mPEG-DSPE 178744-28-0 Methoxy-polyethylene glycol-phosphatidylethanolamine linear PEG phospholipids
mysql 事务原理详解
VTK环境配置