vscode+TeX Live(latex) +latex workshop配置(指定编译输出目录)

介绍

本文章所描述的环境配置仅适用于TeX Live(latex) + vscode + latex workshop(vscode extension)
本配置可以实现以下功能:

  1. tex文件编译。
  2. 自定义编译输出目录。

工具

编译

  • Tex(宏语言)
    • latex(基于Tex的宏集)
  • 编译工具
    • xelatex:使用xetex编译latex
    • pdflatex:使用pdftex编译latex
  • 周边工具
    • bibtex:用于排版参考文献

参考12

编译工具及其命令配置

  "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"]
    }
  ],

使用


  1. LaTeX 与 TeX 有什么本质区别? - 刘海洋的回答 - 知乎
    https://www.zhihu.com/question/49681542/answer/117303280 ↩︎

  2. TeXShop 里面的引擎(如 plain TeX, LaTeX,BibTeX)各适用于什么情况? - 孟晨的回答 - 知乎
    https://www.zhihu.com/question/20638337/answer/21527805 ↩︎

  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值