提供所有软件包预编译的 .fmt 文件的绝对路径

提供所有软件包预编译的 .fmt 文件的绝对路径

我的 latex 设置非常慢,需要 45 秒到 1 分钟才能将所有包编译到一个空文件中。因此,我进行了一些搜索,找到了 mylatexformat,它允许我创建一个包含所有包的 packages.fmt 文件,当将其包含%&packages在 .tex 文件的顶部时,编译时间缩短到三秒。但是,当我将其添加%&/home/username/.latexpreamble/packages到文件顶部时,它不起作用。我使用 latex 设置在我的大学做笔记,因此每个需要 .fmt 文件的课程都有一个子目录。有没有办法拥有一个全局 .fmt 文件(可能通过包含其路径)?提前致谢!

答案1

在 TeX 生态系统中,通常不会使用 TeX 文件中的绝对路径来查找系统范围的文件,而是通过自动搜索(可自定义,但具有合理的默认值)标准目录来查找。如果您使用 TeX Live,您可以pdftex使用以下方式查找搜索格式文件的目录

kpsewhich -engine=pdftex -show-path=fmt | tr : '\n'

在我的系统上显示(附加注释)

# Search in the current directory first. Doesn't help since we want a central location
.
# This location can be used if you have multiple TeX Live versions installed and want to use separate format files for them.
/home/username/.texlive2021/texmf-config/web2c/pdftex
# This one is for automatically generated format files, you shouldn't manully place files there (it is used by fmtutil-user)
/home/username/.texlive2021/texmf-var/web2c/pdftex
# This is a great location for custom format files for your current user
/home/username/texmf/web2c/pdftex
# Here you can store custom format files for all users on your system. The `!!` indicates that you have to run `mktexlsr` after placing files here.
!!/usr/local/texlive/texmf-local/web2c/pdftex
# As before, but specific for TeX Live 2021
!!/usr/local/texlive/2021/texmf-config/web2c/pdftex
# Again an automatically managed locations, this time system wide. (It is used by fmtutil-sys and therefore contains most default format files. Do not touch manually)
!!/usr/local/texlive/2021/texmf-var/web2c/pdftex
# Theoretically for format files directly provided by TeX Live. In practice empty since TeX Live generates the formats on your system instead with fmtutil-sys. Do not touch this directory.
!!/usr/local/texlive/2021/texmf-dist/web2c/pdftex
# Repeating everything but without being pdftex specific. Does not really make sense for format files.
/home/username/.texlive2021/texmf-config/web2c
/home/username/.texlive2021/texmf-var/web2c
/home/username/texmf/web2c
!!/usr/local/texlive/texmf-local/web2c
!!/usr/local/texlive/2021/texmf-config/web2c
!!/usr/local/texlive/2021/texmf-var/web2c
!!/usr/local/texlive/2021/texmf-dist/web2c

Tl;dr:所以您可能希望将您的格式文件存储在~/texmf/web2c/pdftex/packages.fmt或中(特别是如果您安装了多个 TeX Live 版本)~/.texlive2021/texmf-config/web2c/pdftex/packages.fmt

相关内容