问答媒体

 找回密码
 立即注册
快捷导航
搜索
热搜: 活动 交友 discuz
查看: 101|回复: 7

用VSCode配置Latex

[复制链接]

1

主题

6

帖子

12

积分

新手上路

Rank: 1

积分
12
发表于 2022-12-2 19:15:29 | 显示全部楼层 |阅读模式
之前用VScode配置了Latex(原来的配置均从网络汇总),但是换了一台电脑,重新从网上找的配置不太满意,所以把原来的copy过来了,感觉还是原来的顺手呀。就当给自己存个档,顺便留给大家,有需要自取。

  • 安装texlive
  • 安装vscode
  • 在vscode中安装latex workshop 插件
  • 在vscode-setting.json中复制如下代码
完成!
<hr/>另外可能存在一些些问题,譬如评论区有位小伙伴
”build的时候显示Recipe terminated with fatal error: spawn xelatex ENOENT.怎么办“
大概这也是我没想过的问题,我搜了一下,可能的解决方案是
把安装路径加入到系统环境变量path里重启,我的就是  D:\texlive\2020\bin\win32
以及如果点了半天Recipe:xelatex或者Recipe:pdflatex等没反应,一定要检查自己的latex框架写对了没有
\documentclass[UTF8]{ctexart}
\begin{document}

\begin{equation}
    a^2+b^2=c^2
\end{equation}

\end{document}
<hr/>"latex-workshop.latex.tools": [
    {
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
        ]
    },
    {
"name": "latexmk",
"command": "latexmk",
"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": "latexmk",
"tools": [
"latexmk"
        ]
    },
    {
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
        ]
    }
],
"latex-workshop.latex.clean.enabled": false,
"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.view.pdf.viewer": "tab",
"latex-workshop.latex.autoClean.run": "onBuilt"
}<hr/>
回复

使用道具 举报

0

主题

5

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2022-12-2 19:15:47 | 显示全部楼层
萌新想请问一下作者,按照您的setting配置之后,build的时候显示Recipe terminated with fatal error: spawn xelatex ENOENT.怎么办啊
回复

使用道具 举报

0

主题

4

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2022-12-2 19:16:19 | 显示全部楼层
你试试这个吧https://blog.csdn.net/qq_41342036/article/details/106340137
回复

使用道具 举报

1

主题

6

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2022-12-2 19:17:11 | 显示全部楼层
谢谢您,我也有看到这篇文章,但我不会怎么把latex放到path里[大哭]
我有参考https://blog.csdn.net/explorer9607/article/details/103506387
进行操作,加入后在命令行工具里也输入rex -v也有相应的输出,但是在vs code里依然无法识别[大哭]
您能指导一下吗,谢谢您
回复

使用道具 举报

1

主题

5

帖子

4

积分

新手上路

Rank: 1

积分
4
发表于 2022-12-2 19:17:48 | 显示全部楼层
用 latexmk 了,那么多 Recipes 和 tools 都没必要。
回复

使用道具 举报

1

主题

3

帖子

5

积分

新手上路

Rank: 1

积分
5
发表于 2022-12-2 19:18:15 | 显示全部楼层
点开电脑,把texlive下面年份文件夹下面win32文件夹放进PATH
回复

使用道具 举报

0

主题

1

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2022-12-2 19:19:07 | 显示全部楼层
配置了环境变量后还是出现Recipe terminated with fatal error: spawn xelatex是怎么回事,cmd中也没有问题
回复

使用道具 举报

1

主题

5

帖子

10

积分

新手上路

Rank: 1

积分
10
发表于 前天 09:00 | 显示全部楼层
看起来好像不错的样子
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver| 手机版| 小黑屋| 问答媒体

GMT+8, 2025-7-6 22:50 , Processed in 0.144219 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2020, LianLian.

快速回复 返回顶部 返回列表