I discovered latexindent and want to use it on my Windows machine. I am using MiKTeX and Strawberry Perl. MiKTeX has a package manager which lists latexindent. For some reason I cannot install or deinstall it although I am starting the MiKTeX Package Manager as Administrator. It is listed as installed. But when I execute it on my Shell I seem to be missing on Perl module. "Can't locate YAML/Tiny.pm". How do I install that module or solve this issue otherwise? Executing the compiled latexindent.exe file gives the same error. The complete message is:

$ latexindent
Can't locate YAML/Tiny.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/msys /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl .) at C:\Program Files (x86)\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 39.
BEGIN failed--compilation aborted at C:\Program Files (x86)\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 39.
  • 1
    Hello! I'd recommend using latexindent.exe together with defaultSettings.yaml. If you'd prefer to stick with the perl version, then you'll need YAML/Tiny.pm, which you can install as detailed here, for example: stackoverflow.com/questions/6643939/… Let us know how you get on! – cmhughes Sep 22 '16 at 12:17
  • I installed the module from CPAN. From my PowerShell ISE it is working now. – Michael S. Sep 22 '16 at 12:30
  • Do I need arara or will I use a Bash script or PowerShell script to indent all my tex-files? What is the benefit of arara? – Michael S. Sep 22 '16 at 12:35
  • Personally, I'd recommend arara, but it is not a requirement. The reasons I love arara: (1) platform independent, (2) set up per-document rules, (3) set up your editor/IDE once for arara, and not have to do it again -- no complicated flags or arguments (4) easily create new rules for new tasks (5) editor independent (6) consistent syntax across all operating systems... I could sing for days about the reasons I love arara, but that's a separate question :) glad you got latexindent working -- would you like to self answer with details of what you did, perhaps with screenshots? – cmhughes Sep 22 '16 at 12:46
  • 1
    @cmhughes (7) Paulo :) – percusse Sep 22 '16 at 16:05

For now I solved this issue using Windows PowerShell ISE and continue working from there. Furthermore, I added a custom command to my Notepad++ like described here:


    <Command name="latexindent" Ctrl="yes" Alt="yes" Shift="yes" Key="">latexindent -d -w &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    <Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="70">safari &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    <Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/%20$(CURRENT_WORD)</Command>
    <Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">http://www.google.com/search?q=$(CURRENT_WORD)</Command>
    <Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">http://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
    <Command name="Open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
    <Command name="Open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -nosession -multiInst</Command>
    <Command name="Send via Outlook" Ctrl="yes" Alt="yes" Shift="yes" Key="79">outlook /a &quot;$(FULL_CURRENT_PATH)&quot;</Command>

Like this I am able to use it from the IDE. Next step is a script iterating over all tex files using PowerShell ISE. Further step would be a Bash script on Jenkins.

latexindent inside Notepad++

  • Could you show how you fixed it? – cmhughes Sep 22 '16 at 13:32
  • Well, I haven't succeeded in Bash yet. In PowerShell ISE it worked out of the box. – Michael S. Sep 22 '16 at 13:55
  • I meant about the perl module, which seemed at the heart of your question :) – cmhughes Sep 22 '16 at 14:53
  • I understood you but this was not yet successful although your suggestion worked like this: cpan[1]> install YAML::Tiny Reading '.cpan\Metadata' Database was generated on Thu, 22 Sep 2016 00:41:03 GMT YAML::Tiny is up to date (1.69). – Michael S. Sep 22 '16 at 14:58
  • Still same error in Cygwin64 Terminal and in Git Bash. Can't locate YAML/Tiny.pm in @INC (you may need to install the YAML::Tiny module) (@INC contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-threads /usr/lib/perl5/5.22 .) at C:\Program Files (x86)\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 39. BEGIN failed--compilation aborted at C:\Program Files (x86)\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 39. – Michael S. Sep 22 '16 at 14:59

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.