Package & font management

However complete your TeX install looks, you will soon want a package it lacks, or a font that licensing keeps out of the box. This page covers the commands you actually type day to day — TeX Live’s tlmgr and its tlshell GUI, getnonfreefonts for fonts shipped separately, and kpsewhich to answer “where does that file live?” — with what each one does and why you reach for it.

Managing packages with tlmgr

tlmgr (the TeX Live Manager) is the official command for installing, removing, and updating TeX Live packages. It is how you add any of the thousands of CTAN packages your install happens to be missing — the same on Japanese and English setups alike (MiKTeX is a separate world; see below). Start by installing a package by name; its dependencies come along by default.

terminal
# パッケージを 1 つ以上インストール(依存も自動で入る)
tlmgr install siunitx
tlmgr install collection-fontsrecommended

# 依存を引かずに本体だけ/既存の上書き再インストール
tlmgr install --no-depends siunitx
tlmgr install --reinstall siunitx

When packages go into the system-wide tree, tlmgr must run with administrator rights (sudo tlmgr install … on Unix, an elevated shell on Windows). You can also drop files into a per-user tree (TEXMFHOME) by hand, but tlmgr manages the distribution’s own trees. Which tree holds what, and how paths resolve, is the subject of “TeX directory structure & paths” — here we simply trust tlmgr to put things in the right place.

An easy thing to miss: neither tlmgr install nor tlmgr remove will refresh the symlinks in system directories such as /usr/local/bin. If your PATH points straight at TeX Live’s own bin directory you can ignore this, but if you have used tlmgr path add to wire up symlinks for executables, man pages, and info pages, you must rerun tlmgr path add yourself after installing a package that ships a new executable (and tlmgr path remove after removing one).

Learn updates as a pair. --self brings tlmgr itself (the infrastructure) up to date; --all brings every other installed package up to date. Giving both at once is the standard move — tlmgr replaces itself first, then updates the rest. This is also when it auto-removes packages dropped on the server and auto-installs new members of a collection.

terminal
# 定番:自分自身 → 全パッケージの順で最新化
tlmgr update --self --all

# 特定パッケージだけ更新/更新があるか一覧で確認
tlmgr update siunitx
tlmgr update --list

tlmgr info tells you about a package. With no argument it lists every package, marking installed ones with a leading i. Give it a name and it prints the description, license, sizes, contained files, and TeX Catalogue data — querying the repository even for packages you have not installed. When you only half-remember a name, search helps: --global searches the repository rather than your local install, and --file searches by file name across packages.

terminal
# パッケージの詳細(説明・ライセンス・収録ファイル)
tlmgr info siunitx

# 名前・説明から探す/ファイル名で横断検索
tlmgr search --global siunit
tlmgr search --global --file tikz.sty

Choosing a repository (CTAN mirror)

The repository is where tlmgr fetches packages from. By default it uses CTAN’s automatic mirror redirection, but when a connection is slow or you want to pin one mirror, switch permanently with tlmgr option repository. The alias ctan is shorthand for https://mirror.ctan.org/systems/texlive/tlnet; pointing at it routes you to a nearby CTAN mirror automatically.

terminal
# 既定(近くの CTAN ミラーへ自動振り分け)に設定
tlmgr option repository ctan

# 特定ミラーへ固定(例:好きな tlnet ミラーの URL)
tlmgr option repository https://example.org/CTAN/systems/texlive/tlnet

# 今の設定をまとめて確認(repository だけでなく paper なども)
tlmgr option show

To pull from a different mirror just this once, add --repository <url> for that single run without touching the permanent setting. Note that tlmgr option also holds defaults such as paper size: to switch paper for every tool at once use tlmgr paper a4 (or per program, tlmgr dvips paper a4).

The GUI (tlshell), and MiKTeX

If the command line is not your thing, TeX Live ships tlshell, a Tcl/Tk GUI (launch it with tlshell). It is a front end that simply drives tlmgr, so it can do the same things — search, install, remove, bulk-update packages, and switch repositories from a window. It even shows the underlying command log, which makes it a gentle way to learn what tlmgr is doing.

MiKTeX (mostly Windows) is a separate world: instead of tlmgr, its command line is mpm (the MiKTeX Package Manager) and its GUI is the MiKTeX Console. MiKTeX’s hallmark is on-the-fly installation — when a document asks for a package you do not have, it downloads and installs it mid-compile (the Console lets you set this to always install, ask each time, or never). The idea is the same; just the command names and workflow differ.

Fonts shipped separately — getnonfreefonts

