当前位置:网站首页>【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界面双击即可跳转。
边栏推荐
- ImportError: cannot import name ‘Xxxx‘ from partially initialized module ‘xx.xx.xx‘
- Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400
- crontab的定时操作
- np.fliplr与np.flipud
- 朴素贝叶斯文本分类(代码实现)
- 日志jar包冲突,及其解决方法
- 钉钉H5微应用免登鉴权
- DSPE-PEG-COOH CAS:1403744-37-5 磷脂-聚乙二醇-羧基脂质PEG共轭物
- unicloud cloud development record
- Remote file xxx is mapped to the local path xxx and can‘t be found. You can continue debugging....
猜你喜欢
随机推荐
学习JDBC之获取数据库连接的方式
为数学而歌之伯努利家族
opencv之图像二值化处理
MYSQL transaction and lock problem handling
Embedding cutting-edge understanding
活体检测PatchNet学习笔记
Web Screenshots and Reverse Proxy
Tensorflow边用边踩坑
Pytorch学习笔记13——Basic_RNN
After unicloud is released, the applet prompts that the connection to the local debugging service failed. Please check whether the client and the host are under the same local area network.
Cholesterol-PEG-DBCO Cholesterol-Polyethylene Glycol-Diphenylcyclooctyne Chemical Reagent
Chemical Reagent Phospholipid-Polyethylene Glycol-Amino, DSPE-PEG-amine, CAS: 474922-26-4
CAS: 1403744-37-5 DSPE-PEG-FA Phospholipid-Polyethylene Glycol-Folic Acid for Scientific Research
MySQL 入门:Case 语句很好用
[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config
Xiaomi mobile phone SMS location service activation failed
break and continue exit in js
VS2017 connects to MYSQL
Tensorflow相关list
MySQL master-slave switching steps









