0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[LaTeX]パッケージを自分でインストールする

Last updated at Posted at 2022-12-03

環境

  • WSL2上
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
  • TeX Live 2019
    • lualatex
    $ lualatex --version
    This is LuaTeX, Version 1.10.0 (TeX Live 2019/Debian)
    ...(以下略)
    

問題

mhchemを使おうとすると,mhchem.sty not found.とエラー.

おそらく,TeX Liveをインストールしたときにフルインストールしなかったからだと思われる.

解決方法

CTANから必要なstyファイルをダウンロードして,適切な場所にインストールする.

必要なパッケージ

手順

1. ミラーサイトからパッケージのzipファイルをダウンロードして展開

適当なディレクトリ(ここでは~/Downloads/)に移動して,wgetする.

$ cd ~/Downloads
$ wget https://mirrors.ctan.org/macros/latex/contrib/mhchem.zip
$ wget http://mirrors.ctan.org/macros/latex/contrib/chemgreek.zip

次に,ダウンロードしたzipファイルをunzipコマンドで展開する

$ unzip ~/Downloads/mhchem.zip
$ unzip ~/Downloads/chemgreek.zip

このとき,ディレクトリ名はパッケージ名と同じにする.(wgetunzip時に特に変更を加えなければそのようになっているはず)

2. styファイルの置き場所を調べる

ほかのstyファイルが置いてある場所をkpsewhichコマンドで調べる.例えばamsmath.styは,

$ kpsewhich amsmath.sty
/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty

にある.
よって,/usr/share/texlive/texmf-dist/tex/latex/に先程展開したディレクトリを置くことにする.

3. 展開したディレクトリを置き場所に移動

root権限が必要なことに注意.

$ sudo mv ~/Downloads/mhchem /usr/share/texlive/texmf-dist/tex/latex/
$ sudo mv ~/Downloads/chemgreek /usr/share/texlive/texmf-dist/tex/latex/

4. mktexlsrで一覧表を更新

一覧表についての詳細は,本記事末尾の参考記事を参照のこと.

$ sudo mktexlsr
mktexlsr: Updating /usr/local/share/texmf/ls-R...
mktexlsr: Updating /var/lib/texmf/ls-R-TEXLIVEDIST...
mktexlsr: Updating /var/lib/texmf/ls-R-TEXMFMAIN...
mktexlsr: Updating /var/lib/texmf/ls-R...
mktexlsr: Done.

(参考)LaTeX入門/各種パッケージの利用

以上.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?