Last active
July 16, 2024 06:02
-
-
Save ckunte/81aa4ee1376c2384c980b0d87bd0cd5e to your computer and use it in GitHub Desktop.
Typst preamble -- an example
This file contains 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
#let cknotes(doc) = { | |
// settings | |
set page( | |
header: align(left)[ | |
#image("logo.png", width: 9%) | |
], | |
margin: ( | |
top: 2cm, | |
y: 2cm, | |
), | |
numbering: "1 of 1", | |
) | |
// Configure paragraph properties (indented paras) | |
set par(leading: 0.65em, first-line-indent: 12pt, justify: true) | |
show par: set block(spacing: 0.65em) | |
// text characteristics | |
set text( | |
font: "Arial", // New Computer Modern, | |
top-edge: "cap-height", | |
bottom-edge: "baseline", | |
number-type: "old-style", | |
) | |
// link properties | |
show cite: set text(fill: maroon) | |
show link: set text(fill: rgb(0, 0, 255)) | |
show link: underline | |
// colour terms | |
show regex("tb[a,c,d,p]"): set text(fill: red, style: "italic") // for to-be-[advised, confirmed, determined, planned] | |
show strike: set text(style: "italic") | |
// search for words like 2024W25 via REGEX and format the found results | |
show regex("done\([0-9]{4}W[0-9]{2}\)"): set text(fill: rgb(0, 96, 0), style: "italic") | |
// format texts containing these words or phrases | |
show "callback requested": set text(fill: rgb(255, 0, 0), style: "italic") | |
show "info shared": set text(fill: rgb(0, 96, 0), style: "italic") | |
show "callback requested": set text(fill: rgb(255, 0, 0), style: "italic") | |
// background color a little trickier, here are a few examples | |
let hl(content, col) = highlight(fill: col)[#content] | |
show "monitor and maintain": match => { hl(match, rgb(255,179,186)) } | |
show "repair": match => { hl(match, rgb(255,223,186)) } | |
show "replace": match => { hl(match, rgb(255,255,186)) } | |
show "run additional": match => { hl(match, rgb(255,179,186)) } | |
show "impracticable": match => { hl(match, rgb(255,179,186)) } | |
show strike: set text(fill: rgb(0, 96, 0), style: "italic") | |
// small-caps, where supported by font | |
let sc(content) = text(features: ("c2sc",))[#content] | |
show regex("[A-Z]{2,}"): match => { | |
sc(match) | |
} | |
doc | |
} | |
//// Call the following in the main file | |
//#import "/inc/preamble.typ": cknotes | |
//#show: doc => cknotes(doc) | |
//#set document( | |
// title: [<Title of the note here>], | |
// author: "C Kunte", | |
// keywords: "keyword1, keyword2", | |
// date: auto, | |
//) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment