介绍
本文章所描述的环境配置仅适用于TeX Live(latex) + vscode + latex workshop(vscode extension)
。
本配置可以实现以下功能:
- tex文件编译。
- 自定义编译输出目录。
工具
编译
- Tex(宏语言)
- latex(基于Tex的宏集)
- 编译工具
- xelatex:使用xetex编译latex
- pdflatex:使用pdftex编译latex
- 周边工具
- bibtex:用于排版参考文献
编译工具及其命令配置
"latex-workshop.latex.tools": [
{
// 编译工具和命令
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"--output-directory=%OUTDIR%", # 指定编译输出目录
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"--output-directory=%OUTDIR%", # 指定编译输出目录
"%DOCFILE%"
],
},
{
"name": "bibtex",
"command": "bibtex",
"args": ["%OUTDIR%/%DOCFILE%"],
"env": {
"TEXMFOUTPUT": "%OUTDIR%", # 指定编译输出目录
}
}
]
工具链
工具链配置
"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"]
}
]
自定义输出目录
这里是指定编译输出目录的地方。%DIR%/build
指定的输出目录是当前项目根目录里的build目录。
"latex-workshop.latex.outDir": "%DIR%/build"
完整配置
"latex-workshop.latex.outDir": "%DIR%/build",
"latex-workshop.latex.tools": [
{
// 编译工具和命令
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"--output-directory=%OUTDIR%",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"--output-directory=%OUTDIR%",
"%DOCFILE%"
],
},
{
"name": "bibtex",
"command": "bibtex",
"args": ["%OUTDIR%/%DOCFILE%"],
"env": {
"TEXMFOUTPUT": "%OUTDIR%",
}
}
],
"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"]
}
],