Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions packages/preview/bookly/1.1.2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Mathieu Aucejo

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.
110 changes: 110 additions & 0 deletions packages/preview/bookly/1.1.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Book template

[![Generic badge](https://img.shields.io/badge/Version-1.1.2-cornflowerblue.svg)]()
[![MIT License](https://img.shields.io/badge/License-MIT-forestgreen)](https://github.com/maucejo/book_template/blob/main/LICENSE)
[![User Manual](https://img.shields.io/badge/doc-.pdf-mediumpurple)](https://github.com/maucejo/book_template/blob/main/docs/manual.pdf)


The `bookly` template is a Typst package designed for writing academic documents such as theses, French habilitations, or scientific books. It provides a structured format that adheres to academic standards, making it easier for authors to focus on content rather than formatting.

## Basic usage

This section provides the minimal amount of information to get started with the template. For more detailed information, see the [manual](https://github.com/maucejo/book_template/blob/main/docs/manual.pdf).

To use the `bookly` template, you need to include the following line at the beginning of your typ file:

```typ
#import "@preview/bookly:1.1.2": *
```

### Initializing the template

After importing `bookly`, you have to initialize the template by a show rule with the `#bookly()` command. This function takes a set of argument to customize the document.

* `title`: Title of the book
* `author`: Author of the book
* `book-config`: The dictionary allows you to customize various aspects of the book

**Example**
```typ
#show: bookly.with(
author: "Author Name",
fonts: (
body: "Lato",
math: "Lete Sans Math"
),
theme: modern,
lang: "en",
title-page: book-title-page(
series: "Typst book series",
institution: "Typst community",
logo: image("images/typst-logo.svg"),
cover: image("images/book-cover.jpg", width: 45%)
)
)
```

### Main features

* Themes: `classic`, `modern`, `fancy`, `orly`
* Layout: "standard" and "tufte"
* Language support: English and French
* Font customization: Body and math fonts can be customized
* Environments: `front-matter`, `main-matter`, `appendix`, `back-matter`
* Outlines: `tableofcontents`, `listoffigures`, `listoftables`, `minitoc`
* Part and chapter definition: `part`, `chapter`, `chapter-nonum`

> **_Note:_** The chapters can be also written using the Typst standard markup syntax.

### Helper functions

* Subfigures - based on the `subpar` package
```typ
#subfigure(
figure(image("image1.png"), caption: []),
figure(image("image2.png"), caption: []), <b>,
columns: (1fr, 1fr),
caption: [Figure title],
label: <fig:subfig>,
)
```

* Equations
* Boxed equations
```typ
$
#boxeq[$p(A|B) prop p(B|A) space p(A)$]
$
```

* Unnumbered equations
```typ
#nonumeq[$integral_0^1 f(x) dif x = F(1) - F(0)$]
```

* Subequation numbering based on the `equate` package

* Information boxes
* `#info-box` for remarks
* `#tip-box` for tips
* `#important-box` for important notes
* `proof-box` for proofs
* `question-box` for questions
* `custom-box` for user defined boxes

* `book-title-page` for defining the title page of a book

* `thesis-title-page` for defining the title page of a thesis

* `back-cover` for defining the back cover of a book


For more information, please refer to the [manual](https://github.com/maucejo/book_template/blob/main/docs/manual.pdf).

## Licence

MIT licensed

Copyright © 2025 Mathieu AUCEJO (maucejo)


92 changes: 92 additions & 0 deletions packages/preview/bookly/1.1.2/src/bookly-components.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#import "@preview/hydra:0.6.2": hydra
#import "bookly-defaults.typ": *
#import "bookly-helper.typ": *
#import "bookly-themes.typ": *

// Chapter
#let chapter(title: none, abstract: none, toc: true, numbered: true, body) = context {
// Is the chapter numbered?
if not numbered {
numbering-heading = none
numbering-eq = "(1a)"
numbering-fig = "1"

// Heading numbering
set heading(numbering: numbering-heading)

// Equation numbering
set math.equation(numbering: numbering-eq)

// Figure numbering
show figure.where(kind: image): set figure(
supplement: fig-supplement,
numbering: numbering-fig,
gap: 1.5em
)

// Table numbering
show figure.where(kind: table): set figure(
numbering: numbering-fig,
gap: 1.5em
)
}

let toc-header = states.localization.get().toc
if toc {
set page(header: none)
set align(horizon)
heading(title)

if abstract != none {
abstract
}

minitoc
pagebreak()
} else {
heading(title)
}

body
}
}

#let chapter-nonum(body) = {
let numbering-heading = none
let numbering-eq = "(1a)"
let numbering-fig = "1"

// Figure numbering
show figure.where(kind: image): set figure(
supplement: fig-supplement,
numbering: numbering-fig,
gap: 1.5em
)

// Table numbering
show figure.where(kind: table): set figure(
numbering: numbering-fig,
gap: 1.5em
)

// Heading numbering
set heading(numbering: numbering-heading)

// Equation numbering
set math.equation(numbering: numbering-eq)

// Figure numbering
show figure.where(kind: image): set figure(
supplement: fig-supplement,
numbering: numbering-fig,
gap: 1.5em
)

// Table numbering
show figure.where(kind: table): set figure(
numbering: numbering-fig,
gap: 1.5em
)

body
}
61 changes: 61 additions & 0 deletions packages/preview/bookly/1.1.2/src/bookly-defaults.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@


#let fig-supplement = [Figure]
#let text-size = 11pt
#let paper-size = "a4"

#let states = (
author: state("author", none),
colors: state("theme-colors"),
counter-part: counter("part"),
in-outline: state("in-outline", false),
isappendix: state("isappendix", false),
isfrontmatter: state("isfrontmatter", false),
tufte: state("tufte", false),
localization: state("localization"),
num-heading: state("num-heading", "1"),
num-pattern: state("num-pattern", "1.1."),
num-pattern-eq: state("num-pattern-eq", "(1.1)"),
num-pattern-fig: state("num-pattern-fig", "1.1"),
num-pattern-subfig: state("num-pattern-subfig", "1.1a"),
page-numbering: state("page-numbering", "1/1"),
part-numbering: state("part-numbering", "1"),
sidenotecounter: counter("sidenotecounter"),
theme: state("theme", "fancy"),
title: state("title", none),
)

#let default-language = ("en", "de", "fr", "es", "it", "pt")

#let default-config-options = (
part-numbering: "1",
)

#let default-fonts = (
body: "New Computer Modern",
math: "New Computer Modern Math",
raw: "Cascadia Code"
)

#let default-colors = (
primary: rgb("#c1002a"),
secondary: rgb("#dddddd").darken(15%),
boxeq: rgb("#dddddd"),
header: black,
)

// Default Title page
#let default-title-page = context {
set page(
paper: paper-size,
header: none,
footer: none,
margin: auto
)

align(center + horizon)[
#text(size: 3em, fill: states.colors.get().primary)[*#states.title.get()*]
#v(1em)
#text(size: 1.5em)[#states.author.get()]
]
}
64 changes: 64 additions & 0 deletions packages/preview/bookly/1.1.2/src/bookly-environments.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#import "bookly-defaults.typ": *

