在Windows下使用Visual Studio Code+Tex Live搭建Latex环境

在Windows下使用Visual Studio Code搭建Latex环境

  • 1. 下载VS code和Tex Live
  • 2. VS code插件下载安装
  • 3.VS code 配置LaTex环境
  • 4.VS code测试文件

1. 下载VS code和Tex Live

1)vscode下载地址
http://mirrors.ustc.edu.cn/CTAN/systems/texlive/Images/

2)Tex Live下载地址
http://mirrors.ustc.edu.cn/CTAN/systems/texlive/Images/
安装参考https://zhuanlan.zhihu.com/p/38178015

2. VS code插件下载安装

  • LaTeX Workshop*
  • LaTex language support
  • LaTex Preview
  • latex-formatter (需要下载 latexindent.pl,并添加到系统环境变量)

3.VS code 配置LaTex环境

setting.json文件设置recipestools

  • 快捷键cmd(ctrl)+shift+p输入setting打开settings.json把以下代码加入,注意在原本内容的最后一行加上英文逗号换行再复制粘贴,不然会报错

  • recipes的第一个为默认编译方式

  • 推荐使用VS code自带pdf预览:

    "latex-workshop.view.pdf.viewer": "tab",
    
  • 此外如果需要支持中文路径下的文件,需要把以下内容中 的%DOC%改为%DOCFILE%",但此处笔者建议涉及代码 方面不要用中文路径

{
    "latex-workshop.latex.recipes": [
  {
    "name": "pdflatex -> bibtex -> pdflatex*2",
    "tools": [
        "pdflatex",
        "bibtex",
        "pdflatex",
        "pdflatex"
    ]
  },
  {
    "name": "xelatex",
    "tools": [
        "xelatex"
    ]
  }, 
  {
    "name": "latexmk",
    "tools": [
        "latexmk"
    ]
  },
  {
    "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",
    "%DOCFILE%"
  ]
  }, {
  "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": "bibtex",
  "command": "bibtex",
  "args": [
    "%DOCFILE%"
  ]
  }],
  "latex-workshop.view.pdf.viewer": "tab",
  "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"
  ],
  "editor.minimap.enabled": false,
  "breadcrumbs.enabled": true,
  "window.zoomLevel": 0,
  }

4.VS code测试文件

 % !TEX program= xelatex
 \documentclass{ctexart}
 \usepackage[utf8]{inputenc}
 \title{测试}
 \author{作者}
 
\begin{document}
\maketitle
 一份测试文档
\end{document}
  1. 指定TEX文件编译方式为XELATEX
  2. 指定文档类别为ctexart,(用于编译中文)
  3. 指定字符编码为utf8
  4. 文档标题
  5. 作者信息
  6. 在document环境中,生成标题与书写正文

你可能感兴趣的:(编程语言)