LaTeX Installation
November 20, 2019 — April 19, 2021
With special emphasis on installing only the needful things.
By default, distributions like MacTeX, MikTeX, or TexLive waste your hard disk space if you install the whole gigantic thing. 5Gb for a 1980s typesetting system is cheeky, especially from people who delight in claiming that Microsoft Word is over-engineered, and that they are keeping it serious with their svelte, elegant, professional alternative. But LaTeX is not “serious typesetting,” except in the sense that driving a panzer to work is “serious commuting.” (In this commuting metaphor, Microsoft Word is some kind of polka-dotted clown car, as far as mathematics is concerned.)
Alternatively, I could still use most of the LaTeX markup to typeset my mathematics but not for everything else; this is the LaTeX-free mathematics option.
For all the options, I will need to think additionally too hard about fonts.
1 Tectonic
I am trying tectonic out currently. Nothing has broken so far. It is a minimal re-imagining of the TeX distributions with modern dev tools and behaviour. It magically installs whatever I need. I quite like it.
2 Minimalist TeX distribution
However! You can install only what you need using a so-called “minimalist” distribution. (Which is still hundreds of megabytes, but we are going to have to take what breaks we can.)
A gotcha for this method is that it only works for one year, then you must start over. Then I get cut off from updates and have to do a tedious procedure to get another year’s life out of TeX. You can avoid this with the monumental maximalist TeXes not because they do not suffer from this problem, but because they install so much stuff all at once that you rarely notice anything missing, so you can labour on for years with an increasingly obsolescent version self-contained system.
I do not have the drive space to waste on this.
2.1 Minimalist TeXLive
A generic way of doing this on macOS is to install basictex, the minimalist version of TeXLive.
On macOS at least, this command installed minimal TeX.
On Linux, the default TeXLive installation via homebrew is minimalist.
2.2 TinyTeX
If you are an R user, there is tinytex, a semi-managed minimalist LaTeX distribution based on TeXLive but with better defaults, which will automatically install what given R packages need.
You install things via
or using tlmgr
as usual
It includes build helpers, e.g.
Most fancy of all, if you are in the same folder as a TeX log for some failed build, you can automagically attempt to find the missing pieces
It is worth keeping an R console open just for this.
2.3 MikTeX
MikTeX is minimalist by default AFAICT. Have not used.
3 Distro package manager
One can install the tex-full
or similarly-named distribution package, which is maximalist but fairly well tested, and also fairly outdated by the time the distro ships.
4 Docker TeX
All this TeX wrangling seems depressing and time-wasting. You can side-step some details by running containerized TeX, and ignore some of the nonsense. (Not the hard disk space wastage and bloat; that is kind of built-in.) blang/latex-docker is one set of such dockerfiles with a good reputation. There are some newer ones, e.g. schickling/latex, about which I know yet less. qmcgaw/latexdevcontainer targets my IDE specifically.
5 Installing TeX packages
Ok, so if I have installed a minimal TeX, I install things as needed using the TeX package management system tlmgr
.
For example, to render jupyter notebooks, I found I needed:
tlmgr install \
adjustbox \
collectbox \
collection-fontsrecommended \
enumitem \
logreq \
ucs \
xstring
There are more examples of dependency sets below.
In addition to the basic system install, on Debian/Ubuntu distro install I needed to set up user packages via:
and possibly also:
If that doesn’t work you might need alternate methods such as manual install, or TinyTex, documented below.
When I am not sure precisely which TeX package I need but I do know the name of a file which is missing, e.g. times.sty
, the following command will find me candidates.
Weird errors can arise in this manual method. When I got
or
I keep the installation up to date using the following incantation:
Alone amongst all the packages I have tried, biber
, the biblatex executable, and dvipng
, the png backend for DVI rendering seem to want special care, and need their symlinks created manually.
tlmgr install biber
ln -s ~/.TinyTeX/bin/*/biber ~/bin/ # linux
ln -s ~/Library/TinyTeX/bin/*/biber /usr/local/bin/ # macos
tlmgr install dvipng
ln -s ~/.TinyTeX/bin/*/dvipng ~/bin/ # linux
ln -s ~/Library/TinyTeX/bin/*/dvipng /usr/local/bin/ # macos
presumably nothing bad would happen if I just linked everything:
5.1 Example TeX dependencies
To handle fancier jupyter notebook via ipypublish
, we also need
To handle biblatex:
To handle modern referencing:
tlmgr install amsfonts \
amsmath \
lm \
unicode-math \
listings \
fancyvrb \
booktabs \
grffile \
xstring \
logreq \
biblatex \
biber \
fontspec \
polyglossia \
xecjk \
bidi
AMSmath:
To handle Anki flashcard rendering:
To handle latex_fragment
:
To handle .eps
files.
To handle Tom Pollard’s markdown thesis:
tlmgr install truncate \
tocloft \
wallpaper \
morefloats \
sectsty \
siunitx \
threeparttable \
l3packages \
l3kernel \
l3experimental
To format orcid references:
6 Fonts
See LaTeX fonts.
7 Mirror choice
The default option of
does not work in Australia because it will try to download from some hapless server in Indonesia.
Here we must instead set