Why Use BasicTeX
On the macOS platform, there are BasicTeX, MacTeX-no-GUI, MacTeX, and LiveTeX.
All of these can be installed via brew install.
From left to right, the size increases.
BasicTeX is about a few hundred MB, MacTeX is 5 GB, and LiveTeX is 10 GB.
I only use LaTeX sporadically to convert markdown to PDF, so there’s no need to install the huge MacTeX package. Therefore, I chose
brew install basictex
How to Install LaTeX Packages After Installing BasicTeX
After installing BasicTeX, you will find that various .sty files are missing when running LaTeX.
For example:
Conversion failed: Pandoc died with exitcode "43" during conversion: Error producing PDF.
! LaTeX Error: File `footnotebackref.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.58 \setcounter
Another example:
Conversion failed: Pandoc died with exitcode "43" during conversion: Error producing PDF.
! LaTeX Error: File `xeCJK.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.74 \setCJKmainfont
If you don’t want to bother, just honestly install MacTeX. But if you want to face the challenge, keep reading.
Installing Relevant LaTeX Packages via TeX Live’s Package Manager tlmgr
At this point, you need to use TeX Live’s built-in package manager tlmgr (similar to apt, pip, etc.) to install the missing LaTeX packages.
For example:
# This command requires sudo privileges
sudo tlmgr update --self # update tlmgr itself
sudo tlmgr install footnotebackref # install footnotebackref
What if tlmgr Can’t Find the Relevant Package?
Method 1: Manual Download
For example, if the xeCJK package can’t be found:
tlmgr install: package xeCJK not present in repository.
However, it is available on the official website (for some reason, tlmgr cannot find packages that even exist on the official site). Download it, unzip it, and place it in the relevant local directory:
/usr/local/texlive/basictex-2025/texmf-local/tex/latex/xecjk # Note to find your own BasicTeX path and place it there; don’t just copy my path
Especially note that you need to create the texmf-local folder yourself.
In the TeX Live installation layout, there are usually several “texmf” trees (directory trees), such as:
texmf-dist: a collection of packages/fonts/docs provided by the main distribution. TeX - LaTeX Stack Exchangetexmf-config: system-wide configuration directory. TeX - LaTeX Stack Exchangetexmf-var: system-wide variable data directory, e.g. format files, caches, maps. TeX - LaTeX Stack Exchangetexmf-local: a directory tree used specifically for local (on system but not part of main distribution) additions or overrides. TeX - LaTeX Stack Exchange+1texmf-home(orTEXMFHOME): each user’s own texmf tree for user-specific packages/resources. Universidad de Granada+1
After installation, remember to update the TeX filename database so that LaTeX can find the new files:
sudo mktexlsr
# The following might also work
# sudo texhash
Method 2: Download a Larger Package That Contains the Small Package
For example:
tlmgr install: package zref-abspage not present in repository.
Use tlmgr to install the entire zref package:
sudo tlmgr install zref
References
- File
footnotebackref.stynot found. · Issue #141 · Wandmalfarbe/pandoc-latex-template - 我的 TeX 上手环境(BasicTeX) · Lei's Blog
- If you are reckless, come and challenge: a lightweight TeXLive - Yihui Xie | 谢益辉
- Installing ARM version MacTeX and configuration on M1 MacBook Air_mac armitage installation - CSDN Blog