Win10+TeXLive2018+VSCode+LaTexWorkshop+支持中文

打开VSCode

打开扩展管理,搜索LaTeX Workshop点击安装
安装完后启动插件,重启VSCode

插件配置及中文支持

点击文件->首选项->设置
搜索latex-workshop.latex.recipes并点击打开setttings.json,打开后复制下面代码

配置代码如下:

{
    "editor.wordWrap": "on",
    "workbench.startupEditor": "newUntitledFile",
    "latex-workshop.latex.clean.enabled": true,
    "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",
        "*.gz"
    ],
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.latex.recipes": [
 {
            "name": "xelatex",
            "tools": [
              "xelatex",
              "xelatex"
            ]
          },
        {
            "name": "xelatexb",
            "tools": [
              "xelatex",
              "bibtex",
              "xelatex",
              "xelatex"
            ]
          },
        {
          "name": "latexmk",
          "tools": [
            "latexmk"
          ]
        },
        {
          "name": "pdflatex -> bibtex -> pdflatex*2",
          "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
          ]
        }
      ],
      "latex-workshop.latex.tools": [
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
          ]
        },
        {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
          ]
        },
        {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
            "%DOCFILE%"
          ]
        }
      ]
}
配置解释如下

“latex-workshop.latex.clean.enabled”是否删除每次编译成pdf时生成得到中间文件
"latex-workshop.latex.clean.fileTypes"删除哪些文件
“latex-workshop.latex.tools”配置排版引擎程序
"latex-workshop.latex.recipes"定义排版引擎程序调用顺序

注意

默认使用排版引擎程序调用顺序配置"latex-workshop.latex.recipes"中的第一个进行编译排版,上述配置中第一个xelatex不会对bib形式的参考文献编译排版,如用bib形式的参考文献请把第二个xelatexb移到第一个,否则会报错

让LaTeX编译器支持中文,还需在tex文件头部添加如下代码

\documentclass[UTF8]{ctexart} %ctexart是ctex article的缩写
或
\documentclass[UTF8]{article}
\usepackage{ctex}
LaTeX实例
\documentclass[UTF8]{ctexart}
\author{5john}
\title{LaTeX中文支持及字体}
\begin{document}
\maketitle
{\kaishu 这里是楷体显示}{\songti 这里是宋体显示}{\heiti 这里是黑体显示}{\fangsong 这里是仿宋显示}{\lishu 这里是隶书显示}{\youyuan 这里是幼圆显示}
\end{document}
编译结果

经过上述设置,编写好tex文件后,在保存文件的同时进行编译输出

Win10+TeXLive2018+VSCode+LaTexWorkshop+支持中文_第1张图片

注意

文件所在路径和文件名不要有中文,不然会编译失败

你可能感兴趣的:(Latex,latex)