VS code配置支持中文的Latex写作环境并设置SumatraPDF预览编译文件


之前百度试过很多次都没有解决,后来有机会在Google上搜索了下,终于解决,现在记录如下

1. 下载和安装TexLive

官网或者清华镜像

2.安装VSCode

微软官网

3.安装Latex Workshop插件

在这里插入图片描述

4.修改Late Workshop配置

使用 ctrl+shift+P 打开搜索,输入 “setting。json”。粘贴模板。

Ctrl+,打开VSCode设置页面,修改settings.json设置,下面是记录我使用的设置,能够使用,但是还是有一点问题,不想解决了可以直接复制过去,具体也不想分析了,后面提供相关链接

{
      // Latex workshop
      "latex-workshop.latex.tools": [
        {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "-pdf",
          "%DOC%"
          ]
        },
        {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
            ]
        },          
        {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
          ]
        },
        {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
          "%DOCFILE%"
          ]
        }
      ],
  "latex-workshop.latex.recipes": [
        {
          "name": "xelatex",
          "tools": [
          "xelatex"
                      ]
                },
        {
          "name": "latexmk",
          "tools": [
          "latexmk"
                      ]
        },

        {
          "name": "pdflatex -> bibtex -> pdflatex*2",
          "tools": [
          "pdflatex",
          "bibtex",
          "pdflatex",
          "pdflatex"
                      ]
        }
      ],
  "latex-workshop.view.pdf.viewer": "tab",  
  "latex-workshop.latex.clean.fileTypes": [
      "*.aux",
      "*.bbl",
      "*.blg",
      "*.idx",
      "*.ind",
      "*.lof",
      "*.lot",
      "*.out",
      "*.toc",
      "*.acn",
      "*.acr",
      "*.alg",
      "*.glg",
      "*.glo",
      "*.gls",
      "*.ist",
      "*.fls",
      "*.log",
      "*.fdb_latexmk"
    ]
   
  }

注意这个虽然能使用,但是编译时还是会报错,此外这个配置也不涉及使用外部PDF打开文档,因为我懒的搞,等我用的多的时候在弄吧

设置内容解读参考

编写中文Latex(VSCode+TexLive)

使用VSCode编写LaTeX

VSCode配置LaTeX Workstation以支持中文

5.文档实例

我之前一直配置完成不能输出中文,很可能是因为**文档开头没有使用 \usepackage[UTF8]{ctex} **


%!TEX program = pdflatex
\documentclass{article}

\usepackage[UTF8]{ctex}


% 这里是导言区
\begin{document}

Hello, world   !

fuck you latex

你好
中文呢

\end{document}

在这里插入图片描述

修改后的版本

{
      // Latex workshop
      "latex-workshop.latex.tools": [
        {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "-pdf",
          "%DOC%"
          ]
        },
        {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
            ]
        },          
        {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
          ]
        },
        {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
          "%DOCFILE%"
          ]
        }
      ],
  "latex-workshop.latex.recipes": [
        {
          "name": "xelatex",
          "tools": [
          "xelatex"
                      ]
                },
        {
          "name": "latexmk",
          "tools": [
          "latexmk"
                      ]
        },

        {
          "name": "pdflatex -> bibtex -> pdflatex*2",
          "tools": [
          "pdflatex",
          "bibtex",
          "pdflatex",
          "pdflatex"
                      ]
        }
      ],
  "latex-workshop.view.pdf.viewer": "tab",  
  "latex-workshop.latex.clean.fileTypes": [
      "*.aux",
      "*.bbl",
      "*.blg",
      "*.idx",
      "*.ind",
      "*.lof",
      "*.lot",
      "*.out",
      "*.toc",
      "*.acn",
      "*.acr",
      "*.alg",
      "*.glg",
      "*.glo",
      "*.gls",
      "*.ist",
      "*.fls",
      "*.log",
      "*.fdb_latexmk"
    ],

}

同样没有成功使用外部PDF阅读器

设置好用PDF阅读器打开生成文件

