感谢

Latex Vscode 配置
宝藏大佬博客,解决一系列latex微小问题「博客向这位学习」
Latex 简洁入门视频教程,高效明了

特别感谢各位的博客以及视频分享,感谢分享精神,我认为免费开源,分享学习是互联网的最大优点,也是最能推进学习进程的动力。

简介

LaTeX 是一种语言,CTex是一个集合了语言,编译工具的包,可以理解为Anaconda,现在已经比较老了,不建议安装。最新Latex版本为TexLive(win) mactex(macOS) 。
使用理由:

  1. 专注对口,不同期刊会议有不同的要求,latex切换更加方便。
  2. latex公式支持,不再局限于数学公式软件,操作繁杂且令人厌恶。
  3. 自动公式编号,高效文献引用。
  4. 代码书写思维,高效快捷。
  5. 不会卡,不会死机,占用资源底,不会丢。
  6. 跨平台编译,不受系统限制,也不会因为word版本不同显示乱码。

    编辑器

    Vscode

  7. 免费开源,微软大厂出品

  8. 简单小巧,运行速度快
  9. 高活跃社区,用的人越多,约好用。出现问题也好解决。

Texstudio

  1. Latex专业编辑软件。
  2. 设置更专业,界面化。
  3. 报错,界面更加友好。

    配置

    Vscode安装扩展,latex workshop
    创建新的.tex文件,会自动出现TEX扩展。
    就可以开始写了。写完之后,TEX扩展里面由View LatexPDF 可以编译预览。

    中文问题

  4. 基本设置

