How to get MacTeX faster: Easily using BasicTeX

-

If you type equations regularly, you've probably heard of LaTeX. But the OSX distribution (MacTeX) is huge -- the 3 GB file can take forever to download, and it takes up a lot of space. BasicTeX is a much smaller alternative, but it's intimidating to new users. This tutorial sets you up with BasicTeX in no time, so you can easily get started.

1) Installing BasicTeX

I used Homebrew to install BasicTeX, since I can later use it to easily uninstall BasicTeX if needed. You install BasicTeX via brew cask:

brew install brew-cask
brew cask install basictex

2) Choosing an editor

TeXShop is nice if you want a GUI, but I wanted to stick to vim. Luckily, there's a great plugin called vim-latex that you can install in just a few steps. Either is fine, and their respective websites have walkthroughs to get them installed.

3) Fetching dependencies on the fly

Unfortunately, since BasicTeX is so bare-bones, you're going to have to download a lot of packages when you open new documents sometimes. But that's okay!

texliveonfly makes this incredibly easy. First, install:

tlmgr install texliveonfly

Whenever you get a new document, instead of running latex, you can run:

texliveonfly {FILENAME}.tex

4) Making things easier with .bashrc

I added a few lines to my .bashrc file to make the commands more consistent:

alias latex-fix=texliveonfly
alias latex-pdf=pdflatex
alias latex-test=xdvi

After you write a document, use latex-fix -- it will immediately convert it to a PDF and install any dependencies.

On the other hand, you could use the plain latex command as well. If you want to preview the .dvi document generated by the normal latex command, use latex-test. Finally, to convert it to a PDF, just use latex-pdf.

5) Downloading specific packages

Sometimes you might need to just download one specific package. Rather than using texliveonfly, you can use tlmgr directly. Just call tlmgr install pkgname. For example:

LaTeX Error: File 'amsmath.sty' not found.
...
tlmgr install amsmath

This will work most of the time. Sometimes, you might have to search for the package through CTAN and get the actual package name from there.

And that's it. Let me know if you have any difficulties!

For practice, you can try downloading this sample LaTeX file. One possible sequence of commands might be:

latex sample.tex
latex-test sample
latex-pdf sample

Another option is to just call latex-fix sample.tex. If you just followed this tutorial, you're going to have to use latex-fix, since you won't have any of the dependencies needed.

Tags: basictex mactex smaller latex tutorial install

See also: Using custom domains with AWS Elastic Beanstalk

Back to all posts

Neel Somani

About the Author

Neel Somani is the founder of Apptic LLC. In addition to computer science, he's interested in philosophy and entrepreneurship. You can follow him on Google+, LinkedIn, and Twitter.

comments powered by Disqus