latex 环境搭建

 

下载

下载地址 https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/

选择texlive.iso

安装

点击texlive.iso, 选择install-tl进行安装

安装完成后,验证安装结果

输入

latex --version

正常情况类似输出

pdfTeX 3.141592653-2.6-1.40.29 (TeX Live 2026)
kpathsea version 6.4.2
Copyright 2026 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.55; using libpng 1.6.55
Compiled with zlib 1.3.2; using zlib 1.3.2
Compiled with xpdf version 4.06

配置

VSCode中安装LaTeX Workshop插件, settings.json配置参考如下, 注意修改为自己实际的安装路径

// LaTeX编译器配置
"latex-workshop.latex.tools": [
    {
        "name": "pdflatex",
        "command": "参考实际安装pdflatex.exe路径",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "xelatex",
        "command": "参考实际安装xelatex.exe路径",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "参考实际安装bibtex.exe路径",
        "args": [
            "%DOCFILE%"
        ]
    }
],
    
// 编译链配置(优先xelatex,支持中文)
"latex-workshop.latex.recipes": [
    {
        "name": "XeLaTeX",
        "tools": [
            "xelatex"
        ]
    },
    {
        "name": "XeLaTeX -> BibTeX -> XeLaTeX*2",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    }
],

// 保存时自动编译
"latex-workshop.latex.autoBuild.run": "onSave",

// 内置PDF预览(无需额外软件)
"latex-workshop.view.pdf.viewer": "tab",

// 编译后清理临时文件
"latex-workshop.latex.clean.fileTypes": [
    "*.aux",
    "*.bbl",
    "*.blg",
    "*.idx",
    "*.ind",
    "*.lof",
    "*.lot",
    "*.out",
    "*.toc",
    "*.log"
]