终于把PDF预览软件设置成外置的SumatraPDF, 2020年10月15日。
注意:
之前主要错误应该在于软件安装文件夹地址错误。直接复制过来的地址上使用的是 ‘\’,感觉这个在VScode中是转义字符标志,所以没有正确设置地址。应该使用 ‘/’, 或者使用‘\\’。此外有的教程中提到在SumatraPDF软件中进行设置,具体自行百度。

    "latex-workshop.view.pdf.viewer": "external",
        "latex-workshop.view.pdf.external.viewer.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径,这是SumatraPDF安装目录,注意使用‘/’, 在Windows中复制过来的地址是使用'/',这个会出问题,我觉得也可以使用'//'
        "latex-workshop.view.pdf.external.viewer.args": [
            "%PDF%"
        ],
        "latex-workshop.view.pdf.external.synctex.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径
        "latex-workshop.view.pdf.external.synctex.args": [
            "-forward-search",
            "%TEX%",
            "%LINE%",
            "-reuse-instance",
            "-inverse-search",
            "code \"C:\\Users\\CHEN\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" -r -g \"%f:%l\"", // 注意修改路径,注意文件路径中的‘\\’
            "%PDF%",
        ],

配置文件20210129

打开配置文件: ctrl+shift+P

{
      // Latex workshop
      "latex-workshop.latex.tools": [
        {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "-pdf",
          "%DOC%"
          ]
        },
        {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
            ]
        },          
        
        {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
          ]
        },
        {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
          "%DOCFILE%"
          ]
        }
      ],
  "latex-workshop.latex.recipes": [


    {
      "name": "xelatex",
      "tools": [
      "xelatex"
          ]
    },

    {
      "name": "latexmk",
      "tools": [
      "latexmk"
                  ]
    },

    {
      "name": "pdflatex",
      "tools": [
      "pdflatex"
                  ]
    },

    {
      "name": "bibtex",
      "tools": [
      "bibtex"
                  ]
    },

    {  
      "name": "xelatex->bibtex->xelatex->xelatex",  
      "tools": [  
        "xelatex",  
        "bibtex",  
        "xelatex",  
        "xelatex", 
      ]  
    }, 

    {
      "name": "pdflatex -> bibtex -> pdflatex*2",
      "tools": [
      "pdflatex",
      "bibtex",
      "pdflatex",
      "pdflatex"
                  ]
    }

  ],



  "latex-workshop.view.pdf.viewer": "external",  
  "latex-workshop.latex.clean.fileTypes": [
      "*.aux",
      "*.bbl",
      "*.blg",
      "*.idx",
      "*.ind",
      "*.lof",
      "*.lot",
      "*.out",
      "*.toc",
      "*.acn",
      "*.acr",
      "*.alg",
      "*.glg",
      "*.glo",
      "*.gls",
      "*.ist",
      "*.fls",
      "*.log",
      "*.fdb_latexmk"
    ],
    "editor.fontSize": 18,
    "window.zoomLevel": -1,
    "editor.wordWrap": "wordWrapColumn",
    "ltex.dictionary": {
      "en-US": [
        "Acknowledgements",
        "momerized"
      ]
    },
    "terminal.integrated.fontSize": 16,

    // external pdf 
    "latex-workshop.view.pdf.viewer": "external",
        "latex-workshop.view.pdf.external.viewer.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径
        "latex-workshop.view.pdf.external.viewer.args": [
            "%PDF%"
        ],
        "latex-workshop.view.pdf.external.synctex.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", // 注意修改路径
        "latex-workshop.view.pdf.external.synctex.args": [
            "-forward-search",
            "%TEX%",
            "%LINE%",
            "-reuse-instance",
            "-inverse-search",
            "code \"C:\\Users\\CHEN\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" -r -g \"%f:%l\"", // 注意修改路径
            "%PDF%",
        ],


    // English grammer check
    "ltex.enabled": true, // 启用插件
    "ltex.language": "en-US",// 设置语言,这里是德语
    // 要英语就下载对应 English Support,然后这里填 en, 或者 en-US,en-GB 等*/    


}

别人的

别人的一份设置
使用VSCode编写LaTeX

如果编译出错,插件会弹出两个很烦人的气泡,不喜欢的话可以在设置中添加以下代码:

"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,

主设置

// LaTeX
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,

"latex-workshop.latex.tools": [
    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
],

