Configure latex in vscode

Table of contents

1. Download texlive

2. Install texlive

3. Configure latex in vscode

4. Test


1. Download texlive

Download link: Acquiring TeX Live as an ISO image - TeX Users Group

Click the link to enter the texlive official website, as shown in the picture, click download from a nearby CTAN mirror

After entering, select the required texlive version. I chose the 2023 version:

​ The download here may be slow. It is recommended to surf the Internet scientifically, or refer to this mirror website: Index of /CTAN/systems/texlive/Images/ | Tsinghua University Open Source Software Mirror Station | Tsinghua Open Source Mirror

 2. Install texlive

After the download is completed, open texlive and click install-tl-windows

 After running the file, modify the installation path to the D drive in the pop-up interface.

 After modification, click Install and wait for completion.

Completion flag:

 Open the cmd command line and enter the xelatex -v command. If the following output is displayed, the installation is successful:

3. Configure latex in vscode

vscode is installed by default here. If it is not installed, click the link Visual Studio Code - Code Editing. Redefined to install it.

After successful installation, click on the vscode sidebar extension option, search for latex workshop, and click to install.

 After the installation is complete, perform latex configuration.

Click Settings in the lower left corner, then click the upper right corner to switch to settings.json

 The configuration information is as follows, just paste it into settings.json.

"latex-workshop.latex.tools": [	
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
],
"latex-workshop.latex.recipes": [
    {
        "name": "xelatex",
        "tools": [
            "xelatex"
        ],
    },
    {
        "name": "pdflatex",
        "tools": [
            "pdflatex"
        ]
    },
    {
        "name": "xe->bib->xe->xe",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    },
    {
        "name": "pdf->bib->pdf->pdf",
        "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"
],
//tex文件浏览器,可选项为"none" "browser" "tab" "external"
"latex-workshop.view.pdf.viewer": "tab",
//自动编译tex文件
"latex-workshop.latex.autoBuild.run": "onFileChange",
//显示内容菜单:(1)编译文件;(2)定位游标
"latex-workshop.showContextMenu": true,
//显示错误
"latex-workshop.message.error.show": false,
//显示警告
"latex-workshop.message.warning.show": false,
//从使用的包中自动补全命令和环境
"latex-workshop.intellisense.package.enabled": true,
//设置为never,为不清除辅助文件
"latex-workshop.latex.autoClean.run": "never",
//设置vscode编译tex文档时的默认编译链
"latex-workshop.latex.recipe.default": "lastUsed",
// 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",

For a detailed explanation of the commands in the configuration information, please refer to the following two articles:

http://t.csdn.cn/voOg4

Visual Studio Code (vscode) configures LaTeX - Ali-loner's article - Zhihu

4. Test

I downloaded a latex template from github: MathModel/2020 Latex template.zip at master · zhanwen/MathModel · GitHub

After decompressing, open it with vscode and click Build Latex project. If a check mark appears at the bottom, it means the compilation is successful. Otherwise, the check will make an error:

 After the compilation is successful, click view latex PDF, as shown in the figure:

 At this point, you’re done~

Guess you like

Origin blog.csdn.net/weixin_54106682/article/details/130374573