VSCode+TeXLive2022 配置教程

这篇具有很好参考价值的文章主要介绍了VSCode+TeXLive2022 配置教程。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

安装TeXLive2022

下载安装texlive2022,镜像文件还是有点大的,考虑到网速,这里直接到清华镜像网站上进行下载。

image.png
下载4.3GB的文件,随便挑一个iso文件应该都差不多,下载下来之后,打开iso文件,双击下图中的批处理文件进行安装。
image.png
安装没啥好说的,但是记得修改安装目录,不要安装在C盘!!
image.png
点击修改,只要不是C盘都行,然后建议安装目录不要有中文!!!这是给自己省事!此外,TeXworks这个软件,不需要的可以取消勾选,事实上,大概率都不会用这玩意儿吧,毕竟有更好用的编译器!

点击完了之后,等待就行了。大概会持续1h左右,视电脑配置而定,注意,一定不要急着关闭。安装完成的标志是显示欢迎进入Tex世界!我电脑安装好了,就不演示了。

安装Vscode

下载安装vscode,到官网上直接下载安装。

Visual Studio Code:https://code.visualstudio.com/

image.png
直接安装即可,没啥好说了。下面开始配置Vscode。

配置Vscode

进入vscode,安装插件LaTeX Workshop以及LaTeX language support两种支持插件。
image.png
安装好后,在左边,应该有这个图标,
image.png
有一些常用的符号,以及运行tex程序也是在这里,当然为了方便,可以配置快捷键,看后文。

然后,开始VSCode LaTeX配置,在 VSCode 界面下按下ctrl+shift+P,键入“settings”打开settings.json,将下面的内容粘贴进文件里面即可。

{
  "latex-workshop.latex.tools": [
        {
            // 编译工具和命令
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOCFILE%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "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.autoClean.run": "onFailed",
    "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",
        "*.nav",
        "*.snm",
    ],
    "latex-workshop.latex.autoBuild.run": "never",
    "latex-workshop.synctex.afterBuild.enabled": true,
    "latex-workshop.message.error.show": false,
    "latex-workshop.message.warning.show": false,
    "latex-workshop.view.pdf.ref.viewer": "external",
    "latex-workshop.view.pdf.viewer": "external",
    "latex-workshop.view.pdf.external.viewer.command": "D:/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
    ],
    "latex-workshop.view.pdf.external.synctex.command": "D:/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.synctex.args": [
        "-forward-search",
        "%TEX%",
        "%LINE%",
        "-reuse-instance",
        "-inverse-search",
        "\"D:/Microsoft VS Code/code.exe\" -g \"%f:%l\"",
        "%PDF%",
    ],
    "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
    "explorer.confirmDelete": false,
    "editor.fontSize": 17,
    "kite.showWelcomeNotificationOnStartup": false,
    "[latex]": {
        "editor.defaultFormatter": "nickfode.latex-formatter"
    },
}

注意:上面的代码,涉及到目录的都需要修改,将自己电脑里面的目录替换上面代码的目录即可。

快捷键设置

在 VSCode 界面下按下ctrl+shift+P,键入“keyjson”,选择“打开键盘快捷方式(JSON)”,然后把以下代码放入[]里面:

{
    "key": "alt+s",
    "command": "latex-workshop.synctex",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "ctrl+b",
    "command": "latex-workshop.build",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "alt+t",
    "command": "latex-workshop.kill",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "ctrl+r",
    "command": "latex-workshop.recipes"
},

用的比较多的还是ctrl+bctrl+r,前者是设置的编译的快捷键,后者设置的是选择其他recipe编译,当然也可以自行更换为适合自己的快捷键,只需修改“key”那一项即可,这只是我用习惯了的快捷键指令。

代码片段设置(效率++)

在Vscode中,按快捷键ctrl+shift+P打开命令面板,键入snippets,选择配置用户代码片段:
image.png
输入latex(或者下滑找到latex),点击latex.json
VSCode+TeXLive2022 配置教程

粘贴下面的代码到latex.json文件中:

