Commit 5a4a0e2

HPCesia <me@hpcesia.com>
2025-03-19 11:58:59
feat: 英文摘要页面
1 parent 8104711
Changed files (4)
pages/bachelor-abstract-en.typ
@@ -0,0 +1,40 @@
+#import "../utils/style.typ": 字号, 字体
+#import "../utils/invisible-heading.typ": invisible-heading
+
+// 本科生英文摘要页
+#let bachelor-abstract-en(
+  // documentclass 传入的参数
+  twoside: false,
+  fonts: (:),
+  // 其他参数
+  keywords: (),
+  outline-title: "Abstract",
+  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.宋体-英文, weight: "bold")[Abstract])
+  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.宋体-英文, weight: "bold")[Key Words: ]
+  text(size: 字号.小四, font: fonts.宋体-英文, (("",) + keywords.intersperse("; ")).sum())
+}
\ No newline at end of file
template/thesis.typ
@@ -10,6 +10,7 @@
   cover,
   integrity,
   abstract,
+  abstract-en,
 ) = documentclass(
   twoside: true, // 双面模式,会加入空白页,便于打印
   info: (
@@ -59,4 +60,20 @@
   自带黑体/宋体的优先级使用编译环境中存在的字体。
 
   建议使用前先完整浏览本模板中的所有内容,以完整地了解使用模板的方法与 Typst 的基础用法。
+]
+
+// 英文摘要
+
+#abstract-en(
+  keywords: ("Undergraduate Thesis", "Xiamen University", "Typst"),
+  outlined: true,
+  outline-title: "Abstract",
+)[
+  #import "@preview/metalogo:1.2.0": LaTeX
+
+  This template is based on #link("https://github.com/nju-lug/modern-nju-thesis")[Modern NJU Thesis Template] and #link("https://github.com/F5Soft/xmu-template")[Xiamen University Undergraduate Thesis #LaTeX Template], and is created according to the _Xiamen University Undergraduate Thesis (Design) Specification_.
+
+  This template provides high-resolution cover, integrity commitment letter, Chinese and English abstract environments, automatic generation of Chinese and English tables of contents, appendix environment, reference environment, acknowledgment environment, etc. Through Typst's font fallback feature, this template adapts fonts for Windows and macOS systems, using Source Han Sans/Serif, Windows built-in Sans/Serif, and macOS built-in Sans/Serif fonts in order of priority based on what fonts are available in the compilation environment.
+
+  It is recommended to fully browse all the content in this template before use to fully understand how to use the template and the basic usage of Typst.
 ]
\ No newline at end of file
utils/style.typ
@@ -60,4 +60,17 @@
     "Heiti SC",
     "STHeiti",
   ),
+
+  // 由于 `latin-in-cjk` 不包含英文中的引号,导致引号为中文字形,故单独提供英文字体
+  宋体-英文: (
+    "Times New Roman"
+  ),
+  黑体-英文: (
+    "Arial"
+  ),
+  等宽-英文: (
+    "Courier New",
+    "Menlo",
+    "IBM Plex Mono",
+  ),
 )
lib.typ
@@ -4,6 +4,7 @@
 #import "pages/bachelor-cover.typ": bachelor-cover
 #import "pages/bachelor-integrity.typ": bachelor-integrity
 #import "pages/bachelor-abstract.typ": bachelor-abstract
+#import "pages/bachelor-abstract-en.typ": bachelor-abstract-en
 #import "utils/style.typ": 字体, 字号
 
 // 使用函数闭包特性,通过 `documentclass` 函数类进行全局信息配置,然后暴露出拥有了全局配置的、具体的 `layouts` 和 `templates` 内部函数。
@@ -64,5 +65,11 @@
       ..args,
       fonts: fonts + args.named().at("fonts", default: (:)),
     ),
+    // 英文摘要页
+    abstract-en:(..args) => bachelor-abstract-en(
+      twoside: twoside,
+      ..args,
+      fonts: fonts + args.named().at("fonts", default: (:)),
+    ),
   )
 }