1. 程式人生 > 其它 >macOS下Vscode中LaTeX格式化錯誤

macOS下Vscode中LaTeX格式化錯誤

! https://zhuanlan.zhihu.com/p/451898704

macOS 下 vscode 中 LaTeX 格式化錯誤

問題描述

在 VS Code 中安裝 LaTeX Workshop 外掛後,如果按command + s儲存,會出現如下報錯。

Formatting failed. Please refer to LaTeX Workshop Output for details.

解決方法

  1. 關閉 LaTeX Workshop 的程式碼格式化功能

setting.json中將“editor.formatOnSave:”改為false

  1. 自動格式化LaTeX程式碼(推薦)

在終端依次執行以下命令

sudo /usr/bin/cpan5.18 Unicode::GCString
sudo /usr/bin/cpan5.18 App::cpanminus
sudo /usr/bin/cpan5.18 YAML::Tiny
sudo /usr/bin/perl5.18 -MCPAN -e 'install "File::HomeDir"'
sudo cpan Log::Log4perl
sudo cpan Log::Dispatch

在終端中使用which latexindent檢視所在位置,開啟setting.json新增配置,指明latexindent的安裝路徑。

"latex-workshop.latexindent.path": "latexindent所在路徑",

參照資料