{
	"compile setting":{
		"prefix": "compile",
		"body": ["%!TEX program = ${1:xelatex} -> bibtex -> xelatex -> ${1:xelatex}"],
		"description": "set default the compile order"
	},
	"insert figure":{
		"prefix": "figure",
		"body":["\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\\caption{${3}}\n\t\\label{${4}}\n\\end{figure}"],
		"description": "insert figure snippet"
	},
	"insert table":{
		"prefix": "table",
		"body":["\\begin{table}[${1:htbp}]\n\t\\centering\n\t\\caption{${2:caption}}\n\t\t\\begin{tabular}{${3:c|c}}\n\t\t\\hline\n\t\t${4:column1 & column2}\n\t\t\\end{tabular}\n\t\\label{${5:label}}\n\\end{table}"],
		"description": "insert table snippet"
	},
	"insert enumerate":{
		"prefix": "enumerate",
		"body":["\\begin{enumerate}\n\t\\item ${1:enumerate1}\n\t\\item ${2:enumerate2}\n\\end{enumerate}"],
		"description": "insert enumerate snippet"
	},
	"insert item":{
		"prefix": "itemize",
		"body":["\\begin{itemize}\n\t\\item ${1:itemsize1}\n\t\\item ${2:itemsize2}\n\\end{itemize}"],
		"description": "insert item snippet"
	},
	"insert frame":{
		"prefix": "frame",
		"body":["\\begin{frame}{${1}}\n\t${2}\n\\end{frame}"],
		"description": "insert frame snippet"
	},
	"insert paragraph":{
		"prefix": "paragraph",
		"body":["\\paragraph{${1}}~{}\\par"],
		"description": "insert paragraph snippet"
	},
	"insert columns":{
		"prefix": "columns",
		"body":["\\begin{columns}\n\t\\column{0.5\\textwidth}\n${1}\n\t\\column{0.5\\textwidth}\n\\end{columns}"],
		"description": "insert columns snippet"
	},
	"insert figures":{
		"prefix": "figures",
		"body":["\\begin{figure*}[htbp]\n\t\\begin{minipage}{0.5\\textwidth}\n\t\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\t\\caption{${3}}\n\t\t\\label{${4}}\n\t\\end{minipage}\n\t\\hfill\n\t\\begin{minipage}{0.5\\textwidth}\n\t\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\t\\caption{${3}}\n\t\t\\label{${4}}\n\t\\end{minipage}\n\\end{figure*}"],
		"description": "insert figures snippet"
	},
	"insert algorithmic":{
		"prefix": "algorithmic",
		"body":["%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\STATE\\IF  \\ENDIF\\FOR \\ENDFOR\\FOR \\TO  \\ENDFOR\\FORALL \n%\\ENDFOR\\WHILE \\ENDWHILE\\REPEAT  \\UNTIL\\LOOP\n%\\ENDLOOP\\REQUIRE \\ENSURE \\RETURN \\PRINT \\COMMENT,\\AND, \\OR, \\XOR, \\NOT, \\TO, \\TRUE, \\FALSE \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{algorithm}[htbp]\n\t\\caption{${1}}\n\t\\label{al:${2}}\n\t\\begin{algorithmic}\n\t\t\\REQUIRE{${3}}\n\t\t\\ENSURE{${3}}\n\t\\end{algorithmic}\n\\end{algorithm}"],
		"description": "insert algorithmic snippet"
	},
	"insert algorithm":{
		"prefix": "algorithm",
		"body":["\\begin{algorithm}[htbp]\n\t\\caption{${1}}\n\t\\label{al:${2}}\n\t\t\\KwIn{${3}}\n\t\t\\KwOut{${3}}\n\\end{algorithm}"],
		"description": "insert algorithm snippet"
	},
	"insert thebibliography":{
		"prefix": "thebibliography",
		"body":["\\begin{thebibliography}{99}\n\t\\bibitem{ref1} \n\t\\bibitem{ref2} \n\\end{thebibliography}"],
		"description": "insert thebibliography snippet"
	},
}

类似于利用我们自定义的代码片段来自动补全,看个gif演示:
snippets.gif

删除编译产生的无关文件

由于LaTeX文件在编译时会产生一大堆我们不需要的文件,会导致本地目录下一大堆奇奇怪怪的文件,因此强迫症建议直接在编译之后自动删除这些文件。直接在setting.json文件中添加:

    "latex-workshop.view.pdf.viewer": "tab",
    // "latex-workshop.latex.clean.enabled": true,
    "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",
    "*.gz"
    ],
    "latex-workshop.latex.autoClean.run": "onBuilt"

其他设置

  • LaTeX Workshop 默认保存的时候自动编译,如果不喜欢这个设置,可以添加以下代码进入设置区:
"latex-workshop.latex.autoBuild.run": "never",
  • 如果编译出错,插件会弹出两个很烦人的气泡,不喜欢的话可以在设置中添加以下代码:
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,

PS:如果使用VsCode+SumatraPdf来写LaTeX的话,需要注意SumatraPdf只能从VSCode打开,不然双击pdf会跳到cls文件中,导致搜索失败!!这里很烦,算是一个bug,但是平时注意以下就行了,也不算麻烦。文章来源地址https://www.toymoban.com/news/detail-407446.html

