1
- # import " @preview/outrageous:0.3.0"
2
1
# import " ../utils/invisible-heading.typ" : invisible-heading
3
2
# import " ../utils/style.typ" : 字号, 字体
4
3
# import " ../utils/custom-heading.typ" : heading-content
59
58
60
59
{
61
60
set align (center )
62
- text (.. title-text-args , title )
63
61
// 标记一个不可见的标题用于目录生成
64
62
invisible-heading (level : 1 , outlined : outlined , title )
63
+ text (.. title-text-args , title )
64
+
65
65
}
66
66
67
67
v (title-vspace )
68
68
69
- show outline . entry : outrageous . show-entry . with (
70
- // 保留 Typst 基础样式
71
- .. outrageous . presets . typst ,
72
- body-transform : (level , it ) => {
73
- // 设置字体和字号
74
- set text (
75
- font : font . at (calc . min (level , font . len ()) - 1 ),
76
- size : size . at (calc . min (level , size . len ()) - 1 ),
77
- )
78
- // 计算缩进
79
- let indent-list = indent + range (level - indent . len ()). map ((it ) => indent . last ())
80
- let indent-length = indent-list . slice (0 , count : level ). sum ()
81
- if " children" in it . fields () and it . children . len () > 2 {
82
- set text (weight : weight . at (calc . min (level , weight . len ()) - 1 ))
83
- let (number , space , .. text ) = it . children
84
- [# h (indent-length ) # box [# number ] # h (if level > 1 {3pt } else {2pt }) # text . join ()]
85
- } else {
86
- set text (weight : weight . at (calc . min (level , weight . len ()) - 1 ))
87
- h (indent-length ) + it
88
- }
89
- },
90
- vspace : vspace ,
91
- fill : fill ,
92
- .. args ,
69
+ let array-at (arr , pos ) = {
70
+ arr . at (calc . min (pos , arr . len ()) - 1 )
71
+ }
72
+
73
+ show outline . entry . where (level : 1 ): it => link (
74
+ it . element . location (),
75
+ it . indented (
76
+ if it . prefix () != none and repr (it . prefix ()). len () > 2 {
77
+ text (font : fonts . 黑体, size : array-at (size , 0 ), it . prefix ())
78
+ } else { none },
79
+ {
80
+ text (font : fonts . 黑体, size : array-at (size , 0 ), it . body ())
81
+ [ ]
82
+ box (width : 1fr , it . fill )
83
+ [ ]
84
+ it . page ()
85
+ })
93
86
)
94
87
88
+ show outline . entry : it => {
89
+ set block (spacing : array-at (vspace , it . level - 1 ))
90
+ // if it.prefix() != none {it.prefix()} else { block(it) }
91
+ it
92
+ }
93
+
95
94
// 显示目录
96
- outline (title : none , depth : depth )
95
+ outline (title : none , depth : depth , indent : auto )
97
96
}
0 commit comments