Minimal TeXLive installation

Installing texlive from TUG (https://www.tug.org/texlive/acquire-netinstall.html) you can have a minimal latex installation with 76 MB by selecting:

  • the basic scheme

enter image description here

  • not installing documentation and source

enter image description here


I use TinyTeX, it was developed for R but works nicely for other purposes.

Management is done by command-line using tlmgr as usual, and the profile file is easy to understand and adjust:

TinyTeX is a custom (and probably opinionated) LaTeX distribution based on TeX Live that is small in size but still functions well in most cases. Even if you run into the problem of missing LaTeX packages, it should be super clear to you what you need to do. You only install LaTeX packages you actually need. The manual should be at most two pages long.

Please note that TinyTeX assumes that you are not afraid of using the command line... In fact, there is only one single command that you need to know: tlmgr. It is probably not too scary.

TinyTeX only provides an installation script that downloads and installs TeX Live over the network. It may take a couple of minutes, depending on your network speed...

For Linux users, TinyTeX will be installed to $HOME/.TinyTeX and symlinks of executables (such as pdflatex) are created under $HOME/bin, which should be on the PATH environment variable:

wget -qO- \  
"https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" |
sh

...

To uninstall TinyTeX, simply delete the folder from your file manager/browser, or use command line:

# Linux tlmgr path remove 
rm -r "~/.TinyTeX"

Compare the way to uninstall TinyTeX with the ways to uninstall other LaTeX > distributions, and you may appreciate how much simpler it is to get rid of TinyTeX than other LaTeX distributions. That is because TinyTeX is just a self-contained folder.

Edit: @cfr asked how does it work in a multi-user scenario

There are three options, the simple "everyone uses it but only root installs news packages", the complicated "create a tinytex user group and chmod it" and the reasonable "each user may have his local package tree". Questions 7 and 8 on the official FAQ describe it:

1 - Download and prepare a fully portable distro without root:

wget -qO- \
  "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
  sh -s - --admin --no-path

2 - Set symlinks and permissions as root

sudo ~/.TinyTeX/bin/*/tlmgr path add
chown -R root:staff ~/.TinyTeX
chmod -R g+w ~/.TinyTeX
chmod -R g+wx ~/.TinyTeX/bin

3 - Each user initializes its own package tree

tlmgr init-usertree

4 - Users run tlmgr using the --usermode switch to install whatever package they need

tlmgr --usermode install koma-script xcolor

Adjusting these commands to specific sysadmin scenarios should be trivial after a couple minutes of pondering.

Questions 9 and 16 of the FAQ deal with Debian-based package managers\repos\PPAs and with macOS respectively, and are worth a read too.

Second Edit: Just noticed TinyTeX's Hall of Pain...

includes at least three references to the "TeXlive too big for Docker container, MikTeX too esoteric for life" situation: https://yihui.name/tinytex/pain/

A testimonial that mentions files sizes:

Removed TeX Live from my system (openSUSE): 1.5gb. Installed TinyTeX + the dependencies to compile my thesis: 150mb!!!! This is great! — Bruno Rodrigues


I know this is a rather old post, but if you want to build a docker image with a complete TeX Live installation (vanilla TeX Live from TUG) you can reduce its size to about 1.72 GiB instead of 5 GiB which is quite acceptable depending on your needs. However, this just minimizes the image size and does not do on-the-fly installation, because it has all packages.

Okay, so how does it work? The TeX Live installer gives you the option not to install the documentation and source files which results in a TeX tree that only contains the relevant files for a compilation. I highly doubt that you will look up documentation files in a docker image.

Let's start off with the choice of your image. Unfortunately, you cannot use Alpine this time as TeX Live does not ship certain binaries for Linux/MUSL, e.g. biber. So we can resort to Debian.

Furthermore, you need to install some dependencies before getting started, depending on the tools you want to use:

  • JDK for tools like arara
  • libncurses for xindy
  • some perl libraries for biber and other perl tools
  • python-pygments for minted

These are not "expensive" after all. Last but not least you install the vanilla TeX Live with a custom profile:

selected_scheme scheme-full
tlpdbopt_install_docfiles 0
tlpdbopt_install_srcfiles 0
tlpdbopt_autobackup 0
tlpdbopt_sys_bin /usr/bin

That means that you want all package (scheme-full), but do not want any documentation and source files, just the packages. And the last instruction just says that we want our symlinks in /usr/bin, so that we do not have to care about PATH manipulation.

After installing you can call tlmgr path add and you will have your binaries symlinked to your PATH. Then you are ready to go.

Full Dockerfile (partially based on sumankhanal/texlive-2018):

FROM debian:sid

ENV TEXLIVE_INSTALL_NO_CONTEXT_CACHE=1 \ 
    NOPERLDOC=1

RUN apt-get update && \ 
  apt-get install -y wget unzip tar \ 
  make fontconfig perl openjdk-8-jre libgetopt-long-descriptive-perl \
  libdigest-perl-md5-perl libncurses5 \ 
  python3-pygments && \ 
  rm -rf /var/lib/apt/lists/*

RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ 
  tar xzf install-tl-unx.tar.gz && rm install-tl-unx.tar.gz && \ 
  cd install-tl* && \ 
  echo "selected_scheme scheme-full" > install.profile && \ 
  echo "tlpdbopt_install_docfiles 0" >> install.profile && \ 
  echo "tlpdbopt_install_srcfiles 0" >> install.profile && \
  echo "tlpdbopt_autobackup 0" >> install.profile && \ 
  echo "tlpdbopt_sys_bin /usr/bin" >> install.profile && \
  ./install-tl -profile install.profile && cd .. && rm -rf install-tl*

RUN /usr/local/texlive/2018/bin/x86_64-linux/tlmgr path add