Commit 8b7cba0

HPCesia <me@hpcesia.com>
2025-03-19 07:21:30
feat: 中文摘要页面
1 parent e73049d
pages/bachelor-abstract.typ
@@ -0,0 +1,40 @@
+#import "../utils/style.typ": 字号, 字体
+#import "../utils/invisible-heading.typ": invisible-heading
+
+// 本科生中文摘要页
+#let bachelor-abstract(
+  // documentclass 传入的参数
+  twoside: false,
+  fonts: (:),
+  // 其他参数
+  keywords: (),
+  outline-title: "中文摘要",
+  outlined: false,
+  leading: 1.28em,
+  spacing: 1.28em,
+  body,
+) = {
+  // 1.  默认参数
+  fonts = 字体 + fonts
+
+  // 2.  正式渲染
+  pagebreak(weak: true, to: if twoside { "odd" })
+
+  invisible-heading(level: 1, outlined: outlined, outline-title)
+
+  v(spacing)
+  align(center, text(size: 字号.小三, font: fonts.黑体)[摘#h(1.5em)要])
+  v(spacing*2)
+
+  [
+    #set par(first-line-indent: (amount: 2em, all: true), leading: leading, spacing: spacing)
+    #set text(size: 字号.小四, font: fonts.宋体)
+
+    #body
+  ]
+
+  v(spacing)
+
+  text(size: 字号.小四, font: fonts.黑体)[关键词:]
+  text(size: 字号.小四, font: fonts.宋体, (("",) + keywords.intersperse(";")).sum())
+}
\ No newline at end of file
template/thesis.typ
@@ -9,6 +9,7 @@
   // 页面函数
   cover,
   integrity,
+  abstract,
 ) = documentclass(
   twoside: true, // 双面模式,会加入空白页,便于打印
   info: (
@@ -36,4 +37,20 @@
 
 #integrity()
 
-#show: preface
\ No newline at end of file
+#show: preface
+
+#abstract(
+  keywords: ("本科毕业论文", "厦门大学", "Typst"),
+  outlined: true,
+  outline-title: "中文摘要",
+)[
+  #import "@preview/metalogo:1.2.0": LaTeX
+
+  本模板参考#link("https://github.com/nju-lug/modern-nju-thesis")[南京大学学位论文模板 modern-nju-thesis]与#link("https://github.com/F5Soft/xmu-template")[厦门大学本科毕业论文 #LaTeX 模版],并根据《厦门大学本科毕业论文(设计)规范》进行制作。
+
+  本模版提供高清封面、诚信承诺书、中英文摘要环境、中英文目录自动生成、附录环境、参考文献环境、致谢环境等。本模板通过 Typst
+  字体 fallback 功能,适配了 Windows 和 macOS 系统的字体,将以思源黑体/宋体、Windows 自带黑体/宋体、macOS
+  自带黑体/宋体的优先级使用编译环境中存在的字体。
+
+  建议使用前先完整浏览本模板中的所有内容,以完整地了解使用模板的方法与 Typst 的基础用法。
+]
\ No newline at end of file
utils/invisible-heading.typ
@@ -0,0 +1,7 @@
+// 取自 modern-nju-thesis
+
+// 用于创建一个不可见的标题,用于给 outline 加上短标题
+#let invisible-heading(..args) = {
+  set text(size: 0pt, fill: white)
+  heading(numbering: none, ..args)
+}
\ No newline at end of file
lib.typ
@@ -3,6 +3,7 @@
 #import "layouts/preface.typ": preface
 #import "pages/bachelor-cover.typ": bachelor-cover
 #import "pages/bachelor-integrity.typ": bachelor-integrity
+#import "pages/bachelor-abstract.typ": bachelor-abstract
 #import "utils/style.typ": 字体, 字号
 
 // 使用函数闭包特性,通过 `documentclass` 函数类进行全局信息配置,然后暴露出拥有了全局配置的、具体的 `layouts` 和 `templates` 内部函数。
@@ -57,5 +58,11 @@
       ..args,
       fonts: fonts + args.named().at("fonts", default: (:)),
     ),
+    // 中文摘要页
+    abstract: (..args) => bachelor-abstract(
+      twoside: twoside,
+      ..args,
+      fonts: fonts + args.named().at("fonts", default: (:)),
+    ),
   )
 }