review 3.0.0.preview2 → 3.0.0.preview3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -1
  3. data/NEWS.ja.md +49 -0
  4. data/NEWS.md +49 -0
  5. data/README.md +8 -2
  6. data/doc/LICENSE +20 -0
  7. data/doc/config.yml.sample +9 -2
  8. data/doc/customize_epub.ja.md +23 -0
  9. data/doc/customize_epub.md +23 -0
  10. data/doc/format.ja.md +98 -4
  11. data/doc/format.md +98 -1
  12. data/doc/makeindex.ja.md +2 -2
  13. data/doc/pdfmaker.ja.md +12 -3
  14. data/doc/pdfmaker.md +2 -2
  15. data/doc/preproc.ja.md +2 -2
  16. data/doc/quickstart.ja.md +1 -1
  17. data/doc/quickstart.md +1 -1
  18. data/lib/review/compiler.rb +1 -1
  19. data/lib/review/configure.rb +13 -1
  20. data/lib/review/epubmaker.rb +10 -4
  21. data/lib/review/htmlbuilder.rb +31 -9
  22. data/lib/review/init.rb +72 -3
  23. data/lib/review/makerhelper.rb +180 -1
  24. data/lib/review/pdfmaker.rb +23 -4
  25. data/lib/review/version.rb +1 -1
  26. data/lib/review/webmaker.rb +14 -4
  27. data/review.gemspec +1 -1
  28. data/samples/sample-book/src/Rakefile +20 -0
  29. data/samples/sample-book/src/config.yml +3 -2
  30. data/samples/sample-book/src/images/cover-a5.ai +5836 -16
  31. data/samples/sample-book/src/images/cover-b5.ai +5735 -15
  32. data/samples/syntax-book/config.yml +1 -1
  33. data/templates/LICENSE +1 -1
  34. data/templates/latex/config.erb +24 -11
  35. data/templates/latex/layout.tex.erb +15 -5
  36. data/templates/latex/review-jlreq/README.md +2 -1
  37. data/templates/latex/review-jlreq/review-base.sty +165 -22
  38. data/templates/latex/review-jlreq/review-jlreq.cls +180 -110
  39. data/templates/latex/review-jlreq/review-style.sty +13 -125
  40. data/templates/latex/review-jlreq/reviewmacro.sty +7 -0
  41. data/templates/latex/review-jsbook/README.md +129 -0
  42. data/templates/latex/review-jsbook/review-base.sty +33 -20
  43. data/templates/latex/review-jsbook/review-jsbook.cls +545 -0
  44. data/templates/latex/review-jsbook/reviewmacro.sty +7 -0
  45. data/test/assets/test_template.tex +27 -8
  46. data/test/assets/test_template_backmatter.tex +27 -8
  47. data/test/test_helper.rb +3 -0
  48. data/test/test_htmlbuilder.rb +3 -1
  49. data/test/test_pdfmaker.rb +2 -0
  50. data/vendor/gentombow/.gitignore +163 -0
  51. data/vendor/gentombow/LICENSE +27 -0
  52. data/vendor/gentombow/Makefile +36 -0
  53. data/vendor/gentombow/README.md +49 -0
  54. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  55. data/vendor/gentombow/bounddvi-en.tex +135 -0
  56. data/vendor/gentombow/bounddvi.pdf +0 -0
  57. data/vendor/gentombow/bounddvi.sty +87 -0
  58. data/vendor/gentombow/bounddvi.tex +148 -0
  59. data/vendor/gentombow/create_archive.sh +24 -0
  60. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  61. data/vendor/gentombow/gentombow-ja.tex +449 -0
  62. data/vendor/gentombow/gentombow.pdf +0 -0
  63. data/vendor/gentombow/gentombow.sty +747 -0
  64. data/vendor/gentombow/gentombow.tex +298 -0
  65. data/vendor/gentombow/pxgentombow.pdf +0 -0
  66. data/vendor/gentombow/pxgentombow.sty +16 -0
  67. data/vendor/gentombow/pxgentombow.tex +25 -0
  68. data/vendor/gentombow/tests/bounddvi-01-usage.tex +7 -0
  69. data/vendor/gentombow/tests/bounddvi-02-jstombow.tex +7 -0
  70. data/vendor/gentombow/tests/bounddvi-03-grfdvips.tex +9 -0
  71. data/vendor/gentombow/tests/bounddvi-04-grfdvipdfmx.tex +9 -0
  72. data/vendor/gentombow/tests/bounddvi-05-geodvips.tex +8 -0
  73. data/vendor/gentombow/tests/bounddvi-05a-geodvips.tex +9 -0
  74. data/vendor/gentombow/tests/bounddvi-06-geodvipdfmx.tex +8 -0
  75. data/vendor/gentombow/tests/bounddvi-06a-geodvipdfmx.tex +9 -0
  76. data/vendor/gentombow/tests/pxgentombow-01-usage.tex +6 -0
  77. data/vendor/gentombow/tests/pxgentombow-02-js.tex +6 -0
  78. data/vendor/gentombow/tests/pxgentombow-02a-js-error.tex +6 -0
  79. data/vendor/gentombow/tests/pxgentombow-03-notombowdate.tex +8 -0
  80. data/vendor/gentombow/tests/pxgentombow-04-pkgoption.tex +8 -0
  81. data/vendor/gentombow/tests/pxgentombow-05-tatecls.tex +6 -0
  82. metadata +40 -3
Binary file
@@ -0,0 +1,747 @@
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
+ [2018/08/30 v0.9j 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
+
294
+ %% passed from class options
295
+ %% should be declared first inside this package (least priority)
296
+ \DeclareOption{tombow}{\tombowdatetrue}
297
+ \DeclareOption{tombo}{\tombowdatefalse}
298
+ \DeclareOption{mentuke}{\tombowdatefalse \setlength{\@tombowwidth}{\z@}}
299
+
300
+ %% package options part 1
301
+ \DeclareOption{tombowbanner}{\tombowdatetrue}
302
+ \DeclareOption{notombowbanner}{\tombowdatefalse}
303
+ \DeclareOption{tombowdate}{% obsolete since v0.9c (2018/01/11)
304
+ \PackageWarning{\pxgtmb@pkgname}{%
305
+ Option `tombowdate' is renamed;\MessageBreak
306
+ use `tombowbanner' instead}%
307
+ \tombowdatetrue}
308
+ \DeclareOption{notombowdate}{% obsolete since v0.9c (2018/01/11)
309
+ \PackageWarning{\pxgtmb@pkgname}{%
310
+ Option `notombowdate' is renamed;\MessageBreak
311
+ use `notombowbanner' instead}%
312
+ \tombowdatefalse}
313
+
314
+ %% register a list of candidate papersize
315
+ % * \pxgtmb@addpapersize[<tombowname>]{<papername>}{<shorter edge>}{<longer edge>}
316
+ % used for declaration of papersize.
317
+ % when no option is specified (that is, \ifpxgtmb@switch = \iffalse),
318
+ % also used for automatic stocksize determination.
319
+ % * if <tombowname> = \@empty, the next <papername> is assumed.
320
+ % * if <tombowname> = n, stocksize is set to papersize + 2in.
321
+ \def\pxgtmb@addpapersize{\@ifnextchar[{\pxgtmb@addp@persize}{\pxgtmb@addp@persize[\@empty]}}
322
+ \def\pxgtmb@addp@persize[#1]#2#3#4{%
323
+ % get current papersize and search through known standard in ascending order
324
+ \ifx\pxgtmb@guessedtombow\@empty
325
+ \ifx\pxgtmb@guessedpaper\@empty
326
+ % shorter edge -> \@tempdima, longer edge -> \@tempdimb
327
+ \ifdim\paperwidth>\paperheight\relax
328
+ \pxgtmb@landscapetrue
329
+ \@tempdima\paperheight \@tempdimb\paperwidth
330
+ \else
331
+ \pxgtmb@landscapefalse
332
+ \@tempdima\paperwidth \@tempdimb\paperheight
333
+ \fi
334
+ % \@ovri and \@ovro are used temporarily (safe enough)
335
+ \@ovri=#3\relax
336
+ \@ovro=#4\relax
337
+ % when jsclasses-style \mag employment is assumed ...
338
+ \ifx\pxgtmb@magscale\@undefined\else
339
+ \@ovri=\inv@mag\@ovri\relax
340
+ \@ovro=\inv@mag\@ovro\relax
341
+ \fi
342
+ % compare
343
+ \ifdim\@tempdima=\@ovri\relax \ifdim\@tempdimb=\@ovro\relax
344
+ \def\pxgtmb@guessedpaper{#2}%
345
+ \ifx#1\@empty\else
346
+ \def\pxgtmb@guessedtombow{#1}%
347
+ \if n\pxgtmb@guessedtombow\else
348
+ \ExecuteOptions{tombow-#1}% package defaults to tombowdatetrue
349
+ \pxgtmb@switchfalse
350
+ \fi
351
+ \fi
352
+ \fi \fi
353
+ \else
354
+ \def\pxgtmb@guessedtombow{#2}% save for console message
355
+ \pxgtmb@setstock{#3}{#4}% set stockwidth/height
356
+ \fi\fi
357
+ \DeclareOption{tombow-#2}{%
358
+ \pxgtmb@switchtrue
359
+ \tombowdatetrue
360
+ \pxgtmb@setstock{#3}{#4}%
361
+ }%
362
+ \DeclareOption{tombo-#2}{%
363
+ \pxgtmb@switchtrue
364
+ \tombowdatefalse
365
+ \pxgtmb@setstock{#3}{#4}%
366
+ }%
367
+ \DeclareOption{mentuke-#2}{%
368
+ \pxgtmb@switchtrue
369
+ \tombowdatefalse
370
+ \setlength{\@tombowwidth}{\z@}%
371
+ \pxgtmb@setstock{#3}{#4}%
372
+ }%
373
+ }
374
+ \def\pxgtmb@setstock#1#2{%
375
+ \ifpxgtmb@landscape
376
+ \setlength\stockwidth{#2}%
377
+ \setlength\stockheight{#1}%
378
+ \else
379
+ \setlength\stockwidth{#1}%
380
+ \setlength\stockheight{#2}%
381
+ \fi
382
+ % when jsclasses-style \mag employment is assumed ...
383
+ \ifx\pxgtmb@magscale\@undefined\else
384
+ \stockwidth=\inv@mag\stockwidth\relax
385
+ \stockheight=\inv@mag\stockheight\relax
386
+ \fi
387
+ }%
388
+ \@onlypreamble\pxgtmb@addpapersize
389
+ \@onlypreamble\pxgtmb@addp@persize
390
+ \@onlypreamble\pxgtmb@setstock
391
+
392
+ %% initialize before search
393
+ \def\pxgtmb@guessedpaper{}
394
+ \def\pxgtmb@guessedtombow{}
395
+ \@onlypreamble\pxgtmb@guessedpaper
396
+ \@onlypreamble\pxgtmb@guessedtombow
397
+
398
+ %% package options part 2
399
+ % ISO A series <=> JIS B series in the ascending order
400
+ \pxgtmb@addpapersize{a10}{26mm}{37mm}
401
+ \pxgtmb@addpapersize{b10}{32mm}{45mm}
402
+ \pxgtmb@addpapersize{a9}{37mm}{52mm}
403
+ \pxgtmb@addpapersize{b9}{45mm}{64mm}
404
+ \pxgtmb@addpapersize{a8}{52mm}{74mm}
405
+ \pxgtmb@addpapersize{b8}{64mm}{91mm}
406
+ \pxgtmb@addpapersize{a7}{74mm}{105mm}
407
+ \pxgtmb@addpapersize{b7}{91mm}{128mm}
408
+ \pxgtmb@addpapersize{a6}{105mm}{148mm}
409
+ \pxgtmb@addpapersize{b6}{128mm}{182mm}
410
+ \pxgtmb@addpapersize{a5}{148mm}{210mm}
411
+ \pxgtmb@addpapersize{b5}{182mm}{257mm}
412
+ \pxgtmb@addpapersize{a4}{210mm}{297mm}
413
+ \pxgtmb@addpapersize{b4}{257mm}{364mm}
414
+ \pxgtmb@addpapersize{a3}{297mm}{420mm}
415
+ \pxgtmb@addpapersize{b3}{364mm}{515mm}
416
+ \pxgtmb@addpapersize{a2}{420mm}{594mm}
417
+ \pxgtmb@addpapersize{b2}{515mm}{728mm}
418
+ \pxgtmb@addpapersize{a1}{594mm}{841mm}
419
+ \pxgtmb@addpapersize{b1}{728mm}{1030mm}
420
+ \pxgtmb@addpapersize[n]{a0}{841mm}{1189mm}
421
+ \pxgtmb@addpapersize[n]{b0}{1030mm}{1456mm}
422
+
423
+ %% package options part 3
424
+ % ISO C series
425
+ \pxgtmb@addpapersize[a9]{c10}{28mm}{40mm}
426
+ \pxgtmb@addpapersize[a8]{c9}{40mm}{57mm}
427
+ \pxgtmb@addpapersize[a7]{c8}{57mm}{81mm}
428
+ \pxgtmb@addpapersize[a6]{c7}{81mm}{114mm}
429
+ \pxgtmb@addpapersize[a5]{c6}{114mm}{162mm}
430
+ \pxgtmb@addpapersize[a4]{c5}{162mm}{229mm}
431
+ \pxgtmb@addpapersize[a3]{c4}{229mm}{354mm}
432
+ \pxgtmb@addpapersize[a2]{c3}{324mm}{458mm}
433
+ \pxgtmb@addpapersize[a1]{c2}{458mm}{648mm}
434
+ \pxgtmb@addpapersize[a0]{c1}{648mm}{917mm}
435
+ \pxgtmb@addpapersize[n]{c0}{917mm}{1297mm}
436
+ % misc
437
+ \pxgtmb@addpapersize[b4]{a4j}{210mm}{297mm}
438
+ \pxgtmb@addpapersize[b5]{a5j}{148mm}{210mm}
439
+ \pxgtmb@addpapersize[a3]{b4j}{257mm}{364mm}
440
+ \pxgtmb@addpapersize[a4]{b5j}{182mm}{257mm}
441
+ \pxgtmb@addpapersize[b4]{a4var}{210mm}{283mm}
442
+ \pxgtmb@addpapersize[a4]{b5var}{182mm}{230mm}
443
+ \pxgtmb@addpapersize[a3]{letter}{8.5in}{11in}
444
+ \pxgtmb@addpapersize[a3]{legal}{8.5in}{14in}
445
+ \pxgtmb@addpapersize[a4]{executive}{7.25in}{10.5in}
446
+ \pxgtmb@addpapersize[a5]{hagaki}{100mm}{148mm}
447
+
448
+ %% package options part 4
449
+ \def\pxgtmb@pdfbox@status{0}
450
+ \DeclareOption{pdfbox}{\def\pxgtmb@pdfbox@status{1}}
451
+ \DeclareOption{dvips}{\def\pxgtmb@driver{s}}
452
+ \DeclareOption{dvipdfmx}{\def\pxgtmb@driver{m}}
453
+ \DeclareOption{xetex}{\def\pxgtmb@driver{x}}
454
+ \DeclareOption{pdftex}{\def\pxgtmb@driver{p}}
455
+ \DeclareOption{luatex}{\def\pxgtmb@driver{l}}
456
+
457
+ %% default options
458
+ \ExecuteOptions{tombowbanner}% package defaults to tombowdatetrue
459
+ \ProcessOptions
460
+
461
+ %% display search result
462
+ % if any of explicit size option is specified, \ifpxgtmb@switch = \iftrue.
463
+ % otherwise, automatic size detection should be successful.
464
+ \ifpxgtmb@switch\else
465
+ % check status
466
+ \@tempcnta=\z@\relax
467
+ \ifx\pxgtmb@guessedpaper\@empty
468
+ \advance\@tempcnta\@ne\relax
469
+ \fi
470
+ \ifx\pxgtmb@guessedtombow\@empty
471
+ \advance\@tempcnta\tw@\relax
472
+ \else\if n\pxgtmb@guessedtombow
473
+ \advance\@tempcnta\tw@\relax
474
+ \fi\fi
475
+ % message
476
+ \ifodd\@tempcnta
477
+ %\PackageWarningNoLine\pxgtmb@pkgname{%
478
+ % No size option specified, and automatic papersize\MessageBreak
479
+ % detection also failed}
480
+ \else
481
+ \typeout{***** Package \pxgtmb@pkgname\space detected \pxgtmb@guessedpaper paper. *****}
482
+ \fi
483
+ \ifnum\@tempcnta>\@ne\relax
484
+ \PackageWarningNoLine\pxgtmb@pkgname{%
485
+ Output size cannot be determined. Please add size\MessageBreak
486
+ option (e.g. `tombow-a4') to specify output size.\MessageBreak
487
+ Falling back to +1in ..}
488
+ \stockwidth\paperwidth \advance\stockwidth 2in
489
+ \stockheight\paperheight \advance\stockheight 2in
490
+ \else
491
+ \typeout{***** Now the output size is automatically set to \pxgtmb@guessedtombow. *****}
492
+ \fi
493
+ \fi
494
+
495
+ %% warnings
496
+ \ifdim\stockwidth<\paperwidth
497
+ \PackageWarningNoLine\pxgtmb@pkgname{%
498
+ \string\stockwidth\space is smaller than \string\paperwidth!\MessageBreak
499
+ Is this really what you want?}
500
+ \fi
501
+ \ifdim\stockheight<\paperheight
502
+ \PackageWarningNoLine\pxgtmb@pkgname{%
503
+ \string\stockheight\space is smaller than \string\paperheight!\MessageBreak
504
+ Is this really what you want?}
505
+ \fi
506
+
507
+ %% pdf "digital tombo" (driver-dependent)
508
+ % the box size calculation is delayed until \AtBeginDocument
509
+ % to allow users to change \@tombowbleed in the preamble
510
+ \if 1\pxgtmb@pdfbox@status
511
+ % convert pt -> bp
512
+ \def\pxgtmb@PDF@setbp#1#2{%
513
+ \@tempdima=.996264#2\relax % 0.996264 = 72/72.27 (cf. 1in = 72.27pt = 72bp)
514
+ \@tempdima=\pxgtmb@magscale\@tempdima % adjustment for jsclasses-style \mag employment
515
+ \edef#1{\strip@pt\@tempdima}}
516
+ % calculate and create pdf boxes
517
+ \def\pxgtmb@PDF@calcbox{%
518
+ \begingroup
519
+ % provide fallback definition inside this group
520
+ \ifx\pxgtmb@magscale\@undefined
521
+ \def\pxgtmb@magscale{1}%
522
+ \fi
523
+ % set pdf boxes in bp unit
524
+ %\pxgtmb@PDF@setbp\pxgtmb@PDF@crop@ur@x\stockwidth
525
+ %\pxgtmb@PDF@setbp\pxgtmb@PDF@crop@ur@y\stockheight
526
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ll@x{\dimexpr(\stockwidth-\paperwidth)/2}%
527
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ll@y{\dimexpr(\stockheight-\paperheight)/2}%
528
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ur@x{\dimexpr(\stockwidth+\paperwidth)/2}%
529
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@trim@ur@y{\dimexpr(\stockheight+\paperheight)/2}%
530
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ll@x{\dimexpr(\stockwidth-\paperwidth)/2-\@tombowbleed}%
531
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ll@y{\dimexpr(\stockheight-\paperheight)/2-\@tombowbleed}%
532
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ur@x{\dimexpr(\stockwidth+\paperwidth)/2+\@tombowbleed}%
533
+ \pxgtmb@PDF@setbp\pxgtmb@PDF@bleed@ur@y{\dimexpr(\stockheight+\paperheight)/2+\@tombowbleed}%
534
+ \xdef\pxgtmb@PDF@CTM{%
535
+ %% CropBox: implicit (same as MediaBox, large paper size)
536
+ %/CropBox [0 0 \pxgtmb@PDF@crop@ur@x\space \pxgtmb@PDF@crop@ur@y]
537
+ %% BleedBox: explicit (final paper size + surrounding \@tombowbleed)
538
+ \noexpand\pxgtmb@PDF@begin
539
+ /BleedBox [\pxgtmb@PDF@bleed@ll@x\space
540
+ \pxgtmb@PDF@bleed@ll@y\space
541
+ \pxgtmb@PDF@bleed@ur@x\space
542
+ \pxgtmb@PDF@bleed@ur@y] \noexpand\pxgtmb@PDF@end
543
+ %% TrimBox: explicit (final paper size)
544
+ \noexpand\pxgtmb@PDF@begin
545
+ /TrimBox [\pxgtmb@PDF@trim@ll@x\space
546
+ \pxgtmb@PDF@trim@ll@y\space
547
+ \pxgtmb@PDF@trim@ur@x\space
548
+ \pxgtmb@PDF@trim@ur@y] \noexpand\pxgtmb@PDF@end
549
+ %% ArtBox: implicit
550
+ }%
551
+ \endgroup
552
+ }
553
+ %% supported drivers: dvips, dvipdfmx, XeTeX, pdfTeX, LuaTeX
554
+ \ifnum0\ifx\pdfvariable\@undefined\else\the\outputmode\fi=0\relax
555
+ \ifnum0\ifx\pdfpageattr\@undefined\else\the\pdfoutput\fi=0\relax
556
+ %% for DVI output or XeTeX
557
+ \ifx\XeTeXversion\@undefined
558
+ \chardef\pxgtmb@errlevel=\z@
559
+ % check graphics/graphicx/color status
560
+ \ifx\Gin@driver\@undefined
561
+ \ifx\pxgtmb@driver\@undefined % driver option unavailable
562
+ \PackageError{\pxgtmb@pkgname}{%
563
+ Option `pdfbox' is driver-dependent!\MessageBreak
564
+ Please add a driver option}\@ehc
565
+ \def\pxgtmb@driver{s}% fallback
566
+ \fi
567
+ \else
568
+ % check consistency
569
+ \def\pxgtmb@tempa{dvips.def}\ifx\Gin@driver\pxgtmb@tempa
570
+ \ifx\pxgtmb@driver\@undefined
571
+ \def\pxgtmb@driver{s}% pass
572
+ \else
573
+ \if s\pxgtmb@driver\else \chardef\pxgtmb@errlevel=\@ne \fi
574
+ \fi
575
+ \else\def\pxgtmb@tempa{dvipdfmx.def}\ifx\Gin@driver\pxgtmb@tempa
576
+ \ifx\pxgtmb@driver\@undefined
577
+ \def\pxgtmb@driver{m}% pass
578
+ \else
579
+ \if m\pxgtmb@driver\else \chardef\pxgtmb@errlevel=\@ne \fi
580
+ \fi
581
+ \else
582
+ \ifx\pxgtmb@driver\@undefined
583
+ \PackageError{\pxgtmb@pkgname}{%
584
+ Option `pdfbox' is driver-dependent!\MessageBreak
585
+ Please add a driver option}\@ehc
586
+ \def\pxgtmb@driver{s}% fallback
587
+ \fi
588
+ \fi\fi
589
+ \ifnum\pxgtmb@errlevel>\z@
590
+ \PackageWarningNoLine{\pxgtmb@pkgname}{%
591
+ Inconsistent driver option detected!\MessageBreak
592
+ Package `graphics' or `color' already\MessageBreak
593
+ loaded with different driver option}\@ehc
594
+ \fi
595
+ \fi
596
+ \else
597
+ \def\pxgtmb@driver{x}
598
+ \fi
599
+ % required for putting \special to every page
600
+ \ifx\pfmtname\@undefined
601
+ \RequirePackage{atbegshi}
602
+ \else
603
+ \IfFileExists{pxatbegshi.sty}
604
+ {\RequirePackage{pxatbegshi}}
605
+ {\RequirePackage{atbegshi}}
606
+ \fi
607
+ % do it
608
+ \if x\pxgtmb@driver
609
+ %% for XeTeX (similar to dvipdfmx, except for paper size)
610
+ \AtBeginDocument{%
611
+ \pxgtmb@PDF@calcbox
612
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
613
+ \edef\pxgtmb@PDF@CTM{{pdf:put @thispage << \pxgtmb@PDF@CTM >>}}}
614
+ % force paper size
615
+ \pdfpagewidth\stockwidth \pdfpageheight\stockheight
616
+ % emit pdf boxes
617
+ \AtBeginShipout{\setbox\AtBeginShipoutBox=\vbox{%
618
+ \baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
619
+ \expandafter\special\pxgtmb@PDF@CTM % here!
620
+ \copy\AtBeginShipoutBox}}
621
+ \else
622
+ \if s\pxgtmb@driver
623
+ %% for dvips
624
+ \AtBeginDocument{%
625
+ \pxgtmb@PDF@calcbox
626
+ \def\pxgtmb@PDF@begin{[ }\def\pxgtmb@PDF@end{/PAGE pdfmark }%
627
+ \edef\pxgtmb@PDF@CTM{{ps:SDict begin \pxgtmb@PDF@CTM end}}}
628
+ \else\if m\pxgtmb@driver
629
+ %% for dvipdfmx
630
+ \AtBeginDocument{%
631
+ \pxgtmb@PDF@calcbox
632
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
633
+ \edef\pxgtmb@PDF@CTM{{pdf:put @thispage << \pxgtmb@PDF@CTM >>}}}
634
+ \else
635
+ %% for others (in case graphics option wrong)
636
+ \PackageError{\pxgtmb@pkgname}{Sorry, driver unsupported}\@ehc
637
+ \def\pxgtmb@PDF@CTM{{}}% dummy
638
+ \fi\fi
639
+ %% common
640
+ \begingroup
641
+ % when jsclasses-style \mag employment is assumed ...
642
+ % [Note] \special{papersize=<width>,<height>} accepts only non-true units
643
+ % and evaluates them as if they were true units!
644
+ \ifx\pxgtmb@magscale\@undefined\else
645
+ \stockwidth \pxgtmb@magscale\stockwidth
646
+ \stockheight\pxgtmb@magscale\stockheight
647
+ \fi
648
+ \xdef\pxgtmb@PDF@size{{papersize=\the\stockwidth,\the\stockheight}}
649
+ \endgroup
650
+ \AtBeginShipout{\setbox\AtBeginShipoutBox=\vbox{%
651
+ \baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
652
+ % force paper size
653
+ \expandafter\special\pxgtmb@PDF@size
654
+ % emit pdf boxes
655
+ \expandafter\special\pxgtmb@PDF@CTM % here!
656
+ \copy\AtBeginShipoutBox}}
657
+ \fi
658
+ \else
659
+ %% for pdfTeX
660
+ \def\pxgtmb@driver{p}
661
+ % force paper size
662
+ \pdfpagewidth\stockwidth \pdfpageheight\stockheight
663
+ % emit pdf boxes
664
+ \AtBeginDocument{%
665
+ \pxgtmb@PDF@calcbox
666
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
667
+ \edef\pxgtmb@PDF@CTM{{\pxgtmb@PDF@CTM}}%
668
+ \expandafter\pdfpageattr\pxgtmb@PDF@CTM}
669
+ \fi
670
+ \else
671
+ %% for LuaTeX
672
+ \def\pxgtmb@driver{l}
673
+ % force paper size
674
+ \pagewidth\stockwidth \pageheight\stockheight
675
+ % emit pdf boxes
676
+ \AtBeginDocument{%
677
+ \pxgtmb@PDF@calcbox
678
+ \def\pxgtmb@PDF@begin{}\def\pxgtmb@PDF@end{}%
679
+ \edef\pxgtmb@PDF@CTM{pageattr{\pxgtmb@PDF@CTM}}%
680
+ \expandafter\pdfvariable\pxgtmb@PDF@CTM}
681
+ \fi
682
+ \fi
683
+
684
+ %% make visible tombow box according to the current status of
685
+ %% \@bannerfont, \@bannertoken, \@tombowwidth & \@tombowbleed
686
+ \maketombowbox
687
+
688
+ %% shift amount
689
+ \hoffset .5\stockwidth
690
+ \advance\hoffset -.5\paperwidth
691
+ \advance\hoffset-1truein\relax
692
+ \voffset .5\stockheight
693
+ \advance\voffset -.5\paperheight
694
+ \advance\voffset-1truein\relax
695
+
696
+ %% user interface
697
+ \newcommand{\settombowbanner}[1]{%
698
+ \iftombowdate\else
699
+ \PackageWarning{\pxgtmb@pkgname}{%
700
+ Package option `tombowbanner' is not effective.\MessageBreak
701
+ The banner may be discarded}%
702
+ \fi
703
+ \@bannertoken{#1}\maketombowbox}
704
+ \newcommand{\settombowbannerfont}[1]{%
705
+ \font\@bannerfont=#1\relax \maketombowbox}
706
+ \newcommand{\settombowwidth}[1]{%
707
+ \setlength{\@tombowwidth}{#1}\maketombowbox}
708
+ \newcommand{\settombowbleed}[1]{%
709
+ \def\@tombowbleed{#1}\maketombowbox}
710
+ \newcommand{\settombowcolor}[1]{%
711
+ \def\@tombowcolor{#1}}
712
+ % forbid changing \@tombowbleed after \begin{document}
713
+ % because pdf boxes are calculated only inside \AtBeginDocument
714
+ \@onlypreamble\settombowbleed
715
+
716
+ %% patch internal for pdfpages to work with tombow
717
+ %% (tested on pdfpages 2017/10/31 v0.5l)
718
+ %% Note the code is the same as that of pxpdfpages.sty,
719
+ %% but reserved here since gentombow.sty can be used on
720
+ %% any LaTeX format
721
+ %% (cf. pxpdfpages.sty is restricted to (u)pLaTeX)
722
+ \def\pxgtmb@patch@pdfpages{%
723
+ \RequirePackage{etoolbox}
724
+ \patchcmd{\AM@output}{%
725
+ \setlength{\@tempdima}{\AM@xmargin}%
726
+ \edef\AM@xmargin{\the\@tempdima}%
727
+ \setlength{\@tempdima}{\AM@ymargin}%
728
+ \edef\AM@ymargin{\the\@tempdima}%
729
+ }{%
730
+ \setlength{\@tempdima}{\AM@xmargin\iftombow+1in\fi}%
731
+ \edef\AM@xmargin{\the\@tempdima}%
732
+ \setlength{\@tempdima}{\AM@ymargin\iftombow-1in\fi}%
733
+ \edef\AM@ymargin{\the\@tempdima}%
734
+ }
735
+ {\PackageInfo{\pxgtmb@pkgname}{Patch for pdfpages applied}}
736
+ {\PackageWarningNoLine{\pxgtmb@pkgname}{Patch for pdfpages failed}}%
737
+ }
738
+ %% however, if running (u)pLaTeX, use pxpdfpages.sty if available
739
+ \ifx\pfmtname\@undefined\else
740
+ \IfFileExists{pxpdfpages.sty}{%
741
+ \def\pxgtmb@patch@pdfpages{\RequirePackage{pxpdfpages}}%
742
+ }{}
743
+ \fi
744
+ %% do it
745
+ \AtBeginDocument{\@ifpackageloaded{pdfpages}{\pxgtmb@patch@pdfpages}{}}
746
+
747
+ \endinput