LaΤeΧ Installation


With special emphasis on installing only the needful things.

MacTeX or MikTex or TexLive or whatever 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 communiting 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 typset 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.

Minimalist TeX

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 here.)

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.

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.

brew cask install basictex

On linux, the default TeXLive installation via homebrew is minimalist.

brew cask install texlive

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.

install.packages('tinytex')
tinytex::install_tinytex()

You install things via

tlmgr_install('somefinepackageineed')

or using tlmgr as usual

It includes build helpers, e.g.

tinytex::pdflatex('test.tex')\

MikTeX

MikTeX is minimalist per default AFAICT. Have not used.

Distro package maanger

One can install the tex-full or similarly-named distribution package, which is maximalist but fairly well tested.

Docker TeX

All this TeX wrangling seems depressing and time-wasting. You can side-step some details by running containerized TeX, and just ignore a lot 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.

Installing TeX packages

Ok, so if I have installed a possibly 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 set it up via:

tlmgr init-usertree

and possibly also:

sudo apt install xzdec

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 TwX 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.

tlmgr search --global --file "/times.sty"

Weird errors can arise in this manual method. When I got .fmt made by different executable version, the following magical incantation seemed to fix it.

sudo fmtutil --all

orpass

sudo fmtutil-sys --all

I keep the installation up to date using the following incantation:

tlmgr update --self --all
tlmgr path add
fmtutil-sys --all

Alone amongst all the packages I have tried, biber, the biblatex executable, and dvipng, the png backend for DVI rendering seems 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:

ln -s ~/.TinyTeX/bin/*/* ~/bin/  # linux
ln -s ~/Library/TinyTeX/bin/*/* /usr/local/bin/  # macos

Example minimalist TeX dependencies

To handle fancier jupyter notebook via ipypublish, we also need

tlmgr install \
    latexmk \
    translations

To handle biblatex:

tlmgr install biblatex

To handle modern referencing:

tlmgr install placeins \
    todonotes \
    chngcntr \
    doi \
    mdframed \
    needspace \
    cleveref

To handle pandoc:

tlmgr install amsfonts \
    amsmath \
    lm \
    unicode-math \
    ifxetex \
    ifluatex \
    listings  \
    fancyvrb \
    longtable \
    booktabs \
    graphicx \
    grffile \
    xstring \
    logreq \
    biblatex \
    biber \
    fontspec \
    polyglossia  \
    xecjk \
    bidi

To handle Anki flashcard rendering:

tlmgr install bbm-macros \
    dvipng

To handle latex_fragment:

tlmgr install standalone \
    preview

To handle .eps files.

tlmgr install epstopdf

To handle Tom Pollard’s markdown thesis:

tlmgr install truncate \
    tocloft \
    wallpaper \
    morefloats \
    sectsty \
    siunitx \
    threeparttable \
    l3packages \
    l3kernel \
    l3experimental

To format orcid references:

tlmgr install academicons

For my thesis

tlmgr install \
    algorithms \
    appendix \
    biber \
    biblatex \
    chngcntr \
    cm-super \
    datatool \
    dvipng \
    enumitem \
    fancyhdr \
    fancyvrb \
    glossaries \
    jknapltx \
    koma-script \
    mfirstuc \
    ms \
    nomencl \
    pdflscape \
    pdfpages \
    ragged2e \
    realscripts \
    rsfs \
    setspace \
    siunitx \
    synctex \
    textcase \
    type1cm \
    xfor \
    xltxtra

cm-super and type1cm is because I cannot work out how to make julia latex in plots behave itself.

Fonts

See LaTeX fonts.

Mirror choice

The default option of

tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet

does not work in Australia because it will try to download from some hapless server in Indonesia.

Here we must

tlmgr option repository http://mirror.aarnet.edu.au/pub/CTAN/systems/texlive/tlnet