TeX Live
According to Wikipedia:
- TeX Live is a free software distribution for the TeX typesetting system that includes major TeX-related programs, macro packages, and fonts.
TeX Live includes:
- many TeX engines, such as:
- basic macro packages (called formats in TeX parlance), such as:
- many user-produced packages
Alternatives to TeX Live include MikTex and Tectonic, they come with a minimal install, downloading the necessary packages on the go.
Arch-packaged TeX Live vs native TeX Live
There are multiple ways to install TeX Live. While a snapshot of TeX Live should be available from the Arch Linux package repositories (as described below), that snapshot is in most cases updated only once a year. In contrast, TeX Live itself is a rolling release distribution, based on the model of the user having to upgrade once a year, but with individual package upgrades available on a sub-daily basis.
The advantages of having a native and up-to-date TeX Live installation include having access to the latest features and bug fixes and to the relevant documentation. While it is possible to upgrade or install an individual package without having native TeX Live (see TEXMFLOCAL
and TEXMFHOME
), this requires extra care - it is necessary to ensure that the versions of all relevant packages are mutually compatible.
In contrast to native TeX Live, the packages in the Arch repositories tend not to include documentation, which is problematic as the documentation from CTAN is usually only available for the latest version of a TeX package.
Native TeX Live
Installation
See the quickinstall documentation, and, if necessary, the full documentation. The process boils down to:
- downloading the netinstall archive
- unpacking the archive and changing to the newly created directory
- running the install script,
perl ./install-tl
, which starts an interactive installation procedure within a text interface- setting the wanted installation path or paths
- optionally, choosing a subset of the package collections provided by TeX Live
- optionally, choosing the Letter paper size as the default, as opposed to A4
- waiting for everything to download
- As the install script will notify you at the end of the process, it's necessary to add the TeX Live installation to the system executable and documentation paths:
PATH
,MANPATH
,INFOPATH
. The install script prints the exact additions that are required before exiting.
Updating
See the tlmgr documentation, tlmgr update --all
upgrades all packages from the collections chosen during the installation. It will also install any packages that are newly added to an installed TeX Live collection.
Once a year, when there's a new TeX Live release, tlmgr update --all
will fail and it will be necessary to install TeX Live anew.
Arch-packaged TeX Live
- The texlive group contains most TeX Live packages, categorised based on upstream collections (see [1]).
- texlive-basic, the core installation, based on the medium upstream install scheme. The package includes pacman hooks to automate mktexlsr, fmtutil and updmap.
-
texlive-latex contains essential LaTeX packages. (For instance, if you intend to use
pdflatex
, then you need this package). -
texlive-latexrecommended and texlive-latexextra contain many useful LaTeX packages, such as
polyglossia
,amsmath
andgraphicx
. - texlive-fontsrecommended contains essential fonts (including the default Latin Modern)
- texlive-fontsextra contains additional fonts, which can be viewed on the LaTeX Font Catalogue.
- texlive-xetex and texlive-luatex contain packages for XeTeX and LuaTeX respectively.
- texlive-bibtexextra contains the BibLaTeX package and additional BibTeX styles and bibliography databases.
- texlive-mathscience contains essential packages for mathematics, natural sciences and computer science.
- The texlive-lang group contains packages providing character sets and features for languages with non-Latin characters.
- biber provides an alternative bibliography processing backend for BibLaTeX.
Note that some tools in texlive-binextra have optional dependencies which are not automatically installed. For example, latexindent depends on perl-yaml-tiny and perl-file-homedir.
pacman -F
to find the Arch package that provides them:
$ pacman -F soul.sty
extra/texlive-plaingeneric 2023.66594-19 (texlive) usr/share/texmf-dist/tex/generic/soul/soul.sty
Whenever there is a need to install a TeX package available on CTAN, run the following to determine whether it is included in an Arch texlive- package:
$ tlmgr info ctan_package_name | grep collection
This will potentially list the name of a TeX Live collection which corresponds to an Arch texlive- package (also check the texlive group to confirm whether such package exists). For instance, an output of collection: collection-plaingeneric
means that TeX package is included in texlive-plaingeneric.
Alternatively, tlmgr
can be used to manually install a single TeX package (see below).
tllocalmgr
The tllocalmgr utility, provided by tllocalmgrAUR, lets you install (and update) packages from CTAN as pacman packages. See its usage (-h
) for details.
tlmgr
With texlive-basic the tlmgr utility should work out of the box. If you still have issues or you're using the old package texlive-core
then you should follow the following procedure in order to make tlmgr work.
- While texlive-basic provides the tlmgr script in TEXMFDIST, it is broken (FS#74404). You can fix it as described below.
- The texconfig(1) command is mostly broken because it partially depends on tlmgr (FS#59094). The interactive mode of
texconfig
requires dialog.
The tlmgr utility is the standard way of installing and updating packages from CTAN. It requires minor fixes as follows:
First, edit TEXMFDIST/scripts/texlive/tlmgr.pl
and replace $Master = "$Master/../..";
with $Master = "${Master}/../../..";
. The path prefix TEXMFDIST is not a predefined environment variable, it is defined below in this article. Replace it with the correct value.
This can also be done from the command line with sudo sed -i 's/\$Master = "\$Master\/..\/..";/\$Master = "\$Master\/..\/..\/..";/' "$TEXMFDIST/scripts/texlive/tlmgr.pl"
Create an alias for the perl script (which you can add in your shell init file).
alias tlmgr='TEXMFDIST/scripts/texlive/tlmgr.pl --usermode'
Now you can initialize it in user mode (which will use ~/texmf
as install prefix):
$ tlmgr init-usertree
Set your preferred mirror. You need to append /systems/texlive/tlnet
to the path of the mirror. For example:
$ tlmgr option repository http://mirrors.rit.edu/CTAN/systems/texlive/tlnet
Now you can install CTAN packages as usual:
$ tlmgr install package_name
Package documentation
The packages in the official repositories do not contain the documentation or source files of font/macro packages.
For offline access with texdoc
, install the whole TeX Live documentation and source files with texlive-doc.
You can also access the documentation online at:
- https://tug.org/texlive/Contents/live/doc.html
- https://ctan.org/ – the central place for all kinds of material around TeX
-
https://texdoc.org/ (
http://texdoc.org/pkg/packagename
directly yields the relevant PDF)
Usage
See the following resources:
- Wikibooks:LaTeX
- The Not So Short Introduction to LaTeX 2ε
- Getting to Grips with LaTeX – Andrew Roberts
- The TeX FAQ
Some use a TeX editor for creating documents.
High-level wrappers for compiling documents
It almost always makes more sense to use a higher-level tool like latexmk(1), or perhaps arara(1), instead of calling things like pdflatex(1) directly, mostly because lower-level tools need to be run multiple times in general for completely compiling a single document.
texmf trees and Kpathsea
texmf trees (texmf stands for TeX and Metafont) should follow the TeX Directory Structure, or files may not be found.[3]
TeX Live uses the Kpathsea library to lookup paths by filename across multiple texmf trees and the current working directory.
Kpathsea searches the following variables in the reverse order (later trees override earlier ones).
Variables | Arch default 1) | Used by [4] |
---|---|---|
TEXMFDIST |
/usr/share/texmf-dist |
files of the original distribution |
TEXMFLOCAL |
/usr/local/share/texmf:/usr/share/texmf |
administrators for system-wide installation of additional or updated macros, fonts, etc. |
TEXMFSYSVAR |
/var/lib/texmf |
updmap and fmtutil (user mode) to store (cached) runtime data |
TEXMFSYSCONFIG |
/etc/texmf |
updmap and fmtutil (user mode) to store modified configuration data |
TEXMFHOME |
~/texmf |
users for their own individual installations of additional or updated macros, fonts, etc. |
TEXMFVAR |
~/.texlive/texmf-var |
updmap and fmtutil (sys mode) to store (cached) runtime data |
TEXMFCONFIG |
~/.texlive/texmf-config |
updmap and fmtutil (sys mode) to store modified configuration data |
TEXMFCACHE |
$TEXMFSYSVAR;$TEXMFVAR |
ConTeXt MkIV and LuaLaTeX to store (cached) runtime data |
/etc/texmf/web2c/texmf.cnf
[5]; they can be overridden with environment variables.Kpathsea provides the kpsewhich(1) command to lookup paths. When run with the --var-brace-value=VARIABLE
argument it can also print the values of variables.
Kpathsea uses filename databases (ls-R
) to speed up searches in system-wide texmf trees (configured with the TEXMFDBS
variable). This means that when system-wide file trees are changed, mktexlsr(1) or texhash
(a symlink) need to be run as root. Fortunately the texlive-basic automates this with a pacman hook targeting all default system-wide texmf trees but /usr/local/share/texmf
.[6] So as long as you install system-wide packages via pacman you should not need to run mktexlsr or texhash at all.
~/texmf/tex/{format}/
directory structure ({format}
is usually latex
), where custom classes are located in the root of the ./{format}
folder and other local files get placed in a folder with the same name (e.g. mycustompackage.sty
goes to ./{formats}/mycustompackage/mycustompackage.sty
), then run texhash
to update the user database.Tips and tricks
Changing default paper size
It is currently impossible to set the default page size using the texlive tools, because they do not work with the standard Arch package.
Usually, you would run texconfig
or tlmgr
, which are also capable of changing other useful settings.
You can edit the configuration files as follows.
- To set the paper size for the pdftex family of commands (pdftex, pdflatex, etc) edit
/etc/texmf/tex/generic/tex-ini-files/pdftexconfig.tex
file.
which can also be discovered by running kpsewhich pdftexconfig.tex
. Change the two lines that specify the pdfpageheight
and pdfpagewidth
. For example, to use letter size, change
\pdfpageheight = 297 true mm \pdfpagewidth = 210 true mm
to
\pdfpageheight = 11 true in \pdfpagewidth = 8.5 true in
Unfortunately, this will not have any effect until the binary .fmt files are rebuilt. You can do this with fmtutil-sys
. Re-installing texlive-bin with pacman will also do this for you.
- For dvips, you can use the
-t
option to specify the paper size:dvips -t letter foo.dvi
. To change the default, edit/etc/texmf/dvips/config/config.ps
file.
which can also be discovered with kpsewhich config.ps
. The end of this file has sections that list all the paper sizes that dvips knows about. The first listed paper size will be the default. Just move the one that you want to be the default to the top of the list. The behavior of dvips will be affected as soon as the file file is changed.
Making fonts available to Fontconfig
By default, the fonts that come with the various TeX Live packages are not automatically available to Fontconfig. If you want to use them with, say XeTeX or LibreOffice, the easiest approach is to make symlink the font directory to a subdirectory in your user's font path. Run the following for an OpenType font:
$ ln -s /usr/share/texmf-dist/fonts/opentype/public/some_fonts_you_want ~/font_path/OTF/
To make them available to fontconfig, run:
$ fc-cache ~/font_path $ mkfontscale ~/font_path/OTF $ mkfontdir ~/font_path/OTF
Similar steps follow for TrueType fonts and Type 1 fonts. In the lines above, substitute opentype
with truetype
or type1
and substitute OTF
with TTF
or Type1
.
Alternatively, texlive-core[broken link: replaced by texlive-basic] contains the file /usr/share/fontconfig/conf.avail/09-texlive-fonts.conf
that contains a list of the font directories used by TeX Live. You can use this file with:
# ln -s /usr/share/fontconfig/conf.avail/09-texlive-fonts.conf /etc/fonts/conf.d/09-texlive-fonts.conf
And then update fontconfig:
$ fc-cache && mkfontscale && mkfontdir
- This may cause conflicts with XeTeX/XeLaTeX if the same fonts are (separately) available to both TeX and Fontconfig, i.e. if multiple copies of the same font are available on the search path.
- Type 1 fonts will not be available in LibreOffice 5.3 and later.
Updating babelbib language definitions
If you have the very specific problem of babelbib not having the latest language definitions that you need, and you do not want to recompile everything, you can get them manually from https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/ and put them in /usr/share/texmf-dist/tex/latex/babelbib/
. For example:
$ cd /usr/share/texmf-dist/tex/latex/babelbib/ # wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/romanian.bdf # wget [...all-other-language-files...] # wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/babelbib.sty
Afterwards, you need to run texhash
to update the TeX database:
# texhash