[LaTeX] MacTex + VS Code(以哈工大开题报

2020-07-13  本文已影响0人  siliconx

1. 下载MacTex, 下载好后打开安装

MacTeX就是Mac版的TeXLive。MacTex虽然比较大,但是安装好以后就可以直接使用,不用再费心装各种中文依赖包。安装好以后检查一下是否安装成功(要开新的终端窗口,旧终端因为环境变量没有更新,所以会报错):


检查xelatex

2. 下载VS Code并安装插件:

不得不佩服VS Code的强大,什么插件都有,可以说是可定制的IDE了。为了处理LaTeX,需要安装如下插件

3. 配置LaTeX Workshop

LaTeX Workshop默认使用pdfLaTeX进行编译,为了使其支持中文,需要选择XeLaTeX编译。Command+Shift+P, 搜索关键词settings,选择Preference open settings (JSON),插入以下内容:

"latex-workshop.latex.recipes": [
      {
        "name": "xelatex",
        "tools": [
          "xelatex"
        ]
      },
      {
        "name": "xe*2",
        "tools": [
          "xelatex",
          "xelatex"
        ]
      },
      {
        "name": "xelatex -> bibtex -> xelatex*2",
        "tools": [
          "xelatex",
          "bibtex",
          "xelatex",
          "xelatex"
        ]
      }
    ],
    "latex-workshop.latex.tools": [
      {
        "name": "latexmk",
        "command": "latexmk",
        "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "-pdf",
          "%DOC%"
        ]
      },
      {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
        ]
      },
      {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
          "%DOCFILE%"
        ]
      }
    ],
    "latex-workshop.view.pdf.viewer": "tab"

4. 重启VS code

插件重启后才能生效。

5. 下载并编译模板

$ git clone https://github.com/dustincys/hithesis.git
$ cd hithesis
$ xelatex hithesis.ins
编译模版

6. 开始写报告

在VS code中打开hithesis/examples/reports/report.tex
编译:Command+Option+B
查看pdf:Command+Option+V
最终效果:

示例

7.参考文章

  1. https://zhuanlan.zhihu.com/p/107393437
上一篇下一篇

猜你喜欢

热点阅读