• Win 10: vscode latex环境配置


    vscode的编辑器非常强大,推荐使用,这里记录一下自己的配置过程。

    所使用的软件:VSCode + Latex Workshop + MiKTeX + SumatraPDF

    1. VS Code 安装:https://code.visualstudio.com/

    安装过程比较简单,这里不赘述

    2. MiKTex安装:  Getting MiKTeX

    同样,废话不多说,下载安装即可

    3. 在VS Code中安装 Latex Workshop插件(假设对vscode已稍微熟悉,知道怎么下载安装插件)

    4.快捷键 control + shift + p,打开搜索配置,搜索:settings

    设置以下代码:

    1. {
    2. "latex-workshop.latex.recipes": [{
    3. "name": "xelatex",
    4. "tools": [
    5. "xelatex"
    6. ]
    7. }, {
    8. "name": "latexmk",
    9. "tools": [
    10. "latexmk"
    11. ]
    12. },
    13. {
    14. "name": "pdflatex -> bibtex -> pdflatex*2",
    15. "tools": [
    16. "pdflatex",
    17. "bibtex",
    18. "pdflatex",
    19. "pdflatex"
    20. ]
    21. }
    22. ],
    23. "latex-workshop.latex.tools": [{
    24. "name": "latexmk",
    25. "command": "latexmk",
    26. "args": [
    27. "-synctex=1",
    28. "-interaction=nonstopmode",
    29. "-file-line-error",
    30. "-pdf",
    31. "%DOC%"
    32. ]
    33. }, {
    34. "name": "xelatex",
    35. "command": "xelatex",
    36. "args": [
    37. "-synctex=1",
    38. "-interaction=nonstopmode",
    39. "-file-line-error",
    40. "%DOC%"
    41. ]
    42. }, {
    43. "name": "pdflatex",
    44. "command": "pdflatex",
    45. "args": [
    46. "-synctex=1",
    47. "-interaction=nonstopmode",
    48. "-file-line-error",
    49. "%DOC%"
    50. ]
    51. }, {
    52. "name": "bibtex",
    53. "command": "bibtex",
    54. "args": [
    55. "%DOCFILE%"
    56. ]
    57. }],
    58. "latex-workshop.view.pdf.viewer": "tab",
    59. "latex-workshop.latex.autoClean.run": "onBuilt",
    60. "latex-workshop.latex.clean.fileTypes": [
    61. "*.aux",
    62. "*.bbl",
    63. "*.blg",
    64. "*.idx",
    65. "*.ind",
    66. "*.lof",
    67. "*.lot",
    68. "*.out",
    69. "*.toc",
    70. "*.acn",
    71. "*.acr",
    72. "*.alg",
    73. "*.glg",
    74. "*.glo",
    75. "*.gls",
    76. "*.ist",
    77. "*.fls",
    78. "*.log",
    79. "*.fdb_latexmk"
    80. ],
    81. "editor.fontSize": 20,
    82. "latex-workshop.showContextMenu":true, //右键菜单
    83. "jupyter.askForKernelRestart": false,
    84. "editor.fontFamily": "Fira Code Light, Operator Mono",
    85. "terminal.integrated.fontFamily": "monospace",
    86. "editor.renderWhitespace": "all",
    87. "files.autoSave": "onFocusChange",
    88. }

    5. SumatraPDF: 软件下载安装  Sumatra PDF reader download page

    6. 配置SumatraPDF,同时配置双向定位:

    1. // "latex-workshop.view.pdf.viewer": "tab", // 内置pdf阅读器
    2. "latex-workshop.view.pdf.viewer": "external", // 外部pdf阅读器
    3. "latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
    4. "latex-workshop.view.pdf.external.viewer.args": [
    5. "-forward-search",
    6. "%TEX%",
    7. "%LINE%",
    8. "-reuse-instance",
    9. "-inverse-search",
    10. "\"D:/softwares/Microsoft VS Code/Code.exe\" \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    11. "%PDF%"
    12. ],
    13. "latex-workshop.view.pdf.external.synctex.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
    14. "latex-workshop.view.pdf.external.synctex.args": [
    15. "-forward-search",
    16. "%TEX%",
    17. "%LINE%",
    18. "-reuse-instance",
    19. "-inverse-search",
    20. "code \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    21. "%PDF%",],

    注意对应修改:vs code软件位置和SumatraPDF.exe软件为位置

    7. 显示编译结果:

     反向搜索: 双击 PDF 中的任意一处即可跳转到 VSCode 中所对应的内容的源代码处,同时,最好不要清理  gz 后缀的临时文件,否则就不能进行正向和反向搜索

    1)在 LaTeX 文件中,按 Ctrl + Alt + J 跳转到对应的 PDF 文件位置。

       (2)在 PDF 文件中,按下 Ctrl + ← 同时鼠标单机,跳转到对应的 LaTeX 文件位置。

    但双向搜索一般会有以下问题:

    通过VScode唤醒的SumatraPDF,双击PDF文件反向搜索失效(也没有任何报错提示);

    单独打开SumatraPDF,双击PDF文件会跳转到cli.js文件上,如下图:

     可参考这里解决:VScode+Latex+SumatraPDF反向搜索失败解决办法(Version 1.63) - 知乎

    附完整配置:

    1. {
    2. "latex-workshop.latex.recipes": [{
    3. "name": "xelatex",
    4. "tools": [
    5. "xelatex"
    6. ]
    7. }, {
    8. "name": "latexmk",
    9. "tools": [
    10. "latexmk"
    11. ]
    12. },
    13. {
    14. "name": "pdflatex -> bibtex -> pdflatex*2",
    15. "tools": [
    16. "pdflatex",
    17. "bibtex",
    18. "pdflatex",
    19. "pdflatex"
    20. ]
    21. }
    22. ],
    23. "latex-workshop.latex.tools": [{
    24. "name": "latexmk",
    25. "command": "latexmk",
    26. "args": [
    27. "-synctex=1",
    28. "-interaction=nonstopmode",
    29. "-file-line-error",
    30. "-pdf",
    31. "%DOC%"
    32. ]
    33. }, {
    34. "name": "xelatex",
    35. "command": "xelatex",
    36. "args": [
    37. "-synctex=1",
    38. "-interaction=nonstopmode",
    39. "-file-line-error",
    40. "%DOC%"
    41. ]
    42. }, {
    43. "name": "pdflatex",
    44. "command": "pdflatex",
    45. "args": [
    46. "-synctex=1",
    47. "-interaction=nonstopmode",
    48. "-file-line-error",
    49. "%DOC%"
    50. ]
    51. }, {
    52. "name": "bibtex",
    53. "command": "bibtex",
    54. "args": [
    55. "%DOCFILE%"
    56. ]
    57. }],
    58. // "latex-workshop.view.pdf.viewer": "tab", // 内置pdf阅读器
    59. "latex-workshop.view.pdf.viewer": "external", // 外部pdf阅读器
    60. "latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
    61. "latex-workshop.view.pdf.external.viewer.args": [
    62. "-forward-search",
    63. "%TEX%",
    64. "%LINE%",
    65. "-reuse-instance",
    66. "-inverse-search",
    67. "\"D:/softwares/Microsoft VS Code/Code.exe\" \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    68. "%PDF%"
    69. ],
    70. "latex-workshop.view.pdf.external.synctex.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
    71. "latex-workshop.view.pdf.external.synctex.args": [
    72. "-forward-search",
    73. "%TEX%",
    74. "%LINE%",
    75. "-reuse-instance",
    76. "-inverse-search",
    77. "code \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    78. "%PDF%",],
    79. "latex-workshop.latex.autoClean.run": "onBuilt",
    80. "latex-workshop.latex.clean.fileTypes": [
    81. "*.aux",
    82. "*.bbl",
    83. "*.blg",
    84. "*.idx",
    85. "*.ind",
    86. "*.lof",
    87. "*.lot",
    88. "*.out",
    89. "*.toc",
    90. "*.acn",
    91. "*.acr",
    92. "*.alg",
    93. "*.glg",
    94. "*.glo",
    95. "*.gls",
    96. "*.ist",
    97. "*.fls",
    98. "*.log",
    99. "*.fdb_latexmk"
    100. ],
    101. "editor.fontSize": 20,
    102. "latex-workshop.showContextMenu":true, //右键菜单
    103. "jupyter.askForKernelRestart": false,
    104. "editor.fontFamily": "Fira Code Light, Operator Mono",
    105. "terminal.integrated.fontFamily": "monospace",
    106. "editor.renderWhitespace": "all",
    107. "files.autoSave": "onFocusChange",
    108. }

  • 相关阅读:
    一些RabbitMQ面试题
    C++运算符重载
    与设备无关的I/O软件
    ViT模型中的tokens和patches概念辨析
    达梦数据库恢复到指定时间点
    go语言之不必要的拷贝
    labview 创建 00 到 FF 连续数据流
    毕业设计之校园一卡通管理系统的设计与实现
    【面试:并发篇28:volatile】有序性
    Stateflow状态转移练习
  • 原文地址:https://blog.csdn.net/qq_33854260/article/details/126536229