如何正确安装和使用 texlive 和包管理器

如何正确安装和使用 texlive 和包管理器

我想知道如何在 Ubuntu 中正确安装和使用 texlive 以及包管理器 tlmgr。以下是我安装 texlive 的步骤:

sudo apt-get install texlive-latex-base texlive-latex-extra texlive-latex-recommended

现在我确实有 texlive,但是包管理器无法工作。以下是错误

sudo tlmgr update -all
(running on Debian, switching to user mode!)
cannot setup TLPDB in /home/kniwor/texmf at /usr/bin/tlmgr line 5336.

有没有更好的方法来安装 texlive?我现在该怎么做才能修复包管理器?

答案1

先跑tlmgr init-usertree再跑就行sudo tlmgr update --all


也许你会得到:

/usr/bin/tlmgr: Initialization failed (in setup_unix_one):
/usr/bin/tlmgr: could not find a usable xzdec.
/usr/bin/tlmgr: Please install xzdec and try again.
Couldn't set up the necessary programs.
Installation of packages is not supported.
Please report to [email protected].
tlmgr: exiting unsuccessfully (status 1).

如果是这样,您必须xzdec从包管理器或通过 安装该包sudo apt-get install xzdec


要使用 GUI,您还需要安装perl-tk

sudo apt-get install perl-tk

然后您可以通过以下方式调用 GUI:

tlmgr --gui

然后按下Load Default按钮。

答案2

如果您想tlmgr在 Ubuntu 上使用,基本上有两个选择:

  1. 从头安装 texlive 并创建一个虚拟包

  2. 使用安装-tl-ubuntu,如所述tex.SE 上的这个答案

答案3

@Kyle_the_hacker 提供的答案提供了一种设置用户模式管理的简单方法,这是基于 Debian 的发行版所必需的。然而,在我写这个答案的时候,在做任何事情之前,先更新所有收益

❯ sudo tlmgr update -all
(running on Debian, switching to user mode!)
(see /usr/share/doc/texlive-base/README.tlmgr-on-Debian.md)
TLPDB: not a directory, not loading: /root/texmf
tlmgr: user mode not initialized, please read the documentation!

包含.md

TeX Live Manager (tlmgr) on Debian
==================================

Rationale
---------

The TeX Live Manager (tlmgr) is the main configuration and package
management program in *upstream* TeX Live. Thus, the Debian TeX
Team has often received requests for providing `tlmgr` in Debian.

Since package management (installation, update, ...) is the responsability
of APT (apt, apt-get, ...), `tlmgr` *cannot* interfere with it, but uses
the "TeX Live Manager User Mode" instead.

For details concerning the User Mode, see https://tug.org/texlive/doc/tlmgr.html#USER-MODE

Warning
-------

`tlmgr` on Debian automatically switches to user mode. Consequences of this are:

- an initial setup step is necessary (see the documentation)
- packages will be installed into `TEXMFHOME` which normally is `$HOME/texmf`
- packages installed into `TEXMFHOME` will override system-wide installed 
  packages, that means a later system update will **not** be seen by TeX
- not all packages can be installed using the user mode, see the above link
  for details

We strongly recommend **not** to user the TeX Live Manager user mode on Debian.
If you are using it despite the warnings, be prepared to fix your own TeX system.

If you want the full power of TeX Live Manager, we recommend installing
TeX Live from upstream https://tug.org/texlive/quickinstall.html
See also "Integrating vanilla TeX Live with Debian" here https://tug.org/texlive/debian.html

虽然它说不建议tlmgr在 Debian 上使用,但如果你按照@Kyle_the_hacker 的步骤操作,你可能会收到此错误

❯ tlmgr update -all
(running on Debian, switching to user mode!)
(see /usr/share/doc/texlive-base/README.tlmgr-on-Debian.md)

tlmgr: Local TeX Live (2021) is older than remote repository (2023).
Cross release updates are only supported with
  update-tlmgr-latest(.sh/.exe) --update
See https://tug.org/texlive/upgrade.html for details.

如果您从 Ubuntu 的包管理器(apt,可能从包中)安装了 TeX Live,据我所知,如果 上提供的最新版本不是最新版本,texlive-full您就无能为力了……apt

因此,对于这些情况,可接受的答案不起作用。相反,您必须按照以下步骤手动安装 CTAN 包:

  1. 从 CTAN 下载一个包。
  2. 提取文件并将其放置在适当的目录中(例如/usr/local/share/texmf/tex/latex/footmisc/)。
  3. [可选,一些软件包已经有该文件] 通过在适当的源文件(例如和).sty上运行 latex 来生成 .sty 文件。latex footmisc.inslatex footmisc.dtx
  4. 更新此源树中的 ls-R 文件:cd /usr/local/share/texmf/; sudo mktexlsr

这种方法对我有用。有关更多信息,看这里

相关内容