lbt 0.5.1 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 673d0151fc1150a586a1fa60bc61ffc6a18365e53853c7bfb4b5ec3d31a25a0a
4
- data.tar.gz: '03562857ac14de1f32f0d6ece4a20299f1c44fab8be9f1a1417abf1858335c7b'
3
+ metadata.gz: a9cf39baff107d837fdd02c88764d3b161b9569cc3298b479917d44b371a3e63
4
+ data.tar.gz: 754274ca6ee26d3bccfe6b3f1c87621c73ef52bbf37190fc67b9d1cda430b931
5
5
  SHA512:
6
- metadata.gz: 52603a2abf95b41404fc41c62e8046884b1504d26994c77ef13feeb34435038e3fc1c5a6c3a948acb60a5201320ab1282fab2295f68e689fe19595ca8738d7b7
7
- data.tar.gz: bfd3fbd7bdb487acf68dff294e59271fdbe4672936b54b181e26a7523619b01476130c642633ea6448c7d4d6cdf9d1f21022a2f7a86e621501e5cef71e69bef0
6
+ metadata.gz: 34a14917dc084b5185f7b688d089aed5dd3ac9e28b8805d132ebc61884e7c6739448f49ea482c77eb144502b9bc5f6cb7e0d3b2116939e667afca9dc9d8ca924
7
+ data.tar.gz: 7afad25c64d3bdd470c61015b090db21aebb527c1b1ffd3fb827a29f1b2642dea937ccf935b66c78de1101dd137af03f284f93f41e366beb613156e989f2a884
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ 日本語の説明はこのファイルの後半にあります。
2
+
3
+ # LaTeX Build Tools
4
+
5
+ LaTeX Build Tools is a tool to manage big LaTeX source files.
6
+ This version is different from the old versions.
7
+
8
+ - Use `lbt` command to run every sub commands.
9
+ - It is provided as a gem, which is a Ruby library program.
10
+
11
+ The old versions, the one with rake and the other of bash scripts, are moved to the other branches, `rake_version` and `bash` respectively.
12
+
13
+ LaTeX Build Tools supports LuaLaTeX engine only.
14
+ If you want to use another engine, you need to modify `lib/lbt/build.rb` and `lib/lbt/part_typeset.rb`.
15
+
16
+ ## Prerequisite
17
+
18
+ - Linux operating system
19
+ - Ruby. You can install it by one of the followings.
20
+ - Install the distribution package
21
+ - Install it with rbenv. Refer to [Rbenv's GitHub repository](https://github.com/rbenv/rbenv)
22
+ - LuaLaTeX. You can install it by one of the followings.
23
+ - Install the distribution package
24
+ - Install TexLive. Refer to [TexLive website](https://tug.org/texlive/)
25
+
26
+ ## Installation
27
+
28
+ You can install `lbt` from RubyGems.org with gem command.
29
+
30
+ ```
31
+ $ gem install lbt
32
+ ```
33
+
34
+ If you want to install it from the source code, do the following.
35
+
36
+ 1. Click the `Code` button, then click `Download ZIP` in the small dialog.
37
+ 2. Unzip the downloaded Zip file, then a new directory `LaTeX-BuildTools-master` will be created.
38
+ 3. Type `gem build lbt` under the directory, then the gem file `lbt-X.X.X.gem` is created.
39
+ The number `X.X.X` is the version number like `0.5.2`.
40
+ 1. Type `gem install lbt-X.X.X.gem`, where `X.X.X` is the version number.
41
+
42
+ ## Document
43
+
44
+ See [Tutorial.en](https://toshiocp.github.io/LaTeX-BuildTools/Tutorial_en_md.html).
45
+
46
+ ## License
47
+
48
+ GPL. See [License.md](License.md).
49
+
50
+ ----------
51
+
52
+ # LaTeX Build Tools
53
+
54
+ LaTeX Build Toolsは大きなLaTeXソースファイルを管理するためのツールです。
55
+ 現在の版は次の2点が旧版と異なっています。
56
+
57
+ - lbtというコマンドからすべてを起動
58
+ - gem(Rubyのライブラリ・プログラム)として提供される
59
+
60
+ 旧版の、rakeを用いる版とbashスクリプト版は、それぞれ`rake_version`ブランチと`bash`ブランチに移動しました。
61
+
62
+ LaTeX Build ToolsがサポートするLaTeXエンジンはLuaLaTeXです。
63
+ その他のエンジンを使いたい場合は`lib/lbt/build.rb`と`lib/lbt/part_typeset.rb`の修正が必要です。
64
+
65
+ ## 動作条件
66
+
67
+ - Linux オペレーティング・システム
68
+ - Ruby。Rubyのインストール方法は次の2通りがある
69
+ - ディストリビューションのパッケージをインストール
70
+ - Rbenvを用いてインストール。詳しくは[RbenvのGitHubレポジトリ](https://github.com/rbenv/rbenv)を参照してほしい
71
+ - LuaLaTeX。LuaLaTeXのインストール方法は次の2通りがある
72
+ - ディストリビューションのパッケージをインストール
73
+ - TexLiveをインストール。詳しくは[TexLiveのウェブサイト](https://tug.org/texlive/)を参照してほしい
74
+
75
+ ## インストール
76
+
77
+ gemコマンドでRubyGems.orgから`lbt`をインストールする。
78
+
79
+ ```
80
+ $ gem install lbt
81
+ ```
82
+
83
+ 以上が最も簡単なインストール方法だが、ソースコードからインストールしたい場合は次のようにする。
84
+
85
+ 1. GitHubのレポジトリを開き`Code`ボタンをクリック。小さいダイアログが現れるので、`Download ZIP`をクリックする
86
+ 2. ZIPファイルを解凍すると`LaTeX-BuildTools-master`というディレクトリが作られる
87
+ 3. 端末をそのディレクトリに移動して`gem build lbt`とタイプすると、`lbt-X.X.X.gem`というGemファイルが作られる。
88
+ この中の`X.X.X`はバージョン番号で、例えば`0.5.2`などのようなものである
89
+ 4. `gem install lbt-X.X.X.gem`とタイプしてインストールする(`X.X.X`はバージョン番号)
90
+
91
+ ## ドキュメント
92
+
93
+ 使い方の説明は[Tutorial.ja](https://toshiocp.github.io/LaTeX-BuildTools/Tutorial_ja_md.html)を参照してほしい。
94
+
95
+ ## ライセンス
96
+
97
+ GPL。[License.md](License.md)を参照。
data/Tutorial.en.md ADDED
@@ -0,0 +1,160 @@
1
+ # Installation
2
+
3
+ The followings are required for LaTex-Buildtools.
4
+
5
+ - Ruby
6
+ - LualaTeX
7
+ - Lbt (lbt is Latex-Buildtools)
8
+
9
+ The first two items can be installed from the distribution package.
10
+ For example, You can use the `apt` command in Ubuntu.
11
+
12
+ Lbt is provided as a Ruby Gem.
13
+ It can be installed with the `gem` command from RubyGems.org.
14
+
15
+ ```
16
+ $ gem install lbt
17
+ ```
18
+
19
+ # Creating a directory and templates for source files
20
+
21
+ The rest of this tutorial shows how to use `lbt` with an example.
22
+ Its source file is this tutorial.
23
+
24
+ First, use a `new` subcommand to create a directory and templates for source files.
25
+ The `new` subcommand takes the directory name, document class name, and working directory name as arguments.
26
+ The last two arguments can be left out.
27
+ Their default values are `book` and `_build` respectively.
28
+ In this example, we use `article` document class.
29
+
30
+ ```
31
+ $ lbt new Tutorial article
32
+ $ cd Tutorial
33
+ $ ls -a
34
+ . .. .config helper.tex main.tex
35
+ ```
36
+
37
+ The working directory name is written in the `.config` file.
38
+
39
+ ```
40
+ $ cat .config
41
+ build_dir = _build
42
+ ```
43
+
44
+ Since the working directory name was left out, it is `_build` (default value).
45
+ It is used when `build` and `part_typeset` subcommands are executed.
46
+
47
+ The file `main.tex` is the route file of LaTeX sources.
48
+
49
+ ```
50
+ $ cat main.tex
51
+ \documentclass{article}
52
+ \input{helper.tex}
53
+ \title{Title}
54
+ \author{Author}
55
+ \begin{document}
56
+ \maketitle
57
+ \tableofcontents
58
+
59
+ \end{document}
60
+ ```
61
+
62
+ The title and the author need to rewrite.
63
+ They are changed to "Tutorial" and "Toshio Sekiya" respectively.
64
+
65
+ The file `helper.tex` is included into the preamble part of `main.tex`.
66
+ Its contents are mainly package including and command definitions.
67
+
68
+ ```
69
+ $ cat helper.tex
70
+ \usepackage{amsmath,amssymb}
71
+ \usepackage[luatex]{graphicx}
72
+ \usepackage{tikz}
73
+ \usepackage[margin=2.4cm]{geometry}
74
+ \usepackage[colorlinks=true,linkcolor=black]{hyperref}
75
+ % If your source includes Markdown, you may need the following lines.
76
+ % It is because Pandoc generates some undefined commands.
77
+ % The Pandoc template file shows how to define them.
78
+ % You can see it by 'pandoc --print-default-template=latex'.
79
+ \providecommand{\tightlist}{%
80
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
81
+ ```
82
+
83
+ Since we don't need `tikz` package in this example, it can be deleted.
84
+ But you can leave it if you want.
85
+ The last two lines are required when converting Markdown files to LaTeX files with Pandoc.
86
+ The source, which is this tutorial, is Markdown, so we will leave them.
87
+
88
+ # Creating sub files
89
+
90
+ This tutorial has six sections.
91
+ We divide it into six files sec1.md, sec2.md, ... and sec6.md
92
+ They are put under the top directory.
93
+
94
+ # Typesetting
95
+
96
+ Converting LaTeX source files into a PDF file is called typesetting.
97
+ You can typeset them with `build` subcommand of Lbt.
98
+
99
+ ```
100
+ $ lbt build
101
+ ```
102
+
103
+ There are many converting processes.
104
+ Finally a PDF file `Tutorial.pdf` is made in the top directory.
105
+ The name of the PDF file is the same as the title in the source file.
106
+
107
+ # Partial typesetting
108
+
109
+ The bigger are the LaTeX sources, the longer time the typesetting takes.
110
+ Even if your modification is in only one, `build` subcommand converts all the source files.
111
+ It takes long time.
112
+ The subcommand `part_typeset` provides one file typesetting.
113
+ So it is faster than `build` subcommand.
114
+
115
+ ```
116
+ $ lbt part_typeset 1
117
+ ```
118
+
119
+ The argument `1` means `sec1.md`.
120
+ If you want to type sec5.md, use 5 instead of 1.
121
+
122
+ For large documents with parts and chapters, for example, specify "1-2-4" for part1/chap2/sec4.tex.
123
+
124
+ The result is `_build/main.pdf`.
125
+
126
+ # Renumbering
127
+
128
+ Sometimes you may want to insert a section between sec1.md and sec2.md.
129
+ At that time, name it sec1.5.md.
130
+ If you want to renamed these (sec1.md, sec1.5.md and sec2.md) into consecutive number filenames (sec1.md, sec2.md, and sec3.md), use `renum` subcommand.
131
+
132
+ ```
133
+ $ lbt renum
134
+ ```
135
+
136
+ # Pandoc and Top-Level-Division option
137
+
138
+ Lbt uses Pandoc to convert Markdown to LaTeX.
139
+ The default behavior of Pandoc is from the ATX-heading `#` to `\section`.
140
+ See `--top-level-division` option in the Pandoc document.
141
+
142
+ You can change it by modifying `.config` file in your LaTeX-file directory.
143
+ For example, the following makes the conversion from `#` to `\chapter`.
144
+
145
+ ```
146
+ $ cat .config
147
+ build_dir = _build
148
+ top-level-division = chapter
149
+ ```
150
+
151
+ The format is `top-level-division = (part, chapter or section)`.
152
+
153
+ The table shows the commonly used top-level-division.
154
+
155
+ |documentclass|top level division|
156
+ |:-----|:-----|
157
+ |book|chapter or part|
158
+ |report|chapter|
159
+ |article|section|
160
+ |beamer|section|
data/Tutorial.ja.md ADDED
@@ -0,0 +1,155 @@
1
+ # インストール
2
+
3
+ Latex-Buildtoolsを使うには次の3つが必要です。
4
+
5
+ - Rubyのインストール
6
+ - LuaLaTeXのインストール
7
+ - Lbt(lbtはLatex-Buildtoolsのことです)のインストール
8
+
9
+ 最初の2つはディストリビューションのパッケージをインストールするのが最も簡単です。
10
+ 例えばUbuntuであればaptコマンドを使います。
11
+
12
+ LbtはRubyのgemとして提供されるので、gemコマンドでインストールします。
13
+
14
+ ```
15
+ $ gem install lbt
16
+ ```
17
+
18
+ # ソースファイル用ディレクトリとテンプレートの作成
19
+
20
+ ここでは、このチュートリアルをPDFファイルに変換することを通してLbtの使い方を示します。
21
+
22
+ 最初にソースファイル用ディレクトリとテンプレートを作成するために、newサブコマンドを使います。
23
+ newサブコマンドには、ディレクトリ名、ドキュメントクラス名、作業ディレクトリ名を引数に与えますが、後ろの2つは省略できます。
24
+ 省略した場合のデフォルト値はそれぞれbookと\_buildです。
25
+ ここではltjsarticleドキュメントクラスを使います。
26
+
27
+ ```
28
+ $ lbt new Tutorial ltjsarticle
29
+ $ cd Tutorial
30
+ $ ls -a
31
+ . .. .config helper.tex main.tex
32
+ ```
33
+
34
+ .configファイルには作業ディレクトリ名の定義が書かれています。
35
+
36
+ ```
37
+ $ cat .config
38
+ build_dir = _build
39
+ ```
40
+
41
+ newサブコマンドで作業ディレクトリ名を省略したので、デフォルト値の\_buildになっています。
42
+ これはbuildとpart\_typesetサブコマンド実行時に参照されます。
43
+
44
+ main.texはLaTeXソースのルートファイルです。
45
+
46
+ ```
47
+ $ cat main.tex
48
+ \documentclass{ltjsarticle}
49
+ \input{helper.tex}
50
+ \title{Title}
51
+ \author{Author}
52
+ \begin{document}
53
+ \maketitle
54
+ \tableofcontents
55
+
56
+ \end{document}
57
+ ```
58
+
59
+ タイトルと著者は書き換えが必要です。
60
+ タイトルを「チュートリアル」に、著者を「関谷 敏雄」に変更しておきます。
61
+
62
+ helper.texはプリアンブル部に取り込まれます。
63
+ 主にパッケージの取り込みとコマンドの定義をします。
64
+
65
+ ```
66
+ $ cat helper.tex
67
+ \usepackage{amsmath,amssymb}
68
+ \usepackage[luatex]{graphicx}
69
+ \usepackage{tikz}
70
+ \usepackage[margin=2.4cm]{geometry}
71
+ \usepackage[colorlinks=true,linkcolor=black]{hyperref}
72
+ % If your source includes Markdown, you may need the following lines.
73
+ % It is because Pandoc generates some undefined commands.
74
+ % The Pandoc template file shows how to define them.
75
+ % You can see it by 'pandoc --print-default-template=latex'.
76
+ \providecommand{\tightlist}{%
77
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
78
+ ```
79
+
80
+ 今回はtikzは必要ないので削除しても構いませんが、ここではそのままにしておきます。
81
+ 最後の2行は、PandocでMarkdownファイルをLaTeXファイルに変換するときに必要です。
82
+ 今回のソースはMarkdownなので、このまま残しておきます。
83
+
84
+ # 本文ファイルの作成
85
+
86
+ 今回はこのファイル(Readme.ja.md)をセクションごとに別ファイルにしてトップディレクトリに配置します。
87
+ 最初の節(インストール)をsec1.mdとし、以下sec2.md、sec3.md・・・とします。
88
+ このファイルからコピペしてそれぞれのファイルを作ってください。
89
+
90
+ # タイプセット
91
+
92
+ LaTeXのソースファイルからPDFファイルを作ることをタイプセットといいます。
93
+ タイプセットはbuildサブコマンドで実行できます。
94
+
95
+ ```
96
+ $ lbt build
97
+ ```
98
+
99
+ この実行によってトップディレクトリにPDFファイルが生成されます。
100
+ ファイル名にはタイトルが使われるので、「チュートリアル.pdf」となります。
101
+
102
+ # 部分タイプセット
103
+
104
+ LaTexのソースが大きくなると全体のタイプセットに時間がかかるようになります。
105
+ 1つのファイルを書いていて、そのPDFの出来栄えを確かめたいときに全体をタイプセットするのは時間がかかりすぎます。
106
+ そのときは、該当のファイルのみをタイプセットすることができます。
107
+
108
+ ```
109
+ $ lbt part_typeset 1
110
+ ```
111
+
112
+ 引数の1はsec1.mdのことです。
113
+ もしsec5.mdをタイプセットしたければ1の代わりに5を使ってください。
114
+
115
+ PartやChapterのある大きな文書では、例えばpart1/chap2/sec4.texに対して「1-2-4」と引数を指定してください。
116
+
117
+ コンパイル結果は`_build/main.pdf`に保存されます。
118
+
119
+ # リナンバー
120
+
121
+ ときにはsec1.mdとsec2.mdの間にセクションを挿入したいことがあるかもしれません。
122
+ そのときにはsec1.5.mdとしてください。
123
+ これらをsec1.md、sec1.5.md、sec2.mdからsec1.md、sec2.md、sec3.mdのように連続する正整数に直すことをリナンバーと呼ぶことにします。
124
+ renumサブコマンドを実行することでリナンバーできます。
125
+
126
+ ```
127
+ $ lbt renum
128
+ ```
129
+
130
+ # Pandoc と Top-Level-Division オプション
131
+
132
+ LbtはPandocを用いてMarkdownをLaTeXに変換しています。
133
+ デフォルトでは、PandocはATX見出しの`#`を`\section`に変換します。
134
+ 詳しくはPandocのドキュメントの`--top-level-division`を参照してください。
135
+
136
+ これを、LaTeXファイルのディレクトリにある`.config`ファイルを書き換えることで変更できます。
137
+ 例えば、下記のようにすると、`#`が`\chapter`に対応するようになります。
138
+
139
+ ```
140
+ $ cat .config
141
+ build_dir = _build
142
+ top-level-division = chapter
143
+ ```
144
+
145
+ 書き方の書式は`top-level-division = (part, chapter or section)`です。
146
+
147
+ 下記の表は一般的に良く用いられるtop-level-divisionです。
148
+
149
+ |documentclass|top level division|
150
+ |:-----|:-----|
151
+ |book|chapter or part|
152
+ |report|chapter|
153
+ |article|section|
154
+ |beamer|section|
155
+
data/lib/lbt/build.rb CHANGED
@@ -3,8 +3,8 @@ require_relative 'utils.rb'
3
3
  module Lbt
4
4
  # Typeset LaTeX source files into a PDF file.
5
5
  def build
6
- m = File.read(".config").match(/^build_dir = (.*)$/)
7
- build_dir = m[1] ? m[1] : "_build"
6
+ m = get_config[:'build_dir']
7
+ build_dir = m ? m : "_build"
8
8
  raise "main.tex not exist." unless File.exist?('main.tex')
9
9
  mkdir build_dir unless Dir.exist?(build_dir)
10
10
 
@@ -16,8 +16,8 @@ module Lbt
16
16
  return unless File.file? file
17
17
  end
18
18
 
19
- m = File.read(".config").match(/^build_dir = (.*)$/)
20
- build_dir = m[1] ? m[1] : "_build"
19
+ m = get_config[:'build_dir']
20
+ build_dir = m ? m : "_build"
21
21
  raise "main.tex not exist." unless File.exist?('main.tex')
22
22
  mkdir build_dir unless Dir.exist?(build_dir)
23
23
 
data/lib/lbt/utils.rb CHANGED
@@ -105,9 +105,17 @@ If the files are as above, the PCS instance keeps the six filenames whch are sor
105
105
  end
106
106
  end
107
107
 
108
+ # Convert '.config' file into a Hash
109
+ def get_config
110
+ return {} unless File.exist?(".config")
111
+ File.read(".config").split(/\n/).map{|s| s.split('=')}.map{|key, val| [key.strip.to_sym, val.strip]}.to_h
112
+ end
113
+
108
114
  # Return a hash (key: extension, value: Proc object) of converters.
109
115
  def get_converters
110
- converters = {'.md': lambda {|src, dst| system("pandoc -o #{dst} #{src}")} }
116
+ tld = get_config[:'top-level-division']
117
+ tld = tld ? tld : "default"
118
+ converters = {'.md': lambda {|src, dst| system("pandoc --top-level-division=#{tld} -o #{dst} #{src}")} }
111
119
  if File.file?("converters.rb")
112
120
  c = eval(File.read("converters.rb"))
113
121
  c.each {|key, val| converters[key] = val} if c.is_a?(Hash)
metadata CHANGED
@@ -1,22 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshio Sekiya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Lbt is a build tool for LaTeX. It is useful for big documents.
14
14
  email: lxboyjp@gmail.com
15
15
  executables:
16
16
  - lbt
17
17
  extensions: []
18
- extra_rdoc_files: []
18
+ extra_rdoc_files:
19
+ - README.md
20
+ - Tutorial.en.md
21
+ - Tutorial.ja.md
19
22
  files:
23
+ - README.md
24
+ - Tutorial.en.md
25
+ - Tutorial.ja.md
20
26
  - bin/lbt
21
27
  - images/gecko.png
22
28
  - images/lagoon.jpg
@@ -29,7 +35,8 @@ files:
29
35
  homepage: https://github.com/ToshioCP/LaTeX-BuildTools
30
36
  licenses:
31
37
  - GPL-3.0
32
- metadata: {}
38
+ metadata:
39
+ documentation_uri: https://toshiocp.github.io/LaTeX-BuildTools/
33
40
  post_install_message:
34
41
  rdoc_options: []
35
42
  require_paths:
@@ -45,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
52
  - !ruby/object:Gem::Version
46
53
  version: '0'
47
54
  requirements: []
48
- rubygems_version: 3.4.10
55
+ rubygems_version: 3.4.21
49
56
  signing_key:
50
57
  specification_version: 4
51
58
  summary: LaTeX Build Tools