码迷,mamicode.com
首页 > 其他好文 > 详细

VScode 配置为 LaTeX IDE

时间:2019-11-03 12:35:41      阅读:711      评论:0      收藏:0      [点我收藏+]

标签:dir   lis   exe   app   odi   扩展   trap   vsc   一个   

VScode 配置为 LaTeX IDE

安装扩展

ctrl+shift+x调出应用商店,搜索并安装如下扩展:

  • LaTeX Workshop ;
  • pdf-formatter
  • LaTeX Preview

配置LaTeX Workshop

LaTeX文件.tex的编译、预览、辅助文件的清理等都在扩展latex workshop中设置。

LaTeX Workshop中,编译LaTeX文件时顺序执行的一系列/组命令称为LaTeX食谱(recipes),定义在latex-workshop.latex.recipes。缺省情况,LaTeX Workshop包含2个基本的食谱,分别由latex-workshop.latex.recipeslatex-workshop.latex.Tools定义。第一个食谱的tools域中的工具定义在第二个食谱。latex workshop的参数含义见LaTeX Workshop的配置文件"package.json"或https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes了解配置情况。

LaTeX Workshop默认的编译方式为latexmkpdflatex。如下配置修改了latex workshop的编译方式、预览、辅助文件等。特别添加了xelatex及包含bib时的编译。

ctrl+shift+p ->settings->首选项:打开用户设置(Json),在settings.json中添加如下内容:

"latex-workshop.intellisense.package.enabled": true,  //根据加载的包,自动完成命令或包  
"latex-workshop.latex.autoBuild.run": "never",           //禁止保存文件时自动build  
"latex-workshop.latex.recipes": [  
  {  
    "name": "latexmk",  
    "tools": [  
      "latexmk"  
    ]  
  },  
  {  
    "name": "PDFlatex",  
    "tools": [  
      "pdflatex"  
    ]  
  },  
  {  
    "name": "pdflatex ->?? bibtex ->?? pdflatex2",  
    "tools": [  
      "pdflatex",  
      "bibtex",  
      "pdflatex",  
      "pdflatex"  
    ]  
  },  
  {  
    "name": "xelatex",  
    "tools": [  
      "xelatex"  
    ]  
  },  
  {  
    "name": "xelatex -> bibtex -> xelatex",  
    "tools": [  
      "xelatex",  
      "bibtex",  
      "xelatex",  
    ]  
  }  
],  
"latex-workshop.latex.tools":[  
  {  
    "name": "latexmk",  
    "command": "latexmk",  
    "args": [  
      "-synctex=1",  
      "-interaction=nonstopmode",  
      "-file-line-error",  
      "-pdf",  
      "-outdir=%OUTDIR%",  
      "%DOC%"  
    ],  
    "env": {}  
    },  
    {  
    "name": "pdflatex",  
    "command": "pdflatex",  
    "args": [  
      "-synctex=1",  
      "-interaction=nonstopmode",  
      "-file-line-error",  
      "%DOC%"  
    ],  
    "env": {}  
    },  
    {  
    "name": "xelatex",  
    "command": "xelatex",  
    "args": [  
      "-synctex=1",  
      "-interaction=nonstopmode",  
      "-file-line-error",  
      "%DOC%"  
    ],  
    "env": {}  
    },  
    {  
    "name": "bibtex",  
    "command": "bibtex",  
    "args": [  
      "%DOCFILE%"  
    ],  
    "env": {}  
    }  
],  
"latex-workshop.view.pdf.viewer":"tab",  //pdf文件的预览方式  
"latex-workshop.view.pdf.external.synctex": {  
  "command": "SumatraPDF.exe",  
  "args": [  
    "-forward-search",  
    "%TEX%",  
    "%LINE%",  
    "-reuse-instance",  
    "-inverse-search",  
    "D:\\ProgramFiles\\Coding\\VSCode\\Code.exe D:\\ProgramFiles\\Coding\\VSCode\\resources\\app\\ut\\cli.js -r   -g \"%f:%l\"",  
    "%PDF%"  
  ]  
},  
//"latex-workshop.latex.autoClean.run": "onBuilt",  //设置自动清理方式  
"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",  
  "*.nav",  
  "*.snm",  
  "*.synctex.gz"  
],  

修改快捷键

ctrl+k,ctrl+b打开键盘快捷方式面板:

  • 搜索 latex build,将默认的ctrl+alt+b替换为ctrl+b(与Sublime Text 3统一)
  • 搜索latex recipe,设置快捷键为ctlr+r,方便点菜!(ST3中是显示文档大纲)
  • 其他常用的快捷键:
    • ctrl+alt+c:清除辅助文件
    • ctrl+alt+v:查看编译的pdf文件

一些快捷处理

根据latex-workshop.latex.recipes中的name段设定,可在.tex文件首行指定编译方式。如%!TEX program = xelatex表示用xelatex编译文件,而%!TEX program = PDFlatex表示用latexpdf编译文件。多个文件情况,还可以用% !TEX root指定主文件。

示例

%! TeX program = pdflatex
\documentclass{article}

\begin{document}
    press ctrl+b to complie,press ctrl+alt+v to view pdf
\end{document}

参考文章
使用VSCode编写LaTeX

VScode 配置为 LaTeX IDE

标签:dir   lis   exe   app   odi   扩展   trap   vsc   一个   

原文地址:https://www.cnblogs.com/ourweiguan/p/11785660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!