Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
template: port pkuthss aec9080 and a179ca0
Browse files Browse the repository at this point in the history
  • Loading branch information
howardlau1999 committed Nov 11, 2023
1 parent e650545 commit 0c518a2
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
26 changes: 22 additions & 4 deletions chapters/ch01.typ
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,31 @@ Typst 中的标题使用 `=` 表示,其后跟着标题的内容。`=` 的数
],
```typ
遵循 sysu-thesis 的惯例,使用 *黑体* 表示粗体,_楷体_ 表示斜体。
*bold* and _italic_ are very simple.
```,
[
遵循 sysu-thesis 的惯例,使用 *黑体* 表示粗体,_楷体_ 表示斜体。
*bold* and _italic_ are very simple.
]
)\

由于绝大部分中文字体只有单一字形,这里遵循 `sysu-thesis` 的惯例,使用#strong[黑体]表示粗体,#emph[楷体]表示斜体。但需要注意的是,由于语法解析的问题, `*...*``_..._` 的前后可能需要空格分隔,而这有时会导致不必要的空白。 如果不希望出现这一空白,可以直接采用 `#strong``#emph`

#table(
columns: (1fr, 1fr),
[
#set align(center)
代码
],
[
#set align(center)
渲染结果
],
```typ
对于中文情形,*使用 \* 加粗* 会导致额外的空白,#strong[使用 \#strong 加粗]则不会。
```,
[
对于中文情形,*使用 \* 加粗* 会导致额外的空白,#strong[使用 \#strong 加粗]则不会。
]
)\

Expand Down Expand Up @@ -123,8 +145,6 @@ Typst 中的标题使用 `=` 表示,其后跟着标题的内容。`=` 的数

在 Typst 中,定义表格的默认方式是 `table` 函数。但如果需要给表格增加标题,或者在文章中引用表格,则需要将其放置在 `figure` 中,就像下面这样:

#pagebreak()

#table(
columns: (1fr, 1fr),
[
Expand Down Expand Up @@ -216,8 +236,6 @@ Typst 中的标题使用 `=` 表示,其后跟着标题的内容。`=` 的数

@eq 是一个公式。代码中的 `<eq>` 是这一公式的标签,可以在文中通过 `@eq` 来引用。

#pagebreak()

#table(
columns: (1fr, 1fr),
[
Expand Down
4 changes: 2 additions & 2 deletions functions/booktab.typ
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
columns: columns,
..zip(headers, aligns).map(it => [
#set align(it.last())
#textbf(it.first())
#strong(it.first())
])
)
)
Expand All @@ -45,7 +45,7 @@
grid(
columns: columns,
row-gutter: 1em,
..zip(contents, content_aligns).map(it => [
..contents.zip(content_aligns).map(it => [
#set align(it.last())
#it.first()
])
Expand Down
8 changes: 4 additions & 4 deletions functions/figurelist.typ
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
let width = measure(maybe_number, styles).width
box(
width: lengthceil(width),
maybe_number
link(el.location(), maybe_number)
)
})

el.caption
link(el.location(), el.caption)

// Filler dots
box(width: 1fr, h(10pt) + box(width: 1fr, repeat[.]) + h(10pt))
Expand All @@ -33,12 +33,12 @@
} else {
counter(page).at(footers.first().location()).first()
}
str(page_number)
link(el.location(), str(page_number))
linebreak()
v(-0.2em)
}

link(el.location(), line)
line
}
})
}
16 changes: 8 additions & 8 deletions functions/outline.typ
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
let width = measure(maybe_number, styles).width
box(
width: lengthceil(width),
if el.level == 1 {
textbf(maybe_number)
link(el.location(), if el.level == 1 {
strong(maybe_number)
} else {
maybe_number
}
)
))
})
}

if el.level == 1 {
textbf(el.body)
strong(el.body)
} else {
el.body
}
Expand All @@ -65,17 +65,17 @@
} else {
counter(page).at(footer.first().location()).first()
}
if el.level == 1 {
textbf(str(page_number))
link(el.location(), if el.level == 1 {
strong(str(page_number))
} else {
str(page_number)
}
})

linebreak()
v(-0.2em)
}

link(el.location(), line)
line
}
})
}
13 changes: 0 additions & 13 deletions functions/style.typ
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,5 @@
小七: 5pt,
)

#let textit(it) = [
#set text(font: 字体.楷体, style: "italic")
#h(0em, weak: true)
#it
#h(0em, weak: true)
]

#let textbf(it) = [
#set text(font: 字体.黑体, weight: "semibold")
#h(0em, weak: true)
#it
#h(0em, weak: true)
]

#let lengthceil(len, unit: 字号.小四) = calc.ceil(len / unit) * unit
6 changes: 2 additions & 4 deletions functions/underline.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#import "../functions/style.typ": textbf

#let chineseunderline(s, width: 300pt, bold: false) = {
let chars = s.clusters()
let n = chars.len()
Expand All @@ -14,7 +12,7 @@

if measure(nxt, styles).width > width or c == "\n" {
if bold {
ret.push(textbf(now))
ret.push(strong(now))
} else {
ret.push(now)
}
Expand All @@ -34,7 +32,7 @@

if now.len() > 0 {
if bold {
ret.push(textbf(now))
ret.push(strong(now))
} else {
ret.push(now)
}
Expand Down
8 changes: 4 additions & 4 deletions template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
set list(indent: 2em)
set enum(indent: 2em)

show strong: it => textbf(it)
show emph: it => textit(it)
show strong: it => text(font: 字体.黑体, weight: "semibold", it.body)
show emph: it => text(font: 字体.楷体, style: "italic", it.body)
show par: set block(spacing: 行距)
show raw: set text(font: 字体.代码)

Expand All @@ -138,10 +138,10 @@
#set text(size)
#v(2em)
#if it.numbering != none {
textbf(counter(heading).display())
strong(counter(heading).display())
h(0.5em)
}
#textbf(it.body)
#strong(it.body)
#v(1em)
]

Expand Down
2 changes: 1 addition & 1 deletion templates/abstract-en.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// #[
// #set text(字号.小二)
// #set align(center)
// #textbf(论文英文题目)
// #strong(论文英文题目)
// ]
// #[
// #set align(center)
Expand Down
2 changes: 1 addition & 1 deletion templates/cover.typ
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#let fieldname(name) = [
#set align(right + top)
#textbf(name)
#strong(name)
#h(0.25em)
]

Expand Down

0 comments on commit 0c518a2

Please sign in to comment.