diff --git a/hkust-thesis/layouts/appendix.typ b/hkust-thesis/layouts/appendix.typ index 859612f..482136e 100644 --- a/hkust-thesis/layouts/appendix.typ +++ b/hkust-thesis/layouts/appendix.typ @@ -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) diff --git a/hkust-thesis/layouts/refmatter.typ b/hkust-thesis/layouts/refmatter.typ new file mode 100644 index 0000000..1270cae --- /dev/null +++ b/hkust-thesis/layouts/refmatter.typ @@ -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 +} \ No newline at end of file diff --git a/hkust-thesis/template.typ b/hkust-thesis/template.typ index fd80c36..c941dc0 100644 --- a/hkust-thesis/template.typ +++ b/hkust-thesis/template.typ @@ -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 @@ -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 @@ -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: (:)), @@ -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, diff --git a/hkust-thesis/templates/reference-page.typ b/hkust-thesis/templates/reference-body.typ similarity index 56% rename from hkust-thesis/templates/reference-page.typ rename to hkust-thesis/templates/reference-body.typ index 1a82992..f1888ce 100644 --- a/hkust-thesis/templates/reference-page.typ +++ b/hkust-thesis/templates/reference-body.typ @@ -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, ) = { @@ -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( diff --git a/mythesis.typ b/mythesis.typ index 45898d2..35861b1 100644 --- a/mythesis.typ +++ b/mythesis.typ @@ -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", @@ -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 #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 $ -#lorem(20) - -== Laser intreaction with matter +== Laser intreaction with matter #lorem(60) #lorem(50) -=== laser induced forward transfer (LIFT) +=== laser induced forward transfer (LIFT) #lorem(50) @@ -183,7 +177,7 @@ $ E^2 = p^2 + m^2 $ @fig-redSquare is a red square. -=== laser induced backward transfer (LIBT) +=== laser induced backward transfer (LIBT) #lorem(50) @@ -284,7 +278,7 @@ $ E^2 = p^2 + m^2 $ #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) @@ -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