LoginSignup
3
4

More than 5 years have passed since last update.

SphinxでLatex拡張を使ってPDF出力する

Last updated at Posted at 2014-10-02

Latexを使って、作成したドキュメントをpdfで出力する方法

rst2pdf拡張を使ったPDF出力(Sphinxについてのメモ その2(rst2pdf拡張を使ったPDF出力))をやったので、LatexでもPDF出力してみました。

Latexを介して出力したものは、rst2pdfを使って出力したものに比べて相当綺麗だと感じました。rst2pdfに比べてLatexの方はデザインを細かくいじれるようなので、PDFにするならLatex経由の方がいいなと思いました。

環境

OS:Mac OS X 10.9.5
Python:Ver.2.7.7

Latexのインストール

  • TeX Liveインストールを使ってインストール
$ sudo port selfup
$ sudo port install texlive +full

※「Sphinx-Users.jp」のOSXへのTeX Liveインストール (MacTex / MacPorts)には「ビルドに1時間近くかかります。」と書いてありましたが、私の環境では2時間待っても終わりませんでしたので気長に待ちました。(夜中に付けたまま寝て朝には終わってました。)

・・・・
--->  Installing texlive @2014_0+doc+full
--->  Activating texlive @2014_0+doc+full

The "full" installation of TeX Live was selected. This is a full installation of all TeX Live packages, including all languages and their
associated documentation.

--->  Cleaning texlive
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
$

終わった時は、こんな感じのログが出ていました。

プロジェクトの設定変更

conf.pyの修正

language = 'ja'

latex_docclass = {'manual': 'jsbook'}

上記の2行を追加

ビルド

$ make latexpdfja

_build/latexフォルダ内に生成される。

エラーが出た場合

その1 Latexのインストール中

・・・・
--->  Attempting to fetch texlive-latex-34192-run.tar.xz from http://fco.it.distfiles.macports.org/mirrors/macports-distfiles/texlive-latex
--->  Attempting to fetch texlive-latex-34192-run.tar.xz from http://giraffe.cs.washington.edu/texlive/
--->  Attempting to fetch texlive-latex-34192-run.tar.xz from http://ykf.ca.distfiles.macports.org/MacPorts/mpdistfiles/texlive-latex
--->  Attempting to fetch texlive-latex-34192-run.tar.xz from http://svn.macports.org/repository/macports/distfiles/texlive-latex
Error: org.macports.fetch for port texlive-latex returned: fetch failed
Error: Failed to install texlive-latex
Please see the log file for port texlive-latex for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_tex_texlive-latex/texlive-latex/main.log
Error: The following dependencies were not installed: texlive-bibtex-extra texlive-latex texlive-bin-extra detex dvipng gd2 libvpx t1lib latexdiff p5.16-algorithm-diff latexmk pdfjam texlive-latex-recommended pgf texlive-context texlive-fonts-recommended texlive-math-extra texlive-metapost texlive-xetex texlive-generic-recommended texlive-fonts-extra texlive-fontutils lcdf-typetools ps2eps psutils t1utils texlive-formats-extra texlive-games texlive-generic-extra texlive-htmlxml texlive-humanities texlive-lang-african texlive-lang-arabic texlive-lang-chinese texlive-lang-cjk texlive-lang-cyrillic texlive-lang-czechslovak texlive-lang-english texlive-lang-european texlive-lang-french texlive-lang-german texlive-lang-greek texlive-lang-indic texlive-lang-italian texlive-lang-japanese texlive-lang-korean texlive-lang-other texlive-lang-polish texlive-lang-portuguese texlive-lang-spanish texlive-latex-extra texlive-pictures texlive-luatex texlive-music texlive-omega texlive-plain-extra texlive-pstricks texlive-publishers texlive-science
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port texlive failed
  • このようなログが出てましたが、上記のLatexのインストールの手順を再度行ったら成功しました。

その2 ビルド中

・・・・
! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.26

?

conf.pyの以下の部分が間違っていると出るので、余計な半角などが入ってないか確認する。

language = 'ja'
latex_docclass = {'manual': 'jsbook'}
3
4
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
3
4