概要
LaTeXMLを使うためのメモ.
XML::LibXMLのインストール時のエラー対策に時間がかかった.
さきにまとめ
以下のコマンドを順次入力することで,LaTeXMLを用いることができるようになる.
brew install libxml2
brew install libxslt
brew install cpanminus
brew install perl
cpanm XML::LibXML
cpanm XML::LibXSLT
cpanm install URI
cpanm install LWP
env PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" cpanm install XML::LibXSLT --force
cpanm install Parse::RecDescent
cpanm install IO::String
cpanm install Archive::Zip --force
インストール
homebrew を使ってlatexmlコマンドをインストール.
brew install latexml
公式サイトに,XML::LibXMLとXML::LibXSLTが必要で,libxml2とlibxsltをインストールする必要があると書いてあるので,それに従う.
XML::LibXMLとXML::LibXSLTのインストールにはctanmを用いる(詳細は後日追記する予定).
brew install libxml2
brew install libxslt
brew install cpanminus
cpanm XML::LibXML
cpanm XML::LibXSLT
注意1
-
libxml2とlibxsltをインストールするとき,以下が出力されるので,パスを通しておく.
パスを通さないとcpanm XML::LibXSLTでlibxsltを使えない.
If you need to have libxslt first in your PATH run:
echo 'export PATH="/usr/local/opt/libxslt/bin:$PATH"' >> ~/.bash_profile
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
エラー対応
XML::LibXMLのインストール時のエラー
Building and testing ExtUtils-ParseXS-3.35 ... FAIL
! Installing ExtUtils::ParseXS failed. See /Users/username/.cpanm/work/1579493843.67147/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Installed version (3.18) of ExtUtils::ParseXS is not in range '3.30'
! Bailing out the installation for Alien-Build-1.94.
! Installing the dependencies failed: Module 'Alien::Build::Plugin::Prefer::BadVersion' is not installed, Module 'Alien::Build::MM' is not installed, Module 'Alien::Build::Plugin::Build::SearchDep' is not installed, Module 'Alien::Build' is not installed
! Bailing out the installation for Alien-Libxml2-0.12.
! Installing the dependencies failed: Module 'Alien::Libxml2' is not installed
! Bailing out the installation for XML-LibXML-2.0202.
--forceオプションをつければとりあえずインストールはできた.
XML::LibXSLTのインストール時のエラー
Configuring XML-LibXSLT-1.99 ... N/A
! No MYMETA file is found after configure. Your toolchain is too old?
! Configure failed for XML-LibXSLT-1.99. See /Users/username/.cpanm/work/1579494019.73521/build.log for details.
検索してもよくわからん.
とりあえずperlをインストールしたらXML::LibXSLTに必要なdistributionsはインストールできた.
後述する方法でインストールし直す.
brew install perl
cpanm install XML::LibXSLT
(output)
.
.
.
Building and testing XML-LibXSLT-1.99 ... FAIL
! Installing XML::LibXSLT failed. See /Users/username/.cpanm/work/1579495705.81282/build.log for details. Retry with --force to force install it.
18 distributions installed
latexmlに必要なモジュールのインストール
latexmlコマンドを用いてみて,足りないモジュールを適宜cpanmでインストールすればOK.
latexml --dest=xxx.xml xxx.tex
cpanm install URI
cpanm install LWP
(注意2参照)
cpanm install Parse::RecDescent
cpanm install IO::String
cpanm install Archive::Zip --force
注意2
LWPをインストールしてからlatexmlを用いると,以下のエラーが出力される.
Can't locate XML/LibXSLT.pm in @INC (you may need to install the XML::LibXSLT module)
以下の記事にある対策(envコマンドを用いる)を援用することでインストールできる.
macOS Catalina(10.15) の Xcode11 だと /usr/include が無い
env PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" cpanm install XML::LibXSLT --force
最後に
下記コマンドでlatexファイルからxmlファイルを生成できることを確認.
latexml --dest=xxx.xml xxx.tex