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
93 changes: 93 additions & 0 deletions packages/preview/ape/0.4.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Ape for Typst



Tired of documents that look like they were formatted by a troop of baboons? Try Ape for Typst!



This Typst package provides a comprehensive set of tools for structuring and styling academic course documents across various disciplines. It simplifies the process of creating good looking and consistent layouts, allowing students to focus on content creation.

_It mainly supports French (especially for shortcuts)._

**Key Features:**



* **Flexible Title Numbering:** Offers a variety of numbering styles for headings and subheadings

* **Table of Contents Customization:** Provides enhanced outline

* **Front Page Design:** Offers a pre-designed front page templates

* **Easy Integration:** Simple to integrate into your Typst documents with clear and concise functions and components.

* **Helpful function:** function to highlight information (in boxes), shortcuts, plotting, etc.






**Functionalities:**


* Starting a new document
```typst
#import "@preview/ape:0.4.2": *

#show: doc.with(
lang: "en",

title: "Title",
authors: ("Author1", "Author2"),
style: "numbered",

title-page: true,
outline: true,
smallcaps: true,
)
```


*Exemple 1 : (Style : numbered)*
![Exemple 1](exemples/Exemple1.png)

*Exemple 2 : (Style : colored)*

*Soon...*


## Further informations
Some shortcuts are currently only available in french.

* Available style
- Numbered (or numbered-book)
- Plain
- Colored
- Presentation

* Formatting Functions
- `para(name, content)`: Create a named paragraph with custom content
- `rq(content)`: Create a "Remarque" (note) paragraph
- `ex(content)`: Create an "Exemple" (example) paragraph
- `arrow-list(items)`: Create a list with arrow bullets
- `inbox(content)`: Create a box with gray background and border
- There are a lot of varient accesible with `inbox2`, `inbox3`, `inbox4`

* Drawing and Plotting
- `plotting(functions, domain, samples, steps, axis-style, axis, size)`: Plot mathematical functions with customizable options
- `point(coordinates)`: Draw a point at given coordinates
- `point-name(coordinates, name, offset)`: Draw a named point with custom offset
- `quadratic(a, b, c)`: Calculate roots of quadratic equation
- `base(coordinates, name1, name2, angle)`: Draw a base with custom angle
- `spring(x0, y0, xf, yf, repetitions, amplitude)`: Draw a spring

* Mathematical Shortcuts
- `recurrence(property, domain, initialization, heredity, conclusion)`: Format mathematical recurrence proofs
- `dt`, `dx`, `dtheta`: Differential notations
- `ar(content)`: Arrow notation
- `nar(content)`: Norm of arrow notation
- `dot2`, `dot3`: Double and triple dot notations
- `grad`: Gradient notation
- `cste`: Constant notation
33 changes: 33 additions & 0 deletions packages/preview/ape/0.4.2/document/apply-style.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#import "styles/numbered.typ": *
#import "styles/colored.typ": *
#import "styles/plain.typ": *
#import "styles/presentation.typ": *
#import "styles/book.typ": *

#let apply-style(style, content) = {
set heading(numbering: "I)1)a)i)")

if style == "numbered" or style == "numbered-book" {
return numbered(content, style)
} else if style == "book" {
return book(content)
} else if style == "colored" {
return colored(content)
} else if style == "plain" {
return plain(content)
} else if style == "presentation" {
return presentation(content)
} else {
return numbered(content)
}
}

#let get-small-title(style, title, authors) = {
if(style == "numbered-book" ){
style = "numbered"
}
import "styles/" + style + ".typ" as current-style

return current-style.get-small-title(title, authors)

}
56 changes: 56 additions & 0 deletions packages/preview/ape/0.4.2/document/code-display.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#import "../tools/miscellaneous.typ": content-to-string

