TransWikia.com

How to use latexindent on Windows?

TeX - LaTeX Asked by adal on February 25, 2021

I want to use latexindent on my file. When I run the code

latexindent.exe myfile.tex

I get the following error.

Can't locate LatexIndent/Document.pm in @INC (you may need to install the LatexIndent::Document module) (@INC contains: /c/Users/adali/AppData/Local/Programs/MiKTeX 2.9/scripts /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at C:UsersadaliAppDataLocalProgramsMiKTeX 2.9scripts/latexindentlatexindent.pl line 27.
BEGIN failed--compilation aborted at C:UsersadaliAppDataLocalProgramsMiKTeX 2.9scripts/latexindentlatexindent.pl line 27.

(By the way latexindent.pl myfile.tex also gives the same error. And I checked my local files and there is a file called ‘latexindent.pl’ but not an ‘.exe’ version. And I checked I have Perl 5v32 as well, so this is not a Perl issue.)

latexindent manual
reccomends the following code, saying that ”latexindent.pl ships with a script to help with this process; if you run the following script, you should be prompted to install the appropriate modules.”

perl latexindent-module-installer.pl

When I run it, I get the warning:

Can't open perl script "latexindent-module-installer.pl": No such file or directory

I tried to use ”latex-indent-module-installer.exe” hoping that the manual does not mention Windows version, but I get the same error.

The solution in How to use latexindent in TeXStudio on Windows? does not work as well. After I downloaded latexindent manually and put it in C:Program FilesMiKTeX 2.9scriptslatexindent I still get the error that

Can't locate LatexIndent/Document.pm in @INC (you may need to install the LatexIndent::Document module) (@INC contains: /c/Users/adali/AppData/Local/Programs/MiKTeX 2.9/scripts /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at C:UsersadaliAppDataLocalProgramsMiKTeX 2.9scripts/latexindentlatexindent.pl line 27.
BEGIN failed--compilation aborted at C:UsersadaliAppDataLocalProgramsMiKTeX 2.9scripts/latexindentlatexindent.pl line 27.

from the error message I surmise that latexindent does not look into the file that I put the executable into.

So it seems there are two problems.

  1. Miktex does not install the latexindent package fully (The package was available in Miktex, and I even updated it once I encountered the problem)
  2. latexindent does not search all the root texmf files one configures by Miktex.

One Answer

What does not work

  1. Installing it through Miktex (not even several tries of deleting and re-installing)
  2. Downloading the latexindent package and putting it in a non-local texmf location.
  3. running the latexindent-module-installer.
  4. trying to download perl modules through CPAN

What works

  1. Create a local texmf tree
  2. Download the package from CTAN end delete everything except latexindent.exe and defaultSettings.yaml
  3. put those two files under your local texmf tree in a folder called 'scripts'

if you still get a missing perl module error;

  1. run cpan -f -i <missingmodule> from the command prompt
  2. Now you can use the command latexindent.tex myfile.tex

why should we resort to a manual solution

a. Miktex does not properly install latexindent

b. latexindent-module-installer-pl does not work on windows

c. cpan does download the missing modules without force installing from command prompt.

Correct answer by adal on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP