TeX Live: Difference between revisions

From ArchWiki
m (Undo revision 478812 by Jarshvor (talk))
(→‎Arch-packaged TeX Live: Underline a bit more the importance and exemplify just what essential LaTeX packages mean. pdflatex, for instance, will not work without this package.)
 
(247 intermediate revisions by 41 users not shown)
Line 1: Line 1:
[[Category:TeX]]
[[Category:TeX]]
[[fa:LaTeX]]
[[de:TeX]]
[[it:TeX Live]]
[[ja:TeX Live]]
[[ja:TeX Live]]
[[zh-hans:TeX Live]]
[[zh-hans:TeX Live]]
{{Related articles start}}
{{Related articles start}}
{{Related|TeX Live FAQ}}
{{Related|TeX Live/FAQ}}
{{Related|TeX Live and CJK}}
{{Related|TeX Live/CJK}}
{{Related|Ooolatex}}
{{Related|Tectonic}}
{{Related|List of applications/Documents#Scientific_documents}}
{{Related articles end}}
{{Related articles end}}
[https://www.tug.org/texlive/ TeX Live] is an "easy way to get up and running with the [[Wikipedia:TeX|TeX]] document production system. It provides a comprehensive TeX system with binaries for most flavors of Unix, including GNU/Linux, and also Windows. It includes all the major TeX-related programs, macro packages, and fonts that are free software, including support for many languages around the world."
According to [[Wikipedia:TeX Live|Wikipedia]]:


TeX Live is one of the most popular distributions for [[Wikipedia:LaTeX|LaTeX]], [[Wikipedia:ConTeXt|ConTeXt]] and friends.
:'''TeX Live''' is a free software distribution for the [[Wikipedia:TeX|TeX]] typesetting system that includes major TeX-related programs, macro packages, and fonts.


== Installation ==
TeX Live includes:
The TeX Live packages are arranged into two groups in the [[official repositories]]:  
* many TeX engines, such as:
* {{grp|texlive-most}} includes TeX Live applications.
** [[Wikipedia:pdfTeX|pdfTeX]]
* {{grp|texlive-lang}} provides various character sets and non-English features.
**[[Wikipedia:XeTeX|XeTeX]]
**[[Wikipedia:LuaTeX|LuaTeX]]
* basic macro packages (called ''formats'' in TeX parlance), such as:
** [[Wikipedia:LaTeX|LaTeX]]
** [[Wikipedia:ConTeXt|ConTeXt]]
* many user-produced packages


The essential package {{Pkg|texlive-core}} contains the basic texmf-dist tree, while {{Pkg|texlive-bin}} contains the binaries, libraries, and the texmf tree. {{Pkg|texlive-core}} is based on the “medium” install scheme of the upstream distribution. All other packages are based on the eponymous collections in TeX Live. To determine which CTAN packages are included in each package, lookup the files:
== Arch-packaged TeX Live vs native TeX Live ==
  /var/lib/texmf/arch/installedpkgs/<package>_<revnr>.pkgs


{{note|{{Pkg|texlive-langextra}} provides language support for African, Arabic, Armenian, Croatian, Hebrew, Indic, Mongolian, Tibetan and Vietnamese.}}
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.


=== Manual installation ===
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 {{ic|TEXMFLOCAL}} and {{ic|TEXMFHOME}}), this requires extra care - it is necessary to ensure that the versions of all relevant packages are mutually compatible.


See the [https://en.wikibooks.org/wiki/LaTeX/Installation#Custom_installation_with_TeX_Live LaTeX Wikibook] and [https://tug.org/texlive/doc/texlive-en/texlive-en.html#x1-140003 TeX Live Guide]. For programs that require TeX Live to be installed (e.g. kile) you can use the {{AUR|texlive-dummy}} package.
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.
 
{{Note|Multiple installations of TeX Live can peacefully coexist on a single system.}}
 
=== Native TeX Live ===
 
==== Installation ====
 
See the [https://tug.org/texlive/quickinstall.html quickinstall] documentation, and, if necessary, the [https://tug.org/texlive/doc/texlive-en/texlive-en.html full] documentation. The process boils down to:
 
# downloading the netinstall [https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz archive]
# unpacking the archive and changing to the newly created directory
# running the install script, {{ic|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: {{ic|PATH}}, {{ic|MANPATH}}, {{ic|INFOPATH}}. The install script prints the exact additions that are required before exiting.
 
==== Updating ====
 
See the [https://tug.org/texlive/doc/tlmgr.html tlmgr] documentation, {{ic|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, {{ic|tlmgr update --all}} will fail and it will be necessary to install TeX Live anew.
 
=== Arch-packaged TeX Live ===
 
* The {{Grp|texlive}} group contains most TeX Live packages, categorised based on upstream collections (see [https://tex.stackexchange.com/questions/356831/tex-live-package-collection-organisation]).
** {{Pkg|texlive-basic}}, the core installation, based on the ''medium'' upstream install scheme. The package includes [[pacman hook]]s to automate ''mktexlsr'', ''fmtutil'' and ''updmap''.
** {{Pkg|texlive-latex}} contains essential LaTeX packages. (For instance, if you intend to use {{ic|pdflatex}}, then you need this package).
** {{Pkg|texlive-latexrecommended}} and {{Pkg|texlive-latexextra}} contain many useful LaTeX packages, such as {{ic|polyglossia}}, {{ic|amsmath}} and {{ic|graphicx}}.
** {{Pkg|texlive-fontsrecommended}} contains essential fonts (including the default Latin Modern)
** {{Pkg|texlive-fontsextra}} contains additional fonts, which can be viewed on the [https://www.tug.org/FontCatalogue/ LaTeX Font Catalogue].
** {{Pkg|texlive-xetex}} and {{Pkg|texlive-luatex}} contain packages for XeTeX and LuaTeX respectively.
** {{Pkg|texlive-bibtexextra}} contains the [https://ctan.org/pkg/biblatex BibLaTeX] package and additional BibTeX styles and bibliography databases.
** {{Pkg|texlive-mathscience}} contains essential packages for mathematics, natural sciences and computer science.
* The {{Grp|texlive-lang}} group contains packages providing character sets and features for languages with non-Latin characters.
* {{Pkg|biber}} provides an alternative bibliography processing backend for BibLaTeX.
 
Note that some tools in {{Pkg|texlive-binextra}} have optional dependencies which are not automatically installed. For example, ''latexindent'' depends on {{Pkg|perl-yaml-tiny}} and {{Pkg|perl-file-homedir}}.
 
{{Tip|If you are missing specific ''.sty'' files, you can run {{ic|pacman -F}} to find the Arch package that provides them:
{{hc|$ 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 [https://www.ctan.org/ 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 {{Grp|texlive}} group to confirm whether such package exists). For instance, an output of {{ic|collection: collection-plaingeneric}} means that TeX package is included in {{Pkg|texlive-plaingeneric}}.
 
Alternatively, {{ic|tlmgr}} can be used to manually install a single TeX package (see below).
 
{{Note|Some tools and utilities included in TeX Live rely on {{Pkg|ghostscript}}, {{Pkg|perl}}, {{Pkg|python}}, or {{Pkg|ruby}}. See the optional dependencies of each package for details.}}
 
==== tllocalmgr ====
 
{{Warning|1=It has been suggested that tllocalmgr will no longer work. See [https://bbs.archlinux.org/viewtopic.php?id=286197].}}
 
The ''tllocalmgr'' utility, provided by {{AUR|tllocalmgr}}, lets you install (and update) packages from CTAN as [[pacman]] packages. See [https://github.com/hv15/tllocalmgr/blob/master/tllocalmgr#L835 its usage] ({{ic|-h}}) for details.
 
==== tlmgr ====
 
With {{Pkg|texlive-basic}} the ''tlmgr'' utility should work out of the box. If you still have issues or you're using the old package {{ic|texlive-core}} then you should follow the following procedure in order to make ''tlmgr'' work.
 
{{Note|
* While {{Pkg|texlive-basic}} provides the [https://www.tug.org/texlive/tlmgr.html tlmgr] script in ''TEXMFDIST'', it is broken ({{Bug|74404}}). You can fix it as described below.
* The {{man|1|texconfig}} command is mostly broken because it partially depends on ''tlmgr'' ({{Bug|59094}}). The interactive mode of {{ic|texconfig}} requires {{Pkg|dialog}}.
}}
 
{{Accuracy|The "fix" should be incorporated into the {{Pkg|texlive-core}}{{Broken package link|replaced by {{Pkg|texlive-basic}}}} package. Editing files in ''TEXMFDIST'' will not survive package upgrades.}}
 
The ''tlmgr'' utility is the standard way of installing and updating packages from CTAN. It requires minor fixes as follows:
 
First, edit {{ic|''TEXMFDIST''/scripts/texlive/tlmgr.pl}} and replace {{ic|1=$Master = "$Master/../..";}} with {{ic|1=$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 {{ic|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 {{ic|~/texmf}} as install prefix):
 
$ tlmgr init-usertree
 
Set your preferred [https://www.ctan.org/mirrors mirror]. You need to append {{ic|/systems/texlive/tlnet}} to the path of the mirror. For example:
 
<nowiki>$ tlmgr option repository http://mirrors.rit.edu/CTAN/systems/texlive/tlnet</nowiki>
 
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 {{ic|texdoc}}, [[install]] the whole TeX Live documentation and source files with {{Pkg|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/ ({{ic|<nowiki>http://texdoc.org/pkg/</nowiki>''packagename''}} directly yields the relevant PDF)


== Usage ==
== Usage ==


You can test your installation with
See the following resources:
 
* [[Wikibooks:LaTeX]]
* [https://tobi.oetiker.ch/lshort/lshort.pdf The Not So Short In­tro­duc­tion to LaTeX 2ε]
* [https://www.andy-roberts.net/writing/latex Getting to Grips with LaTeX – Andrew Roberts]
* [https://www.texfaq.org/ The TeX FAQ]
 
Some use a [[List of applications/Documents#TeX editors|TeX editor]] for creating documents.
 
=== High-level wrappers for compiling documents ===
 
It almost always makes more sense to use a higher-level tool like {{man|1|latexmk}}, or perhaps {{man|1|arara}}, instead of calling things like {{man|1|pdflatex}} 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 [[Wikipedia:Metafont|Metafont]]) should follow the [https://tug.org/tds/ TeX Directory Structure], or files may not be found.[https://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-110002.3]
 
TeX Live uses the [https://tug.org/texinfohtml/kpathsea.html 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).
 
{| class="wikitable"
! Variables !! Arch default <sup>1)</sup> !! Used by [https://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-110002.3]
|-
| {{ic|TEXMFDIST}} || {{ic|/usr/share/texmf-dist}} ||  files of the original distribution
|-
| {{ic|TEXMFLOCAL}} || {{ic|/usr/local/share/texmf:/usr/share/texmf}} || administrators for system-wide installation of additional or updated macros, fonts, etc.
|-
| {{ic|TEXMFSYSVAR}} || {{ic|/var/lib/texmf}} ||  updmap and fmtutil (user mode) to store (cached) runtime data
|-
| {{ic|TEXMFSYSCONFIG}} || {{ic|/etc/texmf}} || updmap and fmtutil (user mode) to store modified configuration data
|-
| {{ic|TEXMFHOME}} || {{ic|~/texmf}} || users for their own individual installations of additional or updated macros, fonts, etc.
|-
| {{ic|TEXMFVAR}} || {{ic|~/.texlive/texmf-var}} || updmap and fmtutil (sys mode) to store (cached) runtime data
|-
| {{ic|TEXMFCONFIG}} || {{ic|~/.texlive/texmf-config}} || updmap and fmtutil (sys mode) to store modified configuration data
|-
| {{ic|TEXMFCACHE}} || {{ic|$TEXMFSYSVAR;$TEXMFVAR}} || ConTeXt MkIV and LuaLaTeX to store (cached) runtime data
|}
 
{{Note|The default values are defined in {{ic|/etc/texmf/web2c/texmf.cnf}}[https://github.com/archlinux/svntogit-packages/blob/packages/texlive-core/trunk/texmf.cnf]; they can be overridden with [[environment variables]].}}
 
Kpathsea provides the {{man|1|kpsewhich}} command to lookup paths. When run with the {{ic|--var-brace-value{{=}}''VARIABLE''}} argument it can also print the values of variables.
 
Kpathsea uses filename databases ({{ic|ls-R}}) to speed up searches in system-wide texmf trees (configured with the {{ic|TEXMFDBS}} variable). This means that when system-wide file trees are changed, {{man|1|mktexlsr}} or {{ic|texhash}} (a symlink) need to be run as [[root user|root]]. Fortunately the {{Pkg|texlive-core}}{{Broken package link|replaced by {{Pkg|texlive-basic}}}} automates this with a [[pacman hook]] targeting all default system-wide texmf trees but {{ic|/usr/local/share/texmf}}.[https://github.com/archlinux/svntogit-packages/blob/packages/texlive-core/trunk/mktexlsr.hook] So as long as you install system-wide packages via [[pacman]] you should not need to run ''mktexlsr'' or ''texhash'' at all.
 
{{Tip|For setting up a local repository you can create the {{ic|~/texmf/tex/{format}/}} directory structure ({{ic|{format} }} is usually {{ic|latex}}), where custom classes are located in the root of the {{ic|./{format} }} folder and other local files get placed in a folder with the same name (e.g. {{ic|mycustompackage.sty}} goes to {{ic|./{formats}/mycustompackage/mycustompackage.sty}}), then run {{ic|texhash}} to update the user database.}}


$ tex '\empty Hello world!\bye'
== Tips and tricks ==
$ pdftex '\empty Hello world!\bye'


You should get a DVI or a PDF file accordingly.
=== Changing default paper size ===


You will probably want a [[List of applications/Documents#Scientific_documents|TeX editor]]. There are also a few online solutions that let you create TeX-based documents without TeX Live. See the [https://en.wikibooks.org/wiki/LaTeX/Installation#Online_solutions LaTeX wikibook].
{{Accuracy|It is possible by directly editing the config files.[https://tug.org/pipermail/tex-live/2009-April/020692.html]}}


== Important information ==
It is currently impossible to set the default page size using the texlive tools, because they do not work with the standard Arch package.
* The {{Pkg|biber}} utility used to handle biblatex bibliography is provided as a separate package.


* The way to handle font mappings for updmap was improved in September 2009, and installation should now be much more reliable than in the past. In the meantime, if you encounter error messages about unavailable map files, simply remove them by hand from the {{ic|updmap.cfg}} file (ideally using {{Ic|updmap-sys --edit}}). You can also run {{Ic|updmap-sys --syncwithtrees}} to automatically comment out outdated map lines from the config file.
Usually, you would run {{ic|texconfig}} or {{ic|tlmgr}}, which are also capable of changing other useful settings.


* The ConTeXt formats (for MKII and MKIV) are not automatically generated upon installation. See [http://wiki.contextgarden.net the ConTeXT wiki] for instructions on how to do this.
You can edit the configuration files as follows.


* The packages containing the documentation and sources are '''no longer available''' in official repositories. You can locally build them with [[#TeXLive Local Manager|tllocalmgr]]. You can also consult documentation online at https://tug.org/texlive/Contents/live/doc.html or on CTAN. Another possibility is using the online documentation at {{ic|<nowiki>http://texdoc.net/pkg/packagename</nowiki>}} which resolves to the relevant pdf for {{ic|packagename}}, similar to the command line tool {{ic|texdoc}} (which is useless without locally installed documentation).
* To set the paper size for the ''pdftex'' family of commands (''pdftex'', ''pdflatex'', etc) edit {{ic|/etc/texmf/tex/generic/tex-ini-files/pdftexconfig.tex}} file.


* TeX Live (upstream) now provides a tool for incremental updates of CTAN packages. On that basis, we also plan to update our packages on a regular basis (we have written tools that almost automate that task).
which can also be discovered by running {{ic|kpsewhich pdftexconfig.tex}}. Change the two lines that specify the {{ic|pdfpageheight}} and {{ic|pdfpagewidth}}. For example, to use letter size, change


* Some tools and utilities included in TeX Live rely on {{Pkg|ghostscript}}, {{Pkg|perl}}, {{Pkg|python2}}, and {{Pkg|ruby}}.
\pdfpageheight = 297 true mm
\pdfpagewidth  = 210 true mm


* For help and information about TeX Live see: https://tug.org/texlive/doc.html and https://tug.org/texlive/doc/texlive-en/texlive-en.html
to


* System-wide configuration files are under {{ic|/usr/share/texmf-config}}. User-specific ones should be put under {{ic|~/.texlive/texmf-config}}. {{Ic|$TEXMFHOME}} is {{ic|~/texmf}} and {{Ic|$TEXMFVAR}} is {{ic|~/.texlive/texmf-var}}.
\pdfpageheight = 11 true in
\pdfpagewidth  = 8.5 true in


* A skeleton of a local texmf tree is at {{ic|/usr/local/share/texmf}}: this directory is writable for members of the group '''tex'''.
Unfortunately, this will not have any effect until the binary ''.fmt'' files are rebuilt.  You can do this with {{ic|fmtutil-sys}}. Re-installing {{Pkg|texlive-bin}} with [[pacman]] will also do this for you.


===Paper Size===
* For ''dvips'', you can use the {{ic|-t}} option to specify the paper size: {{ic|dvips -t letter foo.dvi}}. To change the default, edit {{ic|/etc/texmf/dvips/config/config.ps}} file.
If you would like to set the default page size to something other than A4 (such as "Letter"), run the following command:
$ texconfig
This command is also capable of changing other useful settings.


===Error with "formats not generated" upon update===
which can also be discovered with {{ic|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.
See [https://bugs.archlinux.org/task/16467 this bug report]. ('''Note that if you do not use the experimental engine ''LuaTeX'', you can ignore this.''') This situation typically occurs when the configuration files {{ic|language.def}} and/or {{ic|language.dat}} for hyphenation patterns contain references to files from earlier releases of {{Ic|texlive-core}}, in particular to the latest experimental hyphenation patterns for German, whose file name changes frequently. Currently they should point to {{ic|dehyph{n,t}-x-2009-06-19.tex}}.  


To solve this, you need to either remove these files: {{ic|/usr/share/texmf-config/tex/generic/config/language.<nowiki>{def,dat}</nowiki>}}
=== Making fonts available to Fontconfig ===
or update them using the newest version under: {{ic|/usr/share/texmf/tex/generic/config/language.<nowiki>{def,dat}</nowiki>}}
and then run
# fmtutil-sys --missing


===Fonts===
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 [[Font configuration#Font paths|user's font path]]. Run the following for an OpenType font:
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 symlinks as follows:
  ln -s /usr/share/texmf-dist/fonts/opentype/public/<some_fonts_you_want> ~/.fonts/OTF/ (or TTF or Type1)


To make them available to fontconfig, run:
$ ln -s /usr/share/texmf-dist/fonts/opentype/public/''some_fonts_you_want'' ~/''font_path''/OTF/
  fc-cache ~/.fonts
  mkfontscale ~/.fonts/OTF (or TTF or Type1)
  mkfontdir ~/.fonts/OTF (or TTF or Type1)


Alternatively, {{Pkg|texlive-core}} contains the file {{ic|/etc/fonts/conf.avail/09-texlive-fonts.conf}} that contains a list of the font directories used by TeX Live. You can use this file with:
To make them available to fontconfig, run:


{{bc|# ln -s /etc/fonts/conf.avail/09-texlive-fonts.conf /etc/fonts/conf.d/09-texlive-fonts.conf}}
$ fc-cache ~/''font_path''
$ mkfontscale ~/''font_path''/OTF
$ mkfontdir ~/''font_path''/OTF


And then update fontconfig:
Similar steps follow for TrueType fonts and Type 1 fonts. In the lines above, substitute {{ic|opentype}} with {{ic|truetype}} or {{ic|type1}} and substitute {{ic|OTF}} with {{ic|TTF}} or {{ic|Type1}}.


{{bc|# fc-cache && mkfontscale && mkfontdir}}
Alternatively, {{Pkg|texlive-core}}{{Broken package link|replaced by {{Pkg|texlive-basic}}}} contains the file {{ic|/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:


{{Note|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.}}
{{bc|# ln -s /usr/share/fontconfig/conf.avail/09-texlive-fonts.conf /etc/fonts/conf.d/09-texlive-fonts.conf}}


== TeXLive Local Manager ==
And then update fontconfig:
{{AUR|texlive-localmanager-git}} is a utility which allows to conveniently manage a TeX Live installation on Arch Linux. See [https://git.archlinux.org/users/remy/texlive-localmanager.git/tree/tllocalmgr#n809 Usage] for details.


== Install .sty files ==
{{bc|$ fc-cache && mkfontscale && mkfontdir}}
TeX Live (and teTeX) uses its own directory indexes (files named {{ic|ls-R}}), and you need to refresh them after you copy something into one of the TeX trees. Or TeX can not see them. Magic command:
{{bc|# mktexlsr}}
or
{{bc|# texhash}}
or
{{bc|# texconfig[-sys] rehash}}
A command line program to search through these indexes is
kpsewhich
Hence you can check that TeX can find a particular file by running
kpsewhich <filename.sty>
The output should be the full path to that file.


Alternatively, sty files that are intended only for a particular user should go in the {{ic|~/texmf/}} tree. For instance, the latex package wrapfig consists of the file {{ic|wrapfig.sty}} and would go in {{ic|~/texmf/tex/latex/wrapfig/wrapfig.sty}}. There is no need to run {{ic|mktexlsr}} or equivalent because {{ic|~/texmf}} is searched every time tex is run.
{{Note|
* 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.
}}


=== Manual Installation  ===
=== Updating babelbib language definitions ===
Normally, new .sty files go in {{ic|/usr/share/texmf-dist/tex/latex/<package name>/*}}. Create this directory if you do not have it. This directory will automatically be searched when *tex is executed. Further discussion can be found here: https://bbs.archlinux.org/viewtopic.php?id=85757


=== Using PKGBUILDs ===
{{Style|You should not change {{ic|/usr/share/texmf-dist/}}.}}
To install a LaTeX package on a global level, you should use a [[PKGBUILD]] for the sake of simplifying maintenance. Examples can be found in the [[AUR]], e.g. {{AUR|texlive-gantt}}.


== Updating babelbib language definitions ==
If you have the very specific problem of [https://www.ctan.org/pkg/babelbib 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 {{ic|/usr/share/texmf-dist/tex/latex/babelbib/}}. For example:
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 {{ic|/usr/share/texmf-dist/tex/latex/babelbib/}}. For example:


{{bc|
{{bc|<nowiki>
# cd /usr/share/texmf-dist/tex/latex/babelbib/  
$ cd /usr/share/texmf-dist/tex/latex/babelbib/  
# wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/romanian.bdf
# wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/romanian.bdf
# wget [...all-other-language-files...]
# wget [...all-other-language-files...]
# wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/babelbib.sty
# wget https://www.tug.org/texlive/devsrc/Master/texmf-dist/tex/latex/babelbib/babelbib.sty
}}
</nowiki>}}


Afterwards, you need to run {{ic|texhash}} to update the TeX database:
Afterwards, you need to run {{ic|texhash}} to update the TeX database:
  # texhash
  # texhash
== Alternatives ==
Alternatives to TeX Live include MikTex and [[Tectonic]], they come with a minimal install, downloading the necessary packages on the go.
== See also ==
* [https://tug.org/texlive/doc.html TeX Live documentation]
* Question and answer sites
** [https://tex.stackexchange.com/ TeX - LaTeX Stack Exchange]
** [https://topanswers.xyz/tex TopTeX (TeX site on TopAnswers)]
* [http://detexify.kirelabs.org/ Detexify LaTeX handwritten symbol recognition]

Latest revision as of 14:13, 29 March 2024

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

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.

Note: Multiple installations of TeX Live can peacefully coexist on a single system.

Native TeX Live

Installation

See the quickinstall documentation, and, if necessary, the full documentation. The process boils down to:

  1. downloading the netinstall archive
  2. unpacking the archive and changing to the newly created directory
  3. running the install script, perl ./install-tl, which starts an interactive installation procedure within a text interface
    1. setting the wanted installation path or paths
    2. optionally, choosing a subset of the package collections provided by TeX Live
    3. optionally, choosing the Letter paper size as the default, as opposed to A4
    4. waiting for everything to download
  4. 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

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.

Tip: If you are missing specific .sty files, you can run 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).

Note: Some tools and utilities included in TeX Live rely on ghostscript, perl, python, or ruby. See the optional dependencies of each package for details.

tllocalmgr

Warning: It has been suggested that tllocalmgr will no longer work. See [2].

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.

Note:
  • 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 factual accuracy of this article or section is disputed.

Reason: The "fix" should be incorporated into the texlive-core[broken link: replaced by texlive-basic] package. Editing files in TEXMFDIST will not survive package upgrades. (Discuss in Talk:TeX Live)

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:

Usage

See the following resources:

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
Note: The default values are defined in /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-core[broken link: replaced by 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.

Tip: For setting up a local repository you can create the ~/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

The factual accuracy of this article or section is disputed.

Reason: It is possible by directly editing the config files.[7] (Discuss in Talk:TeX Live)

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
Note:
  • 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

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: You should not change /usr/share/texmf-dist/. (Discuss in Talk:TeX Live)

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

Alternatives

Alternatives to TeX Live include MikTex and Tectonic, they come with a minimal install, downloading the necessary packages on the go.

See also