当前位置:首页>java>vscode搭建编程环境

vscode搭建编程环境

  • 2026-10-21 13:27:14
vscode搭建编程环境
Latex编程
Texlive 安装
下面我们将介绍如何在vscode中使用latex,丝滑地敲数学公式,让你觉得敲公式是一件很美好的事。首先下载texlive版本,推荐使用清华镜像源下载

镜像网址

https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/
先挂载texlive2025.iso,挂载之后见下图
如果使用图形界面安装,双击或者管理员运行install-tl-windows.bat,按照提示操作即可。但是我图形界面GUI安装出现问题,一直卡在下面这个界面:
索性转命令行安装,并且个人更喜欢代码操作。使用win+R快捷键打开,输入cmd打开命令提示符窗口,切换到挂载目录E盘,在dos窗口输入下面命令
E:install-tl-windows.bat --no-gui
等个几十分钟即可安装完毕。然后配置环境变量,在Path中加入路径C:\texlive\2025\bin\windows 即可。
然后在命令行窗口输入latex -v,得到下面的输出就成功了。
vscode安装latex相关插件及其配置
打开扩展,在应用商店中分别搜索 Latex, Latex Workshop, Math Snippets并安装。为啥推荐使用vscode编辑器呢,因为轻量化、智能化。未使用vscode之前,一直用texsudio,但是它特别笨重,占用内存也大,还是vscode香。
当然,vscode字体也能转成中文,同样在应用商店中搜索Chinese (Simplified)并安装,vscode右下角会提示你切换成中文。关键步骤是配置好settings.json文件,分别按照步骤1,2,3,4操作就能打开settings.json配置文件
我提供一下自己用的配方:
{    "remote.SSH.remotePlatform": {        "666": "linux",        "Fixed-point-meet-CNN": "linux",        "175.6.7.167": "linux",        "gland_seg": "linux",        "DL_img": "linux",        "test": "linux",        "dkk_vscdoe": "linux",        "sch": "linux",        "gly": "linux",        "zyy": "linux",        "gly2": "linux",        "PR_demo": "linux",        "zl_vscdoe": "linux"    },    "git.ignoreMissingGitWarning": true,    "editor.tokenColorCustomizations": {        "[*Light*]": {            "textMateRules": [                {                    "scope": "ref.matchtext",                    "settings": {                        "foreground": "#000"                    }                }            ]        },        "[*Dark*]": {            "textMateRules": [                {                    "scope": "ref.matchtext",                    "settings": {                        "foreground": "#fff"                    }                }            ]        },        "textMateRules": [            {                "scope": "keyword.control.return",                "settings": {                    "foreground": "#0000FF"                }            }        ]    },    "jupyter.askForKernelRestart": false,    "explorer.confirmDragAndDrop": false,    "window.zoomLevel": -1,    "markdown-preview-enhanced.usePandocParser": true,    "markdown-preview-enhanced.pandocPath": "C:\\ProgramData\\chocolatey\\bin\\pandoc.exe",    "markdown-preview-enhanced.automaticallyShowPreviewOfMarkdownBeingEdited": true,    "markdown-preview-enhanced.pandocArguments": [        // "--from=markdown-raw_tex+tex_math_single_backslash",        "--mathjax",        "--highlight-style",        "tango",        // "--filter",        // "pandoc-eqnos", // add this line        // "--filter",        // "./change_eq_refs.py",        "--filter",        "pandoc-crossref",        // "--citeproc",        // "--bibliography=ref.bib",        // "--filter",        "--csl=C:\\ProgramData\\chocolatey\\bin\\pandoc_settings\\apa-numeric-superscript-brackets.csl",        // "--csl=apa.csl",        // "--template=C:\\Users\\zsc\\AppData\\Roaming\\pandoc\\templates\\eisvogel.latex",        // "--metadata-file",        // "./meta.yaml",        // "-c",        // "./body.css",        // "--pdf-engine=xelatex",        "--number-sections"        // "-o",        // "output.pdf"    ],    "[markdown]": {        "editor.quickSuggestions": {            "comments": "on",            "strings": "on",            "other": "on"        }    },    "markdown-preview-enhanced.alwaysShowBacklinksInPreview": false,    "markdown-preview-enhanced.puppeteerArgs": [    ],    "security.workspace.trust.untrustedFiles": "open",    //%*****************************配置Latex编译语言*********************************%//    "latex-workshop.latex.recipe.default": "lastUsed",    "latex-workshop.latex.recipes": [        {            "name": "pdflatex->bibtex->pdflatex*2",            "tools": [                "pdflatex",                "bibtex",                "pdflatex",                "pdflatex"            ]        },        {            "name": "pdflatex",            "tools": [                "pdflatex"            ]        },        {            "name": "xelatex",            "tools": [                "xelatex"            ]        },                {            "name": "xelatex->bibtex->xelatex*2",            "tools": [                "xelatex",                "bibtex",                "xelatex",                "xelatex"            ]        },        {            "name": "xelatex->biber->xelatex*2",            "tools": [                "xelatex",                "biber",                "xelatex",                "xelatex"            ]        }    ],    "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%"            ]        },        {            "name": "biber",            "command": "biber",            "args": [                "%DOCFILE%"            ]        }    ],    "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.linter.enabled": false,    //   不显示行警告    //   "latex-workshop.view.pdf.viewer": "external",      "latex-workshop.view.pdf.viewer": "tab",      "latex-workshop.synctex.afterBuild.enabled": true,      "latex-workshop.latex.autoBuild.run": "never",      "latex-workshop.view.pdf.external.viewer.command": "C:/Install_package/SumatraPDF.exe",      "latex-workshop.view.pdf.external.viewer.args": [        "--unique",        "%PDF%"    ],    "latex-workshop.view.pdf.external.synctex.args": [        "-forward-search",        "%TEX%",        "%LINE%",        "%PDF%",    ],    // "latex-workshop.synctex.afterBuild.enabled": true,    // "latex-workshop.latex.autoBuild.run": "onFileChange",    "latex-workshop.view.pdf.external.synctex.command": "C:/Install_package/SumatraPDF.exe",    "explorer.confirmDelete": false,    "markdown-preview-enhanced.markdownFileExtensions": [        ".md",        ".markdown",        ".mdown",        ".mkdn",        ".mkd",        ".rmd",        ".qmd"    ],    "markdown-preview-enhanced.mathBlockDelimiters": [        [            "$$",            "$$"        ],        [            "\\[",            "\\]"        ]    ],    "markdown-preview-enhanced.latexEngine": "xelatex",    "markdown-preview-enhanced.mathInlineDelimiters": [        [            "$",            "$"        ],        [            "\\(",            "\\)"        ]    ],    "pandoc.docbookOptString": "-s -t html5",    "pandoc.pdfOptString": "-s   --template eisvogel --listings  --pdf-engine=xelatex --from=markdown+raw_tex  -V CJKmainfont=\"SimSun\" --filter pandoc-crossref --citeproc --number-sections -V geometry:\"top=2cm, bottom=1.5cm, left=2cm, right=2cm\" --csl \"C:\\\\ProgramData\\\\chocolatey\\\\bin\\\\pandoc_settings\\\\apa-numeric-superscript-brackets.csl\"",    "pandoc.docxOptString": "-s  --from markdown  --mathjax  -V CJKmainfont=\"SimSun\" --filter pandoc-crossref --citeproc --number-sections -V geometry:\"top=2cm, bottom=1.5cm, left=2cm, right=2cm\" --csl \"C:\\\\ProgramData\\\\chocolatey\\\\bin\\\\pandoc_settings\\\\apa-numeric-superscript-brackets.csl\"",    "python.defaultInterpreterPath": "C:\\Users\\zsc\\Anaconda3\\envs\\zsctorch\\python.exe",    "github.copilot.editor.enableAutoCompletions": true,    "window.confirmSaveUntitledWorkspace": false,    "interactiveWindow.executeWithShiftEnter": true,    "editor.wordWrap": "on",    "update.mode": "none",    "workbench.editorAssociations": {        "*.copilotmd": "vscode.markdown.preview.editor",        "*.csv": "default"    },    "deepseek.lang": "cn",    "diffEditor.ignoreTrimWhitespace": true,    "editor.minimap.enabled": false,    "editor.wordSegmenterLocales": [        "zh-CN"    ],    "github.copilot.nextEditSuggestions.enabled": true,    "workbench.settings.applyToAllProfiles": [    ],}
用上面的内容替换原始settings.json内容即可。配置成功后,左边会有多个构建latex的项目,根据需要选择正确的编译方式然后点击运行。
当然还可以设置快捷键使用上一次的编译方式运行tex文件。在vscode顶端输入下面内容
>首选项: 打开键盘快捷方式(JSON)
打开快捷键绑定设置文件,在打开的 keybindings.json 中添加快捷键条目(示例:Ctrl+Alt+P,绑定到 LaTeX Workshop 的编译命令),参考如下:
[  {    "key": "ctrl+alt+p",    "command": "latex-workshop.build",    "when": "editorTextFocus"  }]
后面直接用快捷键Ctrl+Alt+P即可使用上一次的编译方式运行tex文件。
之前提到的Math Snippets可以用代码片段,比如输入 ii 得到公式环境 $ $。下面给出官方提供的使用模板:
另外还能自己设置习惯的代码片段,提高敲公式效率。比如我做图像处理和优化,经常使用线性模型,平时编程使用Acal就能得到加粗的正体A, bx得到加粗的x等等。具体通过设置打开代码片段配置文件latex.json,即
可以参考个人使用的latex.json配置。最后这些基本准备工作就做完了,体验敲公式起飞的快感。
{    "Math Snippet for a\\mathcal{A}": {        "prefix": "Acal",        "body": [            "\\mathcal{A}"        ],        "description": "Insert \\mathcal{A}"    },    "Math Snippet for \\mathcal{D}": {        "prefix": "Lcal",        "body": [            "\\mathcal{L}"        ],        "description": "Insert \\mathcal{L}"    },    "Math Snippet for \\mathcal{R}": {        "prefix": "Hcal",        "body": [            "\\mathcal{H}"        ],        "description": "Insert \\mathcal{H}"    },    "Math Snippet for \\mathcal{G}": {        "prefix": "Gcal",        "body": [            "\\mathcal{G}"        ],        "description": "Insert \\mathcal{G}"    },    "Math Snippet for \\mathcal{M}": {        "prefix": "Mcal",        "body": [            "\\mathcal{M}"        ],        "description": "Insert \\mathcal{M}"    },    "Math Snippet for \\mathcal{N}": {        "prefix": "Ncal",        "body": [            "\\mathcal{N}"        ],        "description": "Insert \\mathcal{N}"    },    "Math Snippet for \\mathrm{Id}": {        "prefix": "Id",        "body": [            "\\mathrm{Id}"        ],        "description": "Insert \\mathrm{Id}"    },    "Math Snippet for \\mathrm{Fix}": {        "prefix": "Fix",        "body": [            "\\mathrm{Fix}"        ],        "description": "Insert \\mathrm{Fix}"    },    "Math Snippet for \\mathrm{Fix}(T)": {        "prefix": "FixT",        "body": [            "\\mathrm{Fix}(T)"        ],        "description": "Insert \\mathrm{Fix}(T)"    },    "Math Snippet for \\mathcal{L}\\{ \\mathrm{P}_Q \\}": {        "prefix": "landweber",        "body": [            "\\mathcal{L} \\{ \\mathrm{P}_Q \\\\}"        ],        "description": "\\mathcal{L}\\{ \\mathrm{P}_Q \\}"    },    "Math Snippet for \\mathrm{P}_Q": {        "prefix": "pq",        "body": [            "\\mathrm{P}_Q"        ],        "description": "\\mathrm{P}_Q"    },    "Math Snippet for \\mathbf{A}\\mathbf{x}": {        "prefix": "Ax",        "body": [            "\\mathbf{A}\\mathbf{x}"        ],        "description": "\\mathbf{A}\\mathbf{x}"    },    "Math Snippet for \\mathbf{A}\\mathbf{z}": {        "prefix": "Az",        "body": [            "\\mathbf{A}\\mathbf{z}"        ],        "description": "\\mathbf{A}\\mathbf{z}"    },    "Math Snippet for \\mathcal{}": {        "prefix": "cal",        "body": [            "\\mathcal{${1:R}}"        ],        "description": "Insert \\mathcal{} with a placeholder"    },    "Math Snippet for \\mathcal{T}": {        "prefix": "Tcal",        "body": [            "\\mathcal{T}"        ],        "description": "Insert \\mathcal{T} with a placeholder"    },    "Math Snippet for \\mathbb{}": {        "prefix": "bb",        "body": [            "\\mathbb{${1:R}}"        ],        "description": "Insert \\mathbb{} with a placeholder"    },    "Math Snippet for \\mathbb{R}": {        "prefix": "Rbb",        "body": [            "\\mathbb{R}"        ],        "description": "Insert \\mathbf{R}"    },    "Math Snippet for \\mathbb{N}": {        "prefix": "Nbb",        "body": [            "\\mathbb{N}"        ],        "description": "Insert \\mathbf{N}"    },    "Math Snippet for \\mathbf{}": {        "prefix": "bf",        "body": [            "\\mathbf{${1:R}}"        ],        "description": "Insert \\mathbf{} with a placeholder"    },    "Math Snippet for \\mathbf{x}": {        "prefix": "xbf",        "body": [            "\\mathbf{x}"        ],        "description": "Insert \\mathbf{x}"    },    "Math Snippet for \\mathbf{y}": {        "prefix": "ybf",        "body": [            "\\mathbf{y}"        ],        "description": "Insert \\mathbf{y}"    },    "Math Snippet for \\mathbf{u}": {        "prefix": "ubf",        "body": [            "\\mathbf{u}"        ],        "description": "Insert \\mathbf{u}"    },    "Math Snippet for \\mathbf{v}": {        "prefix": "vbf",        "body": [            "\\mathbf{v}"        ],        "description": "Insert \\mathbf{v}"    },    "Math Snippet for \\mathbf{z}": {        "prefix": "zbf",        "body": [            "\\mathbf{z}"        ],        "description": "Insert \\mathbf{z}"    },    "Math Snippet for \\mathbf{a}": {        "prefix": "abf",        "body": [            "\\mathbf{a}"        ],        "description": "Insert \\mathbf{a}"    },    "Math Snippet for \\mathbf{A}": {        "prefix": "Abf",        "body": [            "\\mathbf{A}"        ],        "description": "Insert \\mathbf{A}"    },    "Math Snippet for \\mathbf{H}": {        "prefix": "Hbf",        "body": [            "\\mathbf{H}"        ],        "description": "Insert \\mathbf{H}"    },    "Math Snippet for \\mathbf{K}": {        "prefix": "Kbf",        "body": [            "\\mathbf{K}"        ],        "description": "Insert \\mathbf{H}"    },    "LaTeX - inline math (dollars)": {        "prefix": "ii",        "body": ["$${1}$ $0"],        "description": "Create inline math formula"    },    "LaTeX - dif": {        "prefix": "rm",        "body": ["\\mathrm{${1:R}}"]    },    "Math Snippet for \\{ \\}": {        "prefix": "set",        "body": [            "\\{${1:R}\\\\}"        ],        "description": "\\{ \\}"    },    "Math Snippet for $\\{ \\mathbf{x}^k \\\\}_{k=0}^\\infty$": {        "prefix": "setxk",        "body": [            "$\\{ \\mathbf{x}^k \\\\}_{k=0}^\\infty$"        ],        "description": "$\\{ \\mathbf{x}^k \\\\}_{k=0}^\\infty$"    }}
Copilot智能编程
符合条件的同学可以申请微软的Copilot pro, 编程注入灵魂。无论你是python编程还是latex编程,都具有代码智能补全的功能,极大提高生产效率。比如我申请了两年的pro权限,遇到不会的问题在聊天框给AI想法,让AI帮我解决问题,目前好像还能支持智能体,没有体验过。
Pro 支持GPT,Gemini等一大堆大模型,申请下来之后可以免费用。

最新文章

随机文章