#let code-display(content) = {
// Code
show raw: it => context {
if ("py", "python", "ocaml", "ml").contains(it.lang) {
let breakableVar = false
let lines = (..it.lines,)



// Remove empty lines at the beginning and end
while lines.len() > 0 and content-to-string(lines.first()).trim() == "" {
lines.remove(0)
}
while lines.len() > 0 and content-to-string(lines.last()).trim() == "" {
lines.remove(-1)
}

if (it.lines.len() >= 15) {
breakableVar = true
}


block(
clip: true,
radius: calc.min(9pt, 4pt + 2pt * lines.len()),
stroke: text.fill.lighten(50%) + 0.5pt,
align(
center,
block(
breakable: breakableVar,
grid(
columns: (measure([#lines.len()]).width + 10pt, 20fr),
column-gutter: 0pt,
inset: ((left: 5pt, right: 5pt, rest: 3pt), (left: 10pt, rest: 3pt)),
align: (horizon + left, left),
fill: (text.fill.lighten(75%), text.fill.lighten(88%)),
[],
[],
..for i in range(lines.len()) {
let l = lines.at(i)
(str(i + 1), l.body)
},
[],
[],
),
),
),
)
} else {
it
}
}
content
}
83 changes: 83 additions & 0 deletions packages/preview/ape/0.4.2/document/doc.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#import "outline.typ": *
#import "apply-style.typ": *
#import "header-footer.typ": *
#import "front-pages.typ": *
#import "../tools/shortcuts.typ": *
#import "code-display.typ": *
#import "../tools/formatting.typ": *


= Documents


/*
Labels :
- <title>
- <section>

*/

/*
Style :
- Numbered
- Colored
- Plain
*/

#let doc(
lang: "fr",
title: "Titre",
authors: (),
style: "numbered",
title-page: false,
outline: false,
local-outline: false,
outline-max-depth: 5,
smallcaps: true,
content,
) = context {
set page(margin: 1.5cm)
set text(lang: lang, font: "New Computer Modern")

show: apply-style.with(style)

let (first-real-pages, custom-outline) = get-outline(lang, smallcaps, outline-max-depth)


if (first-real-pages.len() == 0) {
first-real-pages.push(0)
}


show: header-footer.with(style, smallcaps, first-real-pages, title, authors)

front-pages(style, smallcaps, title, title-page, authors, outline, local-outline, custom-outline)

show: shows-shortcuts
show: code-display

// Pre-set

set table(inset: 10pt, stroke: 0.4pt + text.fill.lighten(20%), align: center + horizon, fill: (x, y) => if (x == 0)
or (y == 0) { text.fill.lighten(90%) })


set grid(column-gutter: 10pt, align: horizon)


show image: it => {
align(center, it)
}

show table: it => {
block(clip: true, radius: 0.75em, stroke: it.stroke, it)
}
// content
set par(justify: true)

counter(heading).update(0)


content
}

73 changes: 73 additions & 0 deletions packages/preview/ape/0.4.2/document/front-pages.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#import "apply-style.typ": get-small-title
#import "outline.typ" : get-local-outline

#let front-pages(style, small-caps, title, title-page, authors, outline, local-outline, custom-outline) = {
let sc(c) = {
if small-caps == true {
return smallcaps(c)
} else {
return c
}
}

if title-page {
align(
center + horizon,
[

#{
if type(title) == str {
par(leading: 2em, spacing: 3em, text(size: 5em, hyphenate: false, (strong(title))))
} else {
par(leading: 1.7em, text(size: 5em, hyphenate: false, (strong(title.at(1)))))
par(leading: 1em, spacing: 3em, text(size: 3.25em, hyphenate: false, (title.at(0))))
}
}
#v(1em)

#{
if type(authors) == array {
if authors.len() > 0 {
[
#text(size: 1.55em, sc(authors.at(0)))
\
]
}
if authors.len() > 1 {
[
#text(size: 1.55em, authors.slice(1).map(sc).join(" - "))
]
}
} else {
[
#text(size: 1.55em, sc(authors))
]
}
}

],
)

pagebreak()
if outline {
custom-outline
pagebreak()
}

if local-outline {
get-local-outline()
}
get-small-title(style, title, authors)
} else {
if outline {
custom-outline
pagebreak()
}

get-small-title(style, title, authors)
if local-outline {
get-local-outline()
}
v(20pt)
}
}
Loading