-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtemplate.tex
More file actions
1729 lines (1566 loc) · 54.8 KB
/
template.tex
File metadata and controls
1729 lines (1566 loc) · 54.8 KB
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
\documentclass[12pt,a4paper,openany]{book}
% 设置基础行间距和段落间距
\linespread{1.2} % 增加行间距,从默认的1.0提升到1.2
% --- Packages ---
\usepackage{iftex}
\usepackage{eso-pic} % For background image placement
\usepackage{xstring} % For string comparison in conditionals
% Define allowbreak command early to prevent undefined control sequence errors
% This is needed by the table-wrap filter which inserts \allowbreak commands
% Use a more robust definition that works in all contexts including textbf
\DeclareRobustCommand{\allowbreak}{\discretionary{}{}{}}
% Engine compatibility check and optimization recommendations
% The PDF generation tool automatically selects the optimal LaTeX engine:
% - LuaLaTeX: Used when emoji support is enabled (--emoji flag)
% - XeLaTeX: Used for standard multilingual content without emoji
%
% Engine selection rationale:
% - LuaLaTeX provides better emoji font handling and Unicode support
% - XeLaTeX offers faster compilation for non-emoji content
% - Both engines support CJK (Chinese, Japanese, Korean) text rendering
$if(emoji)$
\ifluatex\else
\PackageWarning{template}{Emoji and multilingual support works best with LuaLaTeX engine. Consider using --engine=lualatex.}
\fi
$endif$
% LuaLaTeX multilingual font configuration
%
% LuaLaTeX provides superior font handling through:
% 1. HarfBuzz text shaping engine for complex scripts
% 2. Native OpenType feature support
% 3. Better Unicode normalization
% 4. Advanced font fallback mechanisms
%
% HarfBuzz renderer benefits:
% - Proper CJK character shaping and spacing
% - Complex script support (Arabic, Devanagari, etc.)
% - Advanced typography features (ligatures, kerning)
% - Emoji and color font support
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Renderer=HarfBuzz}
% Configure main font with comprehensive CJK support
%
% Font selection priority:
% 1. Source Han Sans SC - Adobe/Google's pan-CJK font family
% - Covers Simplified Chinese, Japanese, Korean
% - Excellent Unicode coverage and glyph quality
% - Professional typography features
% 2. Noto Sans CJK SC - Google's alternative CJK solution
% - Similar coverage to Source Han Sans
% - Open source and widely available
% 3. PingFang SC - Apple's system font for Chinese (macOS)
% - High-quality rendering on Apple systems
% - Optimized for screen and print display
\IfFontExistsTF{Source Han Sans SC}{
\setmainfont{Source Han Sans SC}[
Scale=1.0,
UprightFont=Source Han Sans SC Regular,
BoldFont=Source Han Sans SC Bold,
ItalicFont=Source Han Sans SC Regular,
BoldItalicFont=Source Han Sans SC Bold,
Renderer=HarfBuzz
]
\setsansfont{Source Han Sans SC}[
Scale=1.0,
UprightFont=Source Han Sans SC Regular,
BoldFont=Source Han Sans SC Bold,
Renderer=HarfBuzz
]
\typeout{Set main font to Source Han Sans SC for comprehensive CJK support}
}{
\IfFontExistsTF{Noto Sans CJK SC}{
\setmainfont{Noto Sans CJK SC}[
Scale=1.0,
BoldFont=Noto Sans CJK SC Bold,
Renderer=HarfBuzz
]
\setsansfont{Noto Sans CJK SC}[
Scale=1.0,
BoldFont=Noto Sans CJK SC Bold,
Renderer=HarfBuzz
]
\typeout{Set main font to Noto Sans CJK SC}
}{
\IfFontExistsTF{PingFang SC}{
\setmainfont{PingFang SC}[
Scale=1.0,
BoldFont=PingFang SC Semibold,
Renderer=HarfBuzz
]
\typeout{Set main font to PingFang SC (macOS fallback)}
}{
\typeout{Warning: No suitable CJK font found}
}
}
}
\else
% XeLaTeX fallback configuration
%
% XeLaTeX approach for CJK text:
% 1. fontspec package for OpenType font support
% 2. xeCJK package for Chinese, Japanese, Korean text handling
% 3. Automatic font switching between Latin and CJK scripts
% 4. Maintains compatibility with older LaTeX documents
%
% XeLaTeX benefits:
% - Faster compilation than LuaLaTeX for simple documents
% - Wide package compatibility
% - Stable and well-tested CJK support
\usepackage{fontspec}
\usepackage{xeCJK}
% Configure main fonts for XeLaTeX
\IfFontExistsTF{Source Han Sans SC}{
\setmainfont{Source Han Sans SC}[
Scale=1.0,
BoldFont=Source Han Sans SC Bold,
Renderer=HarfBuzz
]
\setCJKmainfont{Source Han Sans SC}[
Scale=1.0,
BoldFont=Source Han Sans SC Bold
]
\typeout{Set fonts to Source Han Sans SC (XeLaTeX)}
}{
\typeout{Using default fonts (XeLaTeX)}
}
\fi
% Enhanced multilingual font support (CJK and emoji)
%
% This section configures specialized fonts for:
% 1. Japanese text (Hiragana, Katakana, Kanji)
% 2. Korean text (Hangul, Hanja)
% 3. Emoji and pictographic symbols
% 4. Proper font fallback chains
%
% Benefits of separate font families:
% - Language-specific glyph variants (e.g., Chinese vs Japanese Kanji)
% - Optimized character spacing and metrics
% - Cultural typography preferences
% - Better rendering quality for each script
\ifluatex
% LuaLaTeX multilingual font configuration
% Uses newfontfamily to define specialized font commands
% 配置日文字体
\IfFontExistsTF{Source Han Sans JP}{
\newfontfamily\jpfont{Source Han Sans JP}[
BoldFont=Source Han Sans JP Bold,
Renderer=HarfBuzz
]
\typeout{Set Japanese font to Source Han Sans JP}
}{
\IfFontExistsTF{Hiragino Sans}{
\newfontfamily\jpfont{Hiragino Sans}[
BoldFont=Hiragino Sans W6,
Renderer=HarfBuzz
]
\typeout{Set Japanese font to Hiragino Sans}
}{
\let\jpfont\rmfamily
\typeout{No Japanese font available, using main font}
}
}
% 配置韩文字体
\IfFontExistsTF{Source Han Sans KR}{
\newfontfamily\krfont{Source Han Sans KR}[
BoldFont=Source Han Sans KR Bold,
Renderer=HarfBuzz
]
\typeout{Set Korean font to Source Han Sans KR}
}{
\IfFontExistsTF{Apple SD Gothic Neo}{
\newfontfamily\krfont{Apple SD Gothic Neo}[
BoldFont=Apple SD Gothic Neo Bold,
Renderer=HarfBuzz
]
\typeout{Set Korean font to Apple SD Gothic Neo}
}{
\let\krfont\rmfamily
\typeout{No Korean font available, using main font}
}
}
\else
% XeLaTeX 的多语言字体配置
\IfFontExistsTF{Source Han Sans JP}{
\setCJKfamilyfont{jp}{Source Han Sans JP}[
BoldFont=Source Han Sans JP Bold
]
\newcommand{\jpfont}{\CJKfamily{jp}}
\typeout{Set Japanese font to Source Han Sans JP (XeLaTeX)}
}{
\newcommand{\jpfont}{}
\typeout{No Japanese font available (XeLaTeX)}
}
\IfFontExistsTF{Source Han Sans KR}{
\setCJKfamilyfont{kr}{Source Han Sans KR}[
BoldFont=Source Han Sans KR Bold
]
\newcommand{\krfont}{\CJKfamily{kr}}
\typeout{Set Korean font to Source Han Sans KR (XeLaTeX)}
}{
\newcommand{\krfont}{}
\typeout{No Korean font available (XeLaTeX)}
}
\fi
$if(emoji)$
% 配置 emoji 字体 - 针对 LuaLaTeX 和 XeLaTeX 优化
\ifluatex
% LuaLaTeX emoji 字体配置
\IfFontExistsTF{Apple Color Emoji}{
\newfontfamily\emojifont{Apple Color Emoji}[
Renderer=HarfBuzz
]
\typeout{Set emoji font to Apple Color Emoji (LuaLaTeX)}
}{
\IfFontExistsTF{Noto Color Emoji}{
\newfontfamily\emojifont{Noto Color Emoji}[
Renderer=HarfBuzz
]
\typeout{Set emoji font to Noto Color Emoji (LuaLaTeX)}
}{
\IfFontExistsTF{Segoe UI Emoji}{
\newfontfamily\emojifont{Segoe UI Emoji}[
Renderer=HarfBuzz
]
\typeout{Set emoji font to Segoe UI Emoji (LuaLaTeX)}
}{
\IfFontExistsTF{Noto Emoji}{
\newfontfamily\emojifont{Noto Emoji}[
Renderer=HarfBuzz
]
\typeout{Set emoji font to Noto Emoji (LuaLaTeX)}
}{
% 使用符号字体作为 fallback
\IfFontExistsTF{Arial Unicode MS}{
\newfontfamily\emojifont{Arial Unicode MS}[
Renderer=HarfBuzz
]
\typeout{Set emoji font to Arial Unicode MS (LuaLaTeX fallback)}
}{
\let\emojifont\rmfamily
\typeout{Warning: No emoji font found (LuaLaTeX), using main font}
}
}
}
}
}
\else
% XeLaTeX emoji 字体配置
\IfFontExistsTF{Apple Color Emoji}{
\newfontfamily\emojifont{Apple Color Emoji}[
Renderer=HarfBuzz,
RawFeature={color=1}
]
\typeout{Set emoji font to Apple Color Emoji with color support (XeLaTeX)}
}{
\IfFontExistsTF{Noto Color Emoji}{
\newfontfamily\emojifont{Noto Color Emoji}[
Renderer=HarfBuzz,
RawFeature={color=1}
]
\typeout{Set emoji font to Noto Color Emoji with color support (XeLaTeX)}
}{
\IfFontExistsTF{Arial Unicode MS}{
\newfontfamily\emojifont{Arial Unicode MS}
\typeout{Set emoji font to Arial Unicode MS (XeLaTeX fallback)}
}{
\let\emojifont\rmfamily
\typeout{Warning: No emoji font found (XeLaTeX), using main font}
}
}
}
\fi
% 配置中文支持
\ifluatex
% LuaLaTeX 中文配置 - 使用 fontset=none 避免默认字体冲突
\usepackage[UTF8,fontset=none]{ctex}
% 手动配置 ctex 字体,使用我们已经设置的字体
\IfFontExistsTF{Source Han Sans SC}{
\setCJKmainfont{Source Han Sans SC}[
BoldFont=Source Han Sans SC Bold
]
\setCJKsansfont{Source Han Sans SC}[
BoldFont=Source Han Sans SC Bold
]
\setCJKmonofont{Source Han Mono SC}[
BoldFont=Source Han Mono SC Bold
]
\typeout{Configured ctex with Source Han Sans SC (LuaLaTeX)}
}{
\typeout{Warning: Source Han Sans SC not found for ctex (LuaLaTeX)}
}
\else
% XeLaTeX 中文配置
\usepackage[UTF8]{ctex}
\typeout{Using ctex for Chinese support (XeLaTeX)}
\fi
% 配置中英文间距(ctex 会自动处理)
\ctexset{
punct=quanjiao,
space=auto,
autoindent=true
}
% 配置符号字体(用于特殊符号和 emoji fallback)
\IfFontExistsTF{Noto Sans Symbols}{
\newfontfamily\symbolfont{Noto Sans Symbols}
\typeout{Set symbol font to Noto Sans Symbols}
}{
\IfFontExistsTF{Segoe UI Symbol}{
\newfontfamily\symbolfont{Segoe UI Symbol}
\typeout{Set symbol font to Segoe UI Symbol}
}{
\IfFontExistsTF{Arial Unicode MS}{
\newfontfamily\symbolfont{Arial Unicode MS}
\typeout{Set symbol font to Arial Unicode MS}
}{
\let\symbolfont\rmfamily
\typeout{Warning: No symbol font found}
}
}
}
$else$
% 非 emoji 模式下也配置符号字体
\IfFontExistsTF{Noto Sans Symbols}{
\newfontfamily\symbolfont{Noto Sans Symbols}
\typeout{Set symbol font to Noto Sans Symbols}
}{
\IfFontExistsTF{Arial Unicode MS}{
\newfontfamily\symbolfont{Arial Unicode MS}
\typeout{Set symbol font to Arial Unicode MS}
}{
\let\symbolfont\rmfamily
\typeout{Warning: No symbol font found}
}
}
$endif$
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{caption}
\usepackage{float}
\usepackage{chngcntr}
\usepackage{pdfpages}
\usepackage{parskip}
\usepackage{listings}
\usepackage{minted}
\usepackage{fvextra}
\usepackage{amsmath} % Required for mathematical environments like align
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage{bookmark}
\usepackage{tocloft}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{enumitem}
\usepackage[normalem]{ulem} % For strikethrough (\sout) and underline commands, normalem preserves \emph
% \usepackage{soul} % Commented out due to conflicts with ulem and CJK text
\usepackage{tikz} % Required for mdframed with framemethod=tikz
\usetikzlibrary{calc} % Required for mdframed breakable frames
\usepackage{seqsplit} % For breaking long sequences like URLs and code
% --- Pandoc Compatibility ---
\providecommand{\tightlist}{%
\setlength{\itemsep}{2pt}\setlength{\parskip}{4pt}} % 增加列表项间距和段落间距
\newcommand{\passthrough}[1]{#1}
% Define missing text formatting commands
\providecommand{\st}[1]{\sout{#1}} % Strikethrough using ulem package
\providecommand{\textsubscript}[1]{\ensuremath{_{\text{#1}}}} % Subscript
\providecommand{\textsuperscript}[1]{\ensuremath{^{\text{#1}}}} % Superscript (if not already defined)
\providecommand{\smallcaps}[1]{\textsc{#1}} % Small caps
\providecommand{\texthl}[1]{\uline{#1}} % Highlight using ulem underline
% Additional Pandoc-generated commands
\providecommand{\oldspacing}{} % Backup for spacing changes
\providecommand{\subtitle}[1]{#1} % Subtitle command
%%%% Table layout section
% This section configures table formatting and layout options
% Uses 'tabularx' and 'makecell' packages for better table handling
% --- Table Column Types ---
% Define auto-wrapping column types
\renewcommand\tabularxcolumn[1]{p{#1}} % top alignment
% For standard (non-tabularx) tables produced by Pandoc, provide better column handling
% Instead of overriding all tables, let Pandoc handle column specs and just ensure consistent formatting
\let\oldtabular\tabular
\renewcommand{\tabular}[1]{%
\oldtabular{#1}% Use Pandoc's column specification
}
% 基本表格支持 - 增强表格线条,使用浅灰色分隔线
\definecolor{tablegraylightline}{gray}{0.7} % 定义浅灰色
\arrayrulecolor{tablegraylightline} % 设置表格线条颜色为浅灰色
\renewcommand{\toprule}{\hline}
\renewcommand{\midrule}{\hline}
\renewcommand{\bottomrule}{\hline}
\renewcommand{\arraystretch}{1.6}
\setlength{\arrayrulewidth}{0.5pt}
% 定义表格列类型 - 使用更合理的宽度分配
\newcolumntype{L}{>{\raggedright\arraybackslash}p{0.33\textwidth}}
\newcolumntype{C}{>{\centering\arraybackslash}p{0.33\textwidth}}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.33\textwidth}}
%%%% Code highlight section
% This section configures syntax highlighting for code blocks in various languages
% Uses both 'listings' and 'minted' packages for comprehensive code formatting
% 'minted' provides better syntax highlighting via Pygments for modern languages
% --- Minted Configuration ---
% Note: minted environments are created by the minted-filter.lua Lua filter
% This filter converts fenced code blocks to proper minted environments with language detection
% 使用 mdframed 包来创建统一的代码块样式
\usepackage[framemethod=tikz]{mdframed}
% 定义引用块样式 - 左侧竖线
\definecolor{quoteborder}{rgb}{0.4,0.4,0.4} % 引用块左侧竖线颜色 - 更深的灰色使竖线更明显
\definecolor{quotebg}{rgb}{0.975,0.975,0.975} % 引用块背景色(非常浅的灰色)
% 定义引用块框架样式
\mdfdefinestyle{quotestyle}{
backgroundcolor=quotebg,
linecolor=quoteborder,
linewidth=4pt, % 左侧竖线宽度 - 增加到 4pt 使竖线更明显
leftline=true, % 只显示左侧线
rightline=false,
topline=false,
bottomline=false,
leftmargin=8pt, % 外部左边距,使整个引用块向右缩进
rightmargin=0pt,
innerleftmargin=20pt, % 左侧内边距,文本与竖线的距离
innerrightmargin=12pt,
innertopmargin=10pt, % 增加上下内边距
innerbottommargin=10pt,
skipabove=20pt, % 引用块前的间距,增加与段落的区分
skipbelow=20pt, % 引用块后的间距,增加与段落的区分
roundcorner=0pt,
splittopskip=\topskip, % 跨页时顶部间距
splitbottomskip=0pt, % 跨页时底部间距
everyline=true % 每一行都应用样式
}
% 定义统一的代码块框架样式 - 为行号预留左边距
\mdfdefinestyle{codeblockstyle}{
backgroundcolor=shadecolor,
linecolor=codeciteborder,
linewidth=1pt,
leftmargin=0pt,
rightmargin=0pt,
innerleftmargin=18pt, % 减少左边距,让行号更靠近边框(25pt 适合三位数行号)
innerrightmargin=12pt,
innertopmargin=6pt, % 减少上边距,让代码更靠近边框顶部
innerbottommargin=6pt, % 减少下边距,让代码更靠近边框底部
skipabove=18pt, % 代码块前的间距,增加与段落的区分
skipbelow=18pt, % 代码块后的间距,增加与段落的区分
roundcorner=0pt,
splittopskip=\topskip, % 跨页时顶部间距
splitbottomskip=0pt, % 跨页时底部间距
everyline=true % 每一行都应用样式
}
% Configure minted global settings - line number position and color control
\setminted{
linenos=true,
numbersep=6pt, % Reduce distance between line numbers and code content (6pt for closer spacing)
xleftmargin=0pt, % No negative margin to ensure line numbers stay inside border
xrightmargin=0pt, % Right margin of code block
resetmargins=false, % Keep margin settings
fontsize=\scriptsize,
breaklines=true,
breakanywhere=true,
tabsize=2,
samepage=false
}
% 自定义行号颜色 - 使用浅灰色
\renewcommand{\theFancyVerbLine}{\textcolor{linenumbercolor}{\scriptsize\arabic{FancyVerbLine}}}
% 定义 Shaded 环境用于 Pandoc 生成的代码块
\usepackage{fancyvrb}
\usepackage{framed}
\setlength{\FrameSep}{12pt} % 设置框架内边距
% 重新定义 shadecolor - 使用更浅的背景色和边框
\definecolor{shadecolor}{rgb}{0.97,0.97,0.98} % 更浅的背景色
\definecolor{codeciteborder}{rgb}{0.85,0.87,0.90} % 更浅的边框颜色
\definecolor{linenumbercolor}{rgb}{0.65,0.65,0.65} % 行号颜色 - 浅灰色
% 定义 Shaded 环境使用自定义框架,确保正确跨页
\newenvironment{Shaded}{%
\def\FrameCommand{%
\fboxsep=\FrameSep%
\fcolorbox{codeciteborder}{shadecolor}%
}%
\MakeFramed{\FrameRestore}%
\vspace{-6pt}% % 减少顶部间距
}{%
\vspace{-6pt}% % 减少底部间距
\endMakeFramed%
}
% 定义 Highlighting 环境用于语法高亮 - 优化版本,与边框完美配合
\newenvironment{Highlighting}{%
$if(emoji)$
\emojicodefont\scriptsize% % 使用支持 emoji 的代码字体,更小字号
$else$
\codefont\scriptsize% % 使用支持中文的代码字体,更小字号
$endif$
\setlength{\parindent}{0pt}%
\setlength{\leftskip}{0pt}% % 减少左边距,让内容更贴近边框
\setlength{\rightskip}{0pt}% % 减少右边距
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\setlength{\parsep}{0pt}%
\setlength{\itemsep}{0pt}%
}{%
}
% 定义 Pandoc 语法高亮命令 - 优化颜色对比度
\newcommand{\CommentTok}[1]{\textcolor{syntaxgreen}{\textit{#1}}}
\newcommand{\KeywordTok}[1]{\textcolor{syntaxblue}{\textbf{#1}}}
\newcommand{\StringTok}[1]{\textcolor{syntaxred}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor{syntaxpurple}{\textbf{#1}}}
\newcommand{\OperatorTok}[1]{\textcolor{syntaxbrown}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\BuiltInTok}[1]{\textcolor{syntaxdarkblue}{\textbf{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor{syntaxblue}{\textbf{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor{syntaxorange}{\textbf{#1}}}
\newcommand{\VariableTok}[1]{\textcolor{syntaxdarkblue}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor{syntaxpurple}{#1}}
\newcommand{\DecValTok}[1]{\textcolor{syntaxorange}{#1}}
\newcommand{\FloatTok}[1]{\textcolor{syntaxorange}{#1}}
\newcommand{\CharTok}[1]{\textcolor{syntaxred}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor{syntaxbrown}{\textbf{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor{syntaxred}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor{syntaxred}{\textbf{#1}}}
\newcommand{\ImportTok}[1]{\textcolor{syntaxdarkblue}{\textbf{#1}}}
\newcommand{\DocumentationTok}[1]{\textcolor{syntaxgreen}{\textit{#1}}}
\newcommand{\AnnotationTok}[1]{\textcolor{syntaxgreen}{\textbf{\textit{#1}}}}
\newcommand{\CommentVarTok}[1]{\textcolor{syntaxgreen}{\textbf{\textit{#1}}}}
\newcommand{\InformationTok}[1]{\textcolor{syntaxgreen}{\textbf{\textit{#1}}}}
\newcommand{\WarningTok}[1]{\textcolor{syntaxorange}{\textbf{\textit{#1}}}}
\newcommand{\AlertTok}[1]{\textcolor{syntaxred}{\textbf{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor{red}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\PreprocessorTok}[1]{\textcolor{syntaxbrown}{\textbf{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\OtherTok}[1]{\textcolor{syntaxdarkblue}{#1}}
% Define syntax highlighting colors for text-only highlighting
\definecolor{syntaxblue}{rgb}{0.0,0.0,0.8} % Keywords
\definecolor{syntaxgreen}{rgb}{0.0,0.5,0.0} % Comments
\definecolor{syntaxred}{rgb}{0.8,0.0,0.0} % Strings
\definecolor{syntaxpurple}{rgb}{0.5,0.0,0.5} % Functions
\definecolor{syntaxorange}{rgb}{0.8,0.4,0.0} % Numbers
\definecolor{syntaxgray}{rgb}{0.5,0.5,0.5} % Line numbers
\definecolor{syntaxdarkblue}{rgb}{0.0,0.0,0.5} % Types
\definecolor{syntaxbrown}{rgb}{0.6,0.3,0.0} % Operators
% --- Enhanced Listings Configuration for Fallback ---
\definecolor{codegray}{gray}{0.95}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codered}{rgb}{0.6,0,0}
\definecolor{backcolour}{rgb}{0.94,0.95,0.96} % 更明显的背景色,与 Shaded 环境一致
\definecolor{framegray}{rgb}{0.75,0.80,0.85} % 更明显的边框颜色
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen}\itshape,
keywordstyle=\color{blue}\bfseries,
numberstyle=\tiny\color{gray},
stringstyle=\color{codepurple},
basicstyle=\codefont\scriptsize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=12pt, % 行号与代码的间距
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
frame=single,
frameround=tttt,
rulecolor=\color{framegray},
framesep=12pt, % 边框内边距,确保行号在边框内
framexleftmargin=0pt, % 不额外增加左边距,让行号紧贴边框
framexrightmargin=0pt, % 不额外增加右边距
framextopmargin=8pt, % 上边距
framexbottommargin=8pt, % 下边距
xleftmargin=0pt, % 整体左边距设为 0,让边框包含行号
xrightmargin=0pt, % 整体右边距设为 0
aboveskip=12pt, % 代码块上方间距
belowskip=12pt % 代码块下方间距
}
% 定义特定语言的样式
\lstdefinelanguage{YAML}{
keywords={true,false,null,yes,no},
keywordstyle=\color{blue}\bfseries,
ndkeywords={},
ndkeywordstyle=\color{codered}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{\#},
morecomment=[s]{/*}{*/},
commentstyle=\color{codegreen}\itshape,
stringstyle=\color{codepurple},
morestring=[b]',
morestring=[b]"
}
\lstdefinelanguage{Bash}{
morekeywords={if,then,fi,else,elif,for,in,do,done,case,esac,while,function,local,export},
sensitive=true,
alsoletter={-}, % allow flags like --help
comment=[l]{\#}
}
\lstdefinelanguage{shell}{
morekeywords={if,then,fi,else,elif,for,in,do,done,case,esac,while,function,local,export},
sensitive=true,
alsoletter={-}, % allow flags like --help
comment=[l]{\#}
}
\lstdefinelanguage{Go}{
morekeywords={break,case,chan,const,continue,default,defer,else,fallthrough,for,func,go,goto,if,import,interface,map,package,range,return,select,struct,switch,type,var},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/}
}
\lstdefinelanguage{TOML}{
morekeywords={true,false},
sensitive=true,
comment=[l]{\#}
}
\lstdefinelanguage{HTML}{
morekeywords={html,head,body,title,div,span,p,a,img,ul,ol,li,table,tr,td,th,form,input,button,script,style,meta,link},
sensitive=false,
comment=[s]{<!--}{-->}
}
\lstdefinelanguage{XML}{
morekeywords={xml,version,encoding,stylesheet,schema,namespace},
sensitive=false,
comment=[s]{<!--}{-->}
}
\lstdefinelanguage{Markdown}{
morekeywords={},
sensitive=true,
comment=[l]{<!--}
}
\lstdefinelanguage{Rust}{
morekeywords={as,break,const,continue,crate,else,enum,extern,false,fn,for,if,in,let,loop,match,mod,move,mut,pub,ref,return,self,Self,static,struct,super,trait,true,type,unsafe,use,where,while},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/}
}
\lstdefinelanguage{Python}{
morekeywords={and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,not,or,pass,print,raise,return,try,while,with,yield},
sensitive=true,
comment=[l]{\#}
}
\lstdefinelanguage{JSON}{
morekeywords={},
sensitive=true,
comment=[l]{//}
}
\lstdefinelanguage{Dockerfile}{
morekeywords={FROM,RUN,CMD,LABEL,EXPOSE,ENV,ADD,COPY,ENTRYPOINT,VOLUME,USER,WORKDIR,ARG,ONBUILD,STOPSIGNAL,HEALTHCHECK,SHELL},
sensitive=false,
comment=[l]{\#}
}
\lstdefinelanguage{INI}{
morekeywords={},
sensitive=true,
comment=[l]{\#},
morecomment=[l]{;}
}
\lstdefinelanguage{JavaScript}{
morekeywords={break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with,const,let,class,extends,super,import,export,from,async,await},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/}
}
\lstdefinelanguage{Text}{}
\lstset{language=Text}
% Language alias mapping macro
\providecommand{\lstalias}[2]{\expandafter\lstdefinelanguage\expandafter{#1}[]{#2}{}}
% Helper aliases so Pandoc names match ours
\lstalias{shell}{Bash}
\lstalias{sh}{Bash}
\lstalias{go}{Go}
\lstalias{python}{Python}
\lstalias{javascript}{JavaScript}
\lstalias{js}{JavaScript}
\lstalias{yaml}{YAML}
\lstalias{yml}{YAML}
\lstalias{json}{JSON}
\lstalias{html}{HTML}
\lstalias{xml}{XML}
\lstalias{toml}{TOML}
\lstalias{dockerfile}{Dockerfile}
\lstalias{rust}{Rust}
\lstalias{rs}{Rust}
\lstalias{markdown}{Markdown}
\lstalias{md}{Markdown}
\lstalias{ini}{INI}
\lstalias{text}{Text}
\lstalias{txt}{Text}
\lstalias{go-html-template}{Go}
\lstalias{gotemplate}{Go}
\lstset{
style=mystyle,
columns=fixed,
keepspaces=true
}
% 为不同语言设置特定样式
\lstset{
language=YAML,
morekeywords={apiVersion,kind,metadata,spec,data,name,namespace,labels,annotations}
}
% --- Document Layout ---
% Figure numbering by chapter
\counterwithin{figure}{chapter}
\renewcommand{\thefigure}{\thechapter-\arabic{figure}}
\captionsetup{labelsep=colon, font=normal} % 将 labelsep=space 改为 colon
\renewcommand{\figurename}{图}
% 优化图片浮动和间距设置
\setlength{\floatsep}{12pt plus 2pt minus 2pt} % 浮动体与浮动体之间的间距
\setlength{\textfloatsep}{12pt plus 2pt minus 2pt} % 浮动体与正文之间的间距
\setlength{\intextsep}{12pt plus 2pt minus 2pt} % 嵌入文本的浮动体前后间距
\setlength{\abovecaptionskip}{6pt} % 图片与标题之间的间距
\setlength{\belowcaptionskip}{6pt} % 标题与下文之间的间距
% 更宽松的浮动体参数
\renewcommand{\topfraction}{0.9} % 页面顶部浮动体的最大比例
\renewcommand{\bottomfraction}{0.8} % 页面底部浮动体的最大比例
\renewcommand{\textfraction}{0.07} % 页面文本的最小比例
\renewcommand{\floatpagefraction}{0.7} % 浮动页面浮动体的最小比例
\setcounter{totalnumber}{50} % 页面浮动体的最大数量
\setcounter{topnumber}{50} % 页面顶部浮动体的最大数量
\setcounter{bottomnumber}{50} % 页面底部浮动体的最大数量
% Table formatting
\renewcommand{\tablename}{表}
\counterwithin{table}{chapter}
\renewcommand{\thetable}{\thechapter-\arabic{table}}
% 设置表格样式
\captionsetup[table]{position=top, labelsep=colon, font=normal}
% 设置表格行间距和基本样式(已在基本表格支持部分设置)
% 设置 longtable 基本间距
\setlength{\LTpre}{1.5em}
\setlength{\LTpost}{1.5em}
% 表格优化:防止文字重叠,适配全宽度表格
\setlength{\tabcolsep}{5pt} % 适当的列间距,适配全宽度表格
\setlength{\extrarowheight}{3pt} % 增加行高
\setlength{\LTcapwidth}{\textwidth} % longtable 标题宽度
% 表格字体大小和宽度控制
\newcommand{\maxTableWidth}{\textwidth}
% Note: \tabulinesep is from longtabu package, not longtable
% For longtable, we use \arraystretch and \tabcolsep for spacing control
\newcommand{\tablefontsize}{\small}
% 优化表格分页
\setlength{\LTleft}{0pt}
\setlength{\LTright}{0pt}
% 表格自动换行列类型(参数化版本)- 优化版本
\newcolumntype{L}[1]{\u003e{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{\u003e{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{\u003e{\raggedleft\arraybackslash}p{#1}}
% 定义更灵活的自动换行列类型,支持断词
\newcolumntype{P}[1]{\u003e{\raggedright\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{M}[1]{\u003e{\centering\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{B}[1]{\u003e{\raggedleft\arraybackslash\hspace{0pt}}b{#1}}
% Page geometry
\geometry{left=2.5cm, right=2.5cm, top=3cm, bottom=3cm, headheight=1.5cm, footskip=1cm}
% Text alignment - ensure left alignment
\raggedright
\setlength{\parindent}{0pt}
\setlength{\parskip}{8pt plus 2pt minus 1pt} % 增加段落间距,从3pt提升到8pt
% ======== 脚注样式优化 ========
% 现代化脚注设计,提升视觉效果和可读性
% 加载脚注样式包,设置悬挂缩进和左对齐
\usepackage[hang,flushmargin]{footmisc}
% 定义脚注线条颜色 - 使用浅灰色,更加现代简洁
\definecolor{footnoterulecolor}{RGB}{180,180,180}
% 重新定义脚注线条样式
\renewcommand{\footnoterule}{%
\kern -3pt%
{\color{footnoterulecolor}%
\hrule width \textwidth height 0.4pt depth 0pt}%
\kern 8pt%
}
% 脚注文本样式优化
\setlength{\footnotesep}{8pt}
\setlength{\skip\footins}{12pt plus 4pt minus 2pt}
% 脚注字体大小优化
\renewcommand{\footnotesize}{\fontsize{9}{11}\selectfont}
% 重新定义脚注编号样式 - 使用平行数字格式,不使用上标
\makeatletter
\renewcommand\@makefntext[1]{%
\setlength{\parindent}{0pt}% % 无首行缩进
\footnotesize\@thefnmark.\,#1% % 编号 + 点 + 小间距 + 内容
}
\makeatother
% ======== 脚注样式优化结束 ========
% Enhanced Unicode character support and emoji fallback commands
\newcommand{\greencheckmark}{\textcolor{green}{✓}}
\newcommand{\redcrossmark}{\textcolor{red}{✗}}
\newcommand{\orangewarningmark}{\textcolor{orange}{⚠}}
% Define enhanced emoji and symbol commands with intelligent fallback
% Universal emoji command that tries multiple font sources in order
\newcommand{\emoji}[1]{%
\ifcsname emojifont\endcsname%
\begingroup%
\emojifont%
#1%
\endgroup%
\else%
\ifcsname symbolfont\endcsname%
\begingroup%
\symbolfont%
#1%
\endgroup%
\else%
#1%
\fi%
\fi%
}
% Smart symbol command that tries symbol font first, then emoji font
\newcommand{\smartsymbol}[1]{%
\ifcsname symbolfont\endcsname%
\begingroup%
\symbolfont%
#1%
\endgroup%
\else%
\ifcsname emojifont\endcsname%
\begingroup%
\emojifont%
#1%
\endgroup%
\else%
#1%
\fi%
\fi%
}
% 定义一个更强大的多字体 fallback 命令
\newcommand{\multifont}[1]{%
\ifcsname emojifont\endcsname%
\begingroup%
\emojifont%
#1%
\endgroup%
\else%
\ifcsname symbolfont\endcsname%
\begingroup%
\symbolfont%
#1%
\endgroup%
\else%
\ifcsname jpfont\endcsname%
\begingroup%
\jpfont%
#1%
\endgroup%
\else%
\ifcsname krfont\endcsname%
\begingroup%
\krfont%
#1%
\endgroup%
\else%
#1%
\fi%
\fi%
\fi%
\fi%
}
% Define common emoji commands with intelligent fallback
$if(emoji)$
% For emoji builds, use smart emoji command with fallback
\DeclareRobustCommand{\emojicheck}{\emoji{✅}}
\DeclareRobustCommand{\emojicross}{\emoji{❌}}
\DeclareRobustCommand{\emojiwarning}{\emoji{⚠️}}
\DeclareRobustCommand{\emojinote}{\emoji{📝}}
\DeclareRobustCommand{\emojitool}{\emoji{🔧}}
\DeclareRobustCommand{\emojiidea}{\emoji{💡}}
\DeclareRobustCommand{\emojirocket}{\emoji{🚀}}
\DeclareRobustCommand{\emojichart}{\emoji{📊}}
\DeclareRobustCommand{\emojitarget}{\emoji{🎯}}
\DeclareRobustCommand{\emojistar}{\emoji{⭐}}
$else$
% For non-emoji builds, provide text fallbacks with symbol font support
\DeclareRobustCommand{\emojicheck}{\smartsymbol{✓}}
\DeclareRobustCommand{\emojicross}{\smartsymbol{✗}}
\DeclareRobustCommand{\emojiwarning}{\smartsymbol{⚠}}
\DeclareRobustCommand{\emojinote}{[NOTE]}
\DeclareRobustCommand{\emojitool}{[TOOL]}
\DeclareRobustCommand{\emojiidea}{[IDEA]}
\DeclareRobustCommand{\emojirocket}{[ROCKET]}
\DeclareRobustCommand{\emojichart}{[CHART]}
\DeclareRobustCommand{\emojitarget}{[TARGET]}
\DeclareRobustCommand{\emojistar}{[STAR]}
$endif$
% Configure symbol fonts for special characters, currency, and emoji
% Add support for missing symbols like currency symbols, punctuation, etc.
\ifluatex
% LuaLaTeX symbol font configuration
% Configure symbol fonts for comprehensive Unicode support
\IfFontExistsTF{Noto Sans Symbols}{
\newfontfamily\symbolfont{Noto Sans Symbols}[Renderer=HarfBuzz]
\typeout{Set symbol font to Noto Sans Symbols}
}{
\IfFontExistsTF{Noto Sans Symbols2}{
\newfontfamily\symbolfont{Noto Sans Symbols2}[Renderer=HarfBuzz]
\typeout{Set symbol font to Noto Sans Symbols2}
}{
\IfFontExistsTF{Segoe UI Symbol}{
\newfontfamily\symbolfont{Segoe UI Symbol}[Renderer=HarfBuzz]
\typeout{Set symbol font to Segoe UI Symbol}
}{
% Use main font as fallback
\let\symbolfont\rmfamily
\typeout{Warning: No symbol font found, using main font}
}
}
}
% Currency font configuration
\IfFontExistsTF{Noto Sans}{
\newfontfamily\currencyfont{Noto Sans}[Renderer=HarfBuzz]