forked from abenori/jlreq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jlreq.cls
6398 lines (6147 loc) · 276 KB
/
jlreq.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%% Japanese document class based on requirements for Japanese text layout
%%
%% The package is distributed under the BSD 2-Clause License
%%
%%
% (based on JLReq 20200811 https://www.w3.org/TR/2020/NOTE-jlreq-20200811/)
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{jlreq}[2021/11/05 jlreq]
\RequirePackage{l3keys2e}
\RequirePackage{etoolbox}
\RequirePackage{jlreq-helpers}
\ExplSyntaxOn
\tl_new:N \l_jlreq_tmpa_tl
\cs_new:Nn \l_jlreq_do: {}
\str_new:N \l_jlreq_tmpa_str
\str_new:N \l_jlreq_tmpb_str
\str_new:N \l_jlreq_tmpc_str
\bool_new:N \l_jlreq_tmpa_bool
\clist_new:N \l_jlreq_tmpa_clist
\seq_new:N \l_jlreq_tmpa_seq
\dim_new:N \l_jlreq_tmpa_dim
\skip_new:N \l_jlreq_tmpa_skip
\box_new:N \l_jlreq_tmpa_box
\box_new:N \l_jlreq_tmpb_box
\box_new:N \l_jlreq_tmpc_box
\cs_set:Nn \__jlreq_undeferr:n {\ClassError{jlreq}{Trying~to~delete~\string#1~even~though~it~is~not~defined,~may~be~a~bug}{\@ehc}}
% クラスファイル内でしか使わないマクロをクラスファイル終了時に未定義にする
\seq_new:N \g__jlreq_aftercls_deletecs_seq
\seq_new:N \g__jlreq_aftercls_deleteif_seq
\cs_set:Nn \__jlreq_aftercls_addtodeletecs:N {
\seq_gput_right:Nn \g__jlreq_aftercls_deletecs_seq {#1}
}
\__jlreq_aftercls_addtodeletecs:N \__jlreq_aftercls_addtodeletecs:N
\cs_set:Nn \__jlreq_aftercls_addtodeleteif:N {
\seq_gput_right:Nn \g__jlreq_aftercls_deleteif_seq {#1}
}
\__jlreq_aftercls_addtodeletecs:N \__jlreq_aftercls_addtodeleteif:N
\AtEndOfClass{%
\seq_map_inline:Nn \g__jlreq_aftercls_deletecs_seq {
\jlreq@helper@undefcs{#1}{\__jlreq_undeferr:n}
}
\seq_map_inline:Nn \g__jlreq_aftercls_deleteif_seq {
\jlreq@helper@undefif{#1}{\__jlreq_undeferr:n}
}
\cs_undefine:N \g__jlreq_aftercls_deletecs_seq
\cs_undefine:N \g__jlreq_aftercls_deleteif_seq
\cs_undefine:N \__jlreq_undeferr:n
}
% preambleにいるかのスイッチ
\newif\ifjlreq@preamble
\jlreq@preambletrue
\AtBeginDocument{\jlreq@preamblefalse}
\def\jlreq@saveoriginalcs#1{%
\@ifundefined{#1}{
\ClassError{jlreq}{Trying~to~save~#1~but~it's~not~defined,~may~be~a~bug}{\@ehc}%
}{}
\@ifundefined{jlreq@original@#1}{}{
\ClassError{jlreq}{Trying~to~save~#1~twice,~may~be~a~bug}{\@ehc}%
}
\begingroup
\edef\jlreq@do{\noexpand\let\exp_not:c {jlreq@original@#1}=\exp_not:c {#1}}
\expandafter\endgroup
\jlreq@do
}
\def\jlreq@useoriginalcs#1{%
\jlreq@if{\ifcsname jlreq@original@#1\endcsname\fi}%
{\csname jlreq@original@#1\endcsname}%
{#1}%
}
\def\jlreq@restoreoriginalcs#1{%
\jlreq@if{\ifcsname jlreq@original@\expandafter\@gobble\string#1\endcsname\fi}%
{\expandafter\let\expandafter#1\csname jlreq@original@\expandafter\@gobble\string#1\endcsname}{}%
}
%. オプションの定義
% オプション処理の際にしか使わない変数(後でそれを元に別の変数を調整する)
% ものは\jlreq@option@<key>に格納する.
% _とかは@に変換する.
% エンジン類
\keys_define:nn { jlreq } {
uplatex .code:n = { \let\jlreq@engine=u }, uplatex .value_forbidden:n = true,
platex .code:n = { \let\jlreq@engine=p }, platex .value_forbidden:n = true,
lualatex .code:n = { \let\jlreq@engine=l }, lualatex .value_forbidden:n = true,
% 文書のタイプ
article_type .choices:nn = {article,report,book}{\def\jlreq@article@type{#1}},
article .code:n = { \def\jlreq@article@type{article} }, article .value_forbidden:n = true,
report .code:n = { \def\jlreq@article@type{report} }, report .value_forbidden:n = true,
book .code:n = { \def\jlreq@article@type{book} }, book .value_forbidden:n = true
}
%.. 基本版面.まずは紙サイズ.
\tl_new:N \g__jlreq_papersizelist_tl
\cs_set:Nn \__jlreq_addpapersize:nnn {
\exp_args:Nnnv \__jlreq_addpapersize_aux:nnn {#1}{#2}{jlreq@helper@papersizelist@#3}
}
\cs_set:Nn \__jlreq_addpapersize_aux:nnn {
\__jlreq_addpapersize_auxi:nnnn {#1}{#2}#3
}
\cs_set:Nn \__jlreq_addpapersize_auxi:nnnn {
\clist_map_inline:nn {#1} {
\tl_gput_right:Nn \g__jlreq_papersizelist_tl { { ##1 } { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} } }
}
\clist_map_inline:nn {#2} {
\keys_define:nn { jlreq } {
##1 .code:n = { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} },
##1 .value_forbidden:n = true
}
}
}
\keys_define:nn { jlreq } {
paper .code:n = {
\str_case:nVF {#1} \g__jlreq_papersizelist_tl
{
\jlreq@helper@dividebycomma{#1}%
\legacy_if:nTF { jlreq@result } {
\setlength{\paperwidth}{\dimexpr\jlreq@resulta\relax}
\setlength{\paperheight}{\dimexpr\jlreq@resultb\relax}
} {
\ClassError { jlreq } { The~paper~#1~is~unknown } {\@ehc}
}
}
}
}
\cs_set:Nn \__jlreq_addpapersize_withwarning:nnnn {
\exp_args:Nnnv \__jlreq_addpapersize_withwarning_aux:nnnn {#1}{#2}{jlreq@helper@papersizelist@#3}{#4}
}
\cs_set:Nn \__jlreq_addpapersize_withwarning_aux:nnnn {
\__jlreq_addpapersize_withwarning_auxi:nnnnn {#1}{#2}#3{#4}
}
\cs_set:Nn \__jlreq_addpapersize_withwarning_auxi:nnnnn {
\cs_set:Nn \l__jlreq_tmpa:n {
\ClassWarningNoLine{jlreq}{#5}
}
\clist_map_inline:nn {#1} {
\tl_gput_right:Nx \g__jlreq_papersizelist_tl { { ##1 } {
\exp_not:o { \l__jlreq_tmpa:n {##1} }
\exp_not:n { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} }
} }
}
\clist_map_inline:nn {#2} {
\cs_set:Nx \l__jlreq_do: {
\exp_not:N \keys_define:nn { jlreq } {
##1 .code:n = {
\exp_not:o { \l__jlreq_tmpa:n {##1} }
\exp_not:n { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} }
},
##1 .value_forbidden:n = true
}
}
\l__jlreq_do:
}
}
\tl_set:Nn \g__jlreq_papersizechangeddate_tl{2021-11-05}
\cs_set:Nn \__jlreq_addpapersize_withjisBwarning:nnnn {
\__jlreq_addpapersize_withwarning:nnnn {#1} {#2} {#3} {The~option~`##1'~means~the~papersize~in~the~ISO~B-series,~not~in~the~JIS~B-series.~This~behavior~was~changed~from~jlreq~version~\g__jlreq_papersizechangeddate_tl.~Use~`paper=#4'~for~the~JIS-B-series.}
}
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize:nnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_aux:nnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_auxi:nnnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning:nnnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning_aux:nnnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning_auxi:nnnnn
\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withjisBwarning:nnnn
\__jlreq_aftercls_addtodeletecs:N \g__jlreq_papersizelist_tl
% 紙サイズ一覧.b*はJIS B.
\__jlreq_addpapersize:nnn{a0paper}{}{a0paper}
\__jlreq_addpapersize:nnn{a1paper}{}{a1paper}
\__jlreq_addpapersize:nnn{a2paper}{}{a2paper}
\__jlreq_addpapersize:nnn{a3paper}{a3paper}{a3paper}
\__jlreq_addpapersize:nnn{a4paper}{a4paper}{a4paper}
\__jlreq_addpapersize:nnn{a5paper}{a5paper}{a5paper}
\__jlreq_addpapersize:nnn{a6paper}{a6paper}{a6paper}
\__jlreq_addpapersize:nnn{a7paper}{}{a7paper}
\__jlreq_addpapersize:nnn{a8paper}{}{a8paper}
\__jlreq_addpapersize:nnn{a9paper}{}{a9paper}
\__jlreq_addpapersize:nnn{a10paper}{}{a10paper}
\__jlreq_addpapersize:nnn{a0,A0}{}{a0paper}
\__jlreq_addpapersize:nnn{a1,A1}{}{a1paper}
\__jlreq_addpapersize:nnn{a2,A2}{}{a2paper}
\__jlreq_addpapersize:nnn{a3,A3}{}{a3paper}
\__jlreq_addpapersize:nnn{a4,A4}{}{a4paper}
\__jlreq_addpapersize:nnn{a5,A5}{}{a5paper}
\__jlreq_addpapersize:nnn{a6,A6}{}{a6paper}
\__jlreq_addpapersize:nnn{a7,A7}{}{a7paper}
\__jlreq_addpapersize:nnn{a8,A8}{}{a8paper}
\__jlreq_addpapersize:nnn{a9,A9}{}{a9paper}
\__jlreq_addpapersize:nnn{a10,A10}{}{a10paper}
\__jlreq_addpapersize:nnn{b0paper}{}{b0paper}
\__jlreq_addpapersize:nnn{b1paper}{}{b1paper}
\__jlreq_addpapersize:nnn{b2paper}{}{b2paper}
\__jlreq_addpapersize:nnn{b3paper}{}{b3paper}
\__jlreq_addpapersize:nnn{b4paper}{}{b4paper}
\__jlreq_addpapersize:nnn{b5paper}{}{b5paper}
\__jlreq_addpapersize:nnn{b6paper}{}{b6paper}
\__jlreq_addpapersize:nnn{b7paper}{}{b7paper}
\__jlreq_addpapersize:nnn{b8paper}{}{b8paper}
\__jlreq_addpapersize:nnn{b9paper}{}{b9paper}
\__jlreq_addpapersize:nnn{b10paper}{}{b10paper}
\__jlreq_addpapersize:nnn{c2paper}{}{c2paper}
\__jlreq_addpapersize:nnn{c3paper}{}{c3paper}
\__jlreq_addpapersize:nnn{c4paper}{}{c4paper}
\__jlreq_addpapersize:nnn{c5paper}{}{c5paper}
\__jlreq_addpapersize:nnn{c6paper}{}{c6paper}
\__jlreq_addpapersize:nnn{c7paper}{}{c7paper}
\__jlreq_addpapersize:nnn{c8paper}{}{c8paper}
\__jlreq_addpapersize:nnn{c2,C2}{}{c2paper}
\__jlreq_addpapersize:nnn{c3,C3}{}{c3paper}
\__jlreq_addpapersize:nnn{c4,C4}{}{c4paper}
\__jlreq_addpapersize:nnn{c5,C5}{}{c5paper}
\__jlreq_addpapersize:nnn{c6,C6}{}{c6paper}
\__jlreq_addpapersize:nnn{c7,C7}{}{c7paper}
\__jlreq_addpapersize:nnn{c8,C8}{}{c8paper}
\__jlreq_addpapersize_withjisBwarning:nnnn{b0,B0}{}{b0paper}{b0j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b1,B1}{}{b1paper}{b1j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b2,B2}{}{b2paper}{b2j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b3,B3}{}{b3paper}{b3j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b4,B4}{}{b4paper}{b4j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b5,B5}{}{b5paper}{b5j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b6,B6}{}{b6paper}{b6j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b7,B7}{}{b7paper}{b7j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b8,B8}{}{b8paper}{b8j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b9,B9}{}{b9paper}{b9j}
\__jlreq_addpapersize_withjisBwarning:nnnn{b10,B10}{}{b10paper}{b10j}
\__jlreq_addpapersize_withjisBwarning:nnnn{}{b4paper}{b4paper}{b4j}
\__jlreq_addpapersize_withjisBwarning:nnnn{}{b5paper}{b5paper}{b5j}
\__jlreq_addpapersize_withjisBwarning:nnnn{}{b6paper}{b6paper}{b6j}
\__jlreq_addpapersize:nnn{b0j}{}{b0j}
\__jlreq_addpapersize:nnn{b1j}{}{b1j}
\__jlreq_addpapersize:nnn{b2j}{}{b2j}
\__jlreq_addpapersize:nnn{b3j}{}{b3j}
\__jlreq_addpapersize:nnn{b4j}{}{b4j}
\__jlreq_addpapersize:nnn{b5j}{}{b5j}
\__jlreq_addpapersize:nnn{b6j}{}{b6j}
\__jlreq_addpapersize:nnn{b7j}{}{b7j}
\__jlreq_addpapersize:nnn{b8j}{}{b8j}
\__jlreq_addpapersize:nnn{b9j}{}{b9j}
\__jlreq_addpapersize:nnn{b10j}{}{b10j}
\__jlreq_addpapersize:nnn{a4var}{}{a4var}
\__jlreq_addpapersize:nnn{b5var}{}{b5var}
\__jlreq_addpapersize:nnn{letter,letterpaper}{letterpaper}{letterpaper}
\__jlreq_addpapersize:nnn{legal,legalpaper}{legalpaper}{legalpaper}
\__jlreq_addpapersize:nnn{executive,executivepaper}{executivepaper}{executivepaper}
\__jlreq_addpapersize:nnn{ansiapaper}{}{ansiapaper}
\__jlreq_addpapersize:nnn{ansibpaper}{}{ansibpaper}
\__jlreq_addpapersize:nnn{ansicpaper}{}{ansicpaper}
\__jlreq_addpapersize:nnn{ansidpaper}{}{ansidpaper}
\__jlreq_addpapersize:nnn{ansiepaper}{}{ansiepaper}
\__jlreq_addpapersize:nnn{hagaki}{}{hagaki}
%.. フォントサイズ,行長,1ページあたりの行数で基本版面のサイズを決める(2.4.1.a)
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@fontsize
\keys_define:nn { jlreq } {
fontsize .tl_set:N = \jlreq@option@fontsize,
10pt .code:n = {\def\jlreq@option@fontsize{10pt}}, 10pt .value_forbidden:n = true,
11pt .code:n = {\def\jlreq@option@fontsize{11pt}}, 11pt .value_forbidden:n = true,
12pt .code:n = {\def\jlreq@option@fontsize{12pt}}, 12pt .value_forbidden:n = true,
jafontsize .tl_set:N = \jlreq@option@jafontsize,
jafontscale .tl_set:N = \jlreq@option@jafontscale
}
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@jafontsize
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@jafontscale
%.. 行の長さ
\keys_define:nn { jlreq } { line_length .tl_set:N = \jlreq@option@line@length }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@line@length
%.. 1ページあたりの行数
\keys_define:nn { jlreq } { number_of_lines .tl_set:N = \jlreq@option@number@of@lines }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@number@of@lines
% 地の空き量,のどの空き量で配置位置を決める(2.4.1.b)省略されたら中央配置.
%.. 天
\keys_define:nn { jlreq } { head_space .tl_set:N = \jlreq@option@head@space }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@head@space
%.. 地
\keys_define:nn { jlreq } { foot_space .tl_set:N = \jlreq@option@foot@space }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@foot@space
%.. のど
\keys_define:nn { jlreq } { gutter .tl_set:N = \jlreq@option@gutter }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@gutter
%.. 小口
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@fore@edge
\keys_define:nn { jlreq } {
fore_edge .tl_set:N = \jlreq@option@fore@edge,
fore-edge .tl_set:N = \jlreq@option@fore@edge
}
%.. 柱とノンブル
% 本文とヘッダ/フッタの間の空き
\keys_define:nn { jlreq } { headfoot_verticalposition .tl_set:N = \jlreq@option@headfoot@verticalpos}
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@headfoot@verticalpos
% 柱やノンブルの左右の空き
\keys_define:nn { jlreq } { headfoot_sidemargin .tl_set:N = \jlreq@headfoot@sidemargin}
%.. 段間
\keys_define:nn { jlreq } { column_gap .tl_set:N = \jlreq@option@column@gap}
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@column@gap
%.. 行送り,指定無しの場合は文字サイズの1.7倍とする.(1.5から2倍が好ましい:2.4.2.d 注3)
\keys_define:nn { jlreq } {
baselineskip .tl_set:N = \jlreq@option@baselineskip,
linegap .code:n = { \def\jlreq@option@baselineskip{1zw + #1} }
}
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@baselineskip
%.. 組み方系
% 行頭に括弧が来たときの配置:3.1.5
% 段落頭指定_折り返し行頭指定 で与える.
\keys_define:nn { jlreq } { open_bracket_pos .choices:nn = {zenkaku_tentsuki,zenkakunibu_nibu,nibu_tentsuki}{\def\jlreq@open@bracket@pos{#1}} }
% ぶら下げ組みをするか:3.8.2 注1
\newif\ifjlreq@burasage\jlreq@burasagefalse
\keys_define:nn { jlreq } { hanging_punctuation .code:n = {\jlreq@burasagetrue}, hanging_punctuation .value_forbidden:n = true}
% jsarticleと同じkanjiskipを使う
\newif\ifjlreq@narrow@kanjiskip\jlreq@narrow@kanjiskipfalse
\keys_define:nn { jlreq } { narrow_kanjiskip .code:n = {\jlreq@narrow@kanjiskiptrue}, narrow_kanjiskip .value_forbidden:n = true}
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@narrow@kanjiskip
%.. 注
% 傍注のタイプ
\keys_define:nn { jlreq } { sidenote_length .tl_set:N = \jlreq@option@sidenote@length }
\__jlreq_aftercls_addtodeletecs:N \jlreq@option@sidenote@length
%.. 逆ノンブル
\newif\ifjlreq@option@use@reverse@pagination
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@option@use@reverse@pagination
\jlreq@option@use@reverse@paginationfalse
\keys_define:nn { jlreq } { use_reverse_pagination .code:n = {\jlreq@option@use@reverse@paginationtrue}, use_reverse_pagination .value_forbidden:n = true }
%.. もろもろ
\newif\if@restonecol\@restonecolfalse
\newif\if@titlepage\@titlepagefalse
\newif\if@landscape\@landscapefalse
\newif\if@tate \@tatefalse
\newif\ifjlreq@option@titlepage \jlreq@option@titlepagefalse % titlepageかnotitlepageかが指定された
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@option@titlepage
\keys_define:nn { jlreq } {
landscape .code:n = {\@landscapetrue}, landscape .value_forbidden:n = true,
tombo .code:n = {\ClassWarningNoLine{jlreq}{The~option~`tombo'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}},
tombow .code:n = {\ClassWarningNoLine{jlreq}{The~option~`tombow'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}},
mentuke .code:n = {\ClassWarningNoLine{jlreq}{The~option~`mentuke'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}},
tate .code:n = { \@tatetrue }, tate .value_forbidden:n = true
}
\newif\ifjlreq@option@twoside\jlreq@option@twosidefalse % onesideかtwosideが指定された
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@option@twoside
\keys_define:nn { jlreq } {
oneside .code:n = { \@twosidefalse\@mparswitchfalse\jlreq@option@twosidetrue }, oneside .value_forbidden:n = true,
twoside .code:n = { \@twosidetrue\@mparswitchtrue\jlreq@option@twosidetrue }, twoside .value_forbidden:n = true,
onecolumn .code:n = { \@twocolumnfalse }, onecolumn .value_forbidden:n = true,
twocolumn .code:n = { \@twocolumntrue }, twocolumn .value_forbidden:n = true,
titlepage .code:n = { \jlreq@option@titlepagetrue\@titlepagetrue }, titlepage .value_forbidden:n = true,
notitlepage .code:n = { \jlreq@option@titlepagetrue\@titlepagefalse }, notitlepage .value_forbidden:n = true,
draft .code:n = { \setlength\overfullrule{5pt} }, draft .value_forbidden:n = true,
final .code:n = { \setlength\overfullrule{0pt} }, final .value_forbidden:n = true
}
\newif\if@openright
\newif\ifjlreq@option@open \jlreq@option@openfalse % openrightかopenanyが指定された
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@option@open
\keys_define:nn { jlreq } {
openright .code:n = { \@openrighttrue\jlreq@option@opentrue }, openright .value_forbidden:n = true,
openany .code:n = { \@openrightfalse\jlreq@option@opentrue }, openany .value_forbidden:n = true,
leqno .code:n = { \input{leqno.clo } }, leqno .value_forbidden:n = true,
fleqn .code:n = { \input{fleqn.clo } }, fleqn .value_forbidden:n = true
}
\newif\ifjlreq@option@enablejfam \jlreq@option@enablejfamtrue
\__jlreq_aftercls_addtodeleteif:N \ifjlreq@option@enablejfam
\keys_define:nn { jlreq } { disablejfam .code:n = { \jlreq@option@enablejfamfalse }, disablejfam .value_forbidden:n = true}
\def\jlreq@note#1{}
\keys_define:nn { jlreq } { jlreq_notes .code:n = { \def\jlreq@note##1{\message{^^JJLReq note: ##1^^J}}}, jlreq_notes .value_forbidden:n = true}
\keys_set:nn { jlreq } {
article_type=article,paper=a4,
number_of_lines={},line_length = {},
head_space={},foot_space={},gutter={},fore_edge={},
jafontsize={},jafontscale={1},baselineskip={17zw/10},
sidenote_length=0pt,column_gap={2zw},
headfoot_verticalposition = {},headfoot_sidemargin={0pt},
open_bracket_pos=zenkaku_tentsuki,
onecolumn,final }
\ProcessKeysOptions { jlreq }
\legacy_if:nF { jlreq@option@titlepage } {
\str_if_eq:VnTF \jlreq@article@type { article } { \@titlepagefalse } { \@titlepagetrue }
}
\legacy_if:nF { jlreq@option@open } {
\str_if_eq:VnTF \jlreq@article@type { book } { \@openrighttrue } { \@openrightfalse }
}
% articleではopenrightは効かない.
\str_if_eq:VnT \jlreq@article@type { article } {
\legacy_if:nT { @openright } {
\ClassWarningNoLine { jlreq } { The~option~`openright'~is~ignored~in~article }
\@openrightfalse
}
}
\legacy_if:nF { jlreq@option@twoside } {
\str_if_eq:VnTF \jlreq@article@type { book } { \@twosidetrue } { \@twosidefalse }
}
\tl_new:N \g__jlreq_jlreqsetup_finally_tl
\NewDocumentCommand{\jlreqsetup} { +m } {
\keys_set:nn { jlreqsetup } {#1}
\tl_use:N \g__jlreq_jlreqsetup_finally_tl
}
% \jlreqsetupの最後に必ず実行される処理を入れる.
\cs_set:Nn \__jlreq_jlreqsetup_addtofinally:n { \tl_gput_right:Nx \g__jlreq_jlreqsetup_finally_tl { \exp_not:n {#1} } }
\__jlreq_aftercls_addtodeletecs:N \__jlreq_jlreqsetup_addtofinally:n
\@onlypreamble\jlreqsetup
% エンジンの設定
\ifx\jlreq@engine\@undefined
\jlreq@helper@guessengine
\let\jlreq@engine=\jlreq@result
\message{jlreq~guessed~engine:~
\ifx l\jlreq@engine lualatex\fi
\ifx p\jlreq@engine platex\fi
\ifx u\jlreq@engine uplatex\fi
}%
\fi
%.. JFMとluatexjaのロード
\ifx l\jlreq@engine
\def\ltj@stdyokojfm{jlreq}
\def\ltj@stdtatejfm{jlreqv}
\directlua{jlreq = {}}
% この値は後でjfm-jlreq内で読む
\directlua{jlreq.open_bracket_pos = [[\jlreq@open@bracket@pos]]}
\ifjlreq@burasage\directlua{jlreq.burasage = true}\else\directlua{jlreq.burasage = false}\fi
% luatexjaのロード
\ifjlreq@option@enablejfam
\RequirePackage{luatexja}
\else
\RequirePackage[disablejfam]{luatexja}
\fi
\RequirePackage{luatexja-adjust}
\ltjenableadjust[lineend=extended,priority=true]
\ltjsetparameter{stretch_priority={kanjiskip=0,xkanjiskip=10}}
\ltjsetparameter{shrink_priority={kanjiskip=0,xkanjiskip=-30}}
\else
\RequirePackage{everyhook}
\def\jlreq@jfmname@prefix{}
\__jlreq_aftercls_addtodeletecs:N \jlreq@jfmname@prefix
\ifjlreq@burasage\edef\jlreq@jfmname@prefix{b\jlreq@jfmname@prefix}\fi
\str_if_eq:VnT \jlreq@open@bracket@pos { zenkakunibu_nibu } {
\edef\jlreq@jfmname@prefix { \jlreq@jfmname@prefix z }
}
\ifx u\jlreq@engine\edef\jlreq@jfmname@prefix{u\jlreq@jfmname@prefix}\fi
\edef\jlreq@jfmname{\jlreq@jfmname@prefix jlreq} % JFMの名前
\edef\jlreq@jfmnameg{\jlreq@jfmname@prefix jlreqg} % ゴシックなJFMの名前
\__jlreq_aftercls_addtodeletecs:N \jlreq@jfmname
\__jlreq_aftercls_addtodeletecs:N \jlreq@jfmnameg
\fi
% (u)pLaTeXの場合ここで初めて\epTeXinputencodingが発行されるので,
% これ以前には和文は使えない.
\ifx l\jlreq@engine\else
\epTeXinputencoding utf8
\def\zw{zw}\def\zh{zh}
% http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1508&parent=8435
\if@tate\AtEndPreamble{\par}\fi
\fi
\let\jlreq@zw=\zw
\let\jlreq@zh=\zh
\if@tate
\AtBeginDocument{\tate\message{《縦組モード》}\adjustbaseline}
\fi
% \jlreq@gol(Gyo Okuri Length), \jlreq@mol (Moji Okuri Length)を定義
\let\jlreq@gol=\zh
\let\jlreq@mol=\zw
%. helper2(エンジン依存系:和文文字を含むものもこれ以降)
% #1のboxを今の真ん中に配置する.
\def\jlreq@box@putcenter#1{%
\begingroup
\jlreq@tempdima=\dimexpr(\ht#1 - \dp#1)/2\relax
\setbox\jlreq@tempboxa=\hbox{阿}%
\edef\jlreq@do{%
\noexpand\lower\the\dimexpr(\jlreq@tempdima - (\ht\jlreq@tempboxa - \dp\jlreq@tempboxa)/2)\relax\unexpanded{\box#1}%
}%
\expandafter\endgroup
\jlreq@do
}
% #1の先頭が文字か
\long\def\jlreq@ifletter#1{%
\jlreq@iffirsttoken{#1}{ }{\@secondoftwo}{%
\expandafter\expandafter\expandafter\jlreq@helper@ifletter\jlreq@getfirsttoken#1\jlreq@uniqtoken{}\jlreq@endmark@
}%
}
\long\def\jlreq@helper@ifletter#1{%
\jlreq@if{%
\ifnum
0%
\ifcat 阿\noexpand #11\fi
\ifcat あ\noexpand #11\fi
\ifcat (\noexpand #11\fi
\ifcat A\noexpand #11\fi
\ifcat 1\noexpand #11\fi
>0~
\fi}%
}
% 組方向を判定
% \jlreq@if(y|t)(dir|box)を定義する.
\jlreq@if{\ifx l\jlreq@engine\fi}{
\def\jlreq@ifydir { \int_compare:nTF { \ltjgetparameter{direction} == 4 } }
\def\jlreq@iftdir { \int_compare:nTF { (\ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8) == 3 } }
\def\jlreq@ifybox#1{ \int_compare:nTF { \ltjgetparameter{boxdir}{#1} == 4 } }
\def\jlreq@iftbox#1{ \int_compare:nTF { (\ltjgetparameter{boxdir}{#1}-(\ltjgetparameter{boxdir}{#1}/8)*8) == 3 } }
}{
\def\jlreq@ifydir{\jlreq@if{\ifydir\fi}}
\def\jlreq@iftdir{\jlreq@if{\iftdir\fi}}
\def\jlreq@ifybox#1{\jlreq@if{\ifybox#1\fi}}
\def\jlreq@iftbox#1{\jlreq@if{\iftbox#1\fi}}
}
% 左ページであるか
% #1 : odd or even or ページ数
\def\jlreq@ifleftpage#1{%
\bool_if:nTF { ( \legacy_if_p:n { @tate } &&
\bool_lazy_or_p:nn { \str_if_eq_p:ee {#1} { odd } }
{ \bool_lazy_and_p:nn { ! \str_if_eq_p:ee {#1} { even } } { \int_if_odd_p:n {#1} } }
) || ( ! \legacy_if_p:n { @tate } &&
\bool_lazy_or_p:nn { \str_if_eq_p:ee {#1} { even } }
{ \bool_lazy_and_p:nn { ! \str_if_eq_p:ee {#1} { odd } } { ! \int_if_odd_p:n {#1} } }
) }
}
\ifx l\jlreq@engine
\def\jlreq@getpostbreakpenalty#1{\ltjgetparameter{postbreakpenalty}{#1}}
\else
\def\jlreq@getpostbreakpenalty#1{\postbreakpenalty#1}
\fi
% 現在行の残りを得る.
\ifx l\jlreq@engine
% 以下のコードはLuaTeX-jaのバグ?に依存している
% https://ja.osdn.net/projects/luatex-ja/ticket/36489
\def\jlreq@calc@current@linewidth@onecolumn{%
\dimexpr
\jlreq@reference@ref{jlreq@[email protected].\the\jlreq@reference@count}{0} sp - \@totalleftmargin -
\ifodd\jlreq@currentpage
\oddsidemargin
\else
\evensidemargin
\fi
\iftombow -1in \fi
- \pdfvariable horigin - \hoffset
\relax
}
\else
% トンボ出力時にはjlreq-trimmarksであることを仮定する.
% 新しいpLaTeXに対しては,jlreq-trimmarksは内部の1inを1trueinに書き換える
\@ifundefined{@tombowreset@@paper}{
\def\jlreq@tombow@adjust{\iftombow -1in \fi}
}{
\def\jlreq@tombow@adjust{\iftombow -1truein \fi}
}
\def\jlreq@calc@current@linewidth@onecolumn{%
\dimexpr
\jlreq@ifydir{%
\jlreq@reference@ref{jlreq@[email protected].\the\jlreq@reference@count}{0} sp - \hoffset
\ifodd\jlreq@currentpage
- \oddsidemargin
\else
- \evensidemargin
\fi
}{%
\ifdim\pdfpagewidth=0pt
\paperheight
\else
\pdfpageheight
\fi
- \topmargin - \headheight - \headsep - \voffset
- \jlreq@reference@ref{jlreq@[email protected].\the\jlreq@reference@count}{0} sp
}%
\jlreq@tombow@adjust
- \@totalleftmargin - 1in
\relax
}
\fi
\def\jlreq@calc@current@linewidth{%
\dimexpr\jlreq@calc@current@linewidth@onecolumn
\if@twocolumn
\ifdim\jlreq@calc@current@linewidth@onecolumn<\dimexpr\linewidth+\columnsep\relax\else
- \linewidth - \columnsep
\fi
\fi
\relax
}
\newdimen\jlreq@current@linewidth
\newdimen\jlreq@rest@linewidth
% この命令以降,次にこの命令を実行する前まで\jlreq@current@linewidth/\jlreq@rest@linewidthで
% この行の行頭からの長さ/残りの長さが取得できる
\jlreq@ifprimitive{\pdfsavepos}{\jlreq@tempatrue}{\jlreq@tempafalse}
\edef\jlreq@savepos@for@rest@linewidth{\unexpanded{%
\jlreq@setcurrentpage
\global\advance\jlreq@reference@count by 1
}%
\ifjlreq@tempa
\unexpanded{%
\pdfsavepos
\jlreq@reference@label{jlreq@[email protected].\the\jlreq@reference@count}{\noexpand\the\noexpand\pdflastxpos}%
\jlreq@reference@label{jlreq@[email protected].\the\jlreq@reference@count}{\noexpand\the\noexpand\pdflastypos}%
}%
\else
\unexpanded{%
\savepos
\jlreq@reference@label{jlreq@[email protected].\the\jlreq@reference@count}{\noexpand\the\noexpand\lastxpos}%
\jlreq@reference@label{jlreq@[email protected].\the\jlreq@reference@count}{\noexpand\the\noexpand\lastypos}%
}%
\fi
\unexpanded{%
\global\jlreq@current@linewidth=\jlreq@calc@current@linewidth
\global\jlreq@rest@linewidth=\dimexpr\linewidth - \jlreq@current@linewidth\relax
\edef\jlreq@savepos@iflabelundefined{\jlreq@reference@ifexist{jlreq@[email protected].\the\jlreq@reference@count}{\noexpand\@secondoftwo}{\noexpand\@firstoftwo}}%
}%
}
\ifx l\jlreq@engine
\newcommand*{\lastnodechar}{\directlua{luatexja.pltx_composite_last_node_char()}}% undocumentedな機能を使っている
\fi
% #1と#2の間に入るjmglue((x)kanjiskipも)を\jlreq@resultskipに入れる
\ifx l\jlreq@engine
\def\jlreq@calc@jfmglue#1#2{%
\begingroup
\setbox\jlreq@tempboxa=\hbox{\inhibitglue #1\inhibitglue\hbox{}\inhibitglue#2\inhibitglue}%
\setbox\jlreq@tempboxb=\hbox{\inhibitglue #1#2\inhibitglue}%
\edef\jlreq@do{\noexpand\jlreq@resultskip=\the\dimexpr\wd\jlreq@tempboxb - \wd\jlreq@tempboxa\relax\noexpand\relax}%
\jlreq@do
\directlua{
local~width = 0~
local~stretch = 0~
local~shrink = 0~
local~n = tex.box["jlreq@tempboxb"].head~
while~n~do~
% すべてのglueの和を計算する.
if~n.id == node.id("glue")~then~
width = width + n.width~
stretch = stretch + n.stretch~
shrink = shrink + n.shrink~
end~
n = n.next~
end~
tex.setglue("jlreq@tempskipa",width,stretch,shrink)
}%
% TeXで計測した物と一致していなければTeXでの方を信じる
\ifdim\jlreq@resultskip=\jlreq@tempskipa
\edef\jlreq@do{\noexpand\jlreq@resultskip=\the\jlreq@tempskipa\relax}%
\fi
\expandafter\endgroup
\jlreq@do
}
\else
\def\jlreq@calc@jfmglue#1#2{%
\begingroup
\setbox\jlreq@tempboxa=\hbox{\inhibitglue #1\inhibitglue\hbox{}\inhibitglue#2\inhibitglue}%
\setbox\jlreq@tempboxb=\hbox{\inhibitglue #1#2\inhibitglue}%
\edef\jlreq@do{\noexpand\jlreq@resultskip=\the\dimexpr\wd\jlreq@tempboxb - \wd\jlreq@tempboxa\relax\noexpand\relax}%
\expandafter\endgroup
\jlreq@do
}
\fi
\newcount\jlreq@lastnodechar
% \jlreq@fixjfm<次の文字>の形で使う.
% jlreq@lastnodecharに入っている値と次のトークン(\futureletで得る)の間に入るJFMグルー等を挿入する
\def\jlreq@fixjfm{%
\begingroup
\ifnum\jlreq@lastnodechar>-1
\def\jlreq@do{\futurelet\jlreq@nextchar\jlreq@insertjfm}%
\else\def\jlreq@do{}\fi
\expandafter\endgroup
\jlreq@do
}
% \jlreq@nextcharと\jlreq@lastnodecharの間のJFMグルーを挿入
\def\jlreq@insertjfm{%
\ifnum\jlreq@getpostbreakpenalty{\jlreq@lastnodechar}=0\else\penalty\jlreq@getpostbreakpenalty{\jlreq@lastnodechar}\fi
\begingroup
\def\jlreq@do{}%
\jlreq@getfirsttoken@expandmacros{\jlreq@nextchar}{\jlreq@tempa}%
\expandafter\jlreq@ifletter\expandafter{\jlreq@tempa}{%
\jlreq@calc@jfmglue{\char\jlreq@lastnodechar}{\jlreq@tempa}%
% \message{fixjfm,~before~lastnodechar~=~\the\jlreq@lastnodechar,~after~=~\meaning\jlreq@nextchar,~Insert:~\the\jlreq@resultskip}
\edef\jlreq@do{%
\noexpand\hskip\the\jlreq@resultskip\space
\noexpand\inhibitglue
}%
}{}%
\expandafter\endgroup
\jlreq@do
}
\ifx l\jlreq@engine
\def\jlreq@divide#1#2{%
\jlreq@resultdimen=\directlua{tex.print(tostring(\strip@pt\dimexpr #1\relax/\strip@pt\dimexpr #2\relax) .. "pt~")}%
}
\else
\let\jlreq@divide=\jlreq@helper@divide
\fi
%. 文字関連設定
% ダミー
\def\@ptsize{0}
%.. (x)kanjiskip
\ifjlreq@narrow@kanjiskip
\providecommand*{\jlreqkanjiskip}{0pt~plus~.1\jlreq@zw ~minus~.01\jlreq@zw}
\else
\providecommand*{\jlreqkanjiskip}{0pt~plus~0.25\jlreq@zw ~minus~0pt}
\fi
\providecommand*{\jlreqxkanjiskip}{0.25\jlreq@zw ~plus~0.25\jlreq@zw ~minus~0.125\jlreq@zw}
\jlreq@if{\ifx l\jlreq@engine\fi}{
\AtBeginDocument{%
\ltjsetparameter{kanjiskip=\jlreqkanjiskip}%
\ltjsetparameter{xkanjiskip=\jlreqxkanjiskip}%
}
}{
\AtBeginDocument{%
\kanjiskip=\jlreqkanjiskip
\xkanjiskip=\jlreqxkanjiskip
}
}
% フォントサイズを設定
\newdimen\jlreq@fontsize
\newdimen\jlreq@jafontsize
\ifx l\jlreq@engine
% Q,zw,zhが正しく扱われるようになる.\dimexprつきに展開される.
\def\jlreq@expand@optionfontsize#1{%
\dimexpr\directlua{
local~act = string.char(92)~
local~s = [[#1]]~
s = s:gsub("[QH]",act .. "dimexpr 0.25mm" .. act .. "relax")~
tex.print(s)~
}\relax
}%
\else
\def\jlreq@expand@optionfontsize#1{\dimexpr#1\relax}
\fi
\__jlreq_aftercls_addtodeletecs:N \jlreq@expand@optionfontsize
\ifx\jlreq@option@fontsize\@empty
\ifx\jlreq@option@jafontsize\@empty
\jlreq@fontsize=10pt
\jlreq@jafontsize=\jlreq@option@jafontscale\jlreq@fontsize
\else
\setlength{\jlreq@jafontsize}{\jlreq@expand@optionfontsize{\jlreq@option@jafontsize}}
\jlreq@divide{\jlreq@jafontsize}{\jlreq@option@jafontscale pt}
\jlreq@fontsize=\jlreq@resultdimen
\fi
\else
\setlength{\jlreq@fontsize}{\jlreq@expand@optionfontsize{\jlreq@option@fontsize}}
\ifx\jlreq@option@jafontsize\@empty
\jlreq@jafontsize=\jlreq@option@jafontscale\jlreq@fontsize
\else
\setlength{\jlreq@jafontsize}{\jlreq@expand@optionfontsize{\jlreq@option@jafontsize}}
\fi
\fi
% 行頭の括弧は \jlreq@open@bracket@before@space \inhibitglue 「みたいにする.
\str_if_eq:VnTF \jlreq@open@bracket@pos { zenkakunibu_nibu } {
\def\jlreq@open@bracket@before@space{\hskip\glueexpr-.5\jlreq@zw\relax}
}{
\def\jlreq@open@bracket@before@space{}
}
\ifx p\jlreq@engine
\def\jlreq@yokokanjiencoding{JY1}
\def\jlreq@tatekanjiencoding{JT1}
\fi
\ifx u\jlreq@engine
\def\jlreq@yokokanjiencoding{JY2}
\def\jlreq@tatekanjiencoding{JT2}
\fi
\ifx l\jlreq@engine
\def\jlreq@yokokanjiencoding{JY3}
\def\jlreq@tatekanjiencoding{JT3}
\fi
\jlreq@divide{\jlreq@jafontsize}{\jlreq@fontsize}
\edef\jlreq@jafontscale{\strip@pt\jlreq@resultdimen}
\__jlreq_aftercls_addtodeletecs:N \jlreq@jafontscale
\ifx l\jlreq@engine
\jlreq@saveoriginalcs{DeclareFontShape}
\def\DeclareFontShape#1#2#3#4#5#6{
\group_begin:
\bool_if:nT { \str_if_eq_p:nn {#1} {JY3} || \str_if_eq_p:nn {#1} {JT3} } {
\tl_set:Nx \l_jlreq_tmpa_tl {#5}
\tl_if_in:NnTF \l_jlreq_tmpa_tl { jfm=jlreq} {
\tl_if_in:NnTF \l_jlreq_tmpa_tl { jfm=jlreqv }{
\tl_replace_all:Nnn \l_jlreq_tmpa_tl { jfm=jlreqv } { jfm=jlreqv-jidori }
}{
\tl_replace_all:Nnn \l_jlreq_tmpa_tl { jfm=jlreq } { jfm=jlreq-jidori }
}
\cs_set:Nx \l_jlreq_do: {
\exp_not:n{ \jlreq@useoriginalcs{DeclareFontShape} {#1} {#2} {#3} { #4-jidori } }
{ \tl_use:N \l_jlreq_tmpa_tl } {#6}
}
}{
\tl_if_in:NnT \l_jlreq_tmpa_tl {<->ssub} {
\cs_set:Nn \l_jlreq_do: {\jlreq@useoriginalcs{DeclareFontShape} {#1} {#2} {#3} { #4-jidori } {#5} {#6} }
}
}
}
\exp_after:wN \group_end: \l_jlreq_do:
\jlreq@useoriginalcs{DeclareFontShape} {#1} {#2} {#3} {#4} {#5} {#6}
}
\DeclareFontShape{JY3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont :jfm=jlreq;script=latn;-kern}{}
\DeclareFontShape{JY3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont :jfm=jlreq;script=latn;-kern}{}
\DeclareFontShape{JT3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont :jfm=jlreqv;script=latn;-kern}{}
\DeclareFontShape{JT3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont :jfm=jlreqv;script=latn;-kern}{}
\else
\DeclareFontShape{\jlreq@yokokanjiencoding}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmname}{}
\DeclareFontShape{\jlreq@yokokanjiencoding}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmnameg}{}
\DeclareFontShape{\jlreq@tatekanjiencoding}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmname-v}{}
\DeclareFontShape{\jlreq@tatekanjiencoding}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmnameg-v}{}
\edef\jlreq@tempa{\ifx u\jlreq@engine u\fi}
\DeclareFontShape{\jlreq@yokokanjiencoding}{mc}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreq-jidori}{}
\DeclareFontShape{\jlreq@yokokanjiencoding}{gt}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreqg-jidori}{}
\DeclareFontShape{\jlreq@tatekanjiencoding}{mc}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreq-v-jidori}{}
\DeclareFontShape{\jlreq@tatekanjiencoding}{gt}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreqg-v-jidori}{}
\fi
\exp_args:Nx \clist_map_inline:nn {\jlreq@yokokanjiencoding,\jlreq@tatekanjiencoding} {% #1 = encoding
\clist_map_inline:nn { n,it,sl,sc } {% ##1 = shape
\clist_map_inline:nn { m,b,bx,sb,c } {% ####1 = series
\bool_if:nF { \str_if_eq_p:nn {##1} {n} && \str_if_eq_p:nn {####1} {m} } {
\DeclareFontShape{#1}{gt}{####1}{##1}{<->ssub*gt/m/n}{}
}
}
\clist_map_inline:nn { bx,b,sb } {% ####1 = series
\DeclareFontShape{#1}{mc}{####1}{##1}{<->ssub*gt/m/n}{}
}
\clist_map_inline:nn { m,c } {% ####1 = series
\bool_if:nF { \str_if_eq_p:nn {##1} {n} && \str_if_eq_p:nn {####1} {m} } {
\DeclareFontShape{#1}{mc}{####1}{##1}{<->ssub*mc/m/n}{}
}
}
}
}
%.. 文字クラスのリスト
% 開き括弧(文字クラス1)
\edef\jlreq@charlist@openingbrackets{(〔[{〈《「『【‘“\ifx p\jlreq@engine\else ⦅〘〖«〝\fi}
% 閉じ括弧(文字クラス2)
\edef\jlreq@charlist@closingbrackets{)〕]}〉》」』】’”\ifx p\jlreq@engine\else ⦆〙〗»〟\fi}
% ハイフン(文字クラス3)
\edef\jlreq@charlist@hyphens{‐〜\ifx p\jlreq@engine\else ゠–\fi}
% 区切り約物(文字クラス4)
\edef\jlreq@charlist@dividingpunctuationmarks{!?\ifx p\jlreq@engine\else ‼⁇⁈⁉\fi}
% 中点類(文字クラス5)
\edef\jlreq@charlist@middlenodes{・:;}
% 句点類(文字クラス6)
\edef\jlreq@charlist@fullstops{。.}
% 読点類(文字クラス7)
\edef\jlreq@charlist@commas{、,}
% 分離禁止文字(文字クラス8)
\edef\jlreq@charlist@inseparablecharacters{—…‥\ifx p\jlreq@engine\else 〳〴〵\fi}
% 繰返し記号(文字クラス9)
\edef\jlreq@charlist@iterationmarks{ヽヾゝゞ々\ifx p\jlreq@engine\else 〻\fi}
% 長音記号(文字クラス10)
\edef\jlreq@charlist@prolongedsoundmark{ー}
% 小書きの仮名(文字クラス11)
\edef\jlreq@charlist@smallkana{ぁぃぅぇぉァィゥェォっゃゅょゎッャュョヮヵヶ\ifx p\jlreq@engine\else ゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ\fi}%ㇷ゚
% 前置省略記号(文字クラス12)
\edef\jlreq@charlist@prefixedabbreviations{¥$£#\ifx p\jlreq@engine\else €№\fi}
% 平仮名(文字クラス15)
\edef\jlreq@charlist@hiragana{あいうえおかがきぎくぐけげこごさざしじすずせぜそぞただちぢつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもやゆよらりるれろわゐゑをん\ifx p\jlreq@engine\else ゔ\fi}% か゚き゚く゚け゚こ゚
% 片仮名(文字クラス16)
\edef\jlreq@charlist@katakana{アイウエオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモヤユヨラリルレロワヰヱヲンヴ\ifx p\jlreq@engine\else ヷヸヹヺ\fi}% カ゚キ゚ク゚ケ゚コ゚セ゚ツ゚ト゚
%.. 行頭括弧調整
\jlreq@saveoriginalcs{item}
\ifx l\jlreq@engine
% \itemの直後は折り返し行頭と同じにする.
\cs_set:Nn \__jlreq_hook_everypar: {}
\renewcommand*{\item}{%
\cs_set:Nn \__jlreq_hook_everypar: { \cs_set:Nn \__jlreq_hook_everypar: {} \inhibitglue }
\expandafter\everypar\expandafter{\the\everypar\__jlreq_hook_everypar:}
\jlreq@useoriginalcs{item}%
}
\else
\AtBeginDocument{\PushPostHook{par}{\jlreq@hook@everypar}}
\def\jlreq@hook@everypar{}
% 非LuaTeXの場合はJFMの入れ替えと\everyparでの処理で対処.
% 行頭括弧に対して\inhibitglueを入れたりする命令を作る
% \jlreq@charlist@openingbracketsの各括弧に対して,\ifx\jlreq@nextchar 「1\fiみたいなのが並んだのを作る
\def\jlreq@tempa{}
\def\jlreq@do#1{\jlreq@ifendmark{#1}{}{\tl_put_right:Nn \jlreq@tempa{\ifx\jlreq@nextchar#11\fi}\jlreq@do}}
\expandafter\jlreq@do\jlreq@charlist@openingbrackets\jlreq@endmark
% JFM glueの伸び縮みで行頭括弧が揃わないのを防ぐために常に\inhibitglueを入れる.
\str_if_eq:VnTF \jlreq@open@bracket@pos { nibu_tentsuki } {
\edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\exp_not:o {\jlreq@tempa}>0~\unexpanded{\hskip -.5\jlreq@zw\inhibitglue}\noexpand\fi}
}{% zenkakunibu_nibu,zenkaku_tentsuki
\edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\exp_not:o {\jlreq@tempa}>0~\unexpanded{\inhibitglue}\noexpand\fi}
}
% source special対策
\def\jlreq@openbracket@hook@i{\ifx\jlreq@nextchar\special\expandafter\jlreq@openbracket@hook@iii\else\expandafter\jlreq@openbracket@hook@ii\fi}
\def\jlreq@openbracket@hook@iii#1#2{#1{#2}\futurelet\jlreq@nextchar\jlreq@openbracket@hook@i}
\def\jlreq@openbracket@hook{\futurelet\jlreq@nextchar\jlreq@openbracket@hook@i}
\let\jlreq@hook@everypar=\jlreq@openbracket@hook
\renewcommand*{\item}{%
\def\jlreq@hook@everypar{%
\let\jlreq@hook@everypar=\jlreq@openbracket@hook
\inhibitglue
}%
\jlreq@useoriginalcs{item}%
}
\fi
%.. 禁則処理
\ifx l\jlreq@engine
\cs_set:Nn \__jlreq_setpostbreakpenalty_aux:nn {\ltjsetparameter{postbreakpenalty={`#1,#2}}}
\cs_set:Nn \__jlreq_setprebreakpenalty_aux:nn {\ltjsetparameter{prebreakpenalty={`#1,#2}}}
\cs_set:Nn \__jlreq_addjaxspmode_aux:nn {%
\jlreq@tempcnta=\ltjgetparameter{jaxspmode}{`#1}%
\str_case:nn {#2} {
{ pre } {%
\ifnum\jlreq@tempcnta=2
\ltjsetparameter{jaxspmode={`#1,allow}}%
\else\ifnum\jlreq@tempcnta=0
\ltjsetparameter{jaxspmode={`#1,preonly}}%
\fi\fi
}
{ post } {%
\ifnum\jlreq@tempcnta=1
\ltjsetparameter{jaxspmode={`#1,allow}}%
\else\ifnum\jlreq@tempcnta=0
\ltjsetparameter{jaxspmode={`#1,postonly}}%
\fi\fi
}
}%
}
\cs_set:Nn \__jlreq_deljaxspmode_aux:nn {
\jlreq@tempcnta=\ltjgetparameter{jaxspmode}{`#1}%
\str_case:nn {#2} {
{ pre } {%
\ifnum\jlreq@tempcnta=2
\ltjsetparameter{jaxspmode={`#1,postonly}}%
\else\ifnum\jlreq@tempcnta=1
\ltjsetparameter{jaxspmode={`#1,inhibit}}%
\fi\fi
}
{ post } {%
\ifnum\jlreq@tempcnta=3
\ltjsetparameter{jaxspmode={`#1,preonly}}%
\else\ifnum\jlreq@tempcnta=2
\ltjsetparameter{jaxspmode={`#1,inhibit}}%
\fi\fi
}
}%
}
\else
\cs_set:Nn \__jlreq_setpostbreakpenalty_aux:nn {\postbreakpenalty`#1=#2}
\cs_set:Nn \__jlreq_setprebreakpenalty_aux:nn {\prebreakpenalty`#1=#2}
\cs_set:Nn \__jlreq_addjaxspmode_aux:nn {
\jlreq@tempcnta=\inhibitxspcode`#1
\str_case:nn {#2} {
{ pre }{%
\ifnum\jlreq@tempcnta=1
\inhibitxspcode`#1=3
\else\ifnum\jlreq@tempcnta=0
\inhibitxspcode`#1=2
\fi\fi
}
{ post }{%
\ifnum\jlreq@tempcnta=2
\inhibitxspcode`#1=3
\else\ifnum\jlreq@tempcnta=0
\inhibitxspcode`#1=1
\fi\fi
}
}%
}
\cs_set:Nn \__jlreq_deljaxspmode_aux:nn {
\jlreq@tempcnta=\inhibitxspcode`#1
\str_case;nn {#2} {
{ pre } {%
\ifnum\jlreq@tempcnta=3
\inhibitxspcode`#1=1