I'm building a script for a CI to get a docker image with minimal distribution of Texlive possible, I specifically want to avoid pulling 5 Gb of texlive-full everytime I need this docker image.

Right now I see this script as

  1. install texlive-something
  2. tlmgr install latexmk
  3. tlmgr install texliveonfly
  4. texliveonfly -c latexmk -a "-pdf -f -synctex=0" myFile.tex (install missing tex packages and compile with latexmk)
  5. deploy results and cache the tex-related part of the image.

Which package should I chose for texlive-something so that these steps work? Thanks in advance.


It seems that the word minimal can lead to some confusion. In this case it means (for a package)

  1. Has a set of binaries (pdflatex, tlmgr, bibtex/biber, perl, I might be missing something) that would allow me to compile an empty document. Should I need some other binaries, I'm ok with adding this dependencies by hand

  2. Contains a minimal set of LaTeX packages so that an empty document would compile. If I understand correctly, most other packages will be handled by texliveonfly (barring some esoteric cases, of course, but that can be handled manually, too).

In other words, minimal in terms of total disk space under the hypothesis that an empty document compiles using the instruments I mentioned.

  • You can say that "minimal" is texlive with nothing more... And it is not even minimal . Anything more is a matter of taste and opinion based... But I gave an answer by my experience with the packages that I always have to install (math is a mast for me anyway... but texlive users love math and if not... have to)
    – koleygr
    Commented Oct 20, 2017 at 13:12
  • I also think that in different linux distros the packages are not exactly the same... (Just noticing for anyone who will see this question) [But this could be because of different texlive releases... not sure... Just happened to me before]
    – koleygr
    Commented Oct 20, 2017 at 13:16
  • 1
    This heavily depends on what you want to use the installation for. Commented Oct 20, 2017 at 13:22
  • @samcarter could you elaborate? Commented Oct 20, 2017 at 13:25
  • 1
    @projetmbc if you are still interested: github.com/ShrykeWindgrace/TeXLive-CI-minimal Commented Jan 31, 2022 at 12:08

9 Answers 9


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

  • Hm, that's interesting, thank you. I'll try to run the installation with this profile. Commented Oct 20, 2017 at 14:14
  • This is the best answer. Always install TeXLive from official source. The various package managers (apt-get, homebrew, etc) may not have packaged the latest TeXLive, or worse, may have incorrect packaging. This has my upvote.
    – user152148
    Commented Jan 19, 2019 at 4:41
  • One problem though: when I followed the official doc to get the minimal-texlive installed, tlmgr is missing from the command-line. (This is with Windows 10 under WSL2, Pengwin distro. I have restarted the machine.)
    – llinfeng
    Commented Dec 9, 2019 at 23:03
  • @llinfeng somehow it doesn't add the exec to PATH. I'm using Lubuntu, that's strange. Commented Mar 18, 2020 at 5:45
  • 1
    @llinfeng I reinstalled and found out that you have to select that create symlinks in standard directories option. Why is it not the default option? Commented Mar 19, 2020 at 12:25

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


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
  • For anyone using this answer: Since this year (1st April of 2021) a binary for musl comes with TeXLive.
    – miile7
    Commented Apr 19, 2021 at 10:34

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://yihui.org/tinytex/install-bin-unix.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

  • 1
    But every user has to do this individually?
    – cfr
    Commented May 23, 2018 at 23:12
  • @cfr: No. In the distribution site there are instructions to install for all users on a Linux system - static install, only root can add packages, or each user having its own package tree. See answer 8 on yihui.name/tinytex/faq Commented May 23, 2018 at 23:16
  • 1
    You might want to clarify that in your answer, since that would be a significant disadvantage for some people. (I guess it doesn't have to be root owned, either. You could do it the way I do for TL with a dedicated user.)
    – cfr
    Commented May 23, 2018 at 23:43

For a CI environment, I would base on one of the Island of TeX texlive images. It is availble at https://gitlab.com/islandoftex/images/texlive

To choose between minimal, basic, small, medium, and full etc., please consult What makes up each TeX Live install-tl scheme?.

For really minimal, start with registry.gitlab.com/islandoftex/images/texlive:TL2023-latest-minimal.

  • 1
    Thanks, I'll take a look. Commented Jul 15, 2023 at 13:31

I use

  1. texlive-lang-greek
  2. texlive-xetex
  3. texlive-latex-extra
  4. texlive-fonts-extra and
  5. texlive-math-extra

You can replace the language with english + more if needed,

You can avoid xetex and fonts-extra if you dont use XeLaTeX

But the others I have discovered are really useful to let them "out of the game"

PS: Also I think your question is opinion based and will probably be closed

  • Thanks, I'll give it a try. Why do you think this question is opinion based? Basically, I'm asking for a name of a package that a) has minimal set of binaries (pdflatex, tlmgr, bibtex/biber, perl, I might be missing something) b) contains a minimal set of LaTeX packages so that at least an empty document would compile. If I understand correctly, everything else will be handled by texliveonfly (barring some esoteric cases, of course). Commented Oct 20, 2017 at 13:15
  • I don't know... Probably I missed things... I didn't answer about compilation of "hello world" latex file... I talked about the texlive packages that are common used in more of the cases (That just allows you to compile as much latex projects as possible without installing everything of texlive). If I am off-topic please let me know to delete the answer.
    – koleygr
    Commented Oct 20, 2017 at 13:20
  • Comment probably important: Never used latexmk till now!
    – koleygr
    Commented Oct 20, 2017 at 13:22
  • Hm, why did you not use latexmk? I don't think I saw a better alternative. I find it quite helpful (and many TeX editors are running it under the hood for their build systems). Commented Oct 20, 2017 at 13:28
  • 1
    You don't say which distro you use. You don't know what distro the OP uses. So you have no idea if these packages even exist there or, if they do, what they provide.
    – cfr
    Commented May 23, 2018 at 23:11

