31

Are there any portable minimal latex/xelatex distributions? I know of MikTeX portable, but at 130MBs it is far from minimal. Alternatively, can I easily make my own distribution?

What I would like to have is:

  • Ability to compile a pre-defined type of XeTeX document
  • Just the required packages included
  • Size under 5MB, ideally under 2MB

Any ideas?

ipavlic
  • 8,091
  • Do you want just XeTeX (i.e. with a plain-like format) or does it also need to have LaTeX? – Joseph Wright Mar 16 '11 at 15:02
  • @Joseph Wright: I would much prefer LaTeX. – ipavlic Mar 16 '11 at 15:14
  • 2
    I may be wrong, but your size requirements sound very optimistic to me. Are you really that constrained by the space available to you? – Anthony Labarre Mar 16 '11 at 15:15
  • 2
    @Anthony Labarre: Most likely, no. I would prefer it to be as minimal as possible. I assumed that TeX is "small" because it was completed in 1989. And then I assumed that LaTeX "can't be much larger". – ipavlic Mar 16 '11 at 15:19
  • @ipavlic: But you've for XeLaTeX, which is bigger on any system, and 'modern' LaTex is a lot bigger than say LaTeX 2.09 (core only) in 1989! – Joseph Wright Mar 16 '11 at 15:21
  • 1
    @Joseph Wright: How big exactly are bare systems which can support XeLaTeX? – ipavlic Mar 16 '11 at 15:26
  • 1
    @Martin Scharrer: You are right about the sizes of USB sticks, but that is not what I am looking for. I stated in my question that I do know of MiKTeX portable, which is around 15 times smaller and thus more appropriate by my criteria. – ipavlic Mar 16 '11 at 15:31
  • Are 130Mb really large considering that virtually everyone has fast broadband internet nowadays and that you can pick up a 16GB pen drive for a mere 20 quid? – Martin H Mar 16 '11 at 15:43
  • 3
    @Martin H: For my purposes, it is. If my requirements can be satisfied, great. If not, what's the next best option? I am perfectly satisfied with an answer 20MBs, 50MBs (or 130MBs) if that is really the smallest size possible. Don't get me wrong, I appreciate your effort. Still, imagine somebody wanted to convince you to use Word instead of LaTeX: "but do you really need excellent line-breaking and so-called-nice-looking documents without wysiwyg in today's fast paced world?" – ipavlic Mar 16 '11 at 15:54
  • 4
    I'm using beside my miktex a rather bare development lua(la)tex (with the binaries from w32tex.org). The bin-folder contains also the format files and is about 10 MB large. To this you must add the space for fonts (luatex and xetex still needs TeX-fonts e.g. for math), packages, tools like dvips (e.g. for pst-pdf), bibtex, makeindex/xindy, package manager, ...

    I would say 5 MB is impossible today. 20 MB is very optimistic.

    – Ulrike Fischer Mar 16 '11 at 15:59
  • @Ulrike Fischer: Thanks! That's what I was looking for. So I'm guessing 25-30MBs is probably feasible. I do not need math fonts. Any pointers on what exactly do I need to download XeLaTeX? – ipavlic Mar 16 '11 at 16:05
  • Get either miktex portable or texlive portable, install it and then remove the things you don't need (in miktex you can use the package manager to remove packages). - And I have no idea if 30MB is feasible, perhaps with the w32tex.org binaries but probably not with miktex. The miktex package with xetex binaries has a size of 14MB. – Ulrike Fischer Mar 16 '11 at 16:23
  • 6
    There exists a script that builds a distribution based on a single document. See http://tex.stackexchange.com/questions/8249/ – Taco Hoekwater Mar 16 '11 at 18:57
  • I don't know whether this is the right place to tell, but I'd suggest trying Lout: http://savannah.nongnu.org/projects/lout (not a TeX, but very similar to it) – Frederico Lopes Jul 04 '11 at 22:04
  • @Orbis: Sorry, but -1 from me. lots of things that do not actually relate to the question are smaller than a TeX distribution, but listing these does not amount to a usable answer. – Taco Hoekwater Jul 04 '11 at 22:11
  • @Tobi: OK! Do you have a better choice under 2Mb? – Frederico Lopes Jul 04 '11 at 23:25
  • @Orbis: It is not the answer to my question but it is helpful to me. Thank you for the information. – ipavlic Jul 05 '11 at 07:55
  • @Orbis: I converted your answer to a comment. I think it is better suited to be one. Thanks for you contribution. – Martin Scharrer Jul 05 '11 at 09:24
  • It seems to me you also collapsed other answers into comments, if I recall correctly. – ipavlic Jul 05 '11 at 12:35

