Skip to content

Commit

Permalink
metropolis-polylux:0.1.0 (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasKroepelin authored Jan 27, 2025
1 parent efa4b75 commit 3ee3201
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 polylux-typ

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.
62 changes: 62 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
![Polylux logo](https://raw.githubusercontent.com/polylux-typ/polylux/ed1e70e74f2a525e80ace9144249c9537917731c/assets/polylux-logo.svg)

# Metropolis

A template for creating presentation slides with Typst and
[Polylux](https://github.com/polylux-typ/polylux/).

![thumbnail](thumbnail.png)


Use via
```sh
typst init @preview/metropolis-polylux your-cool-project
```

A `slides.typ` file will be created for you that you can directly edit and get
going.

At the top of the gnerated `slides.typ`, you will find the line
```typ
#show: metropolis.setup
```
which you can edit to configure the template with the following options:
```typ
#show: metropolis.setup.with(
text-font: "Fira Sans",
math-font: "Fira Math",
code-font: "Fira Code",
text-size: 23pt,
footer: [My cool footer], // defaults to none
)
```
All of them are optional and the default values are shown above.

## Special syntax

Most of the template should be self explanatory but two things might be a bit
surprising:

Slide titles are created using level-one headings (`= A Slide Title`).
Headings of other levels are not affected.
A slide without such a level-one heading will not have a title.

Emphasized text (created like `_this_`) is not shown in italics but in a bright
color (in the original LaTeX version of Metropolis, you would use `\alert` for
this).

## Fonts

By default, the template uses the fonts
[Fira Sans](https://bboxtype.com/typefaces/FiraSans),
[Fira Math](https://github.com/firamath/firamath/releases),
and
[Fira Code](https://github.com/tonsky/FiraCode/releases).
Either make sure you have them installed or specify other fonts in the template.

## About

This theme is inspired by https://github.com/matze/mtheme

The Polylux-port was originally performed by https://github.com/Enivex

86 changes: 86 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// This theme is inspired by https://github.com/matze/mtheme
// The Polylux-port was originally performed by https://github.com/Enivex

#import "@preview/polylux:0.4.0": *

#let bright = rgb("#eb811b")
#let brighter = rgb("#d6c6b7")

#let slide-title-header = toolbox.next-heading(h => {
show: toolbox.full-width-block.with(fill: text.fill, inset: 1em)
set align(horizon)
set text(fill: page.fill, size: 1.2em)
strong(h)
})

#let the-footer(content) = {
set text(size: 0.8em)
show: pad.with(.5em)
set align(bottom)
context text(fill: text.fill.lighten(40%), content)
h(1fr)
toolbox.slide-number
}

#let outline = toolbox.all-sections((sections, _current) => {
enum(tight: false, ..sections)
})

#let progress-bar = toolbox.progress-ratio( ratio => {
set grid.cell(inset: (y: .03em))
grid(
columns: (ratio * 100%, 1fr),
grid.cell(fill: bright)[],
grid.cell(fill: brighter)[],
)
})

#let new-section(name) = slide({
set page(header: none, footer: none)
show: pad.with(20%)
set text(size: 1.5em)
name
toolbox.register-section(name)
progress-bar
})

#let focus(body) = context {
set page(header: none, footer: none, fill: text.fill, margin: 2em)
set text(fill: page.fill, size: 1.5em)
set align(center)
body
}

#let divider = line(length: 100%, stroke: .1em + bright)

#let setup(
footer: none,
text-font: "Fira Sans",
math-font: "Fira Math",
code-font: "Fira Code",
text-size: 23pt,
body,
) = {
set page(
paper: "presentation-16-9",
fill: white.darken(2%),
margin: (top: 3em, rest: 1em),
footer: the-footer(footer),
header: slide-title-header,
)
set text(
font: text-font,
// weight: "light", // looks nice but does not match Fira Math
size: text-size,
fill: rgb("#23373b"), // dark teal
)
set strong(delta: 100)
show math.equation: set text(font: math-font)
show raw: set text(font: code-font)
set align(horizon)
show emph: it => text(fill: bright, it.body)
show heading.where(level: 1): _ => none

body
}

10 changes: 10 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/metropolis.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import "lib.typ": (
bright,
brighter,
focus,
new-section,
outline,
divider,
setup,
progress-bar,
)
71 changes: 71 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/template/slides.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#import "@preview/polylux:0.4.0": *
#import "@preview/metropolis-polylux:0.1.0" as metropolis
#import metropolis: new-section, focus

#show: metropolis.setup

#slide[
#set page(header: none, footer: none, margin: 3em)


#text(size: 1.3em)[
*My presentation title*
]

My subtitle

#metropolis.divider

#set text(size: .8em, weight: "light")
The Author

Jan 16, 2025

Some extra info
]

#slide[
= Agenda

#metropolis.outline
]

#new-section[My first section]

#slide[
= The Fundamental Theorem of Calculus

For $f = (dif F) / (dif x)$ we _know_ that
$
integral_a^b f(x) dif x = F(b) - F(a)
$

See `https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus`
]

#slide[
slide without a title
]

#new-section[My second section]

#slide[
= Heron algorithm

```julia
function heron(x)
r = x
while abs(r^2 - x) > eps()
r = (r + x / r) / 2
end
return r
end
@test heron(42) ≈ sqrt(42)
```
]

#slide[
#show: focus
Something very important
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/preview/metropolis-polylux/0.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "metropolis-polylux"
version = "0.1.0"
entrypoint = "metropolis.typ"
authors = ["Andreas Kröpelin", "Enivex"]
license = "MIT"
description = "Metropolis style template for Polylux"
repository = "https://github.com/polylux-typ/metropolis"
keywords = ["metropolis", "polylux", "presentation", "slides", "slide", "talk", "lecture"]
categories = ["presentation"]

[template]
path = "template"
entrypoint = "slides.typ"
thumbnail = "thumbnail.png"

0 comments on commit 3ee3201

Please sign in to comment.