Some fonts carry licenses like “free to use, but may not be sold,” so they cannot ride along in TeX Live, which is also distributed on a for-sale DVD. TUG’s getnonfreefonts script handles installing exactly these. CTAN holds the fonts and their TeX support files; the script fetches them and wires everything up so TeX can find them.

You install the script itself once first (follow the steps at tug.org/fonts/getnonfreefonts/). Current usage asks you to choose --user (personal install) or --sys (system-wide install) explicitly. List the fonts it offers with --lsfonts, then install one by name. The typewriter font luximono is one such target, for example.

terminal
# 自分専用ツリーで、入れられるフォントの一覧を見る
getnonfreefonts --user --lsfonts

# 自分専用ツリーへ個別に入れる/配布元のものを全部入れる
getnonfreefonts --user luximono
getnonfreefonts --user --all

The key distinction is --user versus --sys. --user installs into your personal tree (TEXMFHOME), while --sys installs into the system-wide tree. The separate getnonfreefonts-sys command found in older notes no longer exists. For everyone on the machine, run getnonfreefonts --sys ... with administrator rights. Afterwards the filename database may need refreshing (mktexlsr), though the script usually takes care of it. Those font and database commands are covered in “Font & DB tools.”

terminal
# システム全体のツリーへ(全ユーザ向け・要管理者権限)
sudo getnonfreefonts --sys luximono

# 念のため手動でファイル名 DB を更新する場合
sudo -H mktexlsr

Finding files with kpsewhich

TeX locates files through a search library called kpathsea, and kpsewhich is the tool that queries that same search from your shell. It answers “which file does this class actually resolve to?” and “are two versions colliding?” in one shot — the first move in most troubleshooting. Hand it a file name and it prints the first path TeX would pick up.

terminal
# このファイルが解決される実際のパスを表示
kpsewhich article.cls
kpsewhich siunitx.sty

# 同名ファイルが複数あれば全部出す(衝突の発見に)
kpsewhich -all siunitx.sty

Beyond paths, it also reports configuration variable values. -var-value=VAR prints the expansion of variable VAR — handy for finding where your user tree (TEXMFHOME) or config tree (TEXMFCONFIG) actually lives. Two kinds of expansion exist: -expand-var expands variables only, while -expand-path fully expands a path including braces.

terminal
# 設定変数の値を見る(ユーザツリーの場所など)
kpsewhich -var-value=TEXMFHOME
kpsewhich -var-value=TEXMFCONFIG

# 変数だけ展開 / パス全体を完全展開
kpsewhich -expand-var='$TEXMFHOME'
kpsewhich -expand-path='$TEXMF'

To disambiguate same-named files of different kinds, use -format=NAME. BibTeX styles (.bst) and bibliography data (.bib), for instance, have separate search paths, so naming the file type resolves the right one. -show-path=NAME prints the entire search path for that type, showing which directories are searched and in what order. List the type names with kpsewhich --help.

terminal
# ファイル種別を指定して探す(.bst と .bib は別パス)
kpsewhich -format=bst plainnat.bst
kpsewhich -format=bib mybibliography.bib

# その種別の探索パス全体を表示(探索順の確認)
kpsewhich -show-path=tex

When the search path depends on the engine, match the context with -engine=NAME or -progname=NAME (e.g. -progname=lualatex). The mechanics of the search itself — the role of texmf.cnf and how the trees are traversed — belong to “TeX directory structure & paths”; here we use kpsewhich purely as a tool for checking what resolves to what.

A practical order for manuscript work

When a report or thesis fails with File ... not found, do not immediately drop a random .sty from the web into the manuscript directory. First separate the file name from the package name. If kpsewhich siunitx.sty finds nothing, run tlmgr search --global --file siunitx.sty to discover which TeX Live package provides it, and only then install it as a distribution package, e.g. tlmgr install siunitx. That lets tlmgr track dependencies, updates, and removal.

For collaboration and CI, “I installed it once on my laptop” is not reproducibility. Record the TeX Live year, extra package names, and any pinned repository or Docker tag in the README or build configuration. Running tlmgr update --self --all right before submission means building the PDF with packages different from yesterday’s. Test updates separately; for the submitted version, freeze the environment that worked.

  • Conference-template-only files may live inside the manuscript repository, because they belong to that submission bundle rather than to the distribution.
  • General-purpose packages should be installed with tlmgr; a stale copy in the manuscript folder will keep shadowing the updated TeX Live version and create confusing failures.
  • Shared machines and CI should record required packages in the README or .latexmkrc, and pin the Docker tag or TeX Live year for reproducibility.