到了这里,关于VSCode+TeXLive2022 配置教程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 2022 VSCode+Vue3安装详细教程

    环境搭建:首先,看看您的电脑账户是否时管理员账户。如果不是,最好请登陆管理员账户。 1. 安装VSCode 官方网站: Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and avai

    2024年02月06日
    浏览(42)
  • Visual Studio2022下载安装教程

    首先去官网下载vs的安装包https://visualstudio.microsoft.com 日常学习使用,选择社区版就可以。 然后等待下载完成,双击安装 Visual Studio安装 根据官网的提示,要至少选择【Desktop Development with C++】 然后更改一下下载的路径,个人建议放在D盘,不要放在C盘,因为该软件所占内存比

    2024年02月11日
    浏览(42)
  • VSCode下载安装教程

    一、下载 Visual Studio Code官网下载 二、安装 1)下载好之后,双击进行安装 2)一直点击下一步 3)选择安装的目录 4)创建快捷方式 5)安装完成 三、切换中文环境 安装完成后,程序自动运行,右下方会弹出一个框框,单击【Install and Restart】可以选择切换成中文环境,方便使

    2024年02月10日
    浏览(28)
  • VS2022:卸载,下载安装教程,及可能遇到的问题

    参考链接:https://blog.csdn.net/weixin_69773211/article/details/129246227 下载地址:https://visualstudio.microsoft.com/zh-hans/?rr=https://www.microsoft.com/zh-cn/ 进入页面后,根据需要对版本进行选择,其中社区版为免费版本: 1.下载完之后双击打开下载的文件 2. 进去后出现主界面,仅用来写c++或者C语

    2024年02月08日
    浏览(66)
  • Visual Studio 2022 免费版最新版本下载安装教程

    首先,登录官网下载免费的社区版Visual Studio Visual Studio官网下载链接 选择需要安装的组件,一般c++就够了,如果从事Linux开发的话,需要滑倒最下面选择Linux和嵌入式( 不需要可以不用选 )    安装地址可以自己选择,如果c盘不够的话可以选择放在D盘,选好之后点击确认即

    2024年02月15日
    浏览(82)
  • 快速下载VScode并配置Python运行环境【详细教程】

    博主:命运之光 前言 本文主要内容,下载VScode和配置Python运行环境, 安装,主打的就是一个简单快速 下载vscode 第一步vscode官网下载 vscode官网下载 点击跳转到下载官网 第二步点击下载 第三步点击下载 下载后等待下载完成即可 安装vscode 第一步 第二步 第三步 第四步 第五步

    2024年02月01日
    浏览(51)
  • SQL Server2022 Express和SSMS下载安装教程(超详细)

    进入官网SQL Server 下载 | Microsoft,选择Express,点击立即下载。 下载完成后,双击打开exe文件,这里选择自定义安装,选择自己想要安装的位置。 等待一段时间下载完毕,弹出安装页面,因为我们的电脑是第一次安装SQL Server,所以在这里我们选择全新独立安装。 接受许可,下

    2023年04月24日
    浏览(43)
  • VScode下载安装教程(及官网下载提示网络错误下载失败问题解决)

    vscode官网 选择windows版本,64位系统: 如上版本的解读: User Installer版:区分计算机账户,切换另一个账户登录计算机会无法使用已经安装好的vscode; System Installer版:不区分计算机用户账户,都可以使用; Zip版:免安装版本,不会产生注册表,可以直接拷贝到其他电脑上面使用

    2024年02月13日
    浏览(55)
  • Tuxera2022 NTFS for Mac 的安装、密钥下载与激活教程

    本篇将为各位小伙伴们集中讲解一下NTFS读写工具Tuxera NTFS for Mac 是如何进行安装、密钥下载与激活的。 安装电脑:2020年MacBook Pro 系统:macOS Monterey 具体安装教程如下: 1、首先下载Tuxera最新版2022(务必从本帖下载安装的Tuxera方可激活) Tuxera2022免费安装包下载: https://souu

    2024年02月14日
    浏览(44)
  • R语言下载安装及VScode配置

    1. R 下载和安装 1.1 下载 网址:https://www.r-project.org/ 选择一个镜像地址下载 选择对应的版本 一般选择base即可 1.2 安装 下载安装包后按提示安装即可。注意尽量不要安装在C盘/系统盘,可能会出现其他错误,不只是占用系统盘空间。 2. VSCODE 配置 2.1 安装R拓展 2.2 安装R语言辅助

    2024年02月01日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包