• LaTex排版系统:TeX Live+Visual Studio Code的配置


    配置Tex排版系统需要安装编译器+编辑器,编译器通常安装TeX Live,编辑器主要有TeXworks、TexStudio、WinEdt、Visual Studio Code等,目前VS Code普遍评价不错。下面介绍Windows平台安装LaTex的详细步骤。

    1 安装TeX Live

    1.1 下载地址选择国内镜像站,官网较慢,点击“texlive.iso”【下载地址:https://mirrors.huaweicloud.com/CTAN/systems/texlive/Images/】。

    2. 下载好后,不需要解压,直接“右键-打开方式-文件资源管理器”即可。然后你就会跳转到一个虚拟光驱里面,点击“install-tl-windows.bat”

     

    3. 安装配置。点击“Advance”,然后可以修改安装目录“Installation root”。点击“Customize”,左边语言包先点击“无”,然后只勾选“Chinese”和“US and UK English”,右边工程包不勾选“TeXworks editor; TL includes only the Windows binary”,即不勾选配置主菜单的“安装TeXworks前端”(工程包和配置主菜单其他项均勾选)。最后点击“确定”,再点击“安装”,耐心等待安装完成,安装时间将持续30分钟甚至更长。

    4. 完成后,灰色“关闭”按钮可以点击。点击“关闭”即完成TeX Live的安装。接着,不要忘记在“此电脑”中右键弹出虚拟光驱。最后(一般不需要),按win+R打开“运行”,输入cmd,或者搜索框搜索“cmd”,打开命令行窗口。输入命令“xelatex -v”,验证安装。

    2 安装Visual Studio Code

    使用官方下载,点击“Download for Windows”,自行安装即可。

    https://code.visualstudio.com/

    3 配置IDE

    1. 先点击“扩展”图标,再搜索“Chinese”,再点击Install,点击右下角弹出窗口的“Restart now”,安装中文语言包。

    2. 接着“Tex”,再点击Install,点击弹出的“信任工作区并安装”按钮,安装Tex扩展包。此外,这个时候你可以适当调整合适的界面字体大小。

    3. 打开LaTeX环境设置页面。点击设置图标,点击菜单中的“设置”,再点击右上角设置按钮,打开json配置文件。实际上,GUI设置页面和json设置页面作用相同。不同的是,GUI设置页面更直观,但项目需要去寻找,比较麻烦,且不能快速导入配置,而json设置页面以代码形式可以很快的导入配置。最后,删除“setting.json”配置文件默认的代码,复制粘贴以下标准配置代码,然后点击左上角“文件-保存”,再关闭“setting.json”。

    1. {
    2. // 设置是否自动编译
    3. "latex-workshop.latex.autoBuild.run":"never",
    4. //右键菜单
    5. "latex-workshop.showContextMenu":true,
    6. //从使用的包中自动补全命令和环境
    7. "latex-workshop.intellisense.package.enabled": true,
    8. //编译出错时设置是否弹出气泡设置
    9. "latex-workshop.message.error.show": false,
    10. "latex-workshop.message.warning.show": false,
    11. // 编译工具和命令
    12. "latex-workshop.latex.tools": [
    13. {
    14. "name": "xelatex",
    15. "command": "xelatex",
    16. "args": [
    17. "-synctex=1",
    18. "-interaction=nonstopmode",
    19. "-file-line-error",
    20. "%DOCFILE%"
    21. ]
    22. },
    23. {
    24. "name": "pdflatex",
    25. "command": "pdflatex",
    26. "args": [
    27. "-synctex=1",
    28. "-interaction=nonstopmode",
    29. "-file-line-error",
    30. "%DOCFILE%"
    31. ]
    32. },
    33. {
    34. "name": "latexmk",
    35. "command": "latexmk",
    36. "args": [
    37. "-synctex=1",
    38. "-interaction=nonstopmode",
    39. "-file-line-error",
    40. "-pdf",
    41. "-outdir=%OUTDIR%",
    42. "%DOCFILE%"
    43. ]
    44. },
    45. {
    46. "name": "bibtex",
    47. "command": "bibtex",
    48. "args": [
    49. "%DOCFILE%"
    50. ]
    51. }
    52. ],
    53. // 用于配置编译链
    54. "latex-workshop.latex.recipes": [
    55. {
    56. "name": "XeLaTeX",
    57. "tools": [
    58. "xelatex"
    59. ]
    60. },
    61. {
    62. "name": "PDFLaTeX",
    63. "tools": [
    64. "pdflatex"
    65. ]
    66. },
    67. {
    68. "name": "BibTeX",
    69. "tools": [
    70. "bibtex"
    71. ]
    72. },
    73. {
    74. "name": "LaTeXmk",
    75. "tools": [
    76. "latexmk"
    77. ]
    78. },
    79. {
    80. "name": "xelatex -> bibtex -> xelatex*2",
    81. "tools": [
    82. "xelatex",
    83. "bibtex",
    84. "xelatex",
    85. "xelatex"
    86. ]
    87. },
    88. {
    89. "name": "pdflatex -> bibtex -> pdflatex*2",
    90. "tools": [
    91. "pdflatex",
    92. "bibtex",
    93. "pdflatex",
    94. "pdflatex"
    95. ]
    96. }
    97. ],
    98. //文件清理。此属性必须是字符串数组
    99. "latex-workshop.latex.clean.fileTypes": [
    100. "*.aux",
    101. "*.bbl",
    102. "*.blg",
    103. "*.idx",
    104. "*.ind",
    105. "*.lof",
    106. "*.lot",
    107. "*.out",
    108. "*.toc",
    109. "*.acn",
    110. "*.acr",
    111. "*.alg",
    112. "*.glg",
    113. "*.glo",
    114. "*.gls",
    115. "*.ist",
    116. "*.fls",
    117. "*.log",
    118. "*.fdb_latexmk"
    119. ],
    120. //设置为onFaild 在构建失败后清除辅助文件
    121. "latex-workshop.latex.autoClean.run": "onFailed",
    122. // 使用上次的recipe编译组合
    123. "latex-workshop.latex.recipe.default": "lastUsed",
    124. // 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
    125. "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click"
    126. }

    此外还可以使用SumatraPDF作为外部查看器,以及更多配置代码,因为不常用,这里不再列出。

    4. 编译测试。正常情况下,新建一个文本文件,选择Latex语言,复制粘贴以下代码,右上角点击编译按钮或ctrl+alt+B进行编译,点击内部查看器或ctrl+alt+V,在右边进行预览,鼠标双击pdf可以定位相应代码位置。

    1. \documentclass[a4paper]{article}
    2. \usepackage[left=1.91cm,right=1.91cm,top=2.54cm,bottom=2.54cm]{geometry} %设置页边距
    3. \usepackage{ctex}
    4. \usepackage{fontspec}
    5. \setmainfont{Times New Roman}
    6. \CJKfamily{zhsong}
    7. \begin{document}
    8. \title{This is a test for vscode}
    9. \author{Tex\ Live}
    10. \date{2022.06.01}
    11. \maketitle
    12. \begin{abstract}
    13. 这里是摘要.
    14. 关键词:\ 这里是关键词\ 这里是关键词.
    15. \end{abstract}
    16. \tableofcontents
    17. \section{This is a section}
    18. Hello world! 你好,世界!
    19. \subsection{This is a subsection}
    20. \begin{thebibliography}{99}
    21. \bibitem{a}作者. \emph{文献}[M]. 地点:出版社,年份.
    22. \bibitem{b}作者. \emph{文献}[M]. 地点:出版社,年份.
    23. \end{thebibliography}
    24. \end{document}

    注:代码模板经常存在不兼容的情况,请按最新标准规范编写代码。

    参考链接:

    【1】https://zhuanlan.zhihu.com/p/491581833

    【2】Index of CTAN-local/systems/texlive/Images

  • 相关阅读:
    在线流程图和思维导图开发技术详解(三)
    Redis-Jedis
    力扣101 对称二叉树 Java版本
    leetcode困难题
    用go实现http服务端和请求端
    【IT面试新理解】
    有关函数模板的那些小知识-.-
    Unity VR开发教程 OpenXR+XR Interaction Toolkit 2.1.1(七)射线抓取
    1.let和const关键字
    【解决问题】413错误 413 Request Entity Too Large 接口返回413 报413nginx
  • 原文地址:https://blog.csdn.net/xxn_723911/article/details/133310608