Skip to content

ivaquero/qooklet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qooklet

Qooklet is a Typst template for scientific notes and booklet-style documents. It provides chapter pages, front matter, localized labels, equation and figure numbering, theorem environments, CSV tables, and styled code blocks with a small set of configurable TOML files.

Features

  • Note mode and booklet mode:
    • note mode is the default and is useful for single chapters or lecture notes;
    • booklet mode is activated after cover() is called and enables book-like front matter, part pages, chapter pages, and appendix pages.
  • Book structure helpers:
    • cover(), epigraph(), preface(), contents(), and part-page();
    • chapter-style() for normal chapters;
    • appendix-style() for appendices.
  • Automatic numbering:
    • equations are numbered by chapter or appendix;
    • figures and tables use localized supplements;
    • references are formatted through the template style.
  • Scientific writing utilities:
    • theorem-like environments from theorion;
    • running headers through hydra;
    • styled raw code blocks through codly.
  • Configurable labels, fonts, page sizes, spacing, and language through TOML.

Installation

From Typst Universe

#import "@preview/qooklet:0.6.2": *

From a Local Checkout

Clone this repository into Typst's local package directory:

  • Linux:
    • $XDG_DATA_HOME/typst/packages/local
    • ~/.local/share/typst/packages/local
  • macOS: ~/Library/Application Support/typst/packages/local
  • Windows: %APPDATA%/typst/packages/local

Then import the local package:

#import "@local/qooklet:0.1.0": *

The local package keeps the version at 0.1.0 for development convenience.

Quick Start

Note Mode

Use note mode when you only need a chapter-style document without cover pages or front matter.

#import "@preview/qooklet:0.6.2": *

#let info = toml("config/info.toml").example

#show: chapter-style.with(
  title: "Bellman Equation",
  info: info,
)

= Bellman Equation

Your content starts here.

Note mode example

Booklet Mode

Calling cover() switches the document to booklet mode.

#import "@preview/qooklet:0.6.2": *

#let info = toml("config/info.toml").example

#cover(info, date: datetime.today())

#epigraph(info: info)[
  A short quote or motto.
]

#preface(info: info)[
  Preface content.
]

#contents(depth: 2, info: info)

#part-page("Main Text", info: info)

#show: chapter-style.with(
  title: "First Chapter",
  info: info,
)

= First Section

Chapter content.

#part-page("Appendix", info: info)

#show: appendix-style.with(
  title: "Supplementary Material",
  info: info,
)

= Additional Notes

Appendix content.

Booklet mode example

Configuration

Most public functions accept info, styles, or names arguments. The default values are loaded from 0.1.0/config.

Document Info

info controls metadata and language. It is commonly passed to cover(), preface(), contents(), part-page(), chapter-style(), and appendix-style().

#let info = toml("config/info.toml").example
[example]
    title = "Your Booklet Name"
    author = "Your Name"
    footer = "Footer Text"
    header = "Header Text"
    lang = "en" # "en" or "zh" by default

Localized Names

Qooklet includes English and Chinese labels by default. Add another language by creating a compatible names table and passing it to the style functions.

[sections.fr]
    preface = "Préface"
    chapter = "Chapitre"
    content = "Table des matières"
    appendix = "Annexe"
    bibliography = "Bibliographie"

[blocks.fr]
    algorithm = "Algorithme"
    table = "Tableau"
    figure = "Figure"
    equation = " Eq. "
    rule = "Règle"
    law = "Loi"
#let info = toml("config/info.toml").example
#let names = toml("config/names.toml")

#show: chapter-style.with(
  title: "Chapitre 1",
  info: info,
  names: names,
)

Make sure info.lang matches a language key in names and styles.

Visual Styles

styles controls page sizes, spacing, font sizes, and font families.

[paper]
    note = "a4"
    booklet = "iso-b5"

[spaces]
    par-indent = 2
    par-leading = 1
    par-spacing = 1
    list-indent = 1.2
    block-above = 1
    block-below = 1
    contents-indent = 1.2

[sizes]
    chapter = 24
    chapter-index = 50
    cover = 36
    author = 24
    date = 18
    epigraph = 16
    preface = 22
    contents = 22
    part = 36
    heading-1 = 16
    heading-2 = 14
    heading-3 = 12
    heading-4 = 10.5
    context = 10.5
    header = 8
    footer = 8

[fonts.en]
    chapter = "Palatino"
    chapter-index = "Palatino"
    cover = "Palatino"
    author = "Times New Roman"
    date = "Times New Roman"
    epigraph = "Georgia"
    preface = "Georgia"
    contents = "Georgia"
    part = "Georgia"
    context = "Georgia"
    math = "Times New Roman"
#let styles = toml("config/styles.toml")

#show: chapter-style.with(
  title: "Custom Styled Chapter",
  styles: styles,
)

API Reference

Structure

  • cover(info, date: datetime.today(), styles: default-styles): creates a cover page and activates booklet mode.
  • epigraph(info: default-info, styles: default-styles)[body]: creates an epigraph page.
  • preface(info: default-info, styles: default-styles, names: default-names)[body]: creates a preface page.
  • contents(depth: 2, info: default-info, styles: default-styles): creates a table of contents. depth can be 1 or 2.
  • part-page(title, info: default-info, styles: default-styles): creates a part divider page.

Styles

  • chapter-style(title: "", info: default-info, styles: default-styles, names: default-names, outline-on: false, heading-depth: 3)[body]: applies chapter layout, headers, footers, heading styles, numbering, references, and theorem styling.
  • appendix-style(...): same as chapter-style(), but uses appendix numbering.
  • front-matter-style(styles: default-styles)[body]: styles front matter pages.
  • cover-style(styles: default-styles)[body]: applies cover/booklet page style.
  • contents-style(depth: 2, lang: "en", names: default-names, styles: default-styles)[body]: lower-level table-of-contents style helper.

Tables

tableq(data, k, inset: 0.3em, stroke-color: rgb("000")) renders flattened CSV data as a centered table using Qooklet's three-line style.

#let data = csv("data.csv")

#figure(
  tableq(data, 5, inset: 0.31em),
  caption: "Dataset Summary",
  supplement: "Table",
  kind: table,
)

Available stroke helpers:

  • table-three-line(stroke-color): three-line table style.
  • table-no-left-right(stroke-color): grid style without left and right borders.

Use the stroke helpers directly with Typst's built-in table when you need more control than tableq() exposes.

Code Blocks

code(text, lang: "python", breakable: true, width: 100%) renders a styled raw code block from a string.

#let compose = read("docker-compose.yml")
#code(compose, lang: "yaml")

Examples

Credits

Qooklet is inspired by haobook by @ParaN3xus.

Thanks also to the creators of hydra, codly, and theorion.

About

A quick start template for scientific booklets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages