TransWikia.com

Minimal TeXLive installation

TeX - LaTeX Asked by TZakrevskiy on January 21, 2021

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.

edit

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.

7 Answers

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

Correct answer by samcarter_is_at_topanswers.xyz on January 21, 2021

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

Answered by koleygr on January 21, 2021

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 managersreposPPAs 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

Answered by Lucas Soares on January 21, 2021

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.

Answered by Clément on January 21, 2021

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

Answered by TeXnician on January 21, 2021

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
make

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-tunes 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

Answered by tripleee on January 21, 2021

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 install `sudo apt --assume-no install texlive-full | 
    awk '/The following additional packages will be installed/{f=1;next} /Suggested packages/{f=0} f' | 
    tr ' ' 'n' | 
    grep -vP 'doc$' | 
    grep -vP 'texlive-lang' | 
    grep -vP 'latex-cjk' | 
    tr 'n' ' '`

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

Answered by shivams on January 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP