# macos如何安装最小latex的basictex并且安装相关依赖包（宏）

**URL:** <https://forum.beginner.center/t/topic/2349>\
**Category:** 🛠工具与编程\
**Tags:** latex\
**Created:** [2025 年11 月 3 日 06:14 UTC](https://forum.beginner.center/t/topic/2349 "2025-11-03T06:14:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![doggie](https://forum.beginner.center/user_avatar/forum.beginner.center/doggie/32/550_2.png) [@doggie](https://forum.beginner.center/u/doggie)\
发布日期： [2025 年11 月 3 日 06:14 UTC](https://forum.beginner.center/t/topic/2349/1 "2025-11-03T06:14:50Z")

</div>

# 为什么要使用basictex

macOS平台提供basictex、mactex-no-gui、mactex、livetex  
这些都可以通过brew install安装

从左到右越来越大  
basictex大概几百mb，mactex 5g，livetex 10g

我只是零星用一下latex[转换markdown到pdf](https://forum.beginner.center/t/topic/2347)，没必要装一个硕大无比的mactex，所以选择了

```auto
brew install basictex

```

# 安装basictex后如何安装latex 宏包

安装basictex后，运行的时候会缺少各种各样的`.sty`  
比如

```bash
转换失败: 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

```

再比如

```bash
转换失败: 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

```

如果你不想折腾，还是老老实实装mactex吧，如果你想迎难而上，继续往下看

# 通过TeX Live 自带的包管理器`tlmgr`安装相关的latex宏包

这时候就需要使用TeX Live 自带的包管理器`tlmgr`（类似于apt、pip等）来安装相关的latex宏包  
比如

```bash
# 这个命令需要sudo权限
sudo tlmgr update --self #更新tlmgr
sudo tlmgr install footnotebackref #安装footnotebackref

```

# 如果tlmgr找不到相关的包怎么办？

## 方法一：手动下载

比如xeCJK包没找到

```auto
tlmgr install: package xeCJK not present in repository.

```

但是在[官网](https://ctan.org/pkg/xecjk)有 （不知道为啥tlmgr连官网上都有的包还找不到），下载下来，解压缩，放到本地相关目录

```auto
 /usr/local/texlive/basictex-2025/texmf-local/tex/latex/xecjk #注意找到你自己的basictex路径再放，别直接复制我的路径

```

特别注意的是`texmf-local`这个文件夹需要自己新建，

> 在 TeX Live 的安装布局中，一般会出现几个 “texmf” 树（目录树）例如：
> 
> - `texmf-dist`：主发行版提供的宏包/字体/文档等集合。 [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/questions/27982/what-are-texlives-four-different-texmf-folders?utm_source=chatgpt.com)
> - `texmf-config`：系统‐范围的配置文件目录。 [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/questions/27982/what-are-texlives-four-different-texmf-folders?utm_source=chatgpt.com)
> - `texmf-var`：系统‐范围的可变数据目录，例如格式文件、缓存、映射表。 [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/questions/27982/what-are-texlives-four-different-texmf-folders?utm_source=chatgpt.com)
> - `texmf-local`：专门用于“本地（系统上但非发行版主体）”添加或覆盖的文件树。 [TeX - LaTeX Stack Exchange+1](https://tex.stackexchange.com/questions/27982/what-are-texlives-four-different-texmf-folders?utm_source=chatgpt.com)
> - `texmf-home`（或 `TEXMFHOME`）: 每个用户自己的 texmf 树，用于用户专属的宏包/资源。 [Universidad de Granada+1](https://www.ugr.es/~ftorralbo/blog/programming/local-texmf/?utm_source=chatgpt.com)

注意安装完以后要更新一下Tex文件名数据库，这样LaTeX才能找到他们

```auto
sudo mktexlsr
# 下面这个好像也行
# sudo texhash

```

## 方法二：下载包含这个小包的大包

比如

```auto
tlmgr install: package zref-abspage not present in repository.

```

使用 `tlmgr` 安装整个 zref 包：

```auto
sudo tlmgr install zref

```

# 参考

- [文件 `footnotebackref.sty' 未找到。 · 问题 #141 · Wandmalfarbe/pandoc-latex-template --- File `footnotebackref.sty’ not found. · Issue #141 · Wandmalfarbe/pandoc-latex-template](https://github.com/Wandmalfarbe/pandoc-latex-template/issues/141)
- [我的 TeX 上手环境（BasicTeX） · Lei's Blog](https://blog.yangl1996.com/post/imported_from_old_blog_72/)
- [是莽撞人就来单挑：还世界一个轻量级 TeXLive - Yihui Xie | 谢益辉](https://yihui.org/cn/2017/06/lightweight-texlive/)
- [m1芯片MacBook Air安装arm版MacTeX及配置\_mac armitage 安装-CSDN博客](https://blog.csdn.net/qq_41437512/article/details/113783266)
