Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 pdcxs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# unofficial-tyut-thesis

非官方太原理工大学本科毕业论文 typst 模板

本项目在 [南京大学学位论文 modern-nju-thesis](https://github.com/nju-lug/modern-nju-thesis) 的基础上进行了修改,在此表示感谢。

只适用于本科生,研究生与博士生请勿使用。

如果需要在在线版APP中使用此模板,需要将 `fonts` 目录中的所有字体上传至项目目录中。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/layouts/appendix.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#import "@preview/i-figured:0.2.4"
#import "@preview/numbly:0.1.0": numbly

// 后记,重置 heading 计数器
#let appendix(
numbering: numbly(
"附录{1:A}. ",
"{1:A}.{2} ",
"{1:A}.{2}.{3} ",
"{1:A}.{2}.{3}.{4} ",
"{1:A}.{2}.{3}.{4}.{5} ",
"{1:A}.{2}.{3}.{4}.{5}.{6} ",
),
// figure 计数
show-figure: i-figured.show-figure.with(numbering: "A-1"),
// equation 计数
show-equation: i-figured.show-equation.with(numbering: "(A-1)"),
// 重置计数
reset-counter: true,
it,
) = {
set heading(numbering: numbering)
if reset-counter {
counter(heading).update(0)
}
// 设置 figure 的编号
show figure: show-figure
// 设置 equation 的编号
show math.equation.where(block: true): show-equation
it
}
24 changes: 24 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/layouts/doc.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#let doc(
info: (:),
fallback: false,
lang: "zh",
margin: (
top: 3.3cm,
bottom: 2.3cm,
left: 2.8cm,
right: 2.3cm,
),
it,
) = {
if type(info.title) == str {
info.title = info.title.split("\n")
}

set text(fallback: fallback, lang: lang)
set page(margin: margin)
set document(
title: (("",) + info.title).sum(),
author: info.author,
)
it
}
34 changes: 34 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/layouts/glossary.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#let glossary_entries = state("glossary_entries", (:))

#let make-glossary-table(gls) = {
for item in gls {
glossary_entries.update(tbl => {
tbl.insert(item.key, (short: item.short, long: item.long, appeared: false, description: item.description))
tbl
})
}
}