#let front-matter(body) = context {
set heading(numbering: none)
set page(numbering: "i")
states.page-numbering.update("i")
states.num-pattern.update(none)
states.isfrontmatter.update(true)

counter(page).update(1)

body
}

// Main matter
#let main-matter(body) = context {
set heading(numbering: "1.1.")

let numbering = "1/1"
set page(numbering: numbering)

states.page-numbering.update("1/1")
states.num-heading.update("1")
states.num-pattern.update("1.1.")
states.num-pattern-fig.update("1.1a")
states.num-pattern-eq.update("(1.1a)")

if states.tufte.get() or not states.isfrontmatter.get() {
counter(page).update(1)
} else {
counter(page).update(0)
}

body
}

// Back matter
#let back-matter(body) = {
set page(header: none, footer: none)

body
}

// Appendix
#let appendix(body) = context {
set heading(numbering: "A.1.")

// Reset heading counter
counter(heading.where(level: 1)).update(0)

// Reset heading counter for the table of contents
counter(heading).update(0)

// Update states for chapter function
states.isfrontmatter.update(false)
states.num-heading.update("A")
states.num-pattern.update("A.1.")
states.num-pattern-fig.update("A.1")
states.num-pattern-subfig.update("A.1a")
states.num-pattern-eq.update("(A.1a)")
states.isappendix.update(true)

body
}
Loading