This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathniancls.dtx
2085 lines (2085 loc) · 72.4 KB
/
niancls.dtx
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
%%%%%% ^^X MetaComment |=>
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*copyright>
Copyright 2023, RadioNoiseE/黄京
NianCLS, 年文檔類
%</copyright>
%<*internal>
\fi
\begingroup
\def\FORMAT{LaTeX2e}
\expandafter\endgroup
\ifx\fmtname\FORMAT\else
\csname fi\endcsname
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\askonceonly
\edef\HEAD{\perCent\perCent 年文檔類 黄京}
\generate{
\usepreamble\HEAD
\usepostamble\empty
\file{niancls.cls}{\from{\jobname.dtx}{cls}}
}
\begingroup
\obeyspaces
\Msg{*******}
\Msg{* End *}
\Msg{*******}
\endgroup
\endbatchfile
%</batchfile>
%<*internal>
\fi
%</internal>
%<*driver>
\makeatletter
\def\ltj@stdmcfont{NotoSerifCJKSC}
\def\ltj@stdyokojfm{eva/{smpl,nstd}}
\makeatother
\documentclass[twoside]{ltjsarticle}
\usepackage[hidelinks]{hyperref}
\pagestyle{headings}
\usepackage{doc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\def\MakePrivateLetters{\makeatletter\catcode`\_=11\catcode`\:=11}
\usepackage{luatexja-fontspec}
\setmainfont{Linux Libertine O}
\setmainjfont{Noto Serif CJK SC}[YokoFeatures={JFM={eva/{smpl,nstd} }}]
\setsansfont{Linux Biolinum O}
\setmonofont{Iosevka Slab}[Scale=0.694,FakeStretch=1.2]
\def\LuaTeX{Lua\kern-.2ex\TeX}
\makeatletter
\def\theCodelineNo{\llap{\reset@font\tiny\sffamily\arabic{CodelineNo}\hskip1pt}}
\makeatother
\parindent=0pt
\IndexPrologue{%
\section{\indexname}
\textit{意大利体的数字表示描述对应索引项的页码;
带下划线的数字表示定义对应索引项的代码行号;
罗马字体的数字表示使用对应索引项的代码行号。}}
\begin{document}
\DocInput{\jobname.dtx}
\PrintIndex
\end{document}
%</driver>
% \fi
%%%%%% ^^X <=|
%%%%%% ^^X Title |=>
% \title{\sffamily\gtfamily 年文檔類{\quad}Nian Style Class}
% \author{黄 京}
% \date{西曆\today}
% \maketitle
%%%%%% ^^X <=|
%%%%%% ^^X Abstract |=>
%% \begin{abstract}
%% 为在{\LuaTeX}下排印中日文本而作的文档类。基于{\sffamily expl3}构建。设计初衷不同于ltj/bxjs系列,不考虑对旧版本的支持。
%% 目标为提供一个灵活的可配置的文档类。支持简中、繁中及日本语。
%% \end{abstract}
%%%%%% ^^X <=|
%%%%%% ^^X TableOfContents |=>
% \tableofcontents
%%%%%% ^^X <=|
%%%%%% ^^X 初始化 |=>
% \section{初始化}
%%%%% ^^X 載入{\LaTeX3}並檢驗依賴 |=>
% \subsection{載入{\LaTeX3}並檢驗依賴}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplClass{niancls}{2023-08-28}{0.0.0}{Nian Document Class}
% \end{macrocode}
% 定义载入文档类信息等。
% \begin{macrocode}
%<@@=ncls>
\prop_gput:Nnn \g_msg_module_name_prop { ncls } { niancls }
% \end{macrocode}
% 申明结束。接下来检查依赖,首先为{\sffamily xparse}、{\sffamily l3keys2e}及{\sffamily etoolbox}宏包。
% \begin{macrocode}
\cs_if_exist:NF \NewDocumentCommand
{ \RequirePackage { xparse } }
\cs_if_exist:NTF \ProcessKeyOptions
{ \cs_new:Nn \@@_keyoptions_process:n { \ProcessKeyOptions [ #1 ] } }
{
\RequirePackage { l3keys2e }
\cs_new:Nn \@@_keyoptions_process:n { \ProcessKeysOptions { #1 } }
}
\cs_if_exist:NF \AtEndPreamble
{ \RequirePackage { etoolbox } }
% \end{macrocode}
% 接下来检查{\sffamily expl3}的版本。
% \begin{macrocode}
\@ifpackagelater { expl3 } { 2021-02-10 } { }
{
\msg_new:nnnn { ncls } { latex3-too-old }
{ Package~`l3kernel'~and~`l3packages'~too~old. }
{
You~need~to~update~your~installation~of~the~bundles~
`l3kernel'~and~`l3packages'. \\
Loading~niancls~will~abort!
}
\msg_critical:nn { ncls } { latex3-too-old }
}
% \end{macrocode}
% 后进行{\LaTeXe}格式之版本检查。
% \begin{macrocode}
\@ifl@t@r \fmtversion { 2021-06-01 } { }
{
\msg_new:nnnn { ncls } { latex-too-old }
{ Format~LaTeX2e~version~too~old. }
{
You~need~to~update~your~LaTeX2e~to~the~latest~release. \\
Loading~niancls~will~abort!
}
\msg_critical:nn { ncls } { latex-too-old }
}
% \end{macrocode}
% 最后检查{\LaTeX}引擎,仅支持使用{\LuaTeX}编译。
% \begin{macrocode}
\sys_if_engine_luatex:F
{
\msg_new:nnnn { ncls } { unsupported-engine }
{ LuaTeX~is~the~only~supported~engine~for~niancls. }
{
You~should~switch~to~LuaTeX~to~use~niancls. \\
Loading~niancls~will~abort!
}
\msg_fatel:nn { ncls } { unsupported-engine }
}
% \end{macrocode}
%%%%% ^^X <=|
%%%%% ^^X 私有定義 |=>
% \subsection{私有定義}
% 定义\verb|\AtEndPreamble|钩子。
% \begin{macrocode}
\cs_new_protected:Npn \@@_at_preamble_end:n { \AtEndPreamble }
% \end{macrocode}
% 「疑」定义\verb|\AtEndOfClass|钩子。
% \begin{macrocode}
\cs_new_protected:Npn \@@_at_cls_end:n { \AtEndOfClass }
% \end{macrocode}
% 定义\verb|\AtBeginDocument|钩子。
% \begin{macrocode}
\cs_new_protected:Npn \@@_at_doc_begin:n { \AtBeginDocument }
% \end{macrocode}
% 定义是否在导言区的状态宏。
% \begin{macrocode}
\newif \ifnpream \npreamtrue
\@@_at_doc_begin:n { \npreamfalse }
% \end{macrocode}
% 定义视情况是否开启\LaTeX3环境的宏。(其实这玩意没太大必要,反而会损失性能,视情况无效化。)
% \begin{macrocode}
\cs_new:Npn \ContExplOn
{ \ifnpream \else \ExplSyntaxOn \fi } %FIXME
\cs_new:Npn \ContExplOff
{ \ifnpream \else \ExplSyntaxOff \fi } %FIXME
% \end{macrocode}
% 定义用于在读取结束后释放缓存的宏。
% \begin{macrocode}
\seq_new:N \g_@@_aftercls_del_seq
\cs_new:Nn \@@_macro_release:N
{ \seq_gput_right:Nn \g_@@_aftercls_del_seq { #1 } }
\@@_at_preamble_end:n
{
\cs_undefine:N \g_@@_aftercls_del_seq
}
% \end{macrocode}
% 封装{\LuaTeX}提供的Lua接口。
% \begin{macrocode}
\cs_new:Npn \@@_luafunc_new:N { \newluafunction }
\cs_new:Npn \@@_luafunc_use:N { \luafunction }
% \end{macrocode}
% 提供键对值的统一错误调试处理模版。
% \begin{macrocode}
\msg_new:nnnn { ncls } { unknown-choice }
{ Unknown~choice~given~to~key~`#1'. }
{
Valid~choices~are:~#2; \\
while~you~gave:~#3.
}
% \end{macrocode}
% 同时为字体缩放\verb|\mag=xreal|预定义同一单位,见「编译模式」处首次使用时的注释。
% \begin{macrocode}
\dim_new:N \mpt
\dim_set:Nn \mpt { \p@ }
% \end{macrocode}
%%%%% ^^X <=|
%%%%% ^^X 內存清理 |=>
% \subsection{內存清理}
% 在导言区末尾清除所有非必要宏。
% \begin{macrocode}
\@@_macro_release:N \@@_keyoptions_process:n
\@@_macro_release:N \@@_at_preamble_end:n
\@@_macro_release:N \@@_at_cls_end:n
\@@_macro_release:N \@@_at_doc_begin:n
\@@_macro_release:N \@@_macro_release:N
\@@_macro_release:N \@@_luafunc_new:N
\@@_macro_release:N \@@_luafunc_use:N
% \end{macrocode}
%%%%% ^^X <=|
%%%%%% ^^X <=|
%%%%%% ^^X 鍵對直之「預處理」 |=>
% \section{鍵對直之「預處理」}
%%%%% ^^X 紙張配置用 |=>
% \subsection{紙張配置用}
%%%% ^^X 尺寸信息 |=>
% \subsubsection{尺寸信息}
% 处理纸张尺寸信息。
% \begin{macrocode}
\tl_new:N \l_@@_paper_sizeinfo_tl
\keys_define:nn { ncls }
{
paper .tl_set:N = \l_@@_paper_sizeinfo_tl,
paper .value_required:n = true,
peper .initial:n = { a4 }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 輔助線 |=>
% \subsubsection{輔助線}
% 是否需要辅助线。为了方便分类,将tombow和mentuke都并入corpmark类,并扔掉了tombo。「补完」
% \begin{macrocode}
\bool_new:N \l_@@_paper_corpmark_mark_bool
\bool_new:N \l_@@_paper_corpmark_date_bool
\keys_define:nn { ncls }
{
corpmark .choice:,
corpmark / tombow .code:n =
{
\bool_set_true:N \l_@@_paper_corpmark_mark_bool
\bool_set_true:N \l_@@_paper_corpmark_date_bool
},
corpmark / mentuke .code:n =
{
\bool_set_true:N \l_@@_paper_corpmark_mark_bool
\bool_set_false:N \l_@@_paper_corpmark_date_bool
},
corpmark / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ corpmark }
{ tombow,~mentuke }
{ \exp_not:n { #1 } }
},
corpmark .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 頁面方向 |=>
% \subsubsection{頁面方向}
% 设置页面方向。
% \begin{macrocode}
\bool_new:N \l_@@_paper_portrait_bool
\keys_define:nn { ncls }
{
orientation .choice:,
orientation / portrait .code:n = { \bool_set_true:N \l_@@_paper_portrait_bool },
orientation / landscape .code:n = { \bool_set_false:N \l_@@_paper_portrait_bool },
orientation / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ orientation }
{ portrait,~landscape }
{ \exp_not:n { #1 } }
},
orientation .value_required:n = true,
orientation .initial:n = { portrait }
}
% \end{macrocode}
%%%% ^^X <=|
%%%%% ^^X <=|
%%%%% ^^X 選項設定 |=>
% \subsection{選項設定}
%%%% ^^X 組版方向 |=>
% \subsubsection{組版方向}
% 确定使用竖书或是横排。
% \begin{macrocode}
\bool_new:N \l_@@_layout_tate_bool
\keys_define:nn { ncls }
{
direction .choice:,
direction / yoko .code:n = { \bool_set_false:N \l_@@_layout_tate_bool },
direction / tate .code:n = { \bool_set_true:N \l_@@_layout_tate_bool },
direction / unknown .code:n =
{
\msg_new:nnxxx { ncls } { unknown-choice }
{ direction }
{ yoko,~tate }
{ \exp_not:n { #1 } }
},
direction .value_required:n = true,
direction .initial:n = { yoko }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 基準語言 |=>
% \subsubsection{基準語言}
% 此处设置待排印文档的基准语言类型:西文或东亚语言。关于东亚语言的区分则在下节关于字体处设置。
% 两者相互正交。同时暂不在导言区末尾清除其的宏定义。
% \begin{macrocode}
\bool_new:N \l_@@_layout_english_bool
\keys_define:nn { ncls }
{
basis .choice:,
basis / english .code:n = { \bool_set_true:N \l_@@_layout_english_bool },
basis / cjk .code:n = { \bool_set_false:N \l_@@_layout_english_bool },
basis / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ basis }
{ english,~cjk }
{ \exp_not:n { #1 } }
},
basis .value_required:n = true,
basis .initial:n = { cjk }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 分欄 |=>
% \subsubsection{分欄}
% 设置全局双栏或单栏。这里只是处理,待后设置。
% \begin{macrocode}
\bool_new:N \l_@@_layout_restonecol_bool
\keys_define:nn { ncls }
{
column .choice:,
column / one .code:n = { \bool_set_false:N \l_@@_layout_restonecol_bool },
column / two .code:n = { \bool_set_true:N \l_@@_layout_restonecol_bool },
column / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ column }
{ one,~two }
{ \exp_not:n { #1 } }
},
column .value_required:n = true,
column .initial:n = { one }
}
% \end{macrocode}
% 然后顺便设置双栏的间距。因为其属于页面尺寸参数需要在初始时通过文档类的选项设定避免多次计算页面故在这里设置。(好长一句话)
% \begin{macrocode}
\tl_new:N \l_@@_layout_column_gap_tl
\keys_define:nn { ncls }
{
column_gap .tl_set:N = \l_@@_layout_column_gap_tl,
column_gap .value_required:n = true,
column_gap .initial:n = { 2 \zw }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 文檔類型 |=>
% \subsubsection{文檔類型}
% 设置文档类型(全局)为文章、论文报告、或书籍。依赖错综复杂,故不使用布尔类型。
% 同时作为较高层次的设置,会影响其它一些选项,故先行初始化其。
% 首先申明这些低阶选项的宏。
% \begin{macrocode}
\bool_new:N \l_@@_layout_twoside_bool
\bool_new:N \l_@@_layout_mparswitch_bool
\bool_new:N \l_@@_layout_titlepage_bool
\bool_new:N \l_@@_layout_openleft_bool
\bool_new:N \l_@@_layout_openright_bool
% \end{macrocode}
% 随后才是键对值配置。
% \begin{macrocode}
\str_new:N \l_@@_layout_doctype_str
\keys_define:nn { ncls }
{
doctype .choice:,
doctype / article .code:n =
{
\str_set:Nn \l_@@_layout_doctype_str { a }
\bool_set_false:N \l_@@_layout_twoside_bool
\bool_set_false:N \l_@@_layout_mparswitch_bool
\bool_set_false:N \l_@@_layout_titlepage_bool
\bool_set_true:N \l_@@_layout_openleft_bool
\bool_set_true:N \l_@@_layout_openright_bool
},
doctype / report .code:n =
{
\str_set:Nn \l_@@_layout_doctype_str { r }
\bool_set_true:N \l_@@_layout_twoside_bool
\bool_set_false:N \l_@@_layout_mparswitch_bool
\bool_set_true:N \l_@@_layout_titlepage_bool
\bool_set_true:N \l_@@_layout_openleft_bool
\bool_set_true:N \l_@@_layout_openright_bool
},
doctype / book .code:n =
{
\str_set:Nn \l_@@_layout_doctype_str { b }
\bool_set_true:N \l_@@_layout_twoside_bool
\bool_set_true:N \l_@@_layout_mparswitch_bool
\bool_set_true:N \l_@@_layout_titlepage_bool
\bool_set_false:N \l_@@_layout_openleft_bool
\bool_set_true:N \l_@@_layout_openright_bool
},
doctype / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ doctype }
{ article,~report,~book }
{ \exp_not:n { #1 } }
},
doctype .value_required:n = true,
doctype .initial:n = { article }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 單雙面 |=>
% \subsubsection{單雙面}
% 设置是单面列印抑或是双面。事关边距,使用两个布尔参数小心处理。同时,此与文档类型有关(依存系)。
% \begin{macrocode}
%<*obsolete>
\bool_new:N \l_@@_layout_twoside_bool
\bool_new:N \l_@@_layout_mparswitch_bool
%</obsolete>
\keys_define:nn { ncls }
{
print .choice:,
print / oneside .code:n =
{
\bool_set_false:N \l_@@_layout_twoside_bool
\bool_set_false:N \l_@@_layout_mparswitch_bool
},
print / twoside .code:n =
{
\bool_set_true:N \l_@@_layout_twoside_bool
\bool_set_true:N \l_@@_layout_mparswitch_bool
},
print / vartwoside .code:n =
{
\bool_set_true:N \l_@@_layout_twoside_bool
\bool_set_false:N \l_@@_layout_mparswitch_bool
},
print / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ print }
{ oneside,~twoside,~vartwoside }
{ \exp_not:n { #1 } }
},
print .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 標題頁 |=>
% \subsubsection{標題頁}
% 是否需要标题页。与文档类型有关(依存系)。
% \begin{macrocode}
%<obsolete> \bool_new:N \l_@@_layout_titlepage_bool
\keys_define:nn { ncls }
{
titlepage .bool_set:N = \l_@@_layout_titlepage_bool,
titlepage .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 章節起 |=>
% \subsubsection{章節起}
% 如何开启新的章节呢?大概只针对论文报告及书籍。也用两个布尔类型实现判别。
% \begin{macrocode}
%<*obsolete>
\bool_new:N \l_@@_layout_openleft_bool
\bool_new:N \l_@@_layout_openright_bool
%</obsolete>
\keys_define:nn { ncls }
{
open .choice:,
open / left .code:n =
{
\bool_set_true:N \l_@@_layout_openleft_bool
\bool_set_false:N \l_@@_layout_openright_bool
},
open / right .code:n =
{
\bool_set_false:N \l_@@_layout_openleft_bool
\bool_set_true:N \l_@@_layout_openright_bool
},
open / any .code:n =
{
\bool_set_true:N \l_@@_layout_openleft_bool
\bool_set_true:N \l_@@_layout_openright_bool
},
open / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ open }
{ left,~right,~any }
{ \exp_not:n { #1 } }
},
open .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 編譯模式 |=>
% \subsubsection{編譯模式}
% 最终成品或暂时替代。其实就是坏盒子长度的区别(零或非零),当然此处也会用到一个布尔型值。由于此时\verb|\mpt|还未被定义,故此处先将其设为\verb|\p@|,用户指定时(希望)它会被正确定义。「需要补完」
% \begin{macrocode}
\bool_new:N \l_@@_layout_draft_bool
\keys_define:nn { ncls }
{
version .choice:,
version / draft .code:n =
{
\bool_set_true:N \l_@@_layout_draft_bool
\dim_set:Nn \overfullrule { 6 \mpt }
},
version / final .code:n =
{
\bool_set_false:N \l_@@_layout_draft_bool
\dim_set:Nn \overfullrule { 0 \mpt }
},
version / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ version }
{ draft,~final }
{ \exp_not:n { #1 } }
},
version .value_required:n = true,
version .initial:n = { final }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 數學公式 |=>
% \subsubsection{數學公式}
% 此处设置数学公式的排版大方向,说人话就是对齐排列方式和编号方式。首先是对齐。
% \begin{macrocode}
\bool_new:N \l_@@_layout_fleqn_bool
\keys_define:nn { ncls }
{
eqalign .choice:,
eqalign / left .code:n = { \bool_set_true:N \l_@@_layout_fleqn_bool },
eqalign / middle .code:n = { \bool_set_false:N \l_@@_layout_fleqn_bool },
eqalign / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ eqalign }
{ left,~middle }
{ \exp_not:n { #1 } }
},
eqalign .value_required:n = true,
eqalign .initial:n = { middle }
}
% \end{macrocode}
% 其次则是编号。
% \begin{macrocode}
\bool_new:N \l_@@_layout_leqno_bool
\keys_define:nn { ncls }
{
eqnum .choice:,
eqnum / left .code:n = { \bool_set_true:N \l_@@_layout_leqno_bool },
eqnum / right .code:n = { \bool_set_false:N \l_@@_layout_leqno_bool },
eqnum / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ eqnum }
{ left,~right }
{ \exp_not:n { #1 } }
},
eqnum .value_required:n = true,
eqnum .initial:n = { right }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 參考文獻式樣設定 |=>
% \subsubsection{參考文獻式樣設定}
% 主要是支持open bib格式,虽然有些无聊。
% \begin{macrocode}
\bool_new:N \l_@@_layout_openbib_bool
\keys_define:nn { ncls }
{
bibstyle .choice:,
bibstyle / open .code:n = { \bool_set_true:N \l_@@_layout_openbib_bool },
bibstyle / plain .code:n = { \bool_set_false:N \l_@@_layout_openbib_bool },
bibstyle / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ bibstyle }
{ open,~plain }
{ \exp_not:n { #1 } }
},
bibstyle .value_required:n = true,
bibstyle .initial:n = { plain }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 依存係設定缺省給 |=>
% \subsubsection{依存係設定缺省給}
% 最后设置所有依赖文档类型的选项参数。
% \begin{macrocode}
%<*obsolete>
\str_if_eq:VnT \l_@@_layout_doctype_str { a }
{
\keys_set:nn { ncls }
{
print .initial:n = { oneside },
titlepage .initial:n = { false },
open .initial:n = { any }
}
}
\str_if_eq:VnT \l_@@_layout_doctype_str { r }
{
\keys_set:nn { ncls }
{
print .initial:n = { vartwoside },
titlepage .initial:n = { true },
open .initial:n = { any }
}
}
\str_if_eq:VnT \l_@@_layout_doctype_str { b }
{
\keys_set:nn { ncls }
{
print .initial:n = { twoside },
titlepage .initial:n = { true },
open .initial:n = { right }
}
}
%</obsolete>
% \end{macrocode}
%%%% ^^X <=|
%%%%% ^^X <=|
%%%%% ^^X 字體相關配置用 |=>
% \subsection{字體相關配置用}
%%%% ^^X 全局基準字體參數設定 |=>
% \subsubsection{全局基準字體參數設定}
% 处理用户所需的全局基准字体设置。
% \begin{macrocode}
\tl_new:N \l_@@_font_magscale_tl
\keys_define:nn { ncls }
{
fontsize .choice:,
fontsize / 7pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 0.694 } },
fontsize / 8pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 0.833 } },
fontsize / 9pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 0.913 } },
fontsize / 10pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1 } },
fontsize / 11pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.0953 } },
fontsize / 12pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.2 } },
fontsize / 13pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.3 } },
fontsize / 14pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.44 } },
fontsize / 15pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.5 } },
fontsize / 16pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.6 } },
fontsize / 17pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 1.728 } },
fontsize / 20pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 2. } },
fontsize / 21pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 2.074 } },
fontsize / 24pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 2.4 } },
fontsize / 25pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 2.488 } },
fontsize / 30pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 2.986 } },
fontsize / 36pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 3.583 } },
fontsize / 43pt .code:n = { \tl_set:Nn \l_@@_font_magscale_tl { 4.3 } },
fontsize / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ fontsize }
{
7pt,~ 8pt,~ 9pt,~ 10pt,~ 11pt,~ 12pt,~ 13pt,~ 14pt,~ 15pt,~
17pt,~ 20pt,~ 21pt,~ 24pt,~ 25pt,~ 30pt,~ 36pt,~ 43pt
}
{ \exp_not:n { #1 } }
},
fontsize .value_required:n = true,
fontsize .initial:n = { 10pt }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 語言設定 |=>
% \subsubsection{語言設定}
% 设置文档类之全局语言。
% \begin{macrocode}
\str_new:N \l_@@_lang_cj_str
\keys_define:nn { ncls }
{
language .choice:,
language / trad .code:n = { \str_set:Nn \l_@@_lang_cj_str { t } },
language / smpl .code:n = { \str_set:Nn \l_@@_lang_cj_str { s } },
language / jp .code:n = { \str_set:Nn \l_@@_lang_cj_str { j } },
language / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ language }
{ trad,~smpl,~jp }
{ \exp_not:n { #1 } }
},
language .value_required:n = true,
language .initial:n = { jp }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體設定 |=>
% \subsubsection{字體設定}
% 设定全局明朝及哥特字体。
% \begin{macrocode}
\tl_new:N \l_@@_font_mincho_tl
\keys_define:nn { ncls }
{
mincho .tl_set:N = \l_@@_font_mincho_tl,
mincho .value_required:n = true,
mincho .initial:n = { HaranoAji Mincho }
}
\tl_new:N \l_@@_font_gothic_tl
\keys_define:nn { ncls }
{
gothic .tl_set:N = \l_@@_font_gothic_tl,
gothic .value_required:n = true,
gothic .initial:n = { HaranoAji Gothic }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字間距 |=>
% \subsubsection{字間距}
% 此处为汉字间间距(\textit{kanjiskip})与西文与汉字间距(\textit{xkanjiskip})的设置处。暂时不在导言区末尾清除其的宏定义。
% 首先为汉字间间距的设置接口。
% \begin{macrocode}
\tl_new:N \l_@@_font_kanjiskip_tl
\keys_define:nn { ncls }
{
kanjiskip .tl_set:N = \l_@@_font_kanjiskip_tl,
kanjiskip .value_required:n = true,
kanjiskip .initial:n = { \z@~plus .1\zw~minus .01\zw }
}
% \end{macrocode}
% 随后为西文与汉字间间距的接口。
% \begin{macrocode}
\tl_new:N \l_@@_font_xkanjiskip_tl
\keys_define:nn { ncls }
{
xkanjiskip .tl_set:N = \l_@@_font_xkanjiskip_tl,
xkanjiskip .value_required:n = true,
xkanjiskip .initial:n = { .25em~plus .15em~minus .06em }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體縮放率設定 |=>
% \subsubsection{字體縮放率設定}
% 设置全局中日字符缩放率的值。
% \begin{macrocode}
\tl_new:N \l_@@_font_cjscale_tl
\keys_define:nn { ncls }
{
scale .tl_set:N = \l_@@_font_cjscale_tl,
scale .value_required:n = true,
scale .initial:n = { 0.924715 }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體矩陣高級設定 |=>
% \subsubsection{字體矩陣高級設定}
% 设置全局标点特性。
% \begin{macrocode}
\bool_new:N \l_@@_jfm_hanging_bool
\bool_new:N \l_@@_jfm_linegap_bool
\keys_define:nn { ncls }
{
punct .multichoice:,
punct / hanging .code:n = { \bool_set_true:N \l_@@_jfm_hanging_bool },
punct / linegap .code:n = { \bool_set_true:N \l_@@_jfm_linegap_bool },
punct / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ punct }
{ hanging,~linegap }
{ \exp_not:n { #1 } }
},
punct .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 視覺字號補正 |=>
% \subsubsection{視覺字號補正}
% 判断是否对NFSS视觉字号进行补正。
% \begin{macrocode}
\bool_new:N \l_@@_font_xreal_bool
\keys_define:nn { ncls }
{
magstyle .choice:,
magstyle / nil .code:n = { \bool_set_false:N \l_@@_font_xreal_bool },
magstyle / xreal .code:n = { \bool_set_true:N \l_@@_font_xreal_bool },
magstyle / unknown .code:n =
{
\msg_error:nnxxx { ncls } { unknown-choice }
{ magstyle }
{ nil,~xreal }
{ \exp_not:n { #1 } }
},
magstyle .value_required:n = true,
magstyle .initial:n = { xreal }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 回滾字體特性 |=>
% \subsubsection{回滾字體特性}
% 设置(可选)的回滚字体特性。其依赖\textsf{luaotfload}宏集的实验特性,危险呐。
% \begin{macrocode}
\bool_new:N \l_@@_font_fallback_bool
\tl_new:N \l_@@_font_fallback_tl
\keys_define:nn { ncls }
{
fallback .code:n =
{
\bool_set_true:N \l_@@_font_fallback_bool
\tl_set:Nn \l_@@_font_fallback_tl { #1 }
},
fallback .value_required:n = true
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體排印參數 |=>
% \subsubsection{字體排印參數}
% 在正文中使用各类选取尺寸的宏时自动设置的版面参数设置。
% \begin{macrocode}
\clist_map_inline:nn { HUGE, Huge, huge, LARGE, Large, large, normal, small, footnote, script, tiny }
{
\clist_map_inline:nn { abovedisplay, abovedisplayshort, belowdisplay, belowdisplayshort }
{
\tl_new:c { l_@@_font_#1 size_##1 skip_tl }
\keys_define:nn { ncls }
{
#1 size / ##1 skip .tl_set:c = { l_@@_font_#1 size_##1 skip_tl },
#1 size / ##1 skip .value_required:n = true
}
}
}
% \end{macrocode}
% 随后为其设定初始值。
% \begin{macrocode}
\keys_define:nn { ncls }
{
HUGEsize / abovedisplayskip .initial:n = { 28 \mpt~plus 8 \mpt~minus 9 \mpt },
HUGEsize / abovedisplayshortskip .initial:n = { 14 \mpt~plus 5 \mpt },
HUGEsize / belowdisplayskip .initial:n = { 28 \mpt~plus 8 \mpt~minus 9 \mpt },
HUGEsize / belowdisplayshortskip .initial:n = { 14 \mpt~plus 5 \mpt },
Hugesize / abovedisplayskip .initial:n = { 25 \mpt~plus 4 \mpt~minus 5 \mpt },
Hugesize / abovedisplayshortskip .initial:n = { 9 \mpt~plus 4 \mpt },
Hugesize / belowdisplayskip .initial:n = { 25 \mpt~plus 4 \mpt~minus 5 \mpt },
Hugesize / belowdisplayshortskip .initial:n = { 9 \mpt~plus 4 \mpt },
hugesize / abovedisplayskip .initial:n = { 23 \mpt~plus 7 \mpt~minus 6 \mpt },
hugesize / abovedisplayshortskip .initial:n = { 7 \mpt~plus 3 \mpt },
hugesize / belowdisplayskip .initial:n = { 23 \mpt~plus 7 \mpt~minus 6 \mpt },
hugesize / belowdisplayshortskip .initial:n = { 7 \mpt~plus 3 \mpt },
LARGEsize / abovedisplayskip .initial:n = { 20 \mpt~plus 6 \mpt~minus 5 \mpt },
LARGEsize / abovedisplayshortskip .initial:n = { 5 \mpt~plus 3 \mpt },
LARGEsize / belowdisplayskip .initial:n = { 20 \mpt~plus 6 \mpt~minus 5 \mpt },
LARGEsize / belowdisplayshortskip .initial:n = { 5 \mpt~plus 3 \mpt },
Largesize / abovedisplayskip .initial:n = { 16 \mpt~plus 6 \mpt~minus 6 \mpt },
Largesize / abovedisplayshortskip .initial:n = { 3 \mpt~plus 2 \mpt },
Largesize / belowdisplayskip .initial:n = { 16 \mpt~plus 6 \mpt~minus 6 \mpt },
Largesize / belowdisplayshortskip .initial:n = { 3 \mpt~plus 2 \mpt },
largesize / abovedisplayskip .initial:n = { 13 \mpt~plus 4 \mpt~minus 5 \mpt },
largesize / abovedisplayshortskip .initial:n = { 2 \mpt~plus 2 \mpt },
largesize / belowdisplayskip .initial:n = { 13 \mpt~plus 4 \mpt~minus 5 \mpt },
largesize / belowdisplayshortskip .initial:n = { 2 \mpt~plus 2 \mpt },
normalsize / abovedisplayskip .initial:n = { 11 \mpt~plus 3 \mpt~minus 4 \mpt },
normalsize / abovedisplayshortskip .initial:n = { 0 \mpt~plus 3 \mpt },
normalsize / belowdisplayskip .initial:n = { 9 \mpt~plus 3\mpt~minus 4 \mpt },
normalsize / belowdisplayshortskip .initial:n = { 9 \mpt~plus 3 \mpt~minus 4 \mpt },
smallsize / abovedisplayskip .initial:n = { 9 \mpt~plus 3 \mpt~minus 4 \mpt },
smallsize / abovedisplayshortskip .initial:n = { 0 \mpt~plus 3 \mpt },
smallsize / belowdisplayskip .initial:n = { 9 \mpt~plus 3 \mpt~minus 4 \mpt },
smallsize / belowdisplayshortskip .initial:n = { 0 \mpt~plus 3 \mpt },
footnotesize / abovedisplayskip .initial:n = { 6 \mpt~plus 2 \mpt~minus 3 \mpt },
footnotesize / abovedisplayshortskip .initial:n = { 0 \mpt~plus 2 \mpt },
footnotesize / belowdisplayskip .initial:n = { 6 \mpt~plus 2 \mpt~minus 3 \mpt },
footnotesize / belowdisplayshortskip .initial:n = { 0 \mpt~plus 2 \mpt },
scriptsize / abovedisplayskip .initial:n = { 4 \mpt~plus 1 \mpt~minus 2 \mpt },
scriptsize / abovedisplayshortskip .initial:n = { 0 \mpt~plus 1 \mpt },
scriptsize / belowdisplayskip .initial:n = { 4 \mpt~plus 1 \mpt~minus 2 \mpt },
scriptsize / belowdisplayshortskip .initial:n = { 0 \mpt~plus 1 \mpt },
tinysize / abovedisplayskip .initial:n = { 2 \mpt~minus 1 \mpt },
tinysize / abovedisplayshortskip .initial:n = { 0 \mpt~plus 1 \mpt },
tinysize / belowdisplayskip .initial:n = { 2 \mpt~minus 1 \mpt },
tinysize / belowdisplayshortskip .initial:n = { 0 \mpt~plus 1 \mpt }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體尺寸設定 |=>
% \subsubsection{字體尺寸設定}
% 各个字体大小选择宏选取对应的字体大小设定。参数单位为\verb|\mpt|。
% \begin{macrocode}
\clist_map_inline:nn { HUGE, Huge, huge, LARGE, Large, large, normal, small, footnote, script, tiny }
{
\tl_new:c { l_@@_font_#1 size_sizeinfo_tl }
\keys_define:nn { ncls }
{
#1 size / size .tl_set:c = { l_@@_font_#1 size_sizeinfo_tl },
#1 size / size .value_required:n = true
}
}
% \end{macrocode}
% 以及对应的初始(默认)值。
% \begin{macrocode}
\keys_define:nn { ncls }
{
HUGEsize / size .initial:n = { 30 },
Hugesize / size .initial:n = { 24.88 },
hugesize / size .initial:n = { 20.74 },
LARGEsize / size .initial:n = { 17.28 },
Largesize / size .initial:n = { 14.4 },
largesize / size .initial:n = { 11 },
normalsize / size .initial:n = { 10 },
smallsize / size .initial:n = { 9 },
footnotesize / size .initial:n = { 8 },
scriptsize / size .initial:n = { 7 },
tinysize / size .initial:n = { 5 }
}
% \end{macrocode}
%%%% <=|
%%%% ^^X 字體行距設定 |=>
% \subsubsection{字體行距設定}
% 允许用户选择各个字体尺寸所对应的两种行距。注意设定的单位为\verb|\mpt|,不支持别的。
% \begin{macrocode}
\clist_map_inline:nn { HUGE, Huge, huge, LARGE, Large, large, normal, small, footnote, script, tiny }
{
\clist_map_inline:nn { baseline, narrowbaseline }
{
\tl_new:c { l_@@_font_#1 size_##1 skip_tl }
\keys_define:nn { ncls }
{
#1 size / ##1 skip .tl_set:c = { l_@@_font_#1 size_##1 skip_tl },
#1 size / ##1 skip .value_required:n = true
}
}
}
% \end{macrocode}
% 并且也为其设定缺省值。
% \begin{macrocode}
\keys_define:nn { ncls }
{
HUGEsize / baselineskip .initial:n = { 40 },
HUGEsize / narrowbaselineskip .initial:n = { 40 },
Hugesize / baselineskip .initial:n = { 33 },
Hugesize / narrowbaselineskip .initial:n = { 33 },
hugesize / baselineskip .initial:n = { 28 },
hugesize / narrowbaselineskip .initial:n = { 28 },
LARGEsize / baselineskip .initial:n = { 25 },
LARGEsize / narrowbaselineskip .initial:n = { 25 },
Largesize / baselineskip .initial:n = { 21 },
Largesize / narrowbaselineskip .initial:n = { 21 },
largesize / baselineskip .initial:n = { 17 },
largesize / narrowbaselineskip .initial:n = { 17 },
normalsize / baselineskip .initial:n = { 16 },
normalsize / narrowbaselineskip .initial:n = { 12 },
smallsize / baselineskip .initial:n = { 13 },
smallsize / narrowbaselineskip .initial:n = { 11 },
footnotesize / baselineskip .initial:n = { 11 },
footnotesize / narrowbaselineskip .initial:n = { 9.5 },
scriptsize / baselineskip .initial:n = { 8 },
scriptsize / narrowbaselineskip .initial:n = { 8 },
tinysize / baselineskip .initial:n = { 6 },
tinysize / narrowbaselineskip .initial:n = { 6 }
}
% \end{macrocode}
%%%% ^^X <=|
%%%% ^^X 字體尺寸其他參數 |=>
% \subsubsection{字體尺寸其他參數}
% 最后为各种尺寸设置上下文参数。
% \begin{macrocode}
\clist_map_inline:nn { HUGE, Huge, huge, LARGE, Large, large, normal, small, footnote, script, tiny }
{
\tl_new:c { l_@@_font_#1 size_listinfo_tl }
\keys_define:nn { ncls }
{
#1 size / list .tl_set:c = { l_@@_font_#1 size_listinfo_tl },
#1 size / list .value_required:n = true
}
}
% \end{macrocode}
% 并设定初始值。仅设置三种尺寸字体的,其余为\verb|\relax|。
% \begin{macrocode}
\keys_define:nn { ncls }
{
HUGEsize / list .initial:n = { \relax },
Hugesize / list .initial:n = { \relax },
hugesize / list .initial:n = { \relax },
LARGEsize / list .initial:n = { \relax },
Largesize / list .initial:n = { \relax },