pandoc2review 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/pandoc.yml +18 -0
  3. data/.gitignore +47 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE +339 -0
  6. data/README.md +105 -0
  7. data/Rakefile +13 -0
  8. data/exe/pandoc2review +12 -0
  9. data/lib/pandoc2review.rb +99 -0
  10. data/lua/filters.lua +163 -0
  11. data/lua/review.lua +620 -0
  12. data/markdown-format.ja.md +721 -0
  13. data/pandoc2review.gemspec +29 -0
  14. data/samples/format.md +276 -0
  15. data/samples/reviewsample/.gitignore +154 -0
  16. data/samples/reviewsample/Gemfile +4 -0
  17. data/samples/reviewsample/Rakefile +3 -0
  18. data/samples/reviewsample/catalog.yml +10 -0
  19. data/samples/reviewsample/ch01.md +38 -0
  20. data/samples/reviewsample/ch02.re +3 -0
  21. data/samples/reviewsample/config-ebook.yml +6 -0
  22. data/samples/reviewsample/config.yml +20 -0
  23. data/samples/reviewsample/images/cover-a5.ai +5836 -16
  24. data/samples/reviewsample/images/cover.jpg +0 -0
  25. data/samples/reviewsample/images/pandoc2review.png +0 -0
  26. data/samples/reviewsample/lib/tasks/review.rake +128 -0
  27. data/samples/reviewsample/lib/tasks/z01_pandoc2review.rake +69 -0
  28. data/samples/reviewsample/sty/README.md +168 -0
  29. data/samples/reviewsample/sty/gentombow.sty +769 -0
  30. data/samples/reviewsample/sty/jsbook.cls +2072 -0
  31. data/samples/reviewsample/sty/jumoline.sty +310 -0
  32. data/samples/reviewsample/sty/plistings.sty +326 -0
  33. data/samples/reviewsample/sty/review-base.sty +530 -0
  34. data/samples/reviewsample/sty/review-custom.sty +1 -0
  35. data/samples/reviewsample/sty/review-jsbook.cls +503 -0
  36. data/samples/reviewsample/sty/review-style.sty +49 -0
  37. data/samples/reviewsample/sty/reviewmacro.sty +15 -0
  38. data/samples/reviewsample/style.css +494 -0
  39. metadata +128 -0
@@ -0,0 +1,128 @@
1
+ # Copyright (c) 2006-2020 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'fileutils'
22
+ require 'rake/clean'
23
+
24
+ BOOK = ENV['REVIEW_BOOK'] || 'book'
25
+ BOOK_PDF = BOOK + '.pdf'
26
+ BOOK_EPUB = BOOK + '.epub'
27
+ CONFIG_FILE = ENV['REVIEW_CONFIG_FILE'] || 'config.yml'
28
+ CATALOG_FILE = ENV['REVIEW_CATALOG_FILE'] || 'catalog.yml'
29
+ WEBROOT = ENV['REVIEW_WEBROOT'] || 'webroot'
30
+ TEXTROOT = BOOK + '-text'
31
+ TOPROOT = BOOK + '-text'
32
+ IDGXMLROOT = BOOK + '-idgxml'
33
+ PDF_OPTIONS = ENV['REVIEW_PDF_OPTIONS'] || ''
34
+ EPUB_OPTIONS = ENV['REVIEW_EPUB_OPTIONS'] || ''
35
+ WEB_OPTIONS = ENV['REVIEW_WEB_OPTIONS'] || ''
36
+ IDGXML_OPTIONS = ENV['REVIEW_IDGXML_OPTIONS'] || ''
37
+ TEXT_OPTIONS = ENV['REVIEW_TEXT_OPTIONS'] || ''
38
+
39
+ def build(mode, chapter)
40
+ sh("review-compile --target=#{mode} --footnotetext --stylesheet=style.css #{chapter} > tmp")
41
+ mode_ext = { 'html' => 'html', 'latex' => 'tex', 'idgxml' => 'xml', 'top' => 'txt', 'plaintext' => 'txt' }
42
+ FileUtils.mv('tmp', chapter.gsub(/re\z/, mode_ext[mode]))
43
+ end
44
+
45
+ def build_all(mode)
46
+ sh("review-compile --target=#{mode} --footnotetext --stylesheet=style.css")
47
+ end
48
+
49
+ task default: :html_all
50
+
51
+ desc 'build html (Usage: rake build re=target.re)'
52
+ task :html do
53
+ if ENV['re'].nil?
54
+ puts 'Usage: rake build re=target.re'
55
+ exit
56
+ end
57
+ build('html', ENV['re'])
58
+ end
59
+
60
+ desc 'build all html'
61
+ task :html_all do
62
+ build_all('html')
63
+ end
64
+
65
+ desc 'preproc all'
66
+ task :preproc do
67
+ Dir.glob('*.re').each do |file|
68
+ sh "review-preproc --replace #{file}"
69
+ end
70
+ end
71
+
72
+ desc 'generate PDF and EPUB file'
73
+ task all: %i[pdf epub]
74
+
75
+ desc 'generate PDF file'
76
+ task pdf: BOOK_PDF
77
+
78
+ desc 'generate static HTML file for web'
79
+ task web: WEBROOT
80
+
81
+ desc 'generate text file (without decoration)'
82
+ task plaintext: TEXTROOT do
83
+ sh "review-textmaker #{TEXT_OPTIONS} -n #{CONFIG_FILE}"
84
+ end
85
+
86
+ desc 'generate (decorated) text file'
87
+ task text: TOPROOT do
88
+ sh "review-textmaker #{TEXT_OPTIONS} #{CONFIG_FILE}"
89
+ end
90
+
91
+ desc 'generate IDGXML file'
92
+ task idgxml: IDGXMLROOT do
93
+ sh "review-idgxmlmaker #{IDGXML_OPTIONS} #{CONFIG_FILE}"
94
+ end
95
+
96
+ desc 'generate EPUB file'
97
+ task epub: BOOK_EPUB
98
+
99
+ IMAGES = FileList['images/**/*']
100
+ OTHERS = ENV['REVIEW_DEPS'] || []
101
+ SRC = FileList['./**/*.re', '*.rb'] + [CONFIG_FILE, CATALOG_FILE] + IMAGES + FileList[OTHERS]
102
+ SRC_EPUB = FileList['*.css']
103
+ SRC_PDF = FileList['layouts/*.erb', 'sty/**/*.sty']
104
+
105
+ file BOOK_PDF => SRC + SRC_PDF do
106
+ FileUtils.rm_rf([BOOK_PDF, BOOK, BOOK + '-pdf'])
107
+ sh "review-pdfmaker #{PDF_OPTIONS} #{CONFIG_FILE}"
108
+ end
109
+
110
+ file BOOK_EPUB => SRC + SRC_EPUB do
111
+ FileUtils.rm_rf([BOOK_EPUB, BOOK, BOOK + '-epub'])
112
+ sh "review-epubmaker #{EPUB_OPTIONS} #{CONFIG_FILE}"
113
+ end
114
+
115
+ file WEBROOT => SRC do
116
+ FileUtils.rm_rf([WEBROOT])
117
+ sh "review-webmaker #{WEB_OPTIONS} #{CONFIG_FILE}"
118
+ end
119
+
120
+ file TEXTROOT => SRC do
121
+ FileUtils.rm_rf([TEXTROOT])
122
+ end
123
+
124
+ file IDGXMLROOT => SRC do
125
+ FileUtils.rm_rf([IDGXMLROOT])
126
+ end
127
+
128
+ CLEAN.include([BOOK, BOOK_PDF, BOOK_EPUB, BOOK + '-pdf', BOOK + '-epub', WEBROOT, 'images/_review_math', 'images/_review_math_text', TEXTROOT, IDGXMLROOT])
@@ -0,0 +1,69 @@
1
+ # Copyright (c) 2020 Kenshi Muto
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'fileutils'
22
+ require 'yaml'
23
+
24
+ def make_mdre(ch, p2r, path)
25
+ if File.exist?(ch) # re file
26
+ FileUtils.cp(ch, path)
27
+ elsif File.exist?(ch.sub(/\.re\Z/, '.md')) # md file
28
+ system("#{p2r} #{ch.sub(/\.re\Z/, '.md')} > #{path}/#{ch}")
29
+ end
30
+ end
31
+
32
+ desc 'run pandoc2review'
33
+ task :pandoc2review do
34
+ path = '_refiles'
35
+ p2r = 'pandoc2review'
36
+ if File.exist?('../../pandoc2review')
37
+ p2r = '../../pandoc2review'
38
+ end
39
+
40
+ unless File.exist?(path)
41
+ Dir.mkdir(path)
42
+ File.write("#{path}/THIS_FOLDER_IS_TEMPORARY", '')
43
+ end
44
+
45
+ catalog = YAML.load_file('catalog.yml')
46
+ %w(PREDEF CHAPS APPENDIX POSTDEF).each do |block|
47
+ if catalog[block].kind_of?(Array)
48
+ catalog[block].each do |ch|
49
+ if ch.kind_of?(Hash) # Parts
50
+ ch.each_pair do |k, v|
51
+ make_mdre(k, p2r, path)
52
+ # Chapters
53
+ v.each {|subch| make_mdre(subch, p2r, path) }
54
+ end
55
+ elsif ch.kind_of?(String) # Chapters
56
+ make_mdre(ch, p2r, path)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ CLEAN.include('_refiles')
64
+ Rake::Task[BOOK_PDF].enhance([:pandoc2review])
65
+ Rake::Task[BOOK_EPUB].enhance([:pandoc2review])
66
+ Rake::Task[WEBROOT].enhance([:pandoc2review])
67
+ Rake::Task[TEXTROOT].enhance([:pandoc2review])
68
+ Rake::Task[TOPROOT].enhance([:pandoc2review])
69
+ Rake::Task[IDGXMLROOT].enhance([:pandoc2review])
@@ -0,0 +1,168 @@
1
+ review-jsbook.cls Users Guide
2
+ ====================
3
+
4
+ 現時点における最新版 `jsbook.cls 2018/06/23 jsclasses (okumura, texjporg)` をベースに、Re:VIEW 向け review-jsbook.cls を実装しました。
5
+
6
+ 過去の Re:VIEW 2 で jsbook.cls で作っていた資産を、ほとんどそのまま Re:VIEW 3 でも利用できます。
7
+
8
+ ## 特徴
9
+
10
+ * クラスオプション `media` により、「印刷用」「電子用」の用途を明示的な意思表示として与えることで、用途に応じた PDF ファイル生成を行えます。
11
+ * (基本的に)クラスオプションを `<key>=<value>` で与えられます。
12
+ * クラスオプション内で、用紙サイズや基本版面を設計できます。
13
+
14
+ ここで、クラスオプションとは、親 LaTeX 文章ファイルにおいて、以下のような位置にカンマ(,)区切りで記述するオプションです。
15
+
16
+ ```latex
17
+ \documentclass[クラスオプションたち(省略可能)]{review-jsbook}
18
+ ```
19
+
20
+ ## Re:VIEW で利用する
21
+
22
+ クラスオプションオプションたちは、Re:VIEW 設定ファイル config.yml 内の texdocumentclass において、以下のような位置に記述します。
23
+
24
+ ```yaml
25
+ texdocumentclass: ["review-jsbook", "クラスオプションたち(省略可能)"]
26
+ ```
27
+
28
+ ## 利用可能なクラスオプションたち
29
+
30
+ ### 用途別 PDF データ作成 `media=<用途名>`
31
+
32
+ 印刷用 `print`、電子用 `ebook` のいずれかの用途名を指定します。
33
+
34
+ * `print`[デフォルト]:印刷用 PDF ファイルを生成します。
35
+ * トンボあり、デジタルトンボあり、hyperref パッケージを `draft` モードで読み込み、表紙は入れない
36
+ * `ebook`:電子用PDFファイルを生成します。
37
+ * トンボなし、hyperref パッケージを読み込み、表紙を入れる
38
+
39
+ ### 表紙の挿入有無 `cover=<trueまたはfalse>`
40
+
41
+ `media` の値によって表紙(config.yml の coverimage に指定した画像)の配置の有無は自動で切り替わりますが、`cover=true` とすれば必ず表紙を入れるようになります。
42
+
43
+ ### 表紙画像のサイズの仕上がり紙面合わせ `cover_fit_page=<trueまたはfalse>`
44
+
45
+ 上記の coverimage で指定する画像ファイルは、原寸を想定しているため、サイズが異なる場合にははみ出たり、小さすぎたりすることになります。できるだけ原寸で用意することを推奨しますが、`cover_fit_page=true` とすれば表紙画像を紙面の仕上がりサイズに合わせて拡縮します。
46
+
47
+ ### 特定の用紙サイズ `paper=<用紙サイズ>`
48
+
49
+ 利用可能な特定の用紙サイズを指定できます。
50
+
51
+ * `a3`
52
+ * `a4` [デフォルト]
53
+ * `a5`
54
+ * `a6`
55
+ * `b4`:JIS B4
56
+ * `b5`:JIS B5
57
+ * `b6`:JIS B6
58
+ * `a4var`:210mm x 283mm
59
+ * `b5var`:182mm x 230mm
60
+ * `letter`
61
+ * `legal`
62
+ * `executive`
63
+
64
+ ### トンボ用紙サイズ `tombopaper=<用紙サイズ>` および塗り足し幅 `bleed_margin=<幅>`
65
+
66
+ `tombopaper` ではトンボ用紙サイズを指定できます。
67
+ [デフォルト]値は自動判定します。
68
+
69
+ `bleed_margin` では塗り足し領域の幅を指定できます。
70
+ [デフォルト]3mm になります。
71
+
72
+ ### カスタム用紙サイズ `paperwidth=<用紙横幅>`, `paperheight=<用紙縦幅>`
73
+
74
+ カスタム用紙サイズ `paperwidth=<用紙横幅>`, `paperheight=<用紙縦幅>` (両方とも与える必要があります)を与えることで、特定の用紙サイズで設定できない用紙サイズを与えられます。
75
+
76
+ たとえば、B5変形 `paperwidth=182mm`, `paperheight=235mm`。
77
+
78
+ ### 基本版面設計 `fontsize=<文字サイズ>`, `baselineskip=<行送り>`, `line_length=<字詰>`, `number_of_lines=<行数>`, `head_space=<天>`, `gutter=<ノド>`, `linegap=<幅>`, `headheight=<幅>`, `headsep=<幅>`, `footskip=<幅>`
79
+
80
+ 基本版面情報を与えます。
81
+ 天、ノドをそれぞれ与えない場合、それぞれ天地、左右中央になります。
82
+
83
+ * `fontsize=10pt`[デフォルト]:標準の文字(normalfontsize)の文字サイズを与えます。pt のほか、Q や mm といった単位も指定可能です。ただし、文字サイズは jsbook の挙動に合わせるために 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, 20pt, 21pt, 25pt, 30pt, 36pt, 43pt のいずれか近いサイズに丸められます。
84
+ * `baselineskip=16pt`[デフォルト]:行送りを与えます。
85
+ * `line_length=<字詰め幅>`:1行字詰めを与えます。字詰め幅には単位を付ける必要があります。文字数であれば「zw」を使うとよいでしょう(例:35zw=35文字)。デフォルトでは jsbook の挙動に従い、紙サイズに基いて決定します。
86
+ * `number_of_lines=<行数>`:行数を与えます。デフォルトでは jsbook の挙動に従い、紙サイズに基いて決定します。
87
+ * `head_space=<幅>`:天を与えます。[デフォルト]は天地中央です。
88
+ * `gutter=<幅>`:ノドを与えます。[デフォルト]は左右中央です。
89
+ * `linegap=<幅>`:行送りを baselineskip で指定する代わりに、通常の文字の高さにこのオプションで指定する幅を加えたものを行送りとします。
90
+
91
+ 例をいくつか挙げます。
92
+
93
+ * `paper=a5, fontsize=10pt, line_length=35zw, number_of_lines=32, baselineskip=16pt,`
94
+ * `paper=b5, fontsize=13Q, baselineskip=20.5H, head_space=20mm, gutter=20mm,`
95
+
96
+ さらに、ヘッダー、フッターに関する位置調整は、TeX のパラメータ `\headheight`, `\headsep`, `\footskip` に対応しており、それぞれ `headheight`, `headsep`, `footskip` を与えられます。
97
+
98
+ ## 開始ページ番号 `startpage=<ページ番号>`
99
+
100
+ 大扉からのページ開始番号を指定します。
101
+
102
+ [デフォルト]は1です。表紙・表紙裏(表1・表2)のぶんを飛ばしたければ、`startpage=3` とします。
103
+
104
+ ## 通しページ番号(通しノンブル) `serial_pagination=<trueまたはfalse>`
105
+
106
+ 大扉からアラビア数字でページ番号を通すかどうかを指定します。
107
+
108
+ * `true`:大扉を開始ページとして、前付(catalog.yml で PREDEF に指定したもの)、さらに本文(catalog.yml で CHAPS に指定したもの)に連続したページ番号をアラビア数字で振ります(通しノンブルと言います)。
109
+ * `false`[デフォルト]:大扉を開始ページとして前付の終わり(通常は目次)までのページ番号をローマ数字で振ります。本文は 1 を開始ページとしてアラビア数字で振り直します(別ノンブルと言います)。
110
+
111
+ ### 隠しノンブル 'hiddenfolio=<プリセット>'
112
+
113
+ 印刷所固有の要件に合わせて、ノドの目立たない位置に小さくノンブルを入れます。
114
+ 'hiddenfolio` にプリセットを与えることで、特定の印刷所さん対応の隠しノンブルを出力することができます。
115
+ 利用可能なプリセットは、以下のとおりです。
116
+
117
+ * `default`:トンボ左上(塗り足しの外)にページ番号を入れます。
118
+ * `marusho-ink`(丸正インキ):塗り足し幅を5mmに設定、ノド中央にページ番号を入れます。
119
+ * `nikko-pc`(日光企画), `shippo`(ねこのしっぽ):ノド中央にページ番号を入れます。
120
+
121
+ 独自の設定を追加したいときには、review-jsbook.cls の実装を参照してください。
122
+
123
+ ページ番号は紙面に入れるものと同じものが入ります。アラビア数字で通したいときには、上記の `serial_pagination=true` も指定してください。
124
+
125
+ ## 標準で review-jsbook.cls を実行したときの jsbook.cls との違い
126
+
127
+ * jsbook.cls のクラスオプション `uplatex`:これまで texdocumentclass に指定が必要だった `uplatex` オプションは不要となっています。
128
+ * jsbook.cls のクラスオプション `nomag`:用紙サイズや版面設計は、review-jsbook.cls 側で行います。
129
+ * hyperref パッケージ:あらかじめ hyperref パッケージを組み込んでおり、`media` オプションにより用途別で挙動を制御します。
130
+
131
+ ### 既存の jsbook.cls のオプションの扱い
132
+
133
+ review-jsbook.cls は jsbook.cls を包んでおり、一部の jsbook.cls のクラスオプションはそのまま指定可能です。
134
+
135
+ * `oneside`: 奇数ページ・偶数ページで柱やページ番号などを同じ体裁にします。review-jsbook.cls にも有効ですが、review-style.sty でこれを打ち消し奇数・偶数で別の見た目にするデザイン (fancyhdr) が定義されているので、review-style.sty も調整する必要があります。
136
+ * `twoside`: 奇数ページ・偶数ページで柱やページ番号などを別の体裁にします (デフォルト)。
137
+ * `vartwoside`: twoside とおおむね同じですが、傍注が小口ではなく常に右側になります。Re:VIEW のデフォルトでは傍注は使用していないので、効果は通常表れません。
138
+ * `onecolumn`: 1段組の体裁にします (デフォルト)。
139
+ * `twocolumn`: 2段組の体裁にします。
140
+ * `openright`: 章の始まりを右ページ (奇数ページ) にします (デフォルト)。前の章が右ページで終わった場合には、白紙のページが1ページ挿入されます。
141
+ * `openleft`: 章の始まりを左ページ (偶数ページ) にします。前の章が左ページで終わった場合には、白紙のページが1ページ挿入されます。
142
+ * `openany`: 章の始まりを左右どちらのページからでも始めます。
143
+ * `draft`: 確認作業のために、overfull box が起きた箇所の行末に罫線を引き、画像は実際に貼り付けずにボックスとファイル名だけを表記するようにします。
144
+ * `final`: 上記の draft の処理を行いません (デフォルト)。
145
+ * `leqno`: 数式の番号を右ではなく左側に置きます。ただし Re:VIEW では LaTeX のやり方での採番付き数式を作っていないので、効果は通常表れません。
146
+ * `fleqn`: 数式をデフォルトの左右中央ではなく、左側に配置します。
147
+ * `english`: 英語ドキュメント向けに、字下げをなくしたり、「章」や「目次」などの定型の文字列を英語化します。しかし、Re:VIEW では定型文字列はロケールファイルで処理しており、ほとんどは無視されます。
148
+ * `jslogo`: 「LaTeX」等のロゴを置き換えます (デフォルト)。
149
+ * `nojslogo`: ロゴを置き換えません。
150
+ * `report`: oneside と openany の両方と同じ効果を持ちます。
151
+ * `landscape`: 用紙を横長で使います。review-jsbook.cls のクラスオプションで基本版面設計をやり直す必要があることに注意してください。
152
+
153
+ jsbook.cls の以下のクラスオプションは挙動が異なります。代わりに review-jsbook.cls のクラスオプションを利用してください。
154
+
155
+ * `8pt`・`9pt`・`10pt`・`11pt`・`12pt`・`14pt`・`17pt`・`20pt`・`21pt`・`25pt`・`30pt`・`36pt`・`43pt`・`12Q`・`14Q`・`10ptj`・`10.5ptj`・`11ptj`・`12ptj`: 基本文字のサイズを指定します。そのまま review-jsbook.cls の fontsize に渡されますが、上記の fontsize クラスオプションの説明にあるとおり丸められます。
156
+ * `tombow`・`tombo`・`mentuke`: トンボや塗り足しを作成しますが、これらは PDF 入稿に求められる正しいデジタルトンボ情報を入れないので使用してはなりません。review-jsbook.cls の `media=print` を使ってください。
157
+ * `a4paper`・`a5paper`・`b5paper`・`b4paper`・`letterpaper`: 紙サイズを指定します。誤りではありませんが、review-jsbook.cls の paper クラスオプションを使うほうが妥当です。
158
+
159
+ jsbook.cls の以下のクラスオプションは無視またはエラーになります。
160
+
161
+ * `uplatex`: 暗黙に指定されるので無視されます。
162
+ * `autodetect-engine`: pLaTeX/upLaTeX を自動判別するオプションですが、Re:VIEW では review-jsbook 利用時に upLaTeX を暗黙に前提としているので無視されます。
163
+ * `papersize`: dvips などに紙サイズ情報を与えるオプションですが、Re:VIEW ではこれを利用しないので、結果的に無視されます。
164
+ * `titlepage`・`notitlepage`: 表題の独立ページ化の有無ですが、Re:VIEW では表題を利用していないため、結果的に無視されます。
165
+ * `usemag`・`nomag`・`nomag*`: 用紙サイズと版面設計は review-jsbook.cls のクラスオプションを使うため、無視されます。
166
+ * `a4j`・`a5j`・`b4j`・`b5j`・`winjis`・`mingoth`: これらは無効としており、エラーになります。review-jsbook.cls のクラスオプションを利用してください。
167
+ * `jis`: jis フォントメトリックスを使う指定ですが、通常の環境ではコンパイルエラーになります。
168
+ * `disablejfam`: 数式内の利用フォント数を増やすために、数式内の日本語文字を使わないようにする指定ですが、Re:VIEW を利用する上では単にエラーを誘発するだけでしょう。
@@ -0,0 +1,769 @@
1
+ %
2
+ % gentombow.sty
3
+ % written by Hironobu Yamashita (@aminophen)
4
+ %
5
+ % This package is part of the gentombow bundle.
6
+ % https://github.com/aminophen/gentombow
7
+ %
8
+
9
+ \NeedsTeXFormat{LaTeX2e}
10
+ \ProvidesPackage{gentombow}
11
+ [2019/07/21 v0.9k Generate crop mark 'tombow']
12
+ \def\pxgtmb@pkgname{gentombow}
13
+ \@namedef{ver@pxgentombow.sty}{}% fake
14
+
15
+ %% error status
16
+ \chardef\pxgtmb@errlevel=\z@
17
+
18
+ %% supported engines
19
+ % case 2: pdfLaTeX etc.
20
+ % case 1: pLaTeX2e <2018-04-01>+2 or older
21
+ % case 0: pLaTeX2e <2018-05-20> or newer
22
+ \ifx\pfmtversion\@undefined
23
+ \@ifpackageloaded{luatexja}{}{\chardef\pxgtmb@errlevel=\tw@}
24
+ \fi
25
+ \ifnum\pxgtmb@errlevel<\tw@
26
+ \ifx\@tombowreset@@paper\@undefined
27
+ \chardef\pxgtmb@errlevel=\@ne
28
+ \fi
29
+ \fi
30
+ \ifcase\pxgtmb@errlevel
31
+ \let\pxgtmb@sel@twoone\@gobble
32
+ \let\pxgtmb@sel@two@one\@gobbletwo
33
+ \let\pxgtmb@sel@two\@gobble
34
+ \or
35
+ \let\pxgtmb@sel@twoone\@firstofone
36
+ \let\pxgtmb@sel@two@one\@secondoftwo
37
+ \let\pxgtmb@sel@two\@gobble
38
+ \or
39
+ \let\pxgtmb@sel@twoone\@firstofone
40
+ \let\pxgtmb@sel@two@one\@firstoftwo
41
+ \let\pxgtmb@sel@two\@firstofone
42
+ \else
43
+ \PackageError{\pxgtmb@pkgname}{%
44
+ This cannot happen!
45
+ Please report to package author}\@ehc
46
+ \expandafter\endinput
47
+ \fi
48
+ \@onlypreamble\pxgtmb@sel@twoone
49
+ \@onlypreamble\pxgtmb@sel@two@one
50
+ \@onlypreamble\pxgtmb@sel@two
51
+
52
+ %%%%% EMULATION BEGIN
53
+
54
+ % required for patching \@outputpage
55
+ \pxgtmb@sel@twoone{\RequirePackage{etoolbox}}
56
+
57
+ % patch \@outputpage
58
+ \begingroup
59
+ \def\pxgtmb@emu@status{0}
60
+ \let\pxgtmb@emu@outputpage\@outputpage
61
+ \pxgtmb@sel@two@one
62
+ {%% case 2 begin
63
+ \patchcmd\pxgtmb@emu@outputpage % try first patch
64
+ {\reset@font\normalsize\normalsfcodes}%
65
+ {\@tombowreset@@paper
66
+ \reset@font\normalsize\normalsfcodes}%
67
+ {}{\def\pxgtmb@emu@status{1}}
68
+ \patchcmd\pxgtmb@emu@outputpage % try second patch
69
+ {\@begindvi \vskip \topmargin}%
70
+ {\@begindvi \@outputtombow \vskip \@@topmargin}%
71
+ {}{\def\pxgtmb@emu@status{1}}
72
+ }%% case 2 end
73
+ {%% case 1 begin
74
+ \patchcmd\pxgtmb@emu@outputpage % try patch
75
+ {%
76
+ \@@topmargin\topmargin
77
+ \iftombow
78
+ \@@paperwidth\paperwidth \advance\@@paperwidth 6mm\relax
79
+ \@@paperheight\paperheight \advance\@@paperheight 16mm\relax
80
+ \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
81
+ \fi
82
+ \reset@font\normalsize\normalsfcodes}
83
+ {\@tombowreset@@paper
84
+ \reset@font\normalsize\normalsfcodes}%
85
+ {}{\def\pxgtmb@emu@status{1}}
86
+ }%% case 1 end
87
+ % commit the change only when successful; otherwise
88
+ % tombow feature is never enabled, exit right away
89
+ \pxgtmb@sel@twoone
90
+ {%% case 2 and 1 begin
91
+ \if 0\pxgtmb@emu@status\relax
92
+ \global\let\@outputpage\pxgtmb@emu@outputpage
93
+ \else
94
+ \PackageError{\pxgtmb@pkgname}{%
95
+ Failed in patching \string\@outputpage!\MessageBreak
96
+ Sorry, I can't proceed anymore...}\@ehc
97
+ \expandafter\expandafter\expandafter\endinput\expandafter
98
+ \fi
99
+ }%% case 2 and 1 end
100
+ \endgroup
101
+ %
102
+
103
+ % provides equivalent for plcore.ltx
104
+ \pxgtmb@sel@two
105
+ {%% case 2 begin
106
+ \newif\iftombow \tombowfalse
107
+ \newif\iftombowdate \tombowdatetrue
108
+ \newdimen\@tombowwidth
109
+ \setlength{\@tombowwidth}{.1\p@}
110
+ }%% case 2 end
111
+ \pxgtmb@sel@twoone
112
+ {%% case 2 and 1 begin
113
+ \setlength{\@tombowwidth}{.1\p@}
114
+ \def\@tombowbleed{3mm}
115
+ \def\@tombowcolor{\normalcolor}
116
+ }%% case 2 and 1 end
117
+ \pxgtmb@sel@two
118
+ {%% case 2 begin
119
+ \newbox\@TL\newbox\@Tl
120
+ \newbox\@TC
121
+ \newbox\@TR\newbox\@Tr
122
+ \newbox\@BL\newbox\@Bl
123
+ \newbox\@BC
124
+ \newbox\@BR\newbox\@Br
125
+ \newbox\@CL
126
+ \newbox\@CR
127
+ \font\@bannerfont=cmtt9
128
+ \newtoks\@bannertoken
129
+ \@bannertoken{}
130
+ }%% case 2 end
131
+ \pxgtmb@sel@twoone
132
+ {%% case 2 and 1 begin
133
+ \def\maketombowbox{% hide \yoko from all boxes
134
+ \setbox\@TL\hbox to\z@{\csname yoko\endcsname\hss
135
+ \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@
136
+ \vrule height10mm width\@tombowwidth depth\z@
137
+ \iftombowdate
138
+ \raise4pt\hbox to\z@{\hskip5mm\@bannerfont\the\@bannertoken\hss}%
139
+ \fi}%
140
+ \setbox\@Tl\hbox to\z@{\csname yoko\endcsname\hss
141
+ \vrule width10mm height\@tombowwidth depth\z@
142
+ \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@}%
143
+ \setbox\@TC\hbox{\csname yoko\endcsname
144
+ \vrule width10mm height\@tombowwidth depth\z@
145
+ \vrule height10mm width\@tombowwidth depth\z@
146
+ \vrule width10mm height\@tombowwidth depth\z@}%
147
+ \setbox\@TR\hbox to\z@{\csname yoko\endcsname
148
+ \vrule height10mm width\@tombowwidth depth\z@
149
+ \vrule width\dimexpr 10mm+\@tombowbleed\relax height\@tombowwidth depth\z@\hss}%
150
+ \setbox\@Tr\hbox to\z@{\csname yoko\endcsname
151
+ \vrule height\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth depth\z@
152
+ \vrule width10mm height\@tombowwidth depth\z@\hss}%
153
+ \setbox\@BL\hbox to\z@{\csname yoko\endcsname\hss
154
+ \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@
155
+ \vrule depth10mm width\@tombowwidth height\z@}%
156
+ \setbox\@Bl\hbox to\z@{\csname yoko\endcsname\hss
157
+ \vrule width10mm depth\@tombowwidth height\z@
158
+ \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@}%
159
+ \setbox\@BC\hbox{\csname yoko\endcsname
160
+ \vrule width10mm depth\@tombowwidth height\z@
161
+ \vrule depth10mm width\@tombowwidth height\z@
162
+ \vrule width10mm depth\@tombowwidth height\z@}%
163
+ \setbox\@BR\hbox to\z@{\csname yoko\endcsname
164
+ \vrule depth10mm width\@tombowwidth height\z@
165
+ \vrule width\dimexpr 10mm+\@tombowbleed\relax depth\@tombowwidth height\z@\hss}%
166
+ \setbox\@Br\hbox to\z@{\csname yoko\endcsname
167
+ \vrule depth\dimexpr 10mm+\@tombowbleed\relax width\@tombowwidth height\z@
168
+ \vrule width10mm depth\@tombowwidth height\z@\hss}%
169
+ \setbox\@CL\hbox to\z@{\csname yoko\endcsname\hss
170
+ \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth
171
+ \vrule height10mm depth10mm width\@tombowwidth}%
172
+ \setbox\@CR\hbox to\z@{\csname yoko\endcsname
173
+ \vrule height10mm depth10mm width\@tombowwidth
174
+ \vrule height.5\@tombowwidth depth.5\@tombowwidth width10mm\hss}%
175
+ }
176
+ \def\@outputtombow{%
177
+ \iftombow
178
+ \vbox to\z@{\kern-\dimexpr 10mm+\@tombowbleed\relax\relax
179
+ \boxmaxdepth\maxdimen
180
+ \moveleft\@tombowbleed \vbox to\@@paperheight{%
181
+ \color@begingroup
182
+ \@tombowcolor
183
+ \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
184
+ \copy\@TL\hfill\copy\@TC\hfill\copy\@TR\hskip\@tombowbleed}%
185
+ \kern-10mm
186
+ \hbox to\@@paperwidth{\copy\@Tl\hfill\copy\@Tr}%
187
+ \vfill
188
+ \hbox to\@@paperwidth{\copy\@CL\hfill\copy\@CR}%
189
+ \vfill
190
+ \hbox to\@@paperwidth{\copy\@Bl\hfill\copy\@Br}%
191
+ \kern-10mm
192
+ \hbox to\@@paperwidth{\hskip\@tombowbleed\relax
193
+ \copy\@BL\hfill\copy\@BC\hfill\copy\@BR\hskip\@tombowbleed}%
194
+ \color@endgroup
195
+ }\vss
196
+ }%
197
+ \fi
198
+ }
199
+ }%% case 2 and 1 end
200
+ \pxgtmb@sel@two
201
+ {%% case 2 begin
202
+ \newdimen\@@paperheight
203
+ \newdimen\@@paperwidth
204
+ \newdimen\@@topmargin
205
+ }%% case 2 end
206
+ \pxgtmb@sel@twoone
207
+ {%% case 2 and 1 begin
208
+ \def\@tombowreset@@paper{%
209
+ \@@topmargin\topmargin
210
+ \iftombow
211
+ \@@paperwidth\paperwidth
212
+ \advance\@@paperwidth 2\dimexpr\@tombowbleed\relax
213
+ \@@paperheight\paperheight \advance\@@paperheight 10mm\relax
214
+ \advance\@@paperheight 2\dimexpr\@tombowbleed\relax
215
+ \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
216
+ \fi
217
+ }
218
+ }%% case 2 and 1 end
219
+ \pxgtmb@sel@two
220
+ {%% case 2 begin
221
+ \newcount\hour
222
+ \newcount\minute
223
+ }%% case 2 end
224
+
225
+ %%%%% EMULATION END
226
+
227
+ %% import from jsclasses
228
+ \hour\time \divide\hour by 60\relax
229
+ \@tempcnta\hour \multiply\@tempcnta 60\relax
230
+ \minute\time \advance\minute-\@tempcnta
231
+
232
+ \ifnum\mag=\@m\else
233
+ % if BXjscls is detected and \mag != 1000,
234
+ % the layout will be definitely broken
235
+ \ifx\bxjs@param@mag\@undefined\else
236
+ \PackageError{\pxgtmb@pkgname}{%
237
+ It seems you are using Japanese `BXjscls'\MessageBreak
238
+ (bxjsarticle, bxjsbook, bxjsreport, etc.) or\MessageBreak
239
+ some derived class. Try adding `nomag' or\MessageBreak
240
+ `nomag*' to the class option list}\@ehc
241
+ \fi
242
+ % if \mag != 1000 and \inv@mag is defined, assume jsclasses-style \mag employment
243
+ \ifx\inv@mag\@undefined\else
244
+ % \pxgtmb@magscale is almost equivalent to \jsc@magscale (introduced around 2016)
245
+ % but defined only when \mag is actually employed
246
+ \begingroup
247
+ % calculation code borrowed from BXjscls
248
+ \@tempcnta=\mag
249
+ \advance\@tempcnta100000\relax
250
+ \def\pxgtmb@tempa#1#2#3#4\@nil{\@tempdima=#2#3.#4\p@}
251
+ \expandafter\pxgtmb@tempa\the\@tempcnta\@nil
252
+ \xdef\pxgtmb@magscale{\strip@pt\@tempdima}
253
+ \endgroup
254
+ \fi
255
+ \fi
256
+
257
+ %% this package will use tombo feature in pLaTeX kernel
258
+ % if tombow-related option is not included in class option list,
259
+ % show info and enable it now
260
+ \iftombow\else
261
+ % if jsclasses is detected and \mag != 1000, it's too late
262
+ % -- When a size option other than `10pt' is specified,
263
+ % jsclasses uses \mag and calculates \oddsidemargin and \topmargin
264
+ % differently, depending on tombow status.
265
+ % In order to force `jsclasses' to calculate correctly,
266
+ % `tombow' or `tombo' is required as a class option.
267
+ % ... or, you may add `nomag' or `nomag*' instead.
268
+ \ifx\pxgtmb@magscale\@undefined\else
269
+ \PackageError{\pxgtmb@pkgname}{%
270
+ It seems you are using Japanese `jsclasses'\MessageBreak
271
+ (jsarticle, jsbook, jsreport, etc.) or some\MessageBreak
272
+ derived class. Please add `tombow' or `tombo'\MessageBreak
273
+ to the class option list}\@ehc
274
+ \fi
275
+ % BXjscls is already checked above, no check here
276
+ \PackageInfo\pxgtmb@pkgname{tombow feature enabled by \pxgtmb@pkgname}
277
+ \fi
278
+ \tombowtrue %\tombowdatetrue %% enabled by tombowbanner option
279
+ \setlength{\@tombowwidth}{.1\p@}%
280
+
281
+ %% import from jsclasses
282
+ \@bannertoken{%
283
+ \jobname\space(\number\year-\two@digits\month-\two@digits\day
284
+ \space\two@digits\hour:\two@digits\minute)}
285
+
286
+ %% prepare dimension
287
+ \ifx\stockwidth\@undefined \newdimen\stockwidth \fi
288
+ \ifx\stockheight\@undefined \newdimen\stockheight \fi
289
+
290
+ %% prepare flag
291
+ \newif\ifpxgtmb@switch \pxgtmb@switchfalse
292
+ \newif\ifpxgtmb@landscape \pxgtmb@landscapefalse
293
+ \newif\ifpxgtmb@pdfx@x \pxgtmb@pdfx@xfalse
294
+
295
+ %% passed from class options
296
+ %% should be declared first inside this package (least priority)
297
+ \DeclareOption{tombow}{\tombowdatetrue}
298
+ \DeclareOption{tombo}{\tombowdatefalse}
299
+ \DeclareOption{mentuke}{\tombowdatefalse \setlength{\@tombowwidth}{\z@}}
300
+
301
+ %% package options part 1
302
+ \DeclareOption{tombowbanner}{\tombowdatetrue}
303
+ \DeclareOption{notombowbanner}{\tombowdatefalse}
304
+ \DeclareOption{tombowdate}{% obsolete since v0.9c (2018/01/11)
305
+ \PackageWarning{\pxgtmb@pkgname}{%
306
+ Option `tombowdate' is renamed;\MessageBreak
307
+ use `tombowbanner' instead}%
308
+ \tombowdatetrue}
309
+ \DeclareOption{notombowdate}{% obsolete since v0.9c (2018/01/11)
310
+ \PackageWarning{\pxgtmb@pkgname}{%
311
+ Option `notombowdate' is renamed;\MessageBreak
312
+ use `notombowbanner' instead}%
313
+ \tombowdatefalse}
314
+
315
+ %% register a list of candidate papersize
316
+ % * \pxgtmb@addpapersize[<tombowname>]{<papername>}{<shorter edge>}{<longer edge>}
317
+ % used for declaration of papersize.
318
+ % when no option is specified (that is, \ifpxgtmb@switch = \iffalse),
319
+ % also used for automatic stocksize determination.
320
+ % * if <tombowname> = \@empty, the next <papername> is assumed.
321
+ % * if <tombowname> = n, stocksize is set to papersize + 2in.
322
+ \def\pxgtmb@addpapersize{\@ifnextchar[{\pxgtmb@addp@persize}{\pxgtmb@addp@persize[\@empty]}}
323
+ \def\pxgtmb@addp@persize[#1]#2#3#4{%
324
+ % get current papersize and search through known standard in ascending order
325
+ \ifx\pxgtmb@guessedtombow\@empty
326
+ \ifx\pxgtmb@guessedpaper\@empty
327
+ % shorter edge -> \@tempdima, longer edge -> \@tempdimb
328
+ \ifdim\paperwidth>\paperheight\relax
329
+ \pxgtmb@landscapetrue
330
+ \@tempdima\paperheight \@tempdimb\paperwidth
331
+ \else
332
+ \pxgtmb@landscapefalse
333
+ \@tempdima\paperwidth \@tempdimb\paperheight
334
+ \fi
335
+ % \@ovri and \@ovro are used temporarily (safe enough)
336
+ \@ovri=#3\relax
337
+ \@ovro=#4\relax
338
+ % when jsclasses-style \mag employment is assumed ...
339
+ \ifx\pxgtmb@magscale\@undefined\else
340
+ \@ovri=\inv@mag\@ovri\relax
341
+ \@ovro=\inv@mag\@ovro\relax
342
+ \fi
343
+ % compare
344
+ \ifdim\@tempdima=\@ovri\relax \ifdim\@tempdimb=\@ovro\relax
345
+ \def\pxgtmb@guessedpaper{#2}%
346
+ \ifx#1\@empty\else
347
+ \def\pxgtmb@guessedtombow{#1}%
348
+ \if n\pxgtmb@guessedtombow\else
349
+ \ExecuteOptions{tombow-#1}% package defaults to tombowdatetrue
350
+ \pxgtmb@switchfalse
351
+ \fi
352
+ \fi
353
+ \fi \fi
354
+ \else
355
+ \def\pxgtmb@guessedtombow{#2}% save for console message
356
+ \pxgtmb@setstock{#3}{#4}% set stockwidth/height
357
+ \fi\fi
358
+ \DeclareOption{tombow-#2}{%
359
+ \pxgtmb@switchtrue
360
+ \tombowdatetrue
361
+ \pxgtmb@setstock{#3}{#4}%
362
+ }%
363
+ \DeclareOption{tombo-#2}{%
364
+ \pxgtmb@switchtrue
365
+ \tombowdatefalse
366
+ \pxgtmb@setstock{#3}{#4}%
367
+ }%
368
+ \DeclareOption{mentuke-#2}{%
369
+ \pxgtmb@switchtrue
370
+ \tombowdatefalse
371
+ \setlength{\@tombowwidth}{\z@}%
372
+ \pxgtmb@setstock{#3}{#4}%
373
+ }%
374
+ }
375
+ \def\pxgtmb@setstock#1#2{%
376
+ \ifpxgtmb@landscape
377
+ \setlength\stockwidth{#2}%
378
+ \setlength\stockheight{#1}%
379
+ \else
380
+ \setlength\stockwidth{#1}%
381
+ \setlength\stockheight{#2}%
382
+ \fi
383
+ % when jsclasses-style \mag employment is assumed ...
384
+ \ifx\pxgtmb@magscale\@undefined\else
385
+ \stockwidth=\inv@mag\stockwidth\relax
386
+ \stockheight=\inv@mag\stockheight\relax
387
+ \fi
388
+ }%
389
+ \@onlypreamble\pxgtmb@addpapersize
390
+ \@onlypreamble\pxgtmb@addp@persize
391
+ \@onlypreamble\pxgtmb@setstock
392
+
393
+ %% initialize before search
394
+ \def\pxgtmb@guessedpaper{}
395
+ \def\pxgtmb@guessedtombow{}
396
+ \@onlypreamble\pxgtmb@guessedpaper
397
+ \@onlypreamble\pxgtmb@guessedtombow
398
+
399
+ %% package options part 2
400
+ % ISO A series <=> JIS B series in the ascending order
401
+ \pxgtmb@addpapersize{a10}{26mm}{37mm}
402
+ \pxgtmb@addpapersize{b10}{32mm}{45mm}
403
+ \pxgtmb@addpapersize{a9}{37mm}{52mm}
404
+ \pxgtmb@addpapersize{b9}{45mm}{64mm}
405
+ \pxgtmb@addpapersize{a8}{52mm}{74mm}
406
+ \pxgtmb@addpapersize{b8}{64mm}{91mm}
407
+ \pxgtmb@addpapersize{a7}{74mm}{105mm}
408
+ \pxgtmb@addpapersize{b7}{91mm}{128mm}
409
+ \pxgtmb@addpapersize{a6}{105mm}{148mm}
410
+ \pxgtmb@addpapersize{b6}{128mm}{182mm}
411
+ \pxgtmb@addpapersize{a5}{148mm}{210mm}
412
+ \pxgtmb@addpapersize{b5}{182mm}{257mm}
413
+ \pxgtmb@addpapersize{a4}{210mm}{297mm}
414
+ \pxgtmb@addpapersize{b4}{257mm}{364mm}
415
+ \pxgtmb@addpapersize{a3}{297mm}{420mm}
416
+ \pxgtmb@addpapersize{b3}{364mm}{515mm}
417
+ \pxgtmb@addpapersize{a2}{420mm}{594mm}
418
+ \pxgtmb@addpapersize{b2}{515mm}{728mm}
419
+ \pxgtmb@addpapersize{a1}{594mm}{841mm}
420
+ \pxgtmb@addpapersize{b1}{728mm}{1030mm}
421
+ \pxgtmb@addpapersize[n]{a0}{841mm}{1189mm}
422
+ \pxgtmb@addpapersize[n]{b0}{1030mm}{1456mm}
423
+
424
+ %% package options part 3
425
+ % ISO C series
426
+ \pxgtmb@addpapersize[a9]{c10}{28mm}{40mm}
427
+ \pxgtmb@addpapersize[a8]{c9}{40mm}{57mm}
428
+ \pxgtmb@addpapersize[a7]{c8}{57mm}{81mm}
429
+ \pxgtmb@addpapersize[a6]{c7}{81mm}{114mm}
430
+ \pxgtmb@addpapersize[a5]{c6}{114mm}{162mm}
431
+ \pxgtmb@addpapersize[a4]{c5}{162mm}{229mm}
432
+ \pxgtmb@addpapersize[a3]{c4}{229mm}{354mm}
433
+ \pxgtmb@addpapersize[a2]{c3}{324mm}{458mm}
434
+ \pxgtmb@addpapersize[a1]{c2}{458mm}{648mm}
435
+ \pxgtmb@addpapersize[a0]{c1}{648mm}{917mm}
436
+ \pxgtmb@addpapersize[n]{c0}{917mm}{1297mm}
437
+ % misc
438
+ \pxgtmb@addpapersize[b4]{a4j}{210mm}{297mm}
439
+ \pxgtmb@addpapersize[b5]{a5j}{148mm}{210mm}
440
+ \pxgtmb@addpapersize[a3]{b4j}{257mm}{364mm}
441
+ \pxgtmb@addpapersize[a4]{b5j}{182mm}{257mm}
442
+ \pxgtmb@addpapersize[b4]{a4var}{210mm}{283mm}
443
+ \pxgtmb@addpapersize[a4]{b5var}{182mm}{230mm}
444
+ \pxgtmb@addpapersize[a3]{letter}{8.5in}{11in}
445
+ \pxgtmb@addpapersize[a3]{legal}{8.5in}{14in}
446
+ \pxgtmb@addpapersize[a4]{executive}{7.25in}{10.5in}
447
+ \pxgtmb@addpapersize[a5]{hagaki}{100mm}{148mm}
448
+
449
+ %% package options part 4
450
+ \def\pxgtmb@pdfbox@status{0}
451
+ \DeclareOption{pdfbox}{\def\pxgtmb@pdfbox@status{1}}
452
+ \DeclareOption{dvips}{\def\pxgtmb@driver{s}}
453
+ \DeclareOption{dvipdfmx}{\def\pxgtmb@driver{m}}
454
+ \DeclareOption{xetex}{\def\pxgtmb@driver{x}}
455
+ \DeclareOption{pdftex}{\def\pxgtmb@driver{p}}
456
+ \DeclareOption{luatex}{\def\pxgtmb@driver{l}}
457
+
458
+ %% default options
459
+ \ExecuteOptions{tombowbanner}% package defaults to tombowdatetrue
460
+ \ProcessOptions
461
+
462
+ %% display search result
463
+ % if any of explicit size option is specified, \ifpxgtmb@switch = \iftrue.
464
+ % otherwise, automatic size detection should be successful.
465
+ \ifpxgtmb@switch\else
466
+ % check status
467
+ \@tempcnta=\z@\relax
468
+ \ifx\pxgtmb@guessedpaper\@empty
469
+ \advance\@tempcnta\@ne\relax
470
+ \fi
471
+ \ifx\pxgtmb@guessedtombow\@empty
472
+ \advance\@tempcnta\tw@\relax
473
+ \else\if n\pxgtmb@guessedtombow
474
+ \advance\@tempcnta\tw@\relax
475
+ \fi\fi
476
+ % message
477
+ \ifodd\@tempcnta
478
+ %\PackageWarningNoLine\pxgtmb@pkgname{%
479
+ % No size option specified, and automatic papersize\MessageBreak
480
+ % detection also failed}
481
+ \else
482
+ \typeout{***** Package \pxgtmb@pkgname\space detected \pxgtmb@guessedpaper paper. *****}
483
+ \fi
484
+ \ifnum\@tempcnta>\@ne\relax
485
+ \PackageWarningNoLine\pxgtmb@pkgname{%
486
+ Output size cannot be determined. Please add size\MessageBreak
487
+ option (e.g. `tombow-a4') to specify output size.\MessageBreak
488
+ Falling back to +1in ..}
489
+ \stockwidth\paperwidth \advance\stockwidth 2in
490
+ \stockheight\paperheight \advance\stockheight 2in
491
+ \else
492
+ \typeout{***** Now the output size is automatically set to \pxgtmb@guessedtombow. *****}
493
+ \fi
494
+ \fi
495
+
496
+ %% warnings
497
+ \ifdim\stockwidth<\paperwidth
498
+ \PackageWarningNoLine\pxgtmb@pkgname{%
499
+ \string\stockwidth\space is smaller than \string\paperwidth!\MessageBreak
500
+ Is this really what you want?}
501
+ \fi
502
+ \ifdim\stockheight<\paperheight
503
+ \PackageWarningNoLine\pxgtmb@pkgname{%
504
+ \string\stockheight\space is smaller than \string\paperheight!\MessageBreak
505
+ Is this really what you want?}
506
+ \fi
507
+
508
+ %% pdf "digital tombo" (driver-dependent)
509
+ % the box size calculation is delayed until \AtBeginDocument
510
+ % to allow users to change \@tombowbleed in the preamble
511
+
512
+ % convert pt -> bp
513
+ \def\pxgtmb@PDF@setbp#1#2{%
514
+ \@tempdima=.996264#2\relax % 0.996264 = 72/72.27 (cf. 1in = 72.27pt = 72bp)
515
+ \@tempdima=\pxgtmb@magscale\@tempdima % adjustment for jsclasses-style \mag employment
516
+ \edef#1{\strip@pt\@tempdima}}
517
+ % calculate and create pdf boxes
518
+ \def\pxgtmb@PDF@calcbox{%
519
+ \begingroup
520
+ % provide fallback definition inside this group
521
+ \ifx\pxgtmb@magscale\@undefined
522
+ \def\pxgtmb@magscale{1}%
523
+ \fi
524
+ % set pdf boxes in bp unit
525
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@crop@ur@x\stockwidth
526
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@crop@ur@y\stockheight
527
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ll@x{\dimexpr(\stockwidth-\paperwidth)/2}%
528
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ll@y{\dimexpr(\stockheight-\paperheight)/2}%
529
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ur@x{\dimexpr(\stockwidth+\paperwidth)/2}%
530
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ur@y{\dimexpr(\stockheight+\paperheight)/2}%
531
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ll@x{\dimexpr(\stockwidth-\paperwidth)/2-\@tombowbleed}%
532
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ll@y{\dimexpr(\stockheight-\paperheight)/2-\@tombowbleed}%
533
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ur@x{\dimexpr(\stockwidth+\paperwidth)/2+\@tombowbleed}%
534
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ur@y{\dimexpr(\stockheight+\paperheight)/2+\@tombowbleed}%
535
+ \xdef\pxgtmb@PDF@CTM{%
536
+ %% CropBox: normally implicit (same as MediaBox, large paper size)
537
+ %% however, pdfx.sty in PDF/X mode sets /CropBox explicitly, so I need to override it!
538
+ \ifpxgtmb@pdfx@x
539
+ \noexpand\pxgtmb@PDF@begin
540
+ /CropBox [0 0
541
+ \pxgtmb@PDF@crop@ur@x\space
542
+ \pxgtmb@PDF@crop@ur@y] \noexpand\pxgtmb@PDF@end
543
+ \fi
544
+ %% BleedBox: explicit (final paper size + surrounding \@tombowbleed)
545
+ \noexpand\pxgtmb@PDF@begin
546
+ /BleedBox [\pxgtmb@PDF@bleed@ll@x\space
547
+ \pxgtmb@PDF@bleed@ll@y\space
548
+ \pxgtmb@PDF@bleed@ur@x\space
549
+ \pxgtmb@PDF@bleed@ur@y] \noexpand\pxgtmb@PDF@end
550
+ %% TrimBox: explicit (final paper size)
551
+ \noexpand\pxgtmb@PDF@begin
552
+ /TrimBox [\pxgtmb@PDF@trim@ll@x\space
553
+ \pxgtmb@PDF@trim@ll@y\space
554
+ \pxgtmb@PDF@trim@ur@x\space
555
+ \pxgtmb@PDF@trim@ur@y] \noexpand\pxgtmb@PDF@end
556
+ %% ArtBox: implicit
557
+ %% [Note] PDF/X requires /TrimBox or /ArtBox but not both!
558
+ }%
559
+ \endgroup
560
+ }
561
+
562
+ % do it
563
+ \AtBeginDocument{\pxgtmb@PDF@emit}
564
+ \def\pxgtmb@PDF@emit{%
565
+ % handle compatibility with pdfx.sty here;
566
+ % if pdfx.sty with PDF/X mode detected, force [pdfbox] option!
567
+ \pxgtmb@handle@pdfx
568
+ \ifpxgtmb@pdfx@x\def\pxgtmb@pdfbox@status{1}\fi
569
+ % start actual procedure for [pdfbox] option
570
+ \if 1\pxgtmb@pdfbox@status
571
+ %% supported drivers: dvips, dvipdfmx, XeTeX, pdfTeX, LuaTeX
572
+ \ifnum0\ifx\pdfvariable\@undefined\else\the\outputmode\fi=0\relax
573
+ \ifnum0\ifx\pdfpageattr\@undefined\else\the\pdfoutput\fi=0\relax
574
+ %% for DVI output or XeTeX
575
+ \ifx\XeTeXversion\@undefined
576
+ \chardef\pxgtmb@errlevel=\z@
577
+ % check graphics/graphicx/color status
578
+ \ifx\Gin@driver\@undefined
579
+ \ifx\pxgtmb@driver\@undefined % driver option unavailable
580
+ \PackageError{\pxgtmb@pkgname}{%
581
+ Option `pdfbox' is driver-dependent!\MessageBreak
582
+ Please add a driver option}\@ehc
583
+ \def\pxgtmb@driver{s}% fallback
584
+ \fi
585
+ \else
586
+ % check consistency
587
+ \def\pxgtmb@tempa{dvips.def}\ifx\Gin@driver\pxgtmb@tempa
588
+ \ifx\pxgtmb@driver\@undefined
589
+ \def\pxgtmb@driver{s}% pass
590
+ \else
591
+ \if s\pxgtmb@driver\else \chardef\pxgtmb@errlevel=\@ne \fi
592
+ \fi
593
+ \else\def\pxgtmb@tempa{dvipdfmx.def}\ifx\Gin@driver\pxgtmb@tempa
594
+ \ifx\pxgtmb@driver\@undefined
595
+ \def\pxgtmb@driver{m}% pass
596
+ \else
597
+ \if m\pxgtmb@driver\else \chardef\pxgtmb@errlevel=\@ne \fi
598
+ \fi
599
+ \else
600
+ \ifx\pxgtmb@driver\@undefined
601
+ \PackageError{\pxgtmb@pkgname}{%
602
+ Option `pdfbox' is driver-dependent!\MessageBreak
603
+ Please add a driver option}\@ehc
604
+ \def\pxgtmb@driver{s}% fallback
605
+ \fi
606
+ \fi\fi
607
+ \ifnum\pxgtmb@errlevel>\z@
608
+ \PackageWarningNoLine{\pxgtmb@pkgname}{%
609
+ Inconsistent driver option detected!\MessageBreak
610
+ Package `graphics' or `color' already\MessageBreak
611
+ loaded with different driver option}\@ehc
612
+ \fi
613
+ \fi
614
+ \else
615
+ \def\pxgtmb@driver{x}
616
+ \fi
617
+ % required for putting \special to every page
618
+ \ifx\pfmtname\@undefined
619
+ \RequirePackage{atbegshi}
620
+ \else
621
+ \IfFileExists{pxatbegshi.sty}
622
+ {\RequirePackage{pxatbegshi}}
623
+ {\RequirePackage{atbegshi}}
624
+ \fi
625
+ % do it
626
+ \if x\pxgtmb@driver
627
+ %% for XeTeX (similar to dvipdfmx, except for paper size)
628
+ \AtBeginDocument{%
629
+ \pxgtmb@PDF@calcbox
630
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
631
+ \edef\pxgtmb@PDF@CTM{{pdf:put @thispage << \pxgtmb@PDF@CTM >>}}}
632
+ % force paper size
633
+ \pdfpagewidth\stockwidth \pdfpageheight\stockheight
634
+ % emit pdf boxes
635
+ \AtBeginShipout{\setbox\AtBeginShipoutBox=\vbox{%
636
+ \baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
637
+ \expandafter\special\pxgtmb@PDF@CTM % here!
638
+ \copy\AtBeginShipoutBox}}
639
+ \else
640
+ \if s\pxgtmb@driver
641
+ %% for dvips
642
+ \AtBeginDocument{%
643
+ \pxgtmb@PDF@calcbox
644
+ \def\pxgtmb@PDF@begin{[ }\def\pxgtmb@PDF@end{/PAGE pdfmark }%
645
+ \edef\pxgtmb@PDF@CTM{{ps:SDict begin \pxgtmb@PDF@CTM end}}}
646
+ \else\if m\pxgtmb@driver
647
+ %% for dvipdfmx
648
+ \AtBeginDocument{%
649
+ \pxgtmb@PDF@calcbox
650
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
651
+ \edef\pxgtmb@PDF@CTM{{pdf:put @thispage << \pxgtmb@PDF@CTM >>}}}
652
+ \else
653
+ %% for others (in case graphics option wrong)
654
+ \PackageError{\pxgtmb@pkgname}{Sorry, driver unsupported}\@ehc
655
+ \def\pxgtmb@PDF@CTM{{}}% dummy
656
+ \fi\fi
657
+ %% common
658
+ \begingroup
659
+ % when jsclasses-style \mag employment is assumed ...
660
+ % [Note] \special{papersize=<width>,<height>} accepts only non-true units
661
+ % and evaluates them as if they were true units!
662
+ \ifx\pxgtmb@magscale\@undefined\else
663
+ \stockwidth \pxgtmb@magscale\stockwidth
664
+ \stockheight\pxgtmb@magscale\stockheight
665
+ \fi
666
+ \xdef\pxgtmb@PDF@size{{papersize=\the\stockwidth,\the\stockheight}}
667
+ \endgroup
668
+ \AtBeginShipout{\setbox\AtBeginShipoutBox=\vbox{%
669
+ \baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
670
+ % force paper size
671
+ \expandafter\special\pxgtmb@PDF@size
672
+ % emit pdf boxes
673
+ \expandafter\special\pxgtmb@PDF@CTM % here!
674
+ \copy\AtBeginShipoutBox}}
675
+ \fi
676
+ \else
677
+ %% for pdfTeX
678
+ \def\pxgtmb@driver{p}
679
+ % force paper size
680
+ \pdfpagewidth\stockwidth \pdfpageheight\stockheight
681
+ % emit pdf boxes
682
+ \AtBeginDocument{%
683
+ \pxgtmb@PDF@calcbox
684
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
685
+ \edef\pxgtmb@PDF@CTM{{\pxgtmb@PDF@CTM}}%
686
+ \expandafter\pdfpageattr\pxgtmb@PDF@CTM}
687
+ \fi\else
688
+ %% for LuaTeX
689
+ \def\pxgtmb@driver{l}
690
+ % force paper size
691
+ \pagewidth\stockwidth \pageheight\stockheight
692
+ % emit pdf boxes
693
+ \AtBeginDocument{%
694
+ \pxgtmb@PDF@calcbox
695
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
696
+ \edef\pxgtmb@PDF@CTM{pageattr{\pxgtmb@PDF@CTM}}%
697
+ \expandafter\pdfvariable\pxgtmb@PDF@CTM}
698
+ \fi
699
+ \fi
700
+ }
701
+
702
+ %% make visible tombow box according to the current status of
703
+ %% \@bannerfont, \@bannertoken, \@tombowwidth & \@tombowbleed
704
+ \maketombowbox
705
+
706
+ %% shift amount
707
+ \hoffset .5\stockwidth
708
+ \advance\hoffset -.5\paperwidth
709
+ \advance\hoffset-1truein\relax
710
+ \voffset .5\stockheight
711
+ \advance\voffset -.5\paperheight
712
+ \advance\voffset-1truein\relax
713
+
714
+ %% user interface
715
+ \newcommand{\settombowbanner}[1]{%
716
+ \iftombowdate\else
717
+ \PackageWarning{\pxgtmb@pkgname}{%
718
+ Package option `tombowbanner' is not effective.\MessageBreak
719
+ The banner may be discarded}%
720
+ \fi
721
+ \@bannertoken{#1}\maketombowbox}
722
+ \newcommand{\settombowbannerfont}[1]{%
723
+ \font\@bannerfont=#1\relax \maketombowbox}
724
+ \newcommand{\settombowwidth}[1]{%
725
+ \setlength{\@tombowwidth}{#1}\maketombowbox}
726
+ \newcommand{\settombowbleed}[1]{%
727
+ \def\@tombowbleed{#1}\maketombowbox}
728
+ \newcommand{\settombowcolor}[1]{%
729
+ \def\@tombowcolor{#1}}
730
+ % forbid changing \@tombowbleed after \begin{document}
731
+ % because pdf boxes are calculated only inside \AtBeginDocument
732
+ \@onlypreamble\settombowbleed
733
+
734
+ %% patch internal of pdfpages.sty to work with tombow
735
+ %% (tested on pdfpages 2017/10/31 v0.5l)
736
+ %% Note the code is the same as that of pxpdfpages.sty,
737
+ %% but reserved here since gentombow.sty can be used on
738
+ %% any LaTeX format
739
+ %% (cf. pxpdfpages.sty is restricted to (u)pLaTeX)
740
+ \def\pxgtmb@patch@pdfpages{%
741
+ \RequirePackage{etoolbox}
742
+ \patchcmd{\AM@output}{%
743
+ \setlength{\@tempdima}{\AM@xmargin}%
744
+ \edef\AM@xmargin{\the\@tempdima}%
745
+ \setlength{\@tempdima}{\AM@ymargin}%
746
+ \edef\AM@ymargin{\the\@tempdima}%
747
+ }{%
748
+ \setlength{\@tempdima}{\AM@xmargin\iftombow+1in\fi}%
749
+ \edef\AM@xmargin{\the\@tempdima}%
750
+ \setlength{\@tempdima}{\AM@ymargin\iftombow-1in\fi}%
751
+ \edef\AM@ymargin{\the\@tempdima}%
752
+ }
753
+ {\PackageInfo{\pxgtmb@pkgname}{Patch for pdfpages applied}}
754
+ {\PackageWarningNoLine{\pxgtmb@pkgname}{Patch for pdfpages failed}}%
755
+ }
756
+ %% however, if running (u)pLaTeX, use pxpdfpages.sty if available
757
+ \ifx\pfmtname\@undefined\else
758
+ \IfFileExists{pxpdfpages.sty}{%
759
+ \def\pxgtmb@patch@pdfpages{\RequirePackage{pxpdfpages}}%
760
+ }{}
761
+ \fi
762
+ %% do it
763
+ \AtBeginDocument{\@ifpackageloaded{pdfpages}{\pxgtmb@patch@pdfpages}{}}
764
+
765
+ %% patch pdfx.sty
766
+ %% (tested on pdfx 2019/02/27 v1.6.3)
767
+ \def\pxgtmb@handle@pdfx{\@ifpackageloaded{pdfx}{\let\ifpxgtmb@pdfx@x\ifpdfx@x}{}}
768
+
769
+ \endinput