VS Code配置LaTeX,正向搜索,反向搜索

5月11日更新:VSCode 自带pdf阅读器的反向搜索:按住Ctrl点击鼠标即可。

--------------------------------------------------------------------------------------------------

1.安装VS Code

2.安装texlive

3.VS Code安装LaTeX Workshop插件

4.安装SumatraPDF作为PDF阅读器

在VS Code中Preferences的settings里添加

//Latex 配置
    "latex-workshop.latex.recipes": [
    {
    "name": "pdflatex",
    "tools": [
          "pdflatex"
        ]
    },
    {
    "name": "xelatex",
    "tools": [
        "xelatex"
        ]
    },
    {
    "name": "lualatex",
    "tools": [
        "lualatex"
        ]
    },
    {
    "name": "bibTeX",
    "tools": [
        "bibtex"
        ]
    },
    {
    "name": "xelatex -> bibtex -> xelatex*2",
    "tools": [
          "xelatex",
          "bibtex",
          "xelatex",
          "xelatex"
        ]
    },
    {
    "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": "pdflatex",
    "command": "pdflatex",
    "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
        ]
    },
    {
    "name": "lualatex",
    "command": "lualatex",
    "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
        ]
    },
    {
    "name": "bibtex",
    "command": "bibtex",
    "args": [
        "%DOCFILE%"
        ]
    }],
    "latex-workshop.view.pdf.viewer": "external",
    "latex-workshop.view.pdf.external.viewer.command": "C:/Program Files/SelfSoftware/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.viewer.args": [
        "-forward-search",
        "%TEX%",
        "%LINE%",
        "-reuse-instance",
        "-inverse-search",
        "\"C:/Program Files/SelfSoftware/Microsoft VS Code/Code.exe\" \"C:/Program Files/SelfSoftware/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
        "%PDF%"
    ],
    "latex-workshop.view.pdf.external.synctex.command": "C:/Program Files/SelfSoftware/SumatraPDF/SumatraPDF.exe",
    "latex-workshop.view.pdf.external.synctex.args": [
        "-forward-search",
        "%TEX%",
        "%LINE%",
        "-reuse-instance",
        "-inverse-search",
        "code \"C:/Program Files/SelfSoftware/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
        "%PDF%",
    ],
    "latex-workshop.latex.clean.fileTypes": [
    "*.aux",
    "*.bbl",
    "*.blg",
    "*.idx",
    "*.ind",
    "*.lof",
    "*.lot",
    "*.out",
    "*.toc",
    "*.acn",
    "*.acr",
    "*.alg",
    "*.glg",
    "*.glo",
    "*.gls",
    "*.ist",
    "*.fls",
    "*.log",
    "*.nav",
    "*.snm",
    "*.vrb",
    "*.fdb_latexmk"
    ],

其中,

"latex-workshop.view.pdf.viewer": "external",

表示使用外部的SumatraPDF作为默认阅读器,也可以修改为tab或browser,即默认使用Code自带阅读器或浏览器查看。

"latex-workshop.latex.clean.fileTypes":

 表示删除掉编译过程中生成的其他文件。(注意保留.synctex.gz文件用于正反向搜索)

代码中的绝对路径,请修改为你的SumatraPDF安装路径。

End

你可能感兴趣的:(环境配置)