How can I install latexindent on macOS?
I found a solution. Latexindent was not present using tlmgr at first, but after updating repository and trying again, I was able to install it.
For anyone else, this is what I did (root required):
sudo tlmgr option repository ctan
sudo tlmgr update --self
sudo tlmgr install latexindent
So probably outdated or a wrong repo URL at first.
ctan
is just an alias for http://mirror.ctan.org/systems/texlive/tlnet
OK, things are a little bit different now:
brew cask install basictex
sudo tlmgr install latexindent
cpan -i Log::Log4perl Log::Dispatch::File YAML::Tiny File::HomeDir Unicode::GCString
and if you want to have the LaTeX Workshop extension on Visual Studio Code working, add the line
"latex-workshop.latexindent.path": "/Library/TeX/texbin/latexindent"
in the settings.json
, you need to also install
sudo tlmgr install latexmk
tested on macOS Catalina 10.15.4.
For anyone trying to install Latexindent.pl on a clean Mojave installation (macOS 10.14.1, November 2018) so that it works with Atom and other IDEs, there are some more steps required.
First, because some of the perl helper modules require compilation, you'll need a working installation of C and perl:
Make sure that you have Xcode installed and working, including command line tools.
sudo xcode-select --switch /Library/Developer/CommandLineTools
Make the header files for c etc. available; see the comment from @Maxx here (https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave):
I quote:
If we are using XCode 10, you will notice that if you navigate to /usr in the Finder, you will not see a folder called 'include' anymore which is why the terminal complains of the absence of the header files which is contained inside the 'include' folder. In this release statement, developer.apple.com/documentation/xcode_release_notes/… (you navigate to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg and run that package to have the 'include' folder installed). Then you should be good to go.
- Install cpan through the terminal to help with perl installations:
cpan App::cpanminus
The next step is to get Latexindent working as a standalone tool:
- Install it using tlmgr as described elsewhere on this page
- Download the entire
Latexindent
zip from https://github.com/cmhughes/latexindent.pl. - Open a terminal window
- In the terminal navigate to the "helper-scripts" directory
- Run
sudo perl latexindent-module-installer.pl
to get all of the other required perl modules installed.
You can now test latexindent.pl by opening a new terminal and navigating to the directory where your .tex file is (let`s call it test.tex). Once there, you can test it without changing your file:
latexindent.pl test.tex
From this point on there are many more useful examples in the documentation on readthedocs or the CTAN Package PDF.
This means that latexindent.pl now works with atom-beautify.