VSCode + LaTeX Workshop 环境配置

转载自:https://www.jianshu.com/p/47c456572e87

TeXLive下载与安装

TeXLive下载链接
百度云下载链接 bfwp
安装时长20分钟左右

VSCode下载与安装

VSCode官网传送门

LaTexWorkshop插件安装

  • 打开VSCode
  • <Ctrl+Shift+x>打开扩展管理,搜索LaTeX Workshop,点击安装
  • 安装完后启动插件,重启VSCode

插件配置及中文支持

  • 点击文件->首选项->设置
  • 搜索latex-workshop.latex.recipes并点击Edit setttings.json,打开后左边为插件默认配置,无法修改,我们可以在右侧用户设置中定义同样的属性名称,达到修改配置的目的

    <p>image.png</p>
    </li>
    

image.png

所有配置如下


 
 
  1. {
  2. "editor.wordWrap": "on",
  3. "workbench.startupEditor": "newUntitledFile",
  4. "latex-workshop.latex.clean.enabled": true,
  5. "latex-workshop.latex.clean.fileTypes": [
  6. "*.aux",
  7. "*.bbl",
  8. "*.blg",
  9. "*.idx",
  10. "*.ind",
  11. "*.lof",
  12. "*.lot",
  13. "*.out",
  14. "*.toc",
  15. "*.acn",
  16. "*.acr",
  17. "*.alg",
  18. "*.glg",
  19. "*.glo",
  20. "*.gls",
  21. "*.ist",
  22. "*.fls",
  23. "*.log",
  24. "*.fdb_latexmk",
  25. "*.gz"
  26. ],
  27. "latex-workshop.view.pdf.viewer": "tab",
  28. "latex-workshop.latex.recipes": [
  29. {
  30. "name": "xelatex",
  31. "tools": [
  32. "xelatex",
  33. "xelatex"
  34. ]
  35. },
  36. {
  37. "name": "xelatexb",
  38. "tools": [
  39. "xelatex",
  40. "bibtex",
  41. "xelatex",
  42. "xelatex"
  43. ]
  44. },
  45. {
  46. "name": "latexmk",
  47. "tools": [
  48. "latexmk"
  49. ]
  50. },
  51. {
  52. "name": "pdflatex -> bibtex -> pdflatex*2",
  53. "tools": [
  54. "pdflatex",
  55. "bibtex",
  56. "pdflatex",
  57. "pdflatex"
  58. ]
  59. }
  60. ],
  61. "latex-workshop.latex.tools": [
  62. {
  63. "name": "xelatex",
  64. "command": "xelatex",
  65. "args": [
  66. "-synctex=1",
  67. "-interaction=nonstopmode",
  68. "-file-line-error",
  69. "%DOC%"
  70. ]
  71. },
  72. {
  73. "name ": "latexmk ",
  74. "command ": "latexmk ",
  75. "args ": [
  76. "-synctex= 1 ",
  77. "-interaction=nonstopmode ",
  78. "-file-line-error ",
  79. "-pdf ",
  80. "%DOC%"
  81. ]
  82. },
  83. {
  84. "name": "pdflatex",
  85. "command": "pdflatex",
  86. "args": [
  87. "-synctex=1",
  88. "-interaction=nonstopmode",
  89. "-file-line-error",
  90. "%DOC%"
  91. ]
  92. },
  93. {
  94. "name ": "bibtex ",
  95. "command ": "bibtex ",
  96. "args ": [
  97. "%DOCFILE%"
  98. ]
  99. }
  100. ]
  101. }

配置解释如下

  • “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文件头部添加如下代码


 
 
  1. \documentclass[UTF8] {ctexart} %ctexart是ctex article的缩写
  2. \documentclass[UTF8] {article}
  3. \usepackage {ctex}

LaTeX实例


 
 
  1. \documentclass[UTF8]{ctexart}
  2. \author{ 5john}
  3. \title{LaTeX中文支持及字体}
  4. \begin{ document}
  5. \maketitle
  6. {\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示},{\lishu 这里是隶书显示},{\youyuan 这里是幼圆显示}
  7. \end{ document}

编译结果

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

 

image.png

注意

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

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值