Skip to content

Commit

Permalink
feat: change ref-page to ref-body
Browse files Browse the repository at this point in the history
  • Loading branch information
github-young committed May 4, 2024
1 parent 2c50e8a commit ec01d56
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 33 deletions.
2 changes: 1 addition & 1 deletion hkust-thesis/layouts/appendix.typ
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
size: constants.font-sizes.title,
)
v(array-at(heading-top-vspace, it.level))
if (it.level == 1) {
if (it.depth == 1) {
[#upper(counter(heading).display()) \ #upper(it.body)]
// it
do-repeat([#linebreak()], 2)
Expand Down
67 changes: 67 additions & 0 deletions hkust-thesis/layouts/refmatter.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#import "../imports.typ": *


#let refmatter(
// i-figured settings
show-equation: i-figured.show-equation,
show-figure: i-figured.show-figure,
reset-counters: i-figured.reset-counters,
// 标题字体与字号
heading-font: "Times New Roman",
heading-size: (12pt,),
heading-weight: ("regular",),
heading-top-vspace: (20pt, 4pt),
heading-bottom-vspace: (20pt, 8pt),
heading-pagebreak: (true, false),
heading-align: (center, auto),
config: (:),
..args,
it,
) = {
// 1.2 处理 heading- 开头的其他参数
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)))

// 2. 辅助函数
let array-at(arr, pos) = {
arr.at(calc.min(pos, arr.len()) - 1)
}

// 4. 处理标题
// 4.2 设置字体字号并加入假段落模拟首行缩进
set heading(numbering: none, supplement: "")
// show heading: reset-counters(equations: true)
show heading: it => {
set text(
font: constants.font-names.title,
size: constants.font-sizes.title,
)
v(array-at(heading-top-vspace, it.level))
[#upper(it.body)]
do-repeat([#linebreak()], 2)
// v(array-at(heading-bottom-vspace, it.level))
}

// 4.3 标题居中与自动换页
show heading: it => {
if (array-at(heading-pagebreak, it.level)) {
// 如果打上了 no-auto-pagebreak 标签,则不自动换页
if ("label" not in it.fields() or str(it.label) != "no-auto-pagebreak") {
pagebreak(weak: true, to: if config.twoside { "odd" })
}
}
if (array-at(heading-align, it.level) != auto) {
set align(array-at(heading-align, it.level))
it
} else {
it
}
}

show heading: it => {reset-counters(it, equations: true)}

// ref matter page numbering
set page(numbering: "1")
it
}
13 changes: 10 additions & 3 deletions hkust-thesis/template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#import "layouts/doc.typ": doc
#import "layouts/mainmatter.typ": mainmatter
#import "layouts/refmatter.typ": refmatter
#import "layouts/postmatter.typ": postmatter
#import "layouts/appendix.typ": appendix

Expand All @@ -16,7 +17,7 @@
#import "templates/toc-page.typ": toc-page
#import "templates/lof-page.typ": lof-page
#import "templates/lot-page.typ": lot-page
#import "templates/reference-page.typ": reference-page
#import "templates/reference-body.typ": reference-body

// Implement

Expand Down Expand Up @@ -139,8 +140,8 @@
info: info + args.named().at("info", default: (:)),
)
},
reference-page: (..args) => {
reference-page(
reference-body: (..args) => {
reference-body(
..args,
config: config + args.named().at("config", default: (:)),
info: info + args.named().at("info", default: (:)),
Expand All @@ -152,6 +153,12 @@
config: config + args.named().at("config", default: (:)),
)
},
refmatter: (..args) => {
refmatter(
..args,
config: config + args.named().at("config", default: (:)),
)
},
postmatter: (..args) => {
postmatter(
..args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@


// 目录生成
#let reference-page(
#let reference-body(
// documentclass 传入参数
config: (:),
info: (:),
bib-filename: "mythesis.bib",
bib-filename: "mypublications.bib",
style: "institute-of-electrical-and-electronics-engineers",
full: false,
page-title: "References",
// 其他参数
..args,
) = {
Expand All @@ -21,21 +22,21 @@
)

// page setting
set page(numbering: "1")
// set page(numbering: "1")

// page rendering
pagebreak(weak: true, to: if config.twoside { "odd" })
// pagebreak(weak: true, to: if config.twoside { "odd" })

// set par(leading: linespacing)

// 显示References
{
set align(center)
let ref-page-title = "References"
invisible-heading(ref-page-title)
heading(outlined: false)[#text(size: constants.font-sizes.title)[#upper(ref-page-title)]]
do-repeat([#linebreak()], 1)
}
// {
// set align(center)
// let ref-page-title = page-title
// invisible-heading(ref-page-title)
// heading(outlined: false)[#text(size: constants.font-sizes.title)[#upper(ref-page-title)]]
// do-repeat([#linebreak()], 1)
// }

{
bibliography(
Expand Down
40 changes: 22 additions & 18 deletions mythesis.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#import "hkust-thesis/template.typ": documentclass

#let (
doc,cover-page,authorization,signature-page,abstract-page,toc-page,lof-page,lot-page,mainmatter,reference-page,postmatter,appendix
doc,cover-page,authorization,signature-page,abstract-page,toc-page,lof-page,lot-page,mainmatter,refmatter,reference-body,postmatter,appendix
) = documentclass(
config: (
twoside: false,
twoside: true,
),
info: (
degree: "PhD",
Expand Down Expand Up @@ -141,29 +141,23 @@ $ i hbar pdv(, t) ket(Psi(hat(r),t)) = [-hbar^2/(2m) nabla^2 + V] ket(Psi(hat(r)

#lorem(100)

= Theory
= Theory <ch-theory>

#lorem(30)

As discussed in @ch-introduction, @ch-introduction, XXX.

#lorem(50)
As discussed in @ch-introduction, @ch-theory, @sec-background, @sec-laser-intreaction-with-matter, @sec-LIFT, XXX.

Some inline equation $E^2 = p^2 + m^2$ and $E^2 = p^2 + m^2$ show something.

#lorem(20)

$ E^2 = p^2 + m^2 $ <ParPhy>

#lorem(20)

== Laser intreaction with matter
== Laser intreaction with matter <sec-laser-intreaction-with-matter>

#lorem(60)

#lorem(50)

=== laser induced forward transfer (LIFT)
=== laser induced forward transfer (LIFT) <sec-LIFT>

#lorem(50)

Expand All @@ -183,7 +177,7 @@ $ E^2 = p^2 + m^2 $ <ParPhy>

@fig-redSquare is a red square.

=== laser induced backward transfer (LIBT)
=== laser induced backward transfer (LIBT) <sec-LIBT>

#lorem(50)

Expand Down Expand Up @@ -284,7 +278,7 @@ $ E^2 = p^2 + m^2 $ <ParPhy>

#lorem(50)

I cite some papers@andren_Microscopicmetavehicles_2021 @dong_Programmableheating_2022 @duy_Laserinducedgraphene_2018.
// I cite some papers@andren_Microscopicmetavehicles_2021 @dong_Programmableheating_2022 @duy_Laserinducedgraphene_2018.

#lorem(100)

Expand All @@ -293,19 +287,29 @@ I cite some papers@andren_Microscopicmetavehicles_2021 @dong_Programmableheating

/* ============================================================ */

// Bibliography settings
#reference-page(
// Ref matter: Bibliography settings
#[
#show: refmatter
= References
#reference-body(
bib-filename: "mythesis.bib",
style: "institute-of-electrical-and-electronics-engineers",
full: false
full: true,
)
]

/* ============================================================ */

#[
#show: appendix
= List of Publications
// #reference-page("../../mypublications.bib", full: true)
// #reference-body(
// bib-filename: "mypublications.bib",
// style: "institute-of-electrical-and-electronics-engineers",
// full: true,
// )


*Known issue*: Typst does not support multiple bib files currently. We cannot simply feed two bib files into typst and get two bibliography pages at once. Hope it will be solved in future releases of typst!

= FYTGS requirements of thesis preparation
Expand Down

0 comments on commit ec01d56

Please sign in to comment.