LoginSignup
1
0

More than 3 years have passed since last update.

latexmlコマンドを使いたい

Last updated at Posted at 2020-01-19

概要

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コマンドをインストール.

install-latexml
brew install latexml

公式サイトに,XML::LibXMLXML::LibXSLTが必要で,libxml2libxsltをインストールする必要があると書いてあるので,それに従う.
XML::LibXMLXML::LibXSLTのインストールにはctanmを用いる(詳細は後日追記する予定).

install-libxml2-and-libxslt
brew install libxml2
brew install libxslt
brew install cpanminus

cpanm XML::LibXML
cpanm XML::LibXSLT

注意1

  • libxml2libxsltをインストールするとき,以下が出力されるので,パスを通しておく.

パスを通さないとcpanm XML::LibXSLTlibxsltを使えない.

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.

example-of-latexml
latexml --dest=xxx.xml xxx.tex
install-modules
  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 が無い

install-XML
env PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" cpanm install XML::LibXSLT --force

最後に

下記コマンドでlatexファイルからxmlファイルを生成できることを確認.

example-of-latexml
latexml --dest=xxx.xml xxx.tex
1
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
1
0