#let gloss(key) = context {
let itm = glossary_entries
.get()
.at(key, default: (
appeared: false,
short: [*???*],
long: [*???*],
description: text(fill: red)[*没有找到 #key 对应的术语*],
))
if itm.appeared {
[#itm.short]
} else {
glossary_entries.update(tbl => {
tbl.insert(key, itm + (appeared: true))
tbl
})
if itm.description != "" {
[#itm.description (#itm.long, #itm.short) ]
} else {
[#itm.long (#itm.short) ]
}
}
}
148 changes: 148 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/layouts/mainmatter.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#import "@preview/numbly:0.1.0": numbly
#import "@preview/pointless-size:0.1.2": zh
#import "@preview/i-figured:0.2.4"
#import "@preview/cuti:0.4.0": show-cn-fakebold
#import "@preview/itemize:0.2.0" as el

#let mainmatter(
twoside: false,
leading: 1.5 * 15.6pt - 0.7em,
spacing: 1.5 * 15.6pt - 0.7em,
font: "SimSun",
justify: true,
text-args: auto,
heading-font: auto,
first-line-indent: (amount: 2em, all: true),
mono-font: ("Courier New", "LXGW WenKai Mono GB"),
numbering: numbly(
"{1}. ",
"{1}.{2} ",
"{1}.{2}.{3} ",
"{1}.{2}.{3}.{4} ",
"{1}.{2}.{3}.{4}.{5} ",
"{1}.{2}.{3}.{4}.{5}.{6} ",
),
heading-weight: ("regular",),
heading-above: (2 * 15.6pt - 0.7em, 1.5 * 15.6pt - 0.4em),
heading-below: (2 * 15.6pt - 0.7em, 1.5 * 15.6pt - 0.7em),
heading-pagebreak: (true, false),
heading-size: (zh(-3), zh(4), zh(-4)),
heading-align: (center, auto),
show-figure: i-figured.show-figure,
show-equation: i-figured.show-equation,
caption-style: none,
caption-size: zh(5),
separator: " ",
..args,
it,
) = {
// 辅助函数
let array-at(arr, pos) = {
arr.at(calc.min(pos, arr.len()) - 1)
}
let unpairs(pairs) = {
let dict = (:)
for pair in pairs {
dict.insert(..pair)
}
dict
}

let heading-text-args-lists = args
.named()
.pairs()
.filter(pair => pair.at(0).starts-with("heading-"))
.map(pair => (
pair.at(0).slice("heading-".len()),
pair.at(1),
))

// 页码设置
set page(numbering: (..nums) => text(size: zh(-5), [#nums.at(0)]))
counter(page).update(1)

// 字体
if text-args == auto {
text-args = (font: ("Times New Roman", font), size: zh(-4))
}
if heading-font == auto {
heading-font = (("Times New Roman", "SimHei"),)
}

// 标题设置
set heading(numbering: numbering)
show heading: it => {
set text(
font: array-at(heading-font, it.level),
size: array-at(heading-size, it.level),
bottom-edge: "descender",
weight: array-at(heading-weight, it.level),
..unpairs(heading-text-args-lists.map(pair => (pair.at(0), array-at(pair.at(1), it.level)))),
)
set block(
above: array-at(heading-above, it.level),
below: array-at(heading-below, it.level),
)
it
}
// 章节标题居中并自动换页
show heading: it => {
if array-at(heading-pagebreak, it.level) {
pagebreak(weak: true)
}
if array-at(heading-align, it.level) != auto {
set align(array-at(heading-align, it.level))
it
} else {
it
}
}

// 正文样式
show: show-cn-fakebold
set text(..text-args)
set par(
leading: leading,
justify: justify,
first-line-indent: first-line-indent,
spacing: spacing,
)
show raw: set text(font: mono-font)
show raw.where(block: true): set par(leading: 0.55em)

// 编号对齐
show: el.default-enum-list

// 脚注样式
show footnote.entry: set text(font: ("Times New Roman", font), size: zh(5))

// figure 编号
show heading: i-figured.reset-counters
show heading: i-figured.reset-counters.with(extra-kinds: ("algo",))
show figure: show-figure.with(extra-prefixes: (algo: "alg:"))

// 公式编号
show math.equation.where(block: true): show-equation
set math.equation(supplement: "公式")

// 表格
show figure.where(kind: table): set figure.caption(position: top)
set figure.caption(separator: separator)
if caption-style == none {
caption-style = (font: ("Times New Roman", "SimHei"))
}
show figure.caption: it => text(size: caption-size, ..caption-style, it)

// 大表格和代码可跨页
show figure: set block(breakable: true)

// 去除空行连接时中文中间的空格
// https://www.w3.org/TR/clreq/#table_of_punctuation_marks
let han-or-punct = "[-\p{sc=Hani}。.,、:;!‼?⁇⸺——……⋯⋯~–—·・‧//「」『』“”‘’()《》〈〉【】〖〗〔〕[]{}_﹏●•]"
show regex(han-or-punct + " " + han-or-punct): it => {
let (a, _, b) = it.text.clusters()
a + b
}

it
}
12 changes: 12 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/layouts/preface.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#let preface(
twoside: false,
..args,
it,
) = {
if twoside {
pagebreak() + " "
}
counter(page).update(0)
set page(numbering: "I")
it
}
86 changes: 86 additions & 0 deletions packages/preview/unofficial-tyut-thesis/0.2.2/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#import "pages/cover.typ": cover
#import "pages/decl.typ": decl
#import "pages/abstract.typ": abstract
#import "pages/abstract-en.typ": abstract-en
#import "layouts/doc.typ": doc
#import "layouts/preface.typ": preface
#import "pages/outline-page.typ": outline-page
#import "layouts/mainmatter.typ": mainmatter
#import "layouts/glossary.typ": gloss, make-glossary-table
#import "pages/acknowledgement.typ": acknowledgement
#import "layouts/appendix.typ": appendix
#import "utils/bilingual.typ": bibliography
#import "@preview/gb7714-bilingual:0.2.3": multicite

#let documentclass(
info: (:),
twoside: false,
anonymous: false,
font: "SimSun",
reference-font: ("Times New Roman", "SimSun"),
) = {
return (
doc: (..args) => {
doc(
..args,
info: info + args.named().at("info", default: (:)),
)
},
cover: (..args) => {
cover(
anonymous: anonymous,
..args,
info: info,
)
},
decl: (..args) => decl(
anonymous: anonymous,
twoside: twoside,
..args,
info: info,
),
abstract: (..args) => abstract(
twoside: twoside,
info: info,
font: font,
..args,
),
abstract-en: (..args) => abstract-en(
twoside: twoside,
info: info,
..args,
),
preface: (..args) => preface(
twoside: twoside,
..args,
),
outline-page: (..args) => outline-page(
twoside: twoside,
font: font,
..args,
),
mainmatter: (..args) => mainmatter(
twoside: twoside,
font: font,
..args,
),
gloss: gloss,
make-glossary-table: make-glossary-table,
bibliography: bibliography,
multicite: multicite,
acknowledgement: (..args) => {
acknowledgement(
anonymous: anonymous,
twoside: twoside,
font: font,
..args,
)
},
appendix: (..args) => {
appendix(
..args,
)
},
twoside: twoside,
)
}
Loading
Loading