Last active
October 22, 2025 14:40
-
-
Save arialdomartini/db6b6b82574b70cbe8ca41e4bf829fca to your computer and use it in GitHub Desktop.
Settings to try typst.typ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // heading numbers on the margin | |
| #show raw: it => { | |
| box( | |
| fill: rgb("#f6f8fa"), | |
| stroke: rgb("#d1d9e0b3"), | |
| outset: (y: 3pt), | |
| inset: (x: 2pt), | |
| radius: 3pt, | |
| it | |
| ) | |
| } | |
| #show heading: it => { | |
| rect( | |
| stroke: {}, | |
| inset: 0em, | |
| place( | |
| right, | |
| dx: -100% - 0.618em, | |
| text( | |
| counter(heading).display() | |
| ), | |
| ) + it.body | |
| ) | |
| } | |
| // chapter titles | |
| #show heading.where(level: 1): it => { | |
| pagebreak(weak: true) | |
| stack( | |
| // Place the grey chapter number in the background | |
| place( | |
| top + right, // Align to the top-righ | |
| dx: -0cm, // Adjust horizontal position | |
| dy: -2.5em, // Adjust vertical position | |
| text( | |
| fill: gray.lighten(30%), | |
| size: 8em, | |
| weight: "bold", | |
| counter(heading).display() | |
| ) | |
| ), | |
| // Display the main title, aligned to the right | |
| block( | |
| width: 100%, | |
| height: 3em, | |
| place( | |
| right, | |
| dx: -1em, | |
| dy: 0em, | |
| align( | |
| right, | |
| text( | |
| size: 2em, | |
| weight: "bold", | |
| it.body | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| } | |
| // paper readable links | |
| show link: it => { | |
| // FIXME: Accept content it.body | |
| if cfg.paper-links and type(it.dest) == str and it.dest != it.body.text { | |
| it | |
| footnote(it.dest) | |
| } | |
| else {it} | |
| } | |
| #set page( | |
| paper: "a5", | |
| header: context { | |
| let headings = query(heading.where(level: 1).before(here())) | |
| if headings.len() == 0 { | |
| return | |
| } | |
| let chapter = headings.last() | |
| align(left)[#chapter.body] | |
| v(-5pt) | |
| line(length: 100%) | |
| } | |
| ) | |
| // flow around picture | |
| #pagebreak() | |
| #let img = image("./static/img/chapter.png", width: 50%) | |
| #let fig = figure( | |
| placement: top, // must be `auto`, `top`, or `bottom` | |
| img | |
| ) | |
| \u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}You want to invent a new language, and you \ | |
| \u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}want to do this in F\#, don't you? And, of course, \ | |
| \u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}you want to base its parser on Monadic Parser \ | |
| \u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}Combinators. You've always wanted. So, let's make \ | |
| \u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}\u{00a0}it happen! | |
| #place( | |
| top + left, | |
| float: false, | |
| dx: -5pt, | |
| dy: -25pt, | |
| img | |
| ) | |
| #pagebreak() | |
| #import "@preview/wrap-it:0.1.1": wrap-content | |
| #let img = image("./static/img/parser-combinators-for-the-rest-of-us/map.png", width: 100%) | |
| #let fig = figure( | |
| img | |
| ) | |
| #let body = lorem(30) | |
| #wrap-content( | |
| fig, | |
| body, | |
| column-gutter: .5em) | |
| #include "content.typ" | |
| #set list(marker: [\u{2023}]) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Complete example
#set page(
paper: "sac-d5",
margin: (left: 5em, right: 1cm))
#set par(
justify: true
)
#set heading(numbering: "1.1.1")
#show link: set text(fill: blue, weight: 700)
#show link: underline
// #show heading: it => {
// block(
// stack(
// place(
// dx: -2.5em,
// text(weight: "regular")[#counter(heading).display()]
// ),
// align(right, it.body)
// )
// )
// }
#show heading: it => {
rect(
stroke: {},
inset: 0em,
place(
right,
dx: -100% - .8em,
text(
counter(heading).display()
),
) + it.body
)
}
#show heading.where(level: 1): it => {
pagebreak(weak: true)
stack(
// Place the grey chapter number in the background
place(
top + right, // Align to the top-righ
dx: -0cm, // Adjust horizontal position
dy: -2.5em, // Adjust vertical position
text(
fill: gray.lighten(30%),
size: 8em,
weight: "bold",
counter(heading).display()
)
),
)
}
= This is a chapter
#lorem(25)
== We Will See
#lorem(25)
=== Here We Go
#lorem(25)
= This is a chapter
#lorem(25)
== we will see
#lorem(25)
=== here we go
#lorem(25)
= Here we go again