这里写自定义目录标题
1.安装texlive2023
1.1 下载texlive2023.iso
在清华镜像站上下载texlive2023.iso(清华镜像链接),
1.2 解压iso文件
iso文件是压缩文件,可以使用winRar解压(如果认为winRar解压速度慢,可以使用7-zip)。这里我用的winRar。
1.3 运行install-tl-windows.bat文件
选择install-tl-windows.bat文件,右键选择以管理员身份运行。
极不建议安装在C盘!不要安装到含有中文的路径下。点“安装”,等待安装完毕。安装过程中不要点击abort。
继续耐心等待安装,
看到“欢迎进入 TeX Live 的世界!”,说明安装成功了。整个安装过程大概需要半个小时,要有耐心。
2.检验texlive是否安装成功
2.1 配置环境变量
在系统环境的path里面加上texlive的安装路径。以我的安装路径为例:D:\Program\texlive\2023\bin\windows
2.2 检验是否安装成功
在cmd窗口输入,
latex -v
出现版本则说明安装成功
3.vscode+latex写作
3.1 vscode安装
不安装在C盘
安装中文语言包
我重新打开VScode后,仍显示中文。这时需要,Ctrl+ Shift +P打开搜索框,输入display 选择Configure display Language,继续选择zh-cn。重启即可得到中文界面。
3.2 安装latex workshop插件
3.3 配置json文件
把下面代码块完全替换json中原代码。注意,要完全替换,即把原来的大括号{ }删了,再把下面的代码复制粘贴上去(包含{ })。一般默认是新安装vscode,因此之前的可能只有一个{ }。
{
//------------------------------LaTeX 配置----------------------------------
// 设置是否自动编译
"latex-workshop.latex.autoBuild.run":"never",
//右键菜单
"latex-workshop.showContextMenu":true,
//从使用的包中自动补全命令和环境
"latex-workshop.intellisense.package.enabled": true,
//编译出错时设置是否弹出气泡设置
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
// 编译工具和命令
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "lualatex",
"command": "lualatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-shell-escape",//这个命令行在网上的Latex Workshop设置里一般没有,所以直接recipe会报错
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
// 用于配置编译链
"latex-workshop.latex.recipes": [
{
"name": "PDFLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "LuaLaTeX",
"tools": [
"lualatex"
]
},
{
"name": "XeLaTeX",
"tools": [
"xelatex"
]
},
{
"name": "BibTeX",
"tools": [
"bibtex"
]
},
{
"name": "LaTeXmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"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"
],
//设置为onFaild 在构建失败后清除辅助文件
"latex-workshop.latex.autoClean.run": "onFailed",
// 使用上次的recipe编译组合
"latex-workshop.latex.recipe.default": "lastUsed",
//使用 SumatraPDF 预览编译好的PDF文件
// 设置VScode内部查看生成的pdf文件
"latex-workshop.view.pdf.viewer": "tab",
// PDF查看器用于在\ref上的[View on PDF]链接
"latex-workshop.view.pdf.ref.viewer": "auto",
"editor.wordWrap": "on",
"editor.renderControlCharacters": false,
}
3.4 tex 测试文件编译
- 打开测试文件所在文件夹
- 点击选中 tex 文件,打开tex文件
- 编译文件
由于进行测试的文件中涉及参考文献的引用(.bib的编译),故而选择xelatex -> bibtex -> xelatex*2编译链。
- 编译成功
当发现页面下方出现 √ 符号时,说明编译成功
- 查看编译完成的pdf
参考教程
- VSCode 安装、配置教程
https://zhuanlan.zhihu.com/p/264785441
https://blog.csdn.net/m0_54689021/article/details/126220114 - VSCode配置texlive环境
https://zhuanlan.zhihu.com/p/624932249
https://zhuanlan.zhihu.com/p/166523064 - 安装texlive2023
https://zhuanlan.zhihu.com/p/617431548