Skip to content
Snippets Groups Projects
Commit d0f449f6 authored by Sivecano's avatar Sivecano
Browse files

update nixos course to use central template with Makefile

parent 9b2dd03b
No related branches found
No related tags found
No related merge requests found
TYPST_ROOT!=git rev-parse --show-toplevel
WATCH=main.typ
all : main.pdf
.PHONY: watch
watch:
typst w --root $(TYPST_ROOT) $(WATCH)
%.pdf : %.typ
typst c --root $(TYPST_ROOT) $<
This diff is collapsed.
This diff is collapsed.
#import "@preview/touying:0.5.3": *
#import "thealternative.typ": *
#import "/typst_template/thealternative.typ": *
#import "@preview/diagraph:0.3.0": *
#show: thealt-theme.with(
......
// This theme is based on inspired by https://github.com/zbowang/BeamerTheme
// adapted by Fadri Lardon
#import "@preview/touying:0.5.3": *
#import "@preview/codly:1.0.0": *
#let _typst-builtin-repeat = repeat
#let thealt-header(self) = {
set align(top)
grid(
rows: (auto, auto),
components.cell(
fill: self.colors.tertiary,
height: 2em,
stroke: self.colors.quaterniary,
components.mini-slides(
self: self,
fill: self.colors.secondary, //.mix((white, 30%), space: rgb),
alpha: 100%,
display-section: false,
display-subsection: true,
linebreaks: false,
short-heading: self.store.mini-slides.at("short-heading", default: false),
),
),
components.cell(
fill: self.colors.primary,
height: 1em,
place(left + horizon, text(fill: self.colors.neutral-lightest, size: 0.7em, utils.display-current-heading(level: 2)), dx: 1.5em)
)
)
}
#let thealt-footer(self) = {
//set align(bottom)
set text(size: 0.8em)
grid(
rows: (auto, auto),
align(horizon, components.cell(
height: .95em,
fill: self.colors.tertiary,
components.left-and-right(
pad(left: 1.5em, text(size: .7em, fill: self.colors.secondary, self.info.title)),
pad(right: 1em, context text(size: .7em, fill: self.colors.secondary, utils.slide-counter.display()))
))
),
align(bottom, components.cell(
fill: self.colors.primary,
height: 1.6em,
components.left-and-right(
pad(left: 1.5em, bottom: .5em, text( size: .9em, fill: self.colors.neutral-lightest, self.info.author)),
pad(right: 1em, bottom: .2em, image( height: 1em, "img/logo_white.svg"))
))
)
)
}
/// Default slide function for the presentation.
///
/// - `config` is the configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
///
/// - `repeat` is the number of subslides. Default is `auto`,which means touying will automatically calculate the number of subslides.
///
/// The `repeat` argument is necessary when you use `#slide(repeat: 3, self => [ .. ])` style code to create a slide. The callback-style `uncover` and `only` cannot be detected by touying automatically.
///
/// - `setting` is the setting of the slide. You can use it to add some set/show rules for the slide.
///
/// - `composer` is the composer of the slide. You can use it to set the layout of the slide.
///
/// For example, `#slide(composer: (1fr, 2fr, 1fr))[A][B][C]` to split the slide into three parts. The first and the last parts will take 1/4 of the slide, and the second part will take 1/2 of the slide.
///
/// If you pass a non-function value like `(1fr, 2fr, 1fr)`, it will be assumed to be the first argument of the `components.side-by-side` function.
///
/// The `components.side-by-side` function is a simple wrapper of the `grid` function. It means you can use the `grid.cell(colspan: 2, ..)` to make the cell take 2 columns.
///
/// For example, `#slide(composer: 2)[A][B][#grid.cell(colspan: 2)[Footer]]` will make the `Footer` cell take 2 columns.
///
/// If you want to customize the composer, you can pass a function to the `composer` argument. The function should receive the contents of the slide and return the content of the slide, like `#slide(composer: grid.with(columns: 2))[A][B]`.
///
/// - `..bodies` is the contents of the slide. You can call the `slide` function with syntax like `#slide[A][B][C]` to create a slide.
#let slide(
config: (:),
repeat: auto,
setting: body => body,
composer: auto,
..bodies,
) = touying-slide-wrapper(self => {
let self = utils.merge-dicts(
self,
config-page(
fill: self.colors.neutral-lightest,
header: thealt-header,
footer: thealt-footer,
),
config-common(subslide-preamble: self.store.subslide-preamble),
)
let new-setting(body) = {
set text(fill: self.colors.neutral-darkest)
setting(body)
}
touying-slide(self: self, config: config, repeat: repeat, setting: setting, composer: composer, ..bodies)
})
/// Title slide for the presentation. You should update the information in the `config-info` function. You can also pass the information directly to the `title-slide` function.
///
/// Example:
///
/// ```typst
/// #show: thealt-theme.with(
/// config-info(
/// title: [Title],
/// logo: emoji.city,
/// ),
/// )
///
/// #title-slide(subtitle: [Subtitle], extra: [Extra information])
/// ```
///
/// - `extra` is the extra information you want to display on the title slide.
#let title-slide(
extra: none,
..args,
) = touying-slide-wrapper(self => {
let self = utils.merge-dicts(
self,
config-page(
fill: self.colors.neutral-lightest,
// header: thealt-header,
// footer: thealt-footer,
),
config-common(subslide-preamble: self.store.subslide-preamble),
)
let info = self.info + args.named()
let body = {
set text(fill: self.colors.neutral-darkest)
set align(center + horizon)
block(
width: 100%,
inset: 3em,
{
block(
inset: 1em,
width: 100%,
radius: 0.2em,
text(size: 1.7em, fill: self.colors.primary, text(weight: "medium",info.title)) + (
if info.subtitle != none {
linebreak()
text(size: 0.9em, fill: self.colors.primary, info.subtitle)
}
),
)
set text(size: .8em)
if info.author != none {
block(spacing: 1em, info.author)
}
v(1em)
set text(size: .8em)
if info.institution != none {
image("img/logo_blue.svg", width: 40%)
}
if extra != none {
block(spacing: 1em, extra)
}
},
)
}
self = utils.merge-dicts(
self,
config-common(freeze-slide-counter: true),
config-page(fill: self.colors.neutral-lightest, margin: 0em),
)
touying-slide(self: self, body)
})
/// Outline slide for the presentation.
#let outline-slide(title: utils.i18n-outline-title, ..args) = touying-slide-wrapper(self => {
self = utils.merge-dicts(
self,
config-page(
fill: self.colors.neutral-lightest,
footer: thealt-footer,
),
)
touying-slide(
self: self,
components.adaptive-columns(
start: text(
1.2em,
fill: self.colors.primary,
weight: "bold",
utils.call-or-display(self, title),
),
text(
fill: self.colors.neutral-darkest,
outline(title: none, indent: 1em, depth: self.slide-level, ..args),
),
),
)
})
/// New section slide for the presentation. You can update it by updating the `new-section-slide-fn` argument for `config-common` function.
///
/// Example: `config-common(new-section-slide-fn: new-section-slide.with(numbered: false))`
///
/// - `title` is the title of the slide. Default is `utils.i18n-outline-title`.
///
/// - `body` is the contents of the slide.
#let new-section-slide(title: utils.i18n-outline-title, ..args, body) = touying-slide-wrapper(self => {
self = utils.merge-dicts(
self,
config-page(
fill: self.colors.neutral-lightest,
footer: thealt-footer,
header: thealt-header,
),
)
touying-slide(
self: self,
align(center + horizon,
text(
3em,
fill: self.colors.secondary,
weight: "bold",
utils.display-current-heading(),
)),
)
})
/// Focus on some content.
///
/// Example: `#focus-slide[Wake up!]`
#let focus-slide(body) = touying-slide-wrapper(self => {
self = utils.merge-dicts(
self,
config-common(freeze-slide-counter: true),
config-page(fill: self.colors.primary, margin: 2em),
)
set text(fill: self.colors.neutral-lightest, size: 1.5em)
touying-slide(self: self, align(horizon + center, body))
})
/// Touying thealt theme.
///
/// Example:
///
/// ```typst
/// #show: thealt-theme.with(aspect-ratio: "16-9", config-colors(primary: blue))`
/// ```
///
/// - `aspect-ratio` is the aspect ratio of the slides. Default is `16-9`.
///
/// - `navigation` is the navigation of the slides. You can choose from `"sidebar"`, `"mini-slides"`, and `none`. Default is `"sidebar"`.
///
/// - `sidebar` is the configuration of the sidebar. You can set the width, filled, numbered, indent, and short-heading of the sidebar. Default is `(width: 10em, filled: false, numbered: false, indent: .5em, short-heading: true)`.
/// - `width` is the width of the sidebar.
/// - `filled` is whether the outline in the sidebar is filled.
/// - `numbered` is whether the outline in the sidebar is numbered.
/// - `indent` is the indent of the outline in the sidebar.
/// - `short-heading` is whether the outline in the sidebar is short.
///
/// - `mini-slides` is the configuration of the mini-slides. You can set the height, x, display-section, display-subsection, and short-heading of the mini-slides. Default is `(height: 4em, x: 2em, display-section: false, display-subsection: true, linebreaks: true, short-heading: true)`.
/// - `height` is the height of the mini-slides.
/// - `x` is the x of the mini-slides.
/// - `display-section` is whether the slides of section is displayed in the mini-slides.
/// - `display-subsection` is whether the slides of subsections is displayed in the mini-slides.
/// - `linebreaks` is whether or linebreaks are in between links for sections and subsections in the mini-slides.
/// - `short-heading` is whether the mini-slides is short. Default is `true`.
///
/// - `footer` is the footer of the slides. Default is `none`.
///
/// - `footer-right` is the right part of the footer. Default is `context utils.slide-counter.display() + " / " + utils.last-slide-number`.
///
/// - `primary` is the primary color of the slides. Default is `rgb("#0c4842")`.
///
/// - `alpha` is the alpha of transparency. Default is `60%`.
///
/// - `outline-title` is the title of the outline. Default is `utils.i18n-outline-title`.
///
/// - `subslide-preamble` is the preamble of the subslide. Default is `self => block(text(1.2em, weight: "bold", fill: self.colors.primary, utils.display-current-heading(depth: self.slide-level)))`.
///
/// ----------------------------------------
///
/// The default colors:
///
/// ```typ
/// config-colors(
/// neutral-darkest: rgb("#000000"),
/// neutral-dark: rgb("#202020"),
/// neutral-light: rgb("#f3f3f3"),
/// neutral-lightest: rgb("#ffffff"),
/// primary: rgb("#0c4842"),
/// )
/// ```
#let thealt-theme(
aspect-ratio: "16-9",
sidebar: (
width: 10em,
filled: false,
numbered: false,
indent: .5em,
short-heading: true,
),
mini-slides: (
height: 4em,
x: 2em,
display-section: false,
display-subsection: true,
linebreaks: true,
short-heading: true,
),
footer: none,
footer-right: context utils.slide-counter.display() + " / " + utils.last-slide-number,
primary: rgb("#254471"),
alpha: 60%,
subslide-preamble: self => block(
text(1.2em, weight: "bold", fill: self.colors.primary, utils.display-current-heading(depth: self.slide-level)),
),
..args,
body,
) = {
sidebar = utils.merge-dicts(
(width: 10em, filled: false, numbered: false, indent: .5em, short-heading: true),
sidebar,
)
mini-slides = utils.merge-dicts(
(height: 4em, x: 2em, display-section: false, display-subsection: true, linebreaks: true, short-heading: true),
mini-slides,
)
set text(size: 20pt)
set par(justify: true)
show: touying-slides.with(
config-page(
paper: "presentation-" + aspect-ratio,
header-ascent: 0em,
footer-descent: 0em,
margin:
(top: mini-slides.height, bottom: 2em, x: mini-slides.x),
),
config-common(
slide-fn: slide,
new-section-slide-fn: new-section-slide,
slide-level: 3,
preamble: {
},
),
config-methods(
init: (self: none, body) => {
show heading: set text(self.colors.primary)
set text(font: "Latin Modern Sans")
body
},
alert: utils.alert-with-primary-color,
),
config-colors(
neutral-darkest: rgb("#000000"),
neutral-dark: rgb("#202020"),
neutral-light: rgb("#f3f3f3"),
neutral-lightest: rgb("#ffffff"),
primary: primary,
secondary: rgb("#f18a20"),
tertiary: rgb("#122238"),
quaterniary: rgb("#15253B"),
),
// save the variables for later use
config-store(
sidebar: sidebar,
mini-slides: mini-slides,
footer: footer,
footer-right: footer-right,
alpha: alpha,
subslide-preamble: subslide-preamble,
),
..args,
)
body
}
#import "@preview/touying:0.5.3": *
#import "/typst_template/thealternative.typ": *
#show: thealt-theme.with(
aspect-ratio: "16-9",
config-info(
title: [Our epic typst talk],
subtitle: [Subtitle],
author: [Fadri Lardon, Johanna Polzin],
date: datetime.today(),
institution: [Institution],
),
)
#show: codly-init.with()
#title-slide()
= I'm a section
== this is an example slide
Hello
=== subsubsection go
```C
# include <iostream>
using namespace std;
int main () {
const int N = 10; // larger N for slower learners
for(int i = 0; i < N; i++) {
cout << "FOSS is also great for non-programmers!" << endl;
}
return 0;
}```
=== subsubsection gogo
```bash
echo "Hello"
```
=== subsubsection gogogo
== another example slide
Hello too
= A second section
== hello
#lorem(80)
=== AAAH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment