Universe
Create project in app

A quick start template for scientific booklets.

Features

Modularization

  • Mode Switch
    • the default mode is note mode
    • when cover() is called the booklet mode will be activated
  • Styles
    • call cover(), epigraph(), preface(), contents() and part-page() to generate corresponding page
    • call chapter-style() and appendix-style() to change to customized layout

Automation

  • Math Equation
    • auto numbering based on chapter
    • link quote to source
  • Figure
    • auto numbering based on chapter
  • Table
    • read as three-line table
  • Code Block
    • stylized by (using codly)
    • read code block

Useful Functions

Tables

  • tableq(data, k, stroke: table-three-line(rgb("000")), inset: 0.3em): reading .csv, where k is the number of columns, and for stroke, qooklet provide 2 predefined styles
    • table-three-line(stroke-color): default style, for three-line table
    • table-no-left-right(stroke-color): for grid without left border and right border
#let data = csv("data.csv")
#figure(
  tableq(data, 5),
  // stroke: table-three-line(rgb("000")),
  // caption: ""
  // supplement: "",
  kind: table,
)

Codes

  • code(text, lang: "python", breakable: true, width: 100%): read stylized code blocks
#let compose = read("docker-compose.yml")
#code(compose, lang: "yaml")

Environments

  • Theorem
    • theorems enviroment is implemented by using theorion (the counters still needs tweaking in the booklet mode)
  • Shorthands
    • scientific shorthands are provided by physica

Get Started

Import qooklet from the @preview namespace.

Note Mode

#import "@preview/qooklet:0.5.2": *
#show: chapter-style.with(
  title: "Chapter Title",
  // the following are optional arguments
  // title: "",
  // info: default-info,
  // styles: default-styles,
  // names: default-names,
  // outline-on: false,
)

where info is an argument that let you customize the information of your booklet using a toml file (if you leave it alone, the following info will be empty).

You can read you info file by the following sentence

#let info = toml("your path").key-you-like

The toml file should look like this

[key-you-like]
    title = "Your Booklet Name"
    author = "Your Name"
    footer = "Some Info You Want to Show"
    header = "Some Info You Want to Show"
    lang = "en" # or "zh"

example

Booklet Mode

The booklet mode will be mode will be activated after calling cover()

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

#let info = toml(your-info-file-path).key-you-like
// for example
// #let info = toml("../config/info.toml").global

// add a cover
#cover(
  // info,
  // date: datetime.today(),
)

#epigraph[
  // Add an epigraph to the document.
]

#preface[
  // Add a preface to the document.
]

#contents

// body
#show: chapter-style.with(
  title: "chapter-title 1",
  info: info,
)

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

// appendix
#part-page[Appendix]
#show: appendix-style
...

example-book

If you are not neither English speaker nor Chinese speaker, you needs to create another toml for section names, assume you are a French speaker, your file should be like

[sections.fr]
    preface = "Préface"
    chapter = "Chapitre"
    content = "Table Des Matières"
    bibliography = "Bibliographie"

[blocks.fr]
    algorithm = "Algorithme"
    table = "Tableau"
    figure = "Figure"
    equation = " Eq."
    rule = "Règle"
    law = "Loi"

Don’t forget to change the key lang in your info toml metioned above!

For more details, see examples.typ and examples-book.typ.

Clone Official Repository

Clone the qooklet repository to your @local workspace:

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

Import qooklet in the document

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

For developement convinience, local repo never changes the version

Credits

Thanks @ParaN3xus for his haobook which offers much inspiration of the rewriting of this template.

Also thanks the creators of the following packages