Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions packages/preview/ncku-thesis-template/0.1.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
template/main.pdf
fonts
21 changes: 21 additions & 0 deletions packages/preview/ncku-thesis-template/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 CHUN-HAO CHANG

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/ncku-thesis-template/0.1.0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ROOT_DIR = .
FONT_DIR = fonts

all: compile

compile:
typst compile --root $(ROOT_DIR) --font-path $(FONT_DIR) template/main.typ
watch:
typst watch --root $(ROOT_DIR) --font-path $(FONT_DIR) template/main.typ
51 changes: 51 additions & 0 deletions packages/preview/ncku-thesis-template/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 國立成功大學 碩博士論文模板 NCKU Thesis/Dissertation Template in Typst

## Introduction

This is a typst template which can be used to write thesis/dissertation in National Cheng Kung University.

這個模板是基於 Typst 排版語言所撰寫的,主要作為[國立成功大學](https://www.ncku.edu.tw/)的碩博士畢業論文撰寫使用。

### What is Typst?

> Typst is a good choice for writing any long form text such as essays, articles, scientific papers, books, reports, and homework assignments.
> Moreover, Typst is a great fit for any documents containing mathematical notation, such as papers in the math, physics, and engineering fields.
> Finally, due to its strong styling and automation features, it is an excellent choice for any set of documents that share a common style, such as a book series.
>
> [Typst Docs](https://typst.app/docs/tutorial/)

Many of you may have heard of or even used LaTeX, the powerful and classic typesetting language. However, its complexity often discourages many from diving deeper into it.

For those who feel overwhelmed by LaTeX's intricate syntax, Typst might be a perfect alternative for you.
As a relatively young language, Typst offers a clean and concise syntax, fast compilation speed, and comprehensive documentation.
Despite its simplicity, Typst retains powerful and flexible typesetting capabilities, enabling users to achieve more than 90% of what they could typically do with LaTeX.

大家應該或多或少都有聽過或甚至是接觸過 LaTex 這個強大且經典的排版語言,但或許也有很多人被其複雜的語法所勸退。
針對這類人來說,或許你非常適合接觸 Typst。Typst 作為一門非常年輕的語言,有簡潔的語法、快速的編譯速度還有詳實的文件可以查閱。
即使語法非常簡潔,Typst 卻不失其強大且具有彈性的排版能力,利用 Typst 可以做到接近 90% 以上本來可以在 LaTex 中做到的事情。

If you’ve never worked with any markup language before, starting with Markdown might be a good idea.
It serves as an excellent introduction and will make transitioning to Typst much smoother.
For those already familiar with LaTeX, you can check out the [Typst - Guide for LaTeX Users](https://typst.app/docs/guides/guide-for-latex-users/).
If you’ve written LaTeX before, picking up Typst will feel like a piece of cake!

對於完全沒有接觸過任合標記式語言(Markup Language)的人,可以先參考看看 Markdown 這門語言,再來接觸 Typst 應該會容易很多!
而對於那些本來就會寫 LaTeX 的人,可以閱讀 [Typst - Guide for LaTeX users](https://typst.app/docs/guides/guide-for-latex-users/),相信上手相信上手 Typst 對於寫過 LaTeX 的人來說根本就是 piece of cake。

## Acknowledgements

The completion of this template owes great gratitude to the following three projects:

本模板的完成極力感謝以下三個專案

1. [canonical-nthu-thesis](https://github.com/kotatsuyaki/canonical-nthu-thesis)
2. [ncku-thesis-template-latex](https://github.com/wengan-li/ncku-thesis-template-latex)
3. [modern-nju-thesis](https://github.com/nju-lug/modern-nju-thesis)

which provided extensive references in terms of ideas and formatting.

在想法上及格式上給予非常多參考

## How to use?

Please refer to the GitHub repository: [Haouo/NCKU-Thesis-Typst](https://github.com/Haouo/NCKU-Thesis-Typst)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#let extended-abstract-en(
title-en: "A Thesis/Dissertation Template written in Typst for National Cheng Kung University",
institute: "Department of Electrical Engineering",
student-en: "Chun-Hao Chang",
advisor-en: "Chia-Chi Tsai",
summary: none,
keywords: (),
doc,
) = {
// show thesis/dissertation title
set text(size: 14pt)
set align(center)
strong(title-en)
v(0.15cm)
// student and advisor names
set text(size: 12pt)
student-en
linebreak()
advisor-en
v(0.25em)
institute
v(0.5cm)

set align(left)
[= 英文延伸摘要 <invisible>]
set heading(outlined: false)
show heading.where(level: 1): it => {
set text(12pt)
set align(center)
smallcaps(it)
v(0.5em)
}

rect(inset: 1em)[
= SUMMARY

#summary

*Keyword*: #keywords.join(", ")
]

doc
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
// Helper function: check whether the current heading is lavel-1 heading
#let is-chapter-start-page() = {
// find chapter headings on the current page.
let all-level-one-heading = query(heading.where(level: 1))
let current-page = here().page()
return (
all-level-one-heading
.filter(it => {
it.location().page() == current-page
})
.len()
> 0
)
}

// define custom numbering function
#let custom-numbering-mainmatter(..args) = {
if args.pos().len() == 1 {
"Chapter " + str(args.pos().at(0)) + "."
} else {
numbering("1.1.1.", ..args)
}
}
#let custom-numbering-appendix(..args) = {
if args.pos().len() == 1 {
"Appendix " + numbering("A", args.pos().at(0)) + "."
} else {
numbering("A.1.1.", ..args)
}
}

/*
* NOTE: this should be applied to the mainmatter of the thesis/dissertation which excludes the appendix part
*/
#let mainmatter-or-appendix(mode: (mainmatter: true, appendix: false), doc) = {
// check mode
assert(
(
(mode.mainmatter and (not mode.appendix))
or (mode.appendix and (not mode.mainmatter))
),
message: "You should only chose one mode! mainmatter or appendix",
)

// chose custom numbering function type according to mode
let custom-numbering(..args) = if mode.mainmatter {
custom-numbering-mainmatter(..args)
} else { custom-numbering-appendix(..args) }

// reset heading counter
counter(heading).update(0)

// Set the page numbering to arabic numerals.
//
// Although we use custom headers and footers to display the page numbers in the body part,
// this is still required to show the page numbers in arabic numerals in the outlines.
set page(
margin: (top: 23mm, bottom: 35mm, left: 30mm, right: 25mm),
numbering: "1",
header: context {
if not is-chapter-start-page() {
let level-1-heading-so-far = query(
heading.where(level: 1).before(here()),
)
let current-chapter-heading = level-1-heading-so-far.last()

// smallcaps([Chapter ] + str(current-chapter-number) + ".")
// h(0.75em)
// smallcaps(current-chapter-heading.body)
// display chapter info on the left
smallcaps(
custom-numbering(counter(heading).get().at(0))
+ " "
+ current-chapter-heading.body,
)
// display page number on the right
h(1fr)
counter(page).display() // page number
}
},
footer: context {
if is-chapter-start-page() {
h(1fr)
counter(page).display() // page number
}
},
)

// set paragraph
set par(
leading: 1.2em,
first-line-indent: 1em,
linebreaks: "optimized",
)

set heading(numbering: custom-numbering)

// NOTE: heading rule 1 -> apply to all headings except for level-1 heading
show heading: it => {
if (it.level > 1) {
set text(size: 14pt)
v(0.75cm)
block(
width: 100%,
{
let all-prev-headings = query(
selector(heading).before(here(), inclusive: false),
)
if all-prev-headings.len() > 1 {
let pre-heading = all-prev-headings.last()
let is-same-page = (
pre-heading.location().page() == it.location().page()
)
let is-colse = (
pre-heading.location().position().y + 65pt
>= it.location().position().y
)
if (is-same-page and is-colse) {
v(-30pt)
}
}
set par(justify: false)
grid(
columns: 2,
gutter: 1em,
counter(heading).display(it.numbering), it.body,
)
v(1em)
},
)
}
}

// NOTE: heading rule 2 -> apply to all level-1 headings
show heading.where(level: 1): it => {
// Start a chapter on a new page unless it's the 1st chapter,
// in which case it is already on a new page.
if counter(heading).get().at(0) != 1 {
pagebreak()
}

// Do not justify top-level headings, which have a large font.
set par(justify: false)

if it.numbering == none {
// Show the body of the heading.
block(
width: 100%,
{
set text(size: 24pt)
v(1.5em)
it.body
v(1em)
},
)
} else {
// Show "Chapter n" and the body of the heading on 2 separate lines.
align(
center,
block(
width: 100%,
{
set text(size: 21pt)
text(counter(heading).display(it.numbering))
linebreak()
it.body
v(1.2cm)
},
),
)
}
}

// WARN: the order of heading-rule-1 and heading-rule-2 is important
// WARN: this is because that the first rule only redering all heading except for level-1
// WARN: then the seoncd rule renders the level-1 headings
// WARN: swaping of the order will make the rendering rule of level-1 headings be overwritten
// WARN: which makes level-1 headings disapper

// display contents
doc
}

38 changes: 38 additions & 0 deletions packages/preview/ncku-thesis-template/0.1.0/layouts/whole.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* NOTE: this is the global settings which applys to the whole documents
* NOTE: includes cover, abstract, acknowledge, mainmatter, reference and appendix
*
* @param main-lang: the main language to writting the thesis/dissertation
* @param doc: contents of the following documents which the show rule apply to
*/
#let whole(
main-lang: (en: true, zh-tw: false),
doc,
) = {
// check the lang type setting
assert(
(
(main-lang.at("en") and (not main-lang.at("zh-tw")))
or (main-lang.at("zh-tw") and (not main-lang.at("en")))
), // XOR logic
message: "You should chose only one main language type!",
)

// apply the the whole thesis/dissertation
set page(paper: "a4")

// set the fonts of whole document
set text(
// NOTE: "Times New Roman" as main english font
// NOTE: "TW-MOE-Std-Kai" as main zh-tw font
font: ("Times New Roman", "TW-MOE-Std-Kai"),
lang: if main-lang.at("zh-tw") { "zh" } else { "en" },
region: if main-lang.at("zh-tw") { "tw" } else { none },
)

// make objects with "invisible" lebel be hidden
show label("invisible"): it => { }

// display the content
doc
}
Loading
Loading