答案1
根据此处找到的文档https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes,可以自定义构建过程中执行的命令行指令。因此,我们可以采用默认示例并向其添加一条指令,以将 pdf 文件复制到主目录中。
在 settings.json 文件中您可以添加:
"latex-workshop.latex.tools": [ // list of tools to be used by recipes
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": ["%DOCFILE%"],
"env": {}
},
{
"name": "pdf windows",
"command": "copy",
"args": ["%OUTDIR_W32%\\%DOCFILE%.pdf", "%DIR_W32%\\"]
},
{
"name": "pdf linux & mac",
"command": "cp",
"args": ["%OUTDIR%/%DOCFILE%.pdf", "%DIR%/"]
}
],
"latex-workshop.latex.recipes": [
{
"name": "latexmk",
"tools": ["latexmk", "pdf windows"] // or "pdf linux & mac" if you are on linux or mac
},
{
"name": "pdflatex -> bibtex -> pdflatex * 2",
"tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex", "pdf windows"] // or "pdf linux & mac" if you are on linux or mac
}
],
如果您使用的不是 Windows,请小心将“pdf windows”更改为“pdf linux & mac”。由于我们只是采用默认示例,并且不修改任何文件(因此进行复制),因此不应该出现任何问题。