How haouo/ncku-thesis-typst works
Main Components
• Configuration & Build Files: At the top level, you have configuration files (typst.toml, Makefile, .gitignore, LICENSE) that set up the environment, building, and versioning of the project.
• Core Library & Setup Module: The file "lib.typ" and the critical "setup" function (defined in setup.typ, referenced by main.typ) serve as the heart of the template, initializing parameters (thesis details like degree, advisor info) and returning key functions.
• Layouts & Template Files: The "layouts" directory (containing layout files like extended-abstract-en.typ, mainmatter-or-appendix.typ, whole.typ) and the "template" directory (with its contents, main.typ, images, ref.bib, setup.typ) define the overall structure, style, and organization of the thesis.
• Document Pages: The "pages" directory holds individual typst files (abstract.typ, cover.typ, outline.typ, etc.) that represent discrete sections of the thesis. They rely on the functions and settings provided by the setup module.
• Assets & Fonts: These directories contain supporting resources such as images and fonts used to ensure the thesis has the required visual styling.
Relationships and Interactions
• The overarching interaction starts with the configuration files which set environment, compilation, and dependency parameters.
• The core “setup()” function (defined in a dedicated file to avoid cyclic dependencies) initializes the document’s metadata and returns a set of functions. These are later imported and used inside the "main.typ" and "contents" files.
• The "layouts" and "template/contents" directories supply the typesetting structure—the layout decisions and content ordering are maintained here. Each layout file contributes to defining sections like the abstract, main matter, or appendices.
• Individual document pages in the "pages" directory then consume these functions (e.g., make_cover, make-abstract-en) to actually generate the document sections. This establishes a clear data flow from configuration through setup to the final rendered document.
• The "utils" directory provides helper code (e.g. page numbering in page-numb.typ) to manage repeated tasks such as pagination.
Architectural Patterns & Design Principles
• Modularity is a significant principle here—the document is broken into distinct components (setup, layouts, pages, and assets), making updates or extensions easier.
• Separation of Concerns is apparent: the project cleanly separates configuration (metadata and build), style/layout (in layouts and template folders), and content (in pages).
• Reusability and Extensibility: The central setup function returns an array of functions that the user calls as needed, ensuring that updates to core formatting or new functionalities can be centrally controlled.
Specific Technologies & Frameworks
• Typst as the primary typesetting language is the central technology.
• The project does not rely on a backend or frontend framework but uses Typst’s inherent capabilities in document formatting.
• Integration with bibliographic content is handled via a reference file (template/ref.bib) and the built-in bibliography function in Typst.