一步完美解决VSCode下LaTeX编译文件的问题

问题描述

问题一

使用LaTex Workshop插件没有xe->bib->xe->xe这条编译链, 而在写中文论文过程中, 一方面需要使用xe编译防止中文乱码, 另一方面需要使用bib编译引入参考文献.

问题二

在使用VSCode编译tex文件的过程中会产生很多冗余的中间文件, 不方便文件查看和管理, 希望在VSCode只保留tex源文件和pdf文件以及实现二者的相互跳转的aux文件.

解决方案

问题一

使用F1找到VSCode的设置文件settings.json, 修改后的配置如下, 设置的具体含义请参考https://zhuanlan.zhihu.com/p/166523064

{
    "liveServer.settings.donotVerifyTags": true,
    "liveServer.settings.donotShowInfoMsg": true,
    "explorer.confirmDelete": false,
    "files.autoSave": "afterDelay",
    "explorer.confirmDragAndDrop": false,
    // latex-workshop设置
    "latex-workshop.latex.autoBuild.run": "onSave",
    "latex-workshop.showContextMenu": true,
    "latex-workshop.intellisense.package.enabled": true,
    "latex-workshop.message.error.show": false,
    "latex-workshop.message.warning.show": false,
    "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%"
            ]
        }
    ],
    "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"
            ]
        },
    ],
}

之后使用xe->bib->xe->xe这条编译链进行编译即可
在这里插入图片描述

问题二

网上针对该问题大多数都是采用在settings.json文件中配置LaTex Workshop插件的参数, 参数多实现繁琐理解复杂, 并且配置后并没有达到我想要的效果.

此外看到有人是通过新建文件夹来存放生成的那些中间文件, 但是当使用编译链时会因为在默认路径中找不到中间文件而报错.

之前学习 Git 的时候有看到可以设置.gitignore文件, 然后在VSCode的设置选项里面找到了解决方法.

选择VSCode中的Settings → \rightarrow Files:Exclude. 模仿给出的**/.git格式添加想要隐藏的文件后缀即可

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值