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 3 years have passed since last update.

【Sphinx】数式や図表のあるreSTドキュメントをPDFにする。

Last updated at Posted at 2021-09-04

1.はじめに

LaTeXについては「名前なら知っている」程度の無頼漢が、数式や図表(matplotlib)のあるreST文書をエラーなくPDFできるようになるまでのメモ。

備考

エラーなくPDFにできるようになりましたが、こんな問題は残っています。

  • 数式がフッター領域にはみ出する。
  • 文章の後にあるはずの図表が文章の前にある。

これらはLaTeXに成熟するにつれて解決する問題だと思います。

2.環境

  • Windows10/Cygwin64
  • Python 3.8.10
  • Sphinx 4.1.2
  • TexLive 20210821

3.概要

  1. Cicaフォントのインストール
  2. matploglibのフォント設定
  3. TexLiveインストール
  4. LuaLaTeXの設定

4.手順

4.1.Cicaフォントのインストール

  1. ダウンロードサイト からダウンロード
  2. cygwin環境に /usr/local/share/fonts/ttf/ を作成
  3. 解答したCicaのttfファイルをこのディレクトリに置く

4.2.matploglibのフォント設定

  1. ~/.matplotlib/matplotlibrc を作成する
  2. この設定ファイルに font.family: Cica を追記

4.3.TexLiveインストール

  1. インストラーのダウンロード
  2. インストラーの実行
  3. パッケージの選択
  4. ダウンロード

選択したパッケージ

  • Additinal fonts が容量を喰うが、数式を使う時は外れない。
  • LaTeX additional package も外すと latexmk のエラーになる。
  • 他はそれほど容量を取らないので、入れても入れなくても大差ない。
===============================================================================
   Select collections:

    a [X] Essential programs and files      w [ ] Italian
    b [X] BibTeX additional styles          x [X] Japanese
    c [X] TeX auxiliary programs            y [ ] Korean
    d [X] ConTeXt and packages              z [ ] Other languages
    e [X] Additional fonts                  A [ ] Polish
    f [X] Recommended fonts                 B [ ] Portuguese
    g [X] Graphics and font utilities       C [ ] Spanish
    h [X] Additional formats                D [X] LaTeX fundamental packages
    i [X] Games typesetting                 E [X] LaTeX additional packages
    j [X] Humanities packages               F [X] LaTeX recommended packages
    k [ ] Arabic                            G [X] LuaTeX packages
    l [ ] Chinese                           H [X] MetaPost and Metafont packages
    m [X] Chinese/Japanese/Korean (base)    I [ ] Music packages
    n [ ] Cyrillic                          J [X] Graphics, pictures, diagrams
    o [ ] Czech/Slovak                      K [X] Plain (La)TeX packages
    p [X] US and UK English                 L [X] PSTricks
    s [ ] Other European languages          M [X] Publisher styles, theses, etc.
    t [ ] French                            N [X] Windows-only support programs
    u [ ] German                            O [X] XeTeX and packages
    v [ ] Greek
    P [X] Mathematics, natural sciences, computer science packages
    S [ ] TeXworks editor; TL includes only the Windows binary

   Actions: (disk space required: 3192 MB)
    <-> deselect all
    <+> select all
    <R> return to main menu
    <Q> quit

   Enter letter(s) to (de)select collection(s):

4.4.LuaLaTeXの設定

SHINX_PROJECT/source/conf.py に次の設定を追記する

# lualatex
latex_engine = 'lualatex'
latex_docclass = {'manual': 'ltjsbook'}
latex_elements = {
    'preamble': r'\usepackage{cancel}',
}

5.make latexpdf 中に発生したエラー

次の二つについて修正したらエラーがでなくりました。

  • \begin{array}{l}{l} の数を式に合わせて変更
  • \bcancel{数式} を使えるようにパッケージの追加

LaTeXのことを何も知らないとエラーメッセージにビビりますが、メッセージ内容で検索したり、先ずはシンプルなreSTドキュメントで試すなどすれば解決すると思います。

以上

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?