4 Answers4

18

Summarising the various comments as an answer, the bottom line is that a target of 5 MB is unrealistic. For example, the Windows XeTeX binary on my system is 2.7 MB, while as Ulrike says

The MiKTeX package with XeTeX binaries has a size of 14MB.

(On my Unix system, the XeTeX binary is 17.8 MB). You need of course in addition to XeTeX the xdvipdfm system (I'm not sure exactly how that is packaged up on different systems.)

As an absolute minimum, you need in addition to the XeTeX binary some structure for finding files (kpsewhich or MiKTeX's equivalent), basic fonts (Computer Modern and Latin Modern), then a basic LaTeX (the base/required/tools, plus whatever you feel is 'minimal'). That is all going to add up.

Looking at the existing small distributions, BasicTeX (Mac-only) is 92 MB and MiKTeX basic is 157 MB. You could try to build something like one of these yourself, but the most obvious way to proceed is

Get either MiKTeX portable or TeX Live portable, install it and then remove the things you don't need (in MiKTeX you can use the package manager to remove packages).

(again from Ulrike's comment).

To get the size down, you should also look to remove all of the doc tree, as this tends to be quite big. Of course, you'll be left with no documentation, but it will be smaller.

Werner
  • 603,163
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
14

As a 13 years long LaTeX user, I managed to have my own minimal distribution extracted from TeXlive, in the way Joseph Wright described in his answer, and installed it on my personal directory on a server at work (on windows platform) so that it runs in any computer I'm connected with.

It consists of pdflatex + bibtex8 + makeindex + scite + sumatrapdf and a few standard packages (base + tools + graphics + geometry + titlesec + pgf + hyperref and dependencies).

I also tweaked fonttext.cfg, fontmath.cfg and preload.cfg to have Latin Modern as default fonts so that I have no cm and ec fonts installed... All this stands in 30MB (~1300 files) so I can confirm that a standalone pdflatex system (without the editor, pdfviewer and extra package like pgf) stands in no more than 20MB. Surely xelatex and lualatex need more space because of bigger binaries.

  • Can you share your experience by explaining the steps? What parts are removed? @Bertrand Morel. – Edy Jo Jan 11 '14 at 02:42
  • I'm interested in the instructions as well, even though it seems like @BertrandMorel is no longer visiting TeX.SE. – Paul Kulchenko May 16 '15 at 05:40
  • @PaulKulchenko, did you have any progress on doing this? I'm also interested. I want a way to compile only a single document, many times, in many computers. – Sigur Nov 04 '16 at 15:02
  • 1
    @Sigur, no, but I looked at SILE instead as it allows for more compact package. – Paul Kulchenko Nov 04 '16 at 21:03
  • @PaulKulchenko, thanks, but I would like to use Tikz package. So... – Sigur Nov 04 '16 at 21:06
  • 1
    @Sigur Have a look at my reply. Basically, you can start by putting your.tex and pdflatex.exe in the same folder and keep adding .dll, .fd, .sty, .cls, .pfb, .tfm, .clo, .map files from a working distribution until pdflatex.exe your.tex successfully produces your.pdf. No subfolders required. – masterxilo Mar 09 '17 at 20:20
6

I have also been wondering why this TeXLive thing is taking up so much space and what all of these files and directories are all about and which ones the program actually uses on my behalf.

So I just copied pdflatex.exe out of there and added files until I could compile a simple article with some math and different fonts in it:

%%hello.tex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}

\title{How to Structure a LaTeX Document} \author{Someone} \date{\today} \maketitle

\begin{abstract} Your abstract goes here... ... \end{abstract}

\section{Structure} This section's content...

\subsection{Top Matter} This subsection's content...

\subsubsection{Article Information} This subsubsection's content...

\emph{hello} hello $x^2, \mathbb R, \mathcal C, \mathfrak F, \int_0^1 \sin(x) \mathrm d x$

\end{document}

Turns out you just need, in addition to pdflatex.exe:

  • some .dlls
  • the .sty files for packages you use and dependencies of the packages you use
  • Some U*.fd files to fix errors of the form LaTeX Font Warning: Font shape `U/*/m/n' undefined
  • texmf.cnf
  • <the documentclass>.cls
  • size10.clo (whatever this is)
  • .tfm (font metric) and .pfb files for all the fonts you use (or plan to use, or a few more)
  • pdftex.map which is a concatenation of all .map files for the fonts you use.

These files don't have to be in the standard latex folder structure. They can just be in the same folder as the pdflatex executable.

I have uploaded a ~10MB (unpacked) folder containing all files necessary to run pdflatex hello.tex in it and have it produce hello.pdf:

https://drive.google.com/drive/folders/1iDTmFBQt8fFUSpOoJZWLw8TEai35awCj (it contains pdflatex.exe (from TeXLive2016), so Google Drive might tell you "contains executable code, download at your own risk")

If you try to compile something more complicated, you should be able to copy over the necessary files from your full TeXLive installation to make this minimum installation capable of compiling it too.


That said, if you are on-the-go or in a low-resource environment but have an internet connection, you might prefer to use things like

which might provide an API to compile some LaTeX for you.

masterxilo
  • 563
  • 1
  • 5
  • 7
  • 1
    This sounds super promising, and 10MB is mighty impressive. Too bad it's Windows only... =( – étale-cohomology Aug 09 '17 at 11:46
  • I am sure the same technique works on unix systems – masterxilo Dec 10 '21 at 08:25
  • I updated the link to my example, this still works on Windows 10 x64, though I did not try with newer texlive versions, don't see a reason why they would have changed things that made this "reduction technique" work though. – masterxilo Dec 30 '23 at 22:15
1

Stripping Thierry Laronde's blazing fast TeX distribution, KerTeX, you can get a plain TeX distribution in under 2MB.

0) The tex executable is 1,229,008 bytes (after running strip on it). (I've modified the C sources a bit so your size may vary slightly.)

1) The plain.fmt file is 541,382 bytes.

Total: 1,770,390 bytes.

2) The rest is just fonts.

I'm using a custom DVI driver (forked from dvipng), and this is all I need to compile .tex source code and render .dvi code.


Type 1 fonts can add a few MBs (since there's so many of them...), but you can keep the total under 2MB. Each Type 1 font is 2 files: a .pfb file and a .tfm file. Each Type 1 font is about 35,000 bytes in total. For example, I'm using these Type 1 fonts: cmssbx10, cmssbx10, cmss10, cmssbx10, cmssi10, cmsl10, cmtt10, cmcsc10, cmmi10, cmsy10, cmbx10, eusm10, eusb10, eufm10, eufb10, cmr10, cmmi7, cmr7.

The KerTeX tex executable (which compiles .tex source code into .dvi), and my DVI driver (which renders .dvi code to the screen and to images) needs the plain.fmt file to work, and the .pfb and .tfm files for fonts. (Though I think tex only needs the TFM files?)

That's it.

(Actually KerTeX's tex executable also needs a KXPATH file in the fonts folder, for some reason, but it's only 6 bytes...)

(By the way, the KerTeX tex executable compiles small TeX files in about 2 milliseconds, so it's more than enough to compile and render .tex source in real time, since the DVI driver can be made pretty fast, too.)