"latex-workshop.latex.recipes": [
    {
        "name": "xelatex",
        "tools": [
            "xelatex"
        ],
    },
    {
        "name": "pdflatex",
        "tools": [
            "pdflatex"
        ]
    },
    {
        "name": "xe->bib->xe->xe",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    },
    {
        "name": "pdf->bib->pdf->pdf",
        "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
        ]
    }
],
"latex-workshop.view.pdf.viewer": "external",

"latex-workshop.view.pdf.external.viewer.command": "C:/.../SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"C:/.../Microsoft VS Code/Code.exe\" \"C:/.../Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    "%PDF%"
],

"latex-workshop.view.pdf.external.synctex.command": "C:/.../SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"C:/.../Microsoft VS Code/Code.exe\" \"C:/.../Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    "%PDF%",
],

配置文件20220112

前面的反向搜索失败,感觉应该是VScode更新的原因,找了好久,需要在反向搜索中添加 --ms-enable-electron-run-as-node

{
  // Latex workshop
  "latex-workshop.latex.tools": [
    // 编译工具和命令
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
],
"latex-workshop.latex.recipes": [
  {
      "name": "pdflatex",
      "tools": [
          "pdflatex"
      ]
  },
  {
    "name": "pdf->bib->pdf->pdf",
    "tools": [
        "pdflatex",
        "bibtex",
        "pdflatex",
        "pdflatex"
    ]
 },
  {
    "name": "xelatex",
    "tools": [
        "xelatex"
    ],
  },
  {
      "name": "xe->bib->xe->xe",
      "tools": [
          "xelatex",
          "bibtex",
          "xelatex",
          "xelatex"
      ]
  }
],



//文件清理。此属性必须是字符串数组
"latex-workshop.latex.clean.fileTypes": [
    "*.aux",
    "*.bbl",
    "*.blg",
    "*.idx",
    "*.ind",
    "*.lof",
    "*.lot",
    "*.out",
    "*.toc",
    "*.acn",
    "*.acr",
    "*.alg",
    "*.glg",
    "*.glo",
    "*.gls",
    "*.ist",
    "*.fls",
    "*.log",
    "*.fdb_latexmk"
],
//设置为onFaild 在构建失败后清除辅助文件
// "latex-workshop.latex.autoClean.run": "onFailed",
"latex-workshop.latex.autoClean.run": "onBuilt",
// 使用上次的recipe编译组合
"latex-workshop.latex.recipe.default": "lastUsed",
// 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",





"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "D:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"D:/Program Files/Microsoft VS Code/Code.exe\" \"D:/Program Files/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
    "%PDF%"
],
// "latex-workshop.view.pdf.external.viewer.args": [
//     "-forward-search",
//     "%TEX%",
//     "%LINE%",
//     "-reuse-instance",
//     "-inverse-search",
//     "\"D:\\Program Files\\Microsoft VS Code\\Code.exe\" \"D:\\Program Files\\Microsoft VS Code\\resources\\app\\out\\cli.js\" -gr \"%f\":\"%l\"",
//     "%PDF%"
// ],
"latex-workshop.view.pdf.external.synctex.command": "D:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
  "latex-workshop.view.pdf.external.synctex.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"D:\\Program Files\\Microsoft VS Code\\Code.exe\" \"D:\\Program Files\\Microsoft VS Code\\resources\\app\\out\\cli.js\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"",
    "%PDF%"
],









// English grammer check
"ltex.enabled": true, // 启用插件
"ltex.language": "en-US",
"workbench.colorTheme": "Monokai High Contrast", // 设置语言,这里是德语
// 要英语就下载对应 English Support,然后这里填 en, 或者 en-US,en-GB 等*/    

// 取消右下角错误报警弹窗
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"diffEditor.wordWrap": "off",
"editor.fontSize": 17,
"security.workspace.trust.untrustedFiles": "open",
"editor.wordWrap": "on",
"update.mode": "none",
"extensions.autoUpdate": false,
"update.showReleaseNotes": false,
"update.enableWindowsBackgroundUpdates": false,
"javascript.updateImportsOnFileMove.enabled": "never",
"typescript.updateImportsOnFileMove.enabled": "never",
"extensions.autoCheckUpdates": false,
"markdown.preview.scrollPreviewWithEditor": false,
"markdown.preview.scrollEditorWithPreview": false,
"latex-workshop.intellisense.update.aggressive.enabled": true,

}

20240129 配置文件

新增 错误警告等底色

{
    // Latex workshop
    "latex-workshop.latex.tools": [
      // compile
      {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
              "-synctex=1",
              "-interaction=nonstopmode",
              "-file-line-error",
              "%DOCFILE%"
          ]
      },
      {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
              "-synctex=1",
              "-interaction=nonstopmode",
              "-file-line-error",
              "-pdf",
              "%DOCFILE%"
          ]
      },
      {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
              "%DOCFILE%"
          ]
      }
  ],
  "latex-workshop.latex.recipes": [
    {
        "name": "pdflatex",
        "tools": [
            "pdflatex"
        ]
    },
    {
      "name": "pdf->bib->pdf->pdf",
      "tools": [
          "pdflatex",
          "bibtex",
          "pdflatex",
          "pdflatex"
      ]
   },
    {
      "name": "xelatex",
      "tools": [
          "xelatex"
      ],
    },
    {
        "name": "xe->bib->xe->xe",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    }
  ],
    
  
  //clean 
  "latex-workshop.latex.clean.fileTypes": [
      "*.aux",
      "*.bbl",
      "*.blg",
      "*.idx",
      "*.ind",
      "*.lof",
      "*.lot",
      "*.out",
      "*.toc",
      "*.acn",
      "*.acr",
      "*.alg",
      "*.glg",
      "*.glo",
      "*.gls",
      "*.ist",
      "*.fls",
      "*.log",
      "*.fdb_latexmk"
  ],
  //clean files on failed
  "latex-workshop.latex.autoClean.run": "onFailed",
  // "latex-workshop.latex.autoClean.run": "onBuilt",
  // adopt last recipt
  "latex-workshop.latex.recipe.default": "lastUsed",
  // 
  "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
  

  
  "latex-workshop.view.pdf.viewer": "external",
  "latex-workshop.view.pdf.external.viewer.command": "D:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
  "latex-workshop.view.pdf.external.viewer.args": [
      "-forward-search",
      "%TEX%",
      "%LINE%",
      "-reuse-instance",
      "-inverse-search",
      "\"D:/Program Files/Microsoft VS Code/Code.exe\" \"D:/Program Files/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
      "%PDF%"
  ],
  // "latex-workshop.view.pdf.external.viewer.args": [
  //     "-forward-search",
  //     "%TEX%",
  //     "%LINE%",
  //     "-reuse-instance",
  //     "-inverse-search",
  //     "\"D:\\Program Files\\Microsoft VS Code\\Code.exe\" \"D:\\Program Files\\Microsoft VS Code\\resources\\app\\out\\cli.js\" -gr \"%f\":\"%l\"",
  //     "%PDF%"
  // ],
  "latex-workshop.view.pdf.external.synctex.command": "D:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
    "latex-workshop.view.pdf.external.synctex.args": [
      "-forward-search",
      "%TEX%",
      "%LINE%",
      "-reuse-instance",
      "-inverse-search",
      "\"D:\\Program Files\\Microsoft VS Code\\Code.exe\" \"D:\\Program Files\\Microsoft VS Code\\resources\\app\\out\\cli.js\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"",
      "%PDF%"
  ],
  
  
  
  // foxit 
  // "latex-workshop.view.pdf.viewer": "external",
  // "latex-workshop.view.pdf.external.viewer.command":"D:\\Program Files (x86)\\Foxit Software\\Foxit PhantomPDF\\FoxitPhantomPDF.exe",
  // "latex-workshop.view.pdf.external.viewer.args": ["%PDF%","/A", "nolock=1"],
  
  
  
  // English grammer check
  "ltex.enabled": true, 
  "ltex.language": "en-US",
  "workbench.colorTheme": "Monokai High Contrast",
  
  
  // cancel pop up message box
  "latex-workshop.message.error.show": false,
  "latex-workshop.message.warning.show": false,
  "latex-workshop.showContextMenu": true,
  "latex-workshop.intellisense.update.aggressive.enabled": true,
  "diffEditor.wordWrap": "off",
  "editor.fontSize": 19,
  "security.workspace.trust.untrustedFiles": "open",
  "editor.wordWrap": "on",
  "update.mode": "none",
  "extensions.autoUpdate": "onlySelectedExtensions",
  "update.showReleaseNotes": false,
  "update.enableWindowsBackgroundUpdates": false,
  "javascript.updateImportsOnFileMove.enabled": "never",
  "typescript.updateImportsOnFileMove.enabled": "never",
  "extensions.autoCheckUpdates": false,
  "markdown.preview.scrollPreviewWithEditor": false,
  "markdown.preview.scrollEditorWithPreview": false,
  "editor.accessibilitySupport": "off",
  
  
  // highlight
  "workbench.colorCustomizations": {
      // highlight
     "editor.selectionBackground": "#f0f70e" ,
      "editor.selectionHighlightBackground": "#b8a621", 
      // 
      "editor.lineHighlightBackground": "#282828", 
    //   "editor.lineHighlightBorder": "#FFFF00",
    //  "editor.wordHighlightBackground": "#ff0000",
  //    "editor.wordHighlightBorder":  "#ff0000",
    //  "editor.worldHighlightStrongBackground": "#ff0000",
  //    "editor.wordHighlightStrongBorder": "#ff0000",
  
  // errors, warnings, infos
      "editorError.background": "#ffff0097",
      "editorError.foreground": "#ff0000",
      "editorWarning.background": "#181818",
      "editorWarning.foreground": "#FFFF00",
      "editorInfo.background": "#181818",
      "editorInfo.foreground": "#73ff00",
      
      "list.errorForeground": "#ff0000",
      // "minimap.warningHighlight": "#ff0000"
      // "editorOverviewRuler.warningForeground": "#ff0000"
      // "statusBarItem.warningBackground": "#ff0000"
      // "editor.inlineValuesBackground": "#ff0000"
  // "editorMarkerNavigation.background": "#ff0000"
  // "testing.message.info.decorationForeground": "#ff0000",
  // "testing.message.error.lineBackground": "#ff0000"
  // "descriptionForeground": "#ff0000"
  
  },
  "window.zoomLevel": 1,
  "editor.scrollPredominantAxis": false,
  "editor.quickSuggestions": {
      "comments": "inline",
      "strings": "inline"
  },
  "editor.quickSuggestionsDelay": 5,
  "terminal.integrated.shellIntegration.suggestEnabled": true,
  "editor.inlineSuggest.suppressSuggestions": true,
  "editor.suggest.shareSuggestSelections": true,
  "git.openRepositoryInParentFolders": "never",
  "emmet.showSuggestionsAsSnippets": true,
  "editor.snippetSuggestions": "top",
  
  
  }
首先,您需要安装 Visual Studio CodeLaTeX 工具链。您可以通过 Homebrew 包管理器安装这些软件包,然后按照以下步骤配置: 1. 安装 Visual Studio Code: ``` brew install --cask visual-studio-code ``` 2. 安装 LaTeX 工具链: ``` brew install --cask mactex-no-gui ``` 3. 安装 LaTeX 插件: 打开 Visual Studio Code,点击左侧的“扩展”按钮,搜索并安装 LaTeX Workshop 插件。该插件将提供 LaTeX 编辑器、编译器和 PDF 预览器。 4. 配置编译器路径: 打开 Visual Studio Code 设置(快捷键:Cmd + ,),搜索“latex”关键字,找到“LaTeX Workshop > Recipes”选项卡。在“recipes”数组中添加以下内容: ``` { "name": "xelatex", "tools": [ "xelatex" ] } ``` 然后找到“LaTeX Workshop > TeXpath”选项卡,将以下路径添加到“paths”数组中: ``` /Library/TeX/texbin ``` 5. 编写 LaTeX 文档: 创建一个新文件,保存为“.tex”扩展名,然后开始编写 LaTeX 代码。您可以使用 Visual Studio Code 自带的 LaTeX 编辑器,也可以使用其他编辑器。在编写完成后,按 F1 键打开命令面板,输入“Build LaTeX project”并运行该命令以编译 LaTeX 代码。您也可以使用快捷键 Ctrl + Alt + B 或者点击 Visual Studio Code 底部的“Build LaTeX project”按钮进行编译。 6. 查看 PDF 预览: 您可以使用 Visual Studio Code 自带的 PDF 预览器查看编译后的 PDF 文件。在编译完成后,单击 Visual Studio Code 底部的“View LaTeX PDF file”按钮即可打开 PDF 预览器。您也可以使用快捷键 Ctrl + Alt + V 打开 PDF 预览器。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值