VSCode中使用LaTex的配置

目录

    • 1.下载安装VSCode
    • 2.下载安装Tex Live
    • 3. 安装LaTex Workshop扩展程序
    • 4. 修改配置文件
    • 6.运行编译

很多程序员喜欢用VSCode写代码,美观度很高,还有很多插件可以一键安装。类似的编辑器还有Atom,很多国外程序员很喜欢,两款编辑器使用感差不多。
用VSCode写latex,做笔记看起来很酷,但编译配置中还是有一些新手不太熟悉的trick。

步骤:

1.下载安装VSCode

https://code.visualstudio.com/Download

2.下载安装Tex Live

http://www.tug.org/texlive/acquire-netinstall.html

3. 安装LaTex Workshop扩展程序

打开VSCode,点击View -> Extension,在左边的搜索栏中搜索LaTex Workshop, 点击install即可安装

4. 修改配置文件

Ctrl+Shift+P打开搜索栏输入setting.json,打开配置文件在这里插入图片描述
在setting.json里加上如下行配置代码
其中,"latex-workshop.latex.tools"中定义了编译工具,如latexmk,xelatex,pdflatex等等
"latex-workshop.latex.recipes"中定义了编译流程,即各种tool的编译顺序。第一个即为默认的编译方式。
在recipes中也可以定义自己的编译方式。

"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",
            "args": [
                "%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.view.pdf.viewer": "tab",
    "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"
    ]

6.运行编译

点击最左边的TEX标签,在Commands里面先选择“Build LaTex project”里的编译方式,再点击“View LaTex PDF”中的任一选项查看PDF。
VSCode中使用LaTex的配置_第1张图片

你可能感兴趣的:(LaTex)