需要XeLatex ,但是原装扩展没有,需要自己加。
找到settings搜索latex,在json配置文件中用这段代码替换

  1. {
  2. "latex-workshop.view.pdf.viewer": "external",
  3. "latex-workshop.view.pdf.external.viewer.command": "E:/soft/SumatraPDF/SumatraPDF.exe", //绝对路径
  4. "latex-workshop.view.pdf.external.viewer.args": [
  5. "--unique",
  6. "%PDF%"
  7. ],
  8. "editor.minimap.enabled": true,
  9. "latex-workshop.latex.tools": [
  10. {
  11. "name": "xelatex",
  12. "command": "xelatex",
  13. "args": [
  14. "-synctex=1",
  15. "-interaction=nonstopmode",
  16. "-file-line-error",
  17. "%DOC%"
  18. ]
  19. },
  20. {
  21. "name": "xelatex-with-shell-escape",
  22. "command": "xelatex",
  23. "args": [
  24. "--shell-escape",
  25. "-synctex=1",
  26. "-interaction=nonstopmode",
  27. "-file-line-error",
  28. "%DOC%"
  29. ]
  30. },
  31. {
  32. "name": "xelatex-latexmk",
  33. "command": "latexmk",
  34. "args": [
  35. "-synctex=1",
  36. "-interaction=nonstopmode",
  37. "-file-line-error",
  38. "-xelatex",
  39. "-outdir=%OUTDIR%",
  40. "%DOC%"
  41. ]
  42. },
  43. {
  44. "name": "xelatex-latexmk-with-shell-escape",
  45. "command": "latexmk",
  46. "args": [
  47. "--shell-escape",
  48. "-synctex=1",
  49. "-interaction=nonstopmode",
  50. "-file-line-error",
  51. "-xelatex",
  52. "-outdir=%OUTDIR%",
  53. "%DOC%"
  54. ]
  55. },
  56. {
  57. "name": "pdflatex",
  58. "command": "pdflatex",
  59. "args": [
  60. "-synctex=1",
  61. "-interaction=nonstopmode",
  62. "-file-line-error",
  63. "%DOC%"
  64. ]
  65. },
  66. {
  67. "name": "pdflatex-with-shell-escape",
  68. "command": "pdflatex",
  69. "args": [
  70. "--shell-escape",
  71. "-synctex=1",
  72. "-interaction=nonstopmode",
  73. "-file-line-error",
  74. "%DOC%"
  75. ]
  76. },
  77. {
  78. "name": "pdflatex-latexmk",
  79. "command": "latexmk",
  80. "args": [
  81. "-synctex=1",
  82. "-interaction=nonstopmode",
  83. "-file-line-error",
  84. "-pdf",
  85. "-outdir=%OUTDIR%",
  86. "%DOC%"
  87. ]
  88. },
  89. {
  90. "name": "pdflatex-latexmk-with-shell-escape",
  91. "command": "latexmk",
  92. "args": [
  93. "--shell-escape",
  94. "-synctex=1",
  95. "-interaction=nonstopmode",
  96. "-file-line-error",
  97. "-pdf",
  98. "-outdir=%OUTDIR%",
  99. "%DOC%"
  100. ]
  101. },
  102. {
  103. "name": "latexmk",
  104. "command": "latexmk",
  105. "args": [
  106. "-synctex=1",
  107. "-interaction=nonstopmode",
  108. "-file-line-error",
  109. "-pdf",
  110. "%DOC%"
  111. ]
  112. },
  113. {
  114. "name": "bibtex",
  115. "command": "bibtex",
  116. "args": [
  117. "%DOCFILE%"
  118. ]
  119. },
  120. ],
  121. "latex-workshop.latex.recipes": [
  122. {
  123. "name": "PDFLaTeX",
  124. "tools": [
  125. "pdflatex"
  126. ]
  127. },
  128. {
  129. "name": "PDFLaTeX with Shell Escape",
  130. "tools": [
  131. "pdflatex-with-shell-escape"
  132. ]
  133. },
  134. {
  135. "name": "PDFLaTeX Auto",
  136. "tools": [
  137. "pdflatex-latexmk"
  138. ]
  139. },
  140. {
  141. "name": "PDFLaTeX Auto with Shell Escape",
  142. "tools": [
  143. "pdflatex-latexmk-with-shell-escape"
  144. ]
  145. },
  146. {
  147. "name": "XeLaTeX",
  148. "tools": [
  149. "xelatex"
  150. ]
  151. },
  152. {
  153. "name": "XeLaTeX with Shell Escape",
  154. "tools": [
  155. "xelatex-with-shell-escape"
  156. ]
  157. },
  158. {
  159. "name": "XeLaTeX Auto",
  160. "tools": [
  161. "xelatex-latexmk"
  162. ]
  163. },
  164. {
  165. "name": "XeLaTeX Auto with Shell Escape",
  166. "tools": [
  167. "xelatex-latexmk-with-shell-escape"
  168. ]
  169. },
  170. {
  171. "name": "PDFLaTeX -> BibTeX -> PDFLaTeX*2",
  172. "tools": [
  173. "pdflatex",
  174. "bibtex",
  175. "pdflatex",
  176. "pdflatex"
  177. ]
  178. },
  179. {
  180. "name": "XeLaTeX -> BibTeX -> XeLaTeX*2",
  181. "tools": [
  182. "xelatex",
  183. "bibtex",
  184. "xelatex",
  185. "xelatex"
  186. ]
  187. },
  188. {
  189. "name": "latexmk",
  190. "tools": [
  191. "latexmk"
  192. ]
  193. },
  194. {
  195. "name": "BibTeX",
  196. "tools": [
  197. "bibtex"
  198. ]
  199. },
  200. ],
  201. }

之后只需要在代码类定义中文包,用xelatex 编译就可以显示中文了

  1. \documentclass[UTF8]{ctexart}
  2. \begin{document}
  3. Hello world
  4. 你好
  5. \end{document}

eTlXBq

表格支持

浏览器搜索 latex table online ,用Excel编辑好,然后放入网站自动生成比较好。
要不然表格敲代码太麻烦了。

引用参考文献

新建bib文件,将bibtex放入到文件,在tex文件中引用。
注意:当你更改了tex文档的时候,需要先进行编译,然后才能预览,否则内容还是修改之前的内容

模版使用

模版下载可以浏览器搜索overleaf,或者搜索投稿论文对应期刊会议网站,一般会提供latex模版。

中文

打开字体册,把这些常用字体都下载下来,记录字体名称,设置对应位置即可。
jTupJ2
.tex头部引入如下代码,用XeLatex编译,注意文件编码要为UTF-8,先启用ctex环境。

  1. \setCJKmainfont[BoldFont=STFangsong, ItalicFont=STFangsong]{STSong}
  2. \setCJKsansfont[BoldFont=STFangsong]{STXihei}
  3. \setCJKmonofont{STFangsong}