Quick and easy: running LaTeX locally on Mac

Michael TimmersMichael Timmers
2 min read

Intro

This is just going to be a quick one, I just thought it was really cool and wanted to share how easy it was to run LaTex locally on a Mac without downloading multiple Gb of UI with something like MacTex. The solution I found uses what ever editor you want, with a minimal of command line dabbling.

So lets start!

Requirements

• Home brew package manager.

• Text editor of choice (really anything!)

Step 1: Install light weight version of LaTeX

Instead of using the GUI app MacTex, which has a hefty file size, install basictex with brew:

brew install basictex

Step 2: Prepare .tex file

Here are some example contents for a test, name the file with the .tex extension:

\documentclass{article}
\begin{document}
  Some example contents!
\end{document}

Step 3: Compiling to PDF

You can now create a pdf by running this command with the text file you created:

pdflatex file.tex -o file.pdf

Alternatively, you can use the entr tool to watch your latex files and automatically compile them. This is what I think makes this solution so simple and powerful.

Step 4: the entr tool

If you don’t already have the entr tool, instal it with brew:

brew install entr

Then you can put this line in a .sh file to be able to run easily:

ls .tex .sty | entr -c pdflatex file.tex -o file.pdf

And just for completeness here is how you would make the .sh file executable by all users:

chmod +x watch.sh

So run ./watch.sh and open the .pdf file that is created. Preview refreshes by default so no need to re-open each time, it will automatically update every time you save the .tex file. This is as long as there are no errors, in which case you will have to press q then enter on the command line that you started watch.sh.

Conclusion

I hope you learnt something and can now have the satisfaction of a non-Overleaf solution for compiling LaTeX easily.

In addition to this, you could also try to install some VS Code extensions, but so far I haven’t been able to get them to work , even when installing the suggested packages with the tlmgr tool. But that is another days work…

I hope you enjoyed this quick overview of LaTeX locally on mac!

Code forth and go!

0
Subscribe to my newsletter

Read articles from Michael Timmers directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Michael Timmers
Michael Timmers