其他分享
首页 > 其他分享> > VSCode + LaTeX Workshop 环境配置

VSCode + LaTeX Workshop 环境配置

作者:互联网

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

TeXLive下载与安装

TeXLive官网传送门
百度云下载链接 bfwp
安装时长20分钟左右

VSCode下载与安装

VSCode官网传送门

LaTexWorkshop插件安装

插件配置及中文支持

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.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

注意

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

标签:LaTeX,pdflatex,name,latex,VSCode,workshop,Workshop,xelatex,tools
来源: https://blog.csdn.net/weixin_43615222/article/details/87888000