LaTeX-Workshop: Formatting failed error
Description
When I activate globally “editor.formatOnSave” (as is done for a while it seems in VSCode), I get this error, everytime I save a Latex file:
I suspect this has something to do wit the fact that I need to enable “formatOnSave” on a global level now, to have it working for my Python programming.
I guess your package does not support formatting, which is why I get this error?
I deactivated the error message by adding this language-specific setting to my settings, like so:
"[latex]": {
"editor.formatOnSave": false,
}
So, I’m fine, I was just wondering if there is actually automatic formatting available for this extension somehow? I will close this issue immediately, but wanted to create the issue for somebody else to find.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 33 (11 by maintainers)
Encountered the same problem on Mac. Here are the packages I installed to make it work.
@thedadams , can u format ur code? (Not saving after formatting) Or u already solved it? It seems it’s just one case of failure.
I’m a Mac User too. My issue is unable to format codes. As @quicky84 said, the problem might be in
latexindentnotLaTeX-Workshop. Here is my error message:If so, here is a shortcut.
More details u can found in this issue in Atom-beaultifier.
In my case, File::HomeDir needs force install
After I tried many many times in two days I solved it.
Solution is that : “latex-workshop.latexindent.path” in vs code settings you can change to your path ,just like this
"latex-workshop.latexindent.path": "C:\\Users\\Jerry\\Downloads\\latexindent\\latexindent.exe"Before of this, you should download latexindent.exe from latexindent . I find that installing from MikTeX console packages isn’t working, so you’d best installed by yourself.
@yenWu Yes, I fixed it. I was missing some perl modules. Thanks for checking.
You can find it by clicking on
View->Outputin the menu and then selectingLaTeX Workshopfrom the dropdown on the right. It should have an entry starting withFormatting failed:and the error message.and how do i find that mysterious log? 😉
@adam-erickson Provided you already have latexindent installed on your Mac, In Visual Studio Code’s settings, go to
Latex-workshop > Latexindent: Path, then set the path to something like/usr/local/texlive/2018/texmf-dist/scripts/latexindent/latexindent.pl. Hope this helps.@fabiocapasso93 unfortunately this cannot be fixed on the extension side. This is up to the user to set the paths of the different tools properly on his installation.
Also, see the wiki page. Feel free to suggest improvements for this page if you think it is detailed enough.
So I just installed MiKTeX on Windows to reproduce this issue. Here is how I got it to work:
latexindentpackage using the MiKTeX Package Managercpanon the command line. In my case those wereLog::Log4perl,Log::Dispatch::FileShared,YAML::TinyandUnicode::GCString(the exact missing packages can be found by executing the formatter a mentioned above and checking the log)I am having this same issue now after using the extension for some time. I have latexindent installed and the Output has no information in it.