3

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:\Users\adali\AppData\Local\Programs\MiKTeX 2.9\scripts/latexindent\latexindent.pl line 27.
BEGIN failed--compilation aborted at C:\Users\adali\AppData\Local\Programs\MiKTeX 2.9\scripts/latexindent\latexindent.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 Files\MiKTeX 2.9\scripts\latexindent 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:\Users\adali\AppData\Local\Programs\MiKTeX 2.9\scripts/latexindent\latexindent.pl line 27.
BEGIN failed--compilation aborted at C:\Users\adali\AppData\Local\Programs\MiKTeX 2.9\scripts/latexindent\latexindent.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.
3
  • Perhaps the solution from tex.stackexchange.com/a/334511/6621 might be helpful?
    – cmhughes
    Jan 2, 2021 at 18:03
  • I tried to do it. But it didn't work. I downloaded 'latexindent' and put the file in C:\Program Files\MiKTeX 2.9\scripts\latexindent but I still get the error
    – adal
    Jan 2, 2021 at 18:26
  • The error message you're reporting looks like you're using the Perl version. For Windows, the only two files you need are latexindent.exe and defaultSettings.yaml, both are available from ctan. Note that Miktex might have it's own version of latexindent.exe which might be different from the ctan version
    – cmhughes
    Jan 2, 2021 at 21:32

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.