自建 Overleaf:定制 ShareLaTeX 容器
ShareLaTeX 容器中默认只安装了少量的宏包。本篇记录了扩充该容器的过程,包括以下内容:
- 安装 TeXLive 的完整宏包
- 安装字体
- 设置
minted宏包 - 将修改后的容器提交为镜像,修改 Overleaf 的设置
进入 Overleaf 的目录后,运行 ./bin/shell 可以进入 ShareLaTeX 容器,以下操作在 ShareLaTeX 容器中进行。
安装 TeXLive 的完整宏包
采用在线方式安装所有的宏包,在国内建议首先要换源。TeXLive 的安装路径在 /usr/local/texlive,现在最新的 TeXLive 版本是 2022。如果 ShareLaTeX 容器中的版本比较旧,就需要设置旧版本软件源。以 2021 为例:1
2
3tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/tex-historic-archive/systems/texlive/2021/tlnet-final/
tlmgr update --self
tlmgr install scheme-full
安装需要的时间比较长。
安装字体
- 思源字体:
apt update && apt install noto-fonts-cjk noto-fonts-cjk-extra; - Windows 字体:从安装了 Office 的 Win10 上把
C:\Windows\Fonts下所有 ttf 与 ttc 格式的字体复制到容器的/usr/share/fonts/truetype/WinFonts下,运行fc-cache -fv更新fontconfig缓存。
minted 宏包的相关设置
minted 是一个代码高亮宏包,需要编译时加上 --shell-escape 参数,另外需要安装 pygmentize:
- 向
/usr/local/texlive/2021/texmf.cnf中添加一行shell_escape = t即可。 apt install python3-pip && pip3 install Pygments安装pygmentize程序。
Overleaf 的相关设置
提交容器
docker commit sharelatex sharelatex:full,所花时间较长,运行 docker image ls 检查结果。
修改 Docker-Compose 设置
在 Overleaf 文件夹下创建 config/docker-compose.override.yml 文件,填入内容:1
2
3
4version: "2.2"
services:
sharelatex:
image: sharelatex:full
运行 ./bin/stop 和 ./bin/up ,重新启动服务。