Win10+VSCode+Texlive+SumatraPDF搭建Latex环境

Win10+VSCode+Texlive+SumatraPDF搭建Latex环境

B站视频配置指南

vscode latex-workshop插件配置模板

简要说明:

  • "latex-workshop.latex.tools": 基本编译工具
  • "latex-workshop.latex.recipes": 编译环境中调用的编译命令组合,会显示在vscode的tex选项的build界面
  • "latex-workshop.view.pdf.viewer": 配置编译生成的pdf的打开方式
  • - "latex-workshop.view.pdf.external.viewer.command": 前一项选择external后,这一项指定外部pdf阅读器的路径(根据自己的sumatra的安装路径填写)
  • - "latex-workshop.view.pdf.external.synctex.command": 配置正反向同步使用的pdf命令,一般同上一项的pdf阅读器路径
  • - "latex-workshop.view.pdf.external.synctex.args": 配置同步参数,该项第六行需要vscode的安装路径进行修改。注意,如果安装路径中有空格,需要在路径前后加``\"``来屏蔽空格
  • - "latex-workshop.view.pdf.internal.synctex.keybinding": 指定从pdf返乡同步至tex的方式。支持双击或者ctrl+单击的方式

配置模板:

{
  "latex-workshop.latex.tools": [
    {
      "name": "pdflatex",
      "command": "pdflatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ]
    },
    {
      "name": "xelatex",
      "command": "xelatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ]
    },
    {
      "name": "bibtex",
      "command": "bibtex",
      "args": [
        "%DOCFILE%"
      ]
    }
  ],


  "latex-workshop.latex.recipes": [
    {
      "name": "pdflatex",
      "tools": [
        "pdflatex"
      ]
    },
    {
      "name": "xelatex",
      "tools": [
        "xelatex"
      ]
    },
    {
      "name": "xe->bib->xe->xe",
      "tools": [
        "xelatex",
        "bibtex",
        "xelatex",
        "xelatex"
      ]
    },
    {
      "name": "pdflatex -> bibtex -> pdflatex*2",
      "tools": [
        "pdflatex",
        "bibtex",
        "pdflatex",
        "pdflatex"
      ]
    }
  ],

  
  "latex-workshop.latex.autoBuild.run": "never",
  "latex-workshop.synctex.afterBuild.enabled": true,

  "latex-workshop.view.pdf.viewer": "external",
  "latex-workshop.view.pdf.external.viewer.command": "C:/SumatraPDF/SumatraPDF.exe",

  "latex-workshop.view.pdf.external.synctex.command": "C:/SumatraPDF/SumatraPDF.exe",
  "latex-workshop.view.pdf.external.synctex.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"C:/VSCode/Code.exe\" -g \"%f:%l\"",
    "%PDF%"
  ],
  "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click"
}

英文示例

选择pdflatex编译

\documentclass{article}
\begin{document}

\title{Response Letter}
\date{}
\maketitle

We greatly appreciate all reviewers and editors for the constructive comments.

\end{document}

中文示例

选择xelatex编译

\documentclass[UTF8]{ctexart}
\begin{document}
    中文测试。
\end{document}

发布于 2020-08-16 21:05