VSCODE 安装LATEX环境,参数配置,常见问题解决

1 准备Texlive安装包

可以从以下网址下载 texlive 的镜像文件:

华为镜像

阿里镜像

官网

网址中大概文件构成

image-20211008165251051

下载完后我们需要的文件构成(我是2020年下载过了,这次就不重新下载了)

image-20211008165405335

将这个镜像文件进行解压

image-202110081654568052 安装Texlive

右键install-tl-windows.bat,单击以管理员身份运行,进入安装界面.

image-20211008165903702

点击左下角的“Advanced”进入高级安装来取消你不需要安装的宏包。

image-20211008170013007

点击“Customize”来取消勾选不需要的宏包。

image-20211008170537299

单是把非中英的语言包取消勾选可以省掉 1G 的空间,要是嫌麻烦全部安装也可以。

image-20211008170457764

安装界面右下角可选择是否安装 TeXworks 编辑器,我觉得既然都来看这篇文章了,那这个应该可以不要了。设置完安装路径等选项之后点击“安装”,之后静坐 20 分钟 - 3 小时等待安装完成。

image-20211008170716843

image-20211008194808162

3 安装VSCODE插件

在拓展栏中搜索 Latex workshop 进行安装

image-20211008171211190

安装完成后,随便打开一个 tex 源文件,可以看到,代码已经被高亮显示,同时侧边栏还有tex的标记即可了

image-20211010165627690

4 添加设置文件

按下F1选择这个打开设置文件

image-20211010165739355

    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            // "command": "biber",
            "args": [
                // "%DOC%"
                "%DOCFILE%"
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "xelatex",
            "tools": ["xelatex"]
        },
        {
            "name": "latexmk",
            "tools": ["latexmk"]
        },
        {
            "name": "pdflatex -> bibtex",
            "tools": ["pdflatex","bibtex"]
        },
        // {
        //     "name": "pdflatex -> bibtex -> pdflatex*2",
        //     "tools": [
        //         "pdflatex",
        //         "bibtex",
        //         "pdflatex",
        //         "pdflatex"
        //     ]
        // },
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
            ]

        }
    ],
    //设置在编译完成后所需要删除的文件格式
    "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.message.error.show": false,
    "latex-workshop.message.warning.show": false,

    "latex-workshop.showContextMenu": true, //添加LaTex Workshop右键菜单。
    "latex-workshop.intellisense.package.enabled": true, //根据加载的包,自动完成命令或包。  
    "latex-workshop.latex.autoBuild.run": "onSave", //保存文件时自动build(也就是说,点击保存文件或者按快捷键Ctrl+S的时候,除了会保存Tex文件,还会帮你编译LaTex为Pdf。

注意要放在原本存在的{}中间

4.1 解释一下菜单栏的作用和这些参数

参数含义
"latex-workshop.latex.tools"编译工具选项,也就是我们上面在 Build LaTex project 下拉菜单看到的,只要在这里配置了 tools ,就会新增到下拉菜单里供我们选择。
"latex-workshop.latex.recipes"配置每一个编译的小环境,有使用 xelatex 的,也有使用 pdflatex 的,或是 xe->bib->xe->xe 连续多次编译的(多次编译的目的是为了生成参考文献,这是 bibtex 的性质决定的)。(可以将带 bib 的 Recipe 放到第一位,就可以作为默认 Recipe 编译了,也可以但因为编译次数比较多,速度会比较慢;)
"latex-workshop.latex.clean.fileType"设置在编译完成后所需要删除的文件格式
"latex-workshop.view.pdf.viewer“设置默认的pdf阅读器

编译工具中 latexmkxelatex这两个都是latex编译器,后者是可以编译中文的。

image-20211011092405647

5 编译完后的效果

重启 vscode 后进行编译,放在浏览器中的效果

image-20211011094406142

6 一些问题的目录

6.1 按照如上设置后还是不能成功编译

报错 Recipe terminated with fatal error: spawn xelatex ENOENT

Latex在VSCODE中编译报错Recipe terminated with fatal error: spawn xelatex ENOENT_

6.2 编译中文的问题 在中文路径下编译的问题

Latex在VSCODE中编译中文,使用中文路径问题解决_呆呆象呆呆的博客-CSDN博客

6.3 The font size command \normalsize is not defined

Latex 报错 LaTeX Error: The font size command \normalsize is not defined问题解决_呆呆象呆呆的博客-CSDN博客

6.4 I found no \citation & \bibstyle & \bibdata commands &

Latex 编译报错 I found no \bibstyle command_呆呆象呆呆的博客-CSDN博客

6.5 LaTeX Warning: Citation “*****” on page y undefined on input line *

Latex参考文献引用失败 报错 LaTeX Warning: Citation “*****” on page y undefined on input line *_呆呆象呆呆的博客-CSDN博客

6.6 进阶的一些设置

  • 快捷键和外置PDF浏览器

配置VS Code为你的LaTex编辑器 - 知乎

  • 外置PDF的反向搜索正向搜索

使用VSCode编写LaTeX - 知乎

  • 常用快捷键

LaTeX+VSCode环境配置 | sirlis

参考文献

(8条消息) vscode配置latex出现Recipe terminated with error. Retry building the project.的问题_kangjielearning的博客-CSDN博客

(20条消息) Latex的Helloworld_博客-----CSDN博客

(7条消息) VSCode与Latex环境的搭建(最简洁,最省事,最舒服的方案,不用搞一堆乱七八糟的配置)_Dezeming的博客-CSDN博客

(7条消息) vscode配置latex出现Recipe terminated with error. Retry building the project.的问题_kangjielearning的博客-CSDN博客

(7条消息) Recipe terminated with error. vscode latex-workshop新的配置文件_u013892042的博客-CSDN博客

(7条消息) vscode写LaTex教程 | 从零开始使用Texlive+vscode+LaTex Workshop插件配置_桃饱の店-CSDN博客_latex workshop 设置

  • 110
    点赞
  • 329
    收藏
    觉得还不错? 一键收藏
  • 18
    评论
配置VS Code的LaTeX环境需要以下几个步骤: 1. 下载并安装VS Code:你可以从[VS Code官网](https://code.visualstudio.com/)下载安装包,然后按照安装向导进行安装。 2. 安装LaTeX插件:在VS Code中,点击左侧边栏的“扩展”按钮,搜索并安装LaTeX Workshop”插件。 3. 配置LaTeX环境:打开VS Code的设置(快捷键Ctrl + ,),输入“latex-workshop.latex.tools”并点击“编辑设置.json”,将以下代码添加到打开的json文件中: ```json "latex-workshop.latex.tools": [{ "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "-outdir=%OUTDIR%", "%DOC%" ], "env": {} }], "latex-workshop.latex.recipes": [{ "name": "latexmk", "tools": [ "latexmk" ] }] ``` 4. 配置LaTeX编译器:打开VS Code的设置,输入“latex-workshop.latex.tools”并点击“编辑设置.json”,在打开的json文件中找到“latex-workshop.latex.tools”字段中的“command”项,将其值修改为你的LaTeX编译器的路径(例如:`"C:\\texlive\\2021\\bin\\win32\\pdflatex.exe"`)。 5. 配置默认编译器:打开VS Code的设置,输入“latex-workshop.latex.recipes”并点击“编辑设置.json”,在打开的json文件中找到“latex-workshop.latex.recipes”字段中的“tools”项,将其值修改为你希望作为默认编译器的工具名称(例如:`"tools": ["latexmk"]`)。 6. 测试LaTeX环境:创建一个新的.tex文件,输入一些LaTeX代码,按下Ctrl + Alt + B编译代码并查看结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值