I come from a project where the documentation guideline simply says

apt-get install build-essential python3 python3-pip \
    texlive-latex-extra texlive-fonts-recommended latexmk
pip3 install sphinx sphinx_rtd_theme

I kept on doing this and noticing that it pulled in on the order of 1 gigabyte of -doc packages which would never get used for anything actually. When you are sitting on the bus and your phone drops to 3G, that means something like 30 minutes of additional build time.

I don't want to investigate the full dependency chain and replace the texlive-latex-extra dependency with a long, hand-tuned list of packages which is going to change behind my back without notice. I don't want to build my own replacement. I just want to download less.

On Debian, a simple but crude workaround is equivs, which allows you to build a small package which does more or less nothing at all. In fact, one of the original motivations for equivs was to allow you to lie to dpkg that something is already installed so it doesn't pull it in as a dependency.

Going over the build transcript, I see the following packages which I don't need. I dropped these into an equivs package and install that as part of the build.

texlive-latex-base-doc         # 45.6M
texlive-fonts-recommended-doc  #  2.7M
texlive-latex-extra-doc        #  364M
texlive-latex-recommended-doc  # 40.6M
texlive-pictures-doc           #  105M
texlive-pstricks-doc           #  238M

That's some 796M of packages with pure documentation, and about 60% of the entire volume of dependencies. I'm sure the downloads could be pruned further if you know what you are doing, but this was definitely low-hanging fruit.

My set of equivs-built fake packages is available from https://packagecloud.io/tripleee/texlive-no-doc/install and the source is on Github: https://github.com/tripleee/texlive-no-doc-equivs


I use texlive-full but remove the docs and the language packs from it. To do so, I don't install the texlive-full metapackage, rather all the packages that it installs (minus the docs and language packs). For this, I run this piped command:

sudo apt-get install $(sudo apt-get --assume-no install texlive-full |
    awk '/The following additional packages will be installed/{f=1;next}
        /Suggested packages/{f=0}
        f { for(i=1; i<=NF; ++i)
            if ($i !~ /doc$|texlive-lang|latex-cjk/)
                print $i }')

Note that latex-cjk is the collection of Chinese-Japanese-Korean language/font packs.

This brings down my LaTeX installation from 6.5GB to merely 3.5GB (and yet I have all the packages that I will ever need).

After this, I install the language packages separately which I require:

sudo apt install texlive-lang-english texlive-lang-german

Source: https://gist.github.com/shivams/0e62b79aaef345560c11aa1862b7029c

  • Your regex doesn't use any of the facilities of grep -P so you can drop that option, which is nonstandard. You can combine the regexes into one, or use grep -v -e 'doc$' -e 'texlive-lang' -e 'latex-cjk' and I don't think the final tr is useful, either. (A better fix still would be to refactor all of this into the Awk script; see also useless use of grep.)
    – tripleee
    Commented Dec 21, 2021 at 19:08
  • True @tripleee. I just use grep with the -P option everywhere out of habit. But you're correct. We can make this solution more standard by using standard grep and maybe even awk. Kindly feel free to edit and update the answer.
    – shivams
    Commented Dec 21, 2021 at 21:38
  • I have submitted an edit suggestion to fold all the logic into the Awk script; it actually simplified it rather nicely, too.
    – tripleee
    Commented Dec 22, 2021 at 5:41

Quite some time has passed since I asked this question, and I have yet another approach to add. One can take NixOS as the base distro for the docker (nixos/nix:latest is about 170 MB according to docker registry), and then have a very fine-grained control over the schemes and packages to add, albeit at a price of using nix link

Obvious downside of this approach is nix - yet another language and ecosystem to learn, and hence a limitation in collaboration and mental load.

An example of my recent "no fancy packages at all" document - it required the following declaration

with import <nixpkgs> {};

stdenvNoCC.mkDerivation {
  name = "project name";
  buildInputs = [
    (texlive.combine { inherit (texlive) scheme-basic latexmk csquotes metafont float cm-super graphics; })
  src = pkgs.lib.sources.sourceFilesBySuffices ./. [".tex" "Makefile" ".dot" ".txt" ".nix"];

TeX-related part of this script boils down to

(texlive.combine { inherit (texlive) scheme-basic latexmk csquotes metafont float cm-super graphics; })

In my CI runner the nix-build downloads additional ~100MB of data, which is ok-ish for my current needs; it means that I have a ~270MB download size. I still think that we can do better=)


For Mac OS X, you can use BasicTeX. It is the option recommended for instance by pandoc (they just recommend to install the collection-fontsrecommended package on top of it).

Quoting About BasicTeX-2017:

BasicTeX (73 MB) is an installation package for Mac OS X based on TeX Live 2017. Unlike MacTeX, this package is deliberately small. Yet it contains all of the standard tools needed to write TeX documents, including TeX, LaTeX, pdfTeX, MetaFont, dvips, MetaPost, and XeTeX.

Apparently, this package is just a wrapper of the standard TeXLive installation script, tuning some paths and setting the installation to the "TeX Live small scheme" option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .