Skip to content

Commit

Permalink
Dev (#8)
Browse files Browse the repository at this point in the history
* 🎨 修改质数表的生成逻辑,调整 n 的默认值为 100,并优化表格单元格的填充样式 (#5)

* Feature/more configs (#7)

* 🎨 修改论文模板以支持自定义页眉,添加默认页眉内容

* 👽️ 使用新版的zihao,移除了个人定义的cn-zihao函数

* 💡 增加了 paper 部分参数以及控制的说明

* ✏️ 调整导入方式,避免 import *
  • Loading branch information
Ri-Nai authored Feb 8, 2025
1 parent 518eb50 commit eb68fd8
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 82 deletions.
18 changes: 14 additions & 4 deletions undergraduate-thesis-template/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
student-id: "1120234514",
guide-teacher: "暂无,求包养",
date: datetime.today(),
// declare: false // 是否需要声明页
// 若 abstract-content 为空,或参数缺省,则不显示中文摘要
abstract-content: [
本文……。

摘要正文选用模板中的样式所定义的“正文”,每段落首行缩进2个字符;或者手动设置成每段落首行缩进2个汉字,字体:宋体,字号:小四,行距:固定值22磅,间距:段前、段后均为0行。【阅后删除此段】

摘要是一篇具有独立性和完整性的短文,应概括而扼要地反映出本论文的主要内容。包括研究目的、研究方法、研究结果和结论等,特别要突出研究结果和结论。中文摘要力求语言精炼准确,本科生毕业设计(论文)摘要建议300-500字。摘要中不可出现参考文献、图、表、化学结构式、非公知公用的符号和术语。英文摘要与中文摘要的内容应一致。【阅后删除此段】
],

// 若 abstract-en-content 为空,或参数缺省,则不显示英文摘要
abstract-en-content: [
#lorem(40)
],
Expand Down Expand Up @@ -266,14 +271,19 @@ $
) <99-table>
]
#[
#let n = 500
#let n = 100
#figure(
caption: "1 - " + str(n) + " 质数表",
table(
columns: 10,
..range(2, n + 1)
.filter(x => range(2, calc.floor(calc.sqrt(x)) + 1).all(y => calc.rem-euclid(x, y) != 0))
.map(x => repr(x)),
[1],
..range(2, n + 1).map(x => table.cell(
fill: if range(2, calc.floor(calc.sqrt(x)) + 1).all(y => calc.rem-euclid(x, y) != 0) {
luma(200)
},
str(x),
),
)),
),
)
]
Expand Down
6 changes: 3 additions & 3 deletions undergraduate-thesis-template/pages/abstract-en.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh
#import "../utils/ziti.typ": zh, zihao

#let abstract-en(
title: "",
Expand All @@ -11,15 +11,15 @@
}

#let en-title(it) = {
set text(weight: "bold", size: cn-zh("三号"))
set text(weight: "bold", size: zh("三号"))
set par(justify: false)
set align(center)
v(1.5em)
it
}

#show heading.where(level: 1): it => {
set text(size: cn-zh("三号"), weight: "regular")
set text(size: zh("三号"), weight: "regular")

set align(center)
v(3em)
Expand Down
6 changes: 3 additions & 3 deletions undergraduate-thesis-template/pages/abstract.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh
#import "../utils/ziti.typ": zh, zihao

#let abstract(
title: "",
Expand All @@ -10,15 +10,15 @@
return
}
#let zh-title(it) = {
set text(font: "SimHei", weight: "bold", size: cn-zh("小二"))
set text(font: "SimHei", weight: "bold", size: zh("小二"))

set align(center)
v(1em)
it
}

#show heading.where(level: 1): it => {
set text(font: "SimHei", size: cn-zh("三号"))
set text(font: "SimHei", size: zh("三号"))

set align(center)
v(0.6em)
Expand Down
4 changes: 2 additions & 2 deletions undergraduate-thesis-template/pages/contents.typ
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh
#import "../utils/ziti.typ": zh, zihao

// inspired from 璜珀's blog https://blog.hpcesia.com/posts/5252cfe9/
#let contents() = {
align(center)[
#v(0.6em)
#text(
size: cn-zh("三号"),
size: zh("三号"),
font: "SimHei",
"目 录",
)<contents>
Expand Down
16 changes: 8 additions & 8 deletions undergraduate-thesis-template/pages/cover.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh
#import "../utils/ziti.typ": zh, zihao



Expand All @@ -16,16 +16,16 @@
cover-logo-path: "../assets/header.png",
) = {
set align(center)
show: cn-zihao("五号")
show: zihao("五号")

v(6em)

image(cover-logo-path, width: 9.87cm)

v(-0.8 * cn-zh("小初"))
v(-0.8 * zh("小初"))

text(
size: cn-zh("小初"),
size: zh("小初"),
// 由于使用了 fakebold,所以这里用不了 tracking 这个属性
//在 word 里显示的是设置 3 磅的字间距,感觉是左右各包了 3 磅
// tracking: 6pt,
Expand All @@ -37,13 +37,13 @@
]


v(-0.8 * cn-zh("小初"))
v(-0.8 * zh("小初"))

box(
height: 6.6cm,
align(horizon)[
#text(
size: cn-zh("二号"),
size: zh("二号"),
font: "STxihei",
weight: "bold",
title,
Expand All @@ -52,7 +52,7 @@
#set par(leading: 1.25em)

#text(
size: cn-zh("三号"),
size: zh("三号"),
font: "Times New Roman",
weight: "bold",
title-en,
Expand All @@ -62,7 +62,7 @@

set par(leading: 1em)

show: cn-zihao("三号")
show: zihao("三号")


let info_key(key) = (
Expand Down
6 changes: 3 additions & 3 deletions undergraduate-thesis-template/pages/declaration-typst.typ
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh
#import "../utils/ziti.typ": zh, zihao

#let declaration() = [
#set par(leading: 0.96em, justify: true, first-line-indent: 2em, spacing: 1em)

#set text(font: "SimSun", size: cn-zh("小三"))
#set text(font: "SimSun", size: zh("小三"))

#show heading.where(level: 1): it => {
set text(font: "SimHei", size: cn-zh("二号"), weight: "bold")
set text(font: "SimHei", size: zh("二号"), weight: "bold")
set align(center)
v(1em)
it
Expand Down
3 changes: 0 additions & 3 deletions undergraduate-thesis-template/pages/declaration.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#import "../utils/ziti.typ": cn-zihao, cn-zh


#let declaration() = {
set page(
paper: "a4",
Expand Down
4 changes: 2 additions & 2 deletions undergraduate-thesis-template/pages/supplementary.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": *
#import "../utils/ziti.typ": zh, zihao


#let supplematry-page(title: "", body) = {
Expand All @@ -10,7 +10,7 @@
set heading(numbering: numberfunc)
show heading.where(level: 1): it => {
set align(center)
show: cn-zihao("三号")
show: zihao("三号")
v(-0.5em)
text(weight: "regular", it)
v(0.2em)
Expand Down
4 changes: 2 additions & 2 deletions undergraduate-thesis-template/styles/set-figure.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/i-figured:0.2.4"
#import "../utils/ziti.typ": *
#import "../utils/ziti.typ": zh, zihao, songti

// copied from https://github.com/werifu/HUST-typst-template/blob/main/utilities/set-numbering.typ and set-figure.typ

Expand All @@ -14,7 +14,7 @@

#let show-caption(body) = {
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption: set text(font: songti, size: cn-zh("五号"))
show figure.caption: set text(font: songti, size: zh("五号"))
set figure.caption(separator: h(0.5em))

body
Expand Down
8 changes: 4 additions & 4 deletions undergraduate-thesis-template/styles/set-heading.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": *
#import "../utils/ziti.typ": zh, zihao, heiti

#let show-heading(body) = {

Expand Down Expand Up @@ -33,19 +33,19 @@
}
show heading.where(level: 1): it => {
set align(center)
show: cn-zihao("三号")
show: zihao("三号")
v(0.6em)
it
v(0.4em)
}
show heading.where(level: 2): it => {
show: cn-zihao("四号")
show: zihao("四号")
v(0.6em)
it
v(0.3em)
}
show heading.where(level: 3): it => {
show: cn-zihao("小四")
show: zihao("小四")
v(0.6em)
it
v(0.1em)
Expand Down
10 changes: 5 additions & 5 deletions undergraduate-thesis-template/styles/set-paper-page.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "../utils/ziti.typ": *
#import "../utils/ziti.typ": zh, zihao, songti

#let show-paper-page-size(body) = {
set page(
Expand All @@ -16,11 +16,11 @@
body
}

#let show-paper-header(body) = {
#let show-paper-header(header, body) = {
set page(
header: {
set text(font: songti, cn-zh("四号"), tracking: 1pt)
align(center)[北京理工大学本科生毕业设计(论文)]
set text(font: songti, zh("四号"), tracking: 1pt)
align(center, header)
v(-0.8em)
line(length: 100%, stroke: 0.7pt)
},
Expand All @@ -42,7 +42,7 @@
}

#let show-mainbody(body) = {
set text(font: songti, cn-zh("小四"), hyphenate: false)
set text(font: songti, zh("小四"), hyphenate: false)

set par(leading: 1.15em, first-line-indent: 2em, justify: true)

Expand Down
27 changes: 14 additions & 13 deletions undergraduate-thesis-template/template.typ
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#import "styles/set-paper-page.typ": *
#import "styles/set-heading.typ": *
#import "styles/set-paper-page.typ": show-paper-page-size, show-paper-header, show-paper-footer, show-mainbody
#import "styles/set-heading.typ": show-heading
#import "styles/set-figure.typ": show-figure
#import "styles/set-code.typ": *
#import "styles/set-code.typ": show-code

#import "utils/ziti.typ": *
#import "utils/indent-funs.typ": *
#import "utils/ziti.typ": zh, zihao
#import "utils/indent-funs.typ": show-fix-indent, indent
#import "utils/three-line-table.typ": three-line-table
#import "utils/bib-citation.typ": bib-cite

#import "pages/cover.typ": *
#import "pages/declaration.typ": *
#import "pages/abstract.typ": *
#import "pages/abstract-en.typ": *
#import "pages/contents.typ": *
#import "pages/supplementary.typ": *
#import "pages/cover.typ": cover
#import "pages/declaration.typ": declaration
#import "pages/abstract.typ": abstract
#import "pages/abstract-en.typ": abstract-en
#import "pages/contents.typ": contents
#import "pages/supplementary.typ": supplematry-page, references, conclusion, acknowledgements, appendices

#import "@preview/cuti:0.3.0": show-cn-fakebold

Expand All @@ -34,6 +34,7 @@
abstract-en-content: [],
keywords: (),
keywords-en: (),
header: "北京理工大学本科生毕业设计(论文)",
body,
) = {
// 应用模板样式和格式设置:
Expand All @@ -49,7 +50,7 @@
show: show-code
show: show-mainbody


// 设置参考文献风格:
// - 使用 GB/T 7714-2005 数字格式引用样式
// - 可选择使用北京理工大学自定义引用样式(需取消注释第二行)
Expand Down Expand Up @@ -78,7 +79,7 @@
// 设置文档显示样式:
// - show-paper-header: 显示论文页眉
// - show-paper-footer: 显示论文页脚,使用"I"样式
show: show-paper-header
show: show-paper-header.with(header)
show: show-paper-footer.with(style: "I")

// 生成中文摘要
Expand Down
31 changes: 1 addition & 30 deletions undergraduate-thesis-template/utils/ziti.typ
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
#import "@preview/pointless-size:0.1.0": zh, zihao
#import "@preview/pointless-size:0.1.1": zh, zihao

#let chinese-overrides = (
("初号", 42pt),
("小初", 36pt),
("一号", 26pt),
("小一", 24pt),
("二号", 22pt),
("小二", 18pt),
("三号", 16pt),
("小三", 15pt),
("四号", 14pt),
("小四", 12pt),
("五号", 10.5pt),
("小五", 9pt),
("六号", 7.5pt),
("小六", 6.5pt),
("七号", 5.5pt),
("八号", 5pt),
("", 42pt),
("", 26pt),
("", 22pt),
("", 16pt),
("", 14pt),
("", 10.5pt),
("", 7.5pt),
("", 5.5pt),
("", 5pt),
)
#let cn-zihao(size) = zihao(size, overrides: chinese-overrides)
#let cn-zh(size) = zh(size, overrides: chinese-overrides)
#let songti = ("Times New Roman", "SimSun")
#let heiti = ("Times New Roman", "SimHei")

0 comments on commit eb68fd8

Please sign in to comment.