#let layouts = ( "small": ("height": 9cm, "space": 1.4cm), "medium": ("height": 10.5cm, "space": 1.6cm), "large": ("height": 12cm, "space": 1.8cm), ) #let slides( content, title: none, subtitle: none, footer-title: none, footer-subtitle: none, date: none, authors: (), affiliations: none, logo: none, corner-logo: none, layout: "medium", ratio: 4 / 3, title-color: none, first-slide: true, bg-color: white, count: "dot", footer: true, toc: true, theme: "normal", ) = { // Parsing if layout not in layouts { panic("Unknown layout " + layout) } let (height, space) = layouts.at(layout) let width = ratio * height if count not in (none, "dot", "number", "dot-section") { panic( "Unknown Count, valid counts are 'dot', 'dot-section' and 'number', or none", ) } if theme not in ("normal", "full") { panic("Unknown Theme, valid themes are 'full' and 'normal'") } // Colors if title-color == none { title-color = blue.darken(50%) } let block-color = title-color.lighten(90%) let body-color = title-color.lighten(80%) let header-color = title-color.lighten(65%) let fill-color = title-color.lighten(50%) let frac(x) = x - calc.floor(x) let speck = title-color.darken(30%) let grain = tiling(size: (60pt, 60pt))[ #for i in range(150) { place( top + left, dx: frac(calc.sin(i * 12.9898) * 43758.5453) * 60pt, dy: frac(calc.sin(i * 78.233 + 1.3) * 12345.678) * 60pt, circle(radius: 0.8pt, fill: gradient.radial( speck.transparentize(75%), speck.transparentize(100%), )), ) } ] let grain-overlay = place(top + left, rect( width: 100%, height: 100%, fill: grain, stroke: none, )) let ox-gradient = gradient.linear( title-color.lighten(16%), title-color.saturate(12%), angle: 40deg, ) // Setup set document( title: title, author: authors, ) set heading(numbering: "1.a") let section_counter = counter("section") // PAGE---------------------------------------------- set page( fill: bg-color, width: width, height: height, margin: (x: 0.5 * space, top: 1.15 * space, bottom: 0.45 * space), // HEADER header: [ #context { let page = here().page() let headings = query(selector(heading.where(level: 2))) let heading = headings.rev().find(x => x.location().page() <= page) if heading != none { set align(top) if (theme == "full") { block( width: 100%, fill: ox-gradient, height: space * 0.85, outset: (x: 0.5 * space), )[ #place(top + left, dx: -0.5 * space, rect( width: 100% + space, height: 100%, fill: grain, stroke: none, )) #set text(1.4em, weight: "bold", fill: bg-color) #v(space / 2) #heading.body #if not heading.location().page() == page [ #{ numbering("(i)", page - heading.location().page() + 1) } ] ] } else if (theme == "normal") { set text(1.4em, weight: "bold", fill: title-color) v(space / 2) heading.body if not heading.location().page() == page [ #{ numbering("(i)", page - heading.location().page() + 1) } ] } } } // COUNTER ============================================================ #if count == "dot" { // DOT COUNTER ------------------------- set align(right + top) context { let last = counter(page).final().first() let current = here().page() let limit = calc.ceil(last / 2) // the limit automatically allows to have even rows of dots // if number of pages > 20 if last > 20 { v(-space / 1.3) // first row of dots for i in range(1, limit + 1) { // Before the current page if i <= current { link((page: i, x: 0pt, y: 0pt))[ #box(circle( radius: 0.06cm, fill: fill-color, stroke: 1pt + fill-color, )) ] } // After the current page else { link((page: i, x: 0pt, y: 0pt))[ #box(circle(radius: 0.06cm, stroke: 1pt + fill-color)) ] } } v(-space / 1.6) linebreak() // second row of dots for i in range(limit + 1, last + 1) { // Before the current page if i <= current { link((page: i, x: 0pt, y: 0pt))[ #box(circle( radius: 0.06cm, fill: fill-color, stroke: 1pt + fill-color, )) ] } // After the current page else { link((page: i, x: 0pt, y: 0pt))[ #box(circle(radius: 0.06cm, stroke: 1pt + fill-color)) ] } } } else { // Normal Counter if number of pages < 20 v(-space / 1.5) for i in range(1, last + 1) { // Before and including the current page if i <= current { link((page: i, x: 0pt, y: 0pt))[ #box(circle( radius: 0.08cm, fill: fill-color, stroke: 1pt + fill-color, )) ] } // After the current page else { link((page: i, x: 0pt, y: 0pt))[ #box(circle(radius: 0.08cm, stroke: 1pt + fill-color)) ] } } } } } else if count == "dot-section" { // DOT SECTION COUNTER ------------------------- v(-space / 1.5) set align(right + top) context { let last = counter(page).final().first() let current = here().page() // Logic to find the current section let sections = query(heading.where(level: 1)) let current_section_nr = section_counter.get().at(0) let current_section_page = { if current_section_nr > 0 { sections.at(int(current_section_nr - 1)).location().page() } else { 1 } // special case for first section (typically outline) } let next_section_page = { if current_section_nr < int(sections.len()) { sections.at(int(current_section_nr)).location().page() } else { last } } // Display the counter for all except last section if next_section_page - current_section_page < 3 { // For sections that only have 1 page leave the counter blank // NOTE: that it also dosnt show a counter if last section < 2 pages } else if current_section_nr < int(sections.len()) { // Current Section Dot link((page: current_section_page, x: 0pt, y: 0pt))[ #box(rotate(-90deg)[#polygon.regular( stroke: 1pt + fill-color, size: 0.2cm, vertices: 3, )]) #h(0.1cm) ] // Prec and Current Pages Dot for i in range(current_section_page + 1, next_section_page) { if i <= current { link((page: i, x: 0pt, y: 0pt))[ #box(circle( radius: 0.08cm, fill: fill-color, stroke: 1pt + fill-color, )) ] } else { link((page: i, x: 0pt, y: 0pt))[ #box(circle(radius: 0.08cm, stroke: 1pt + fill-color)) ] } } // Next Section Dot link((page: next_section_page, x: 0pt, y: 0pt))[ #h(0.1cm) #box(rotate(90deg)[#polygon.regular( stroke: 1pt + fill-color, size: 0.2cm, vertices: 3, )]) ] } else { // Current Section Dot link((page: current_section_page, x: 0pt, y: 0pt))[ #box(rotate(-90deg)[#polygon.regular( stroke: 1pt + fill-color, size: 0.2cm, vertices: 3, )]) #h(0.1cm) ] // Prec and Current Pages Dot (note that the last slide is included by extending range + 1) for i in range(current_section_page + 1, next_section_page + 1) { if i <= current { link((page: i, x: 0pt, y: 0pt))[ #box(circle( radius: 0.08cm, fill: fill-color, stroke: 1pt + fill-color, )) ] } else { link((page: i, x: 0pt, y: 0pt))[ #box(circle(radius: 0.08cm, stroke: 1pt + fill-color)) ] } } } } } else if count == "number" { // NUMBER COUNTER ------------------------- v(-space / 1.5) set align(right + top) context { let last = counter(page).final().first() let current = counter(page).get().first() set text(weight: "bold") set text(fill: white) if theme == "full" set text(fill: title-color) if theme == "normal" [#current / #last] } } ], header-ascent: 0%, // FOOTER ---------------------------------------------------- footer: [ #if footer == true { set text(0.7em) // Colored Style if (theme == "normal") { columns(2, gutter: 0cm)[ // Left side of the Footer #align(left)[#block( width: 100%, outset: (left: 0.5 * space, bottom: 0cm), height: 0.3 * space, fill: fill-color, inset: (right: 3pt), )[ #v(0.1 * space) #set align(right) #smallcaps()[#if footer-title != none { footer-title } else { title }] ] ] // Right Side of the Footer #align(right)[#block( width: 100%, outset: (right: 0.5 * space, bottom: 0cm), height: 0.3 * space, fill: body-color, inset: (left: 3pt), )[ #v(0.1 * space) #set align(left) #if footer-subtitle != none { footer-subtitle } else if subtitle != none { subtitle } else if authors != none { if (type(authors) != array) { authors = (authors,) } authors.join(", ", last: " and ") } else [#date] ] ] ] } // Normal Styling of the Footer else if (theme == "full") { box()[#line(length: 50%, stroke: 2pt + fill-color)] box()[#line(length: 50%, stroke: 2pt + body-color)] v(-0.33cm) grid( columns: (1fr, 1fr), align: (right, left), inset: 4pt, [#smallcaps()[ #if footer-title != none { footer-title } else { title }]], [#if footer-subtitle != none { footer-subtitle } else if subtitle != none { subtitle } else if authors != none { if (type(authors) != array) { authors = (authors,) } authors.join(", ", last: " and ") } else [#date] ], ) } } ], footer-descent: 0.15 * space, ) // SLIDES STYLING -------------------------------------------------- // Section Slides show heading.where(level: 1): x => { section_counter.step() set page(header: none, footer: none, margin: 0cm) set align(horizon) grid( columns: (1fr, 3fr), rows: 100%, inset: (x, y) => if x == 0 { 0pt } else { (left: 0.6 * space) }, align: (center + horizon, left + horizon), [#block(width: 100%, height: 100%, fill: ox-gradient, clip: true)[ #grain-overlay #align(center + horizon)[#context text( 6em, weight: "bold", fill: bg-color.transparentize(40%), )[#section_counter.display()]] ]], [#text(1.7em, weight: "bold", fill: title-color)[#x.body]], ) } show heading.where(level: 2): pagebreak(weak: true) // this is where the magic happens show heading: set text(1.1em, fill: title-color) // ADDITIONAL STYLING -------------------------------------------------- // Terms show terms.item: it => { stack( block( width: 100%, inset: 5pt, fill: header-color, radius: (top: 0.2em, bottom: 0cm), strong(it.term), ), block( width: 100%, inset: 5pt, fill: block-color, radius: (top: 0cm, bottom: 0.2em), it.description, ), ) } // Code show raw.where(block: false): it => { box( fill: white, inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, baseline: 1pt, )[#text(it)] } show raw.where(block: true): it => { block( radius: 0.4em, fill: white, width: 100%, inset: (x: 1em, y: 0.85em), stroke: (left: 3pt + fill-color, rest: 0.6pt + header-color), it, ) } // Bullet List show list: set list(marker: ( text(fill: title-color)[•], text(fill: title-color)[‣], text(fill: title-color)[-], )) // Enum let color_number(nrs) = text(fill: title-color)[*#nrs.*] set enum(numbering: color_number) // Table show table: set table( stroke: (x, y) => ( x: none, bottom: 0.8pt + black, top: if y == 0 { 0.8pt + black } else if y == 1 { 0.4pt + black } else { 0pt }, ), ) show table.cell.where(y: 0): set text( style: "normal", weight: "bold", ) // for first / header row set table.hline(stroke: 0.4pt + black) set table.vline(stroke: 0.4pt) // Quote set quote(block: true) show quote.where(block: true): it => { v(-5pt) block( fill: block-color, inset: 5pt, radius: 1pt, stroke: (left: 3pt + fill-color), width: 100%, outset: (left: -5pt, right: -5pt, top: 5pt, bottom: 5pt), )[#it] v(-5pt) } // Link show link: it => { if type(it.dest) != str { // Local Links it } else { underline(stroke: 0.5pt + title-color)[#it] // Web Links } } // Outline set outline( // target: heading.where(level: 1), indent: auto, ) show outline: set heading(level: 2) // To not make the TOC heading a section slide by itself // Bibliography set bibliography( title: none, ) // References show ref: it => { // Filter only for links, not for citations if it.element != none { let el = it.element set text(size: 0.7em, fill: white) box( fill: fill-color, outset: (x: 0.0em, y: 0.2em), radius: 0.8em, height: 0.8em, inset: (x: 0.5em), //stroke: (bottom: fill-color), )[ // if no supplement is passed #if el.func() == heading and it.supplement == auto { link(el.location(), el.body) } else if el.func() == heading { // if a supplement is passed link(el.location(), it.supplement.text) } else { // everything else (equations, figures etc) it } ] } else { // these are the citations return it } } // CONTENT--------------------------------------------- // Title Slide if (title == none) { panic("A title is required") } else if (first-slide == false) { // Remove the first page for custom arrangements } else { if (type(authors) != array) { authors = (authors,) } set page(footer: none, header: none, margin: 0cm) block( inset: (x: 0.5 * space, top: 1em, bottom: 0pt), fill: ox-gradient, width: 100%, height: 52%, )[ // Cover image behind the orange band #place(top + left, dx: -0.5 * space, dy: -1em, image( "figures/rustacean-banner.png", width: 100% + space, height: 100% + 1em, fit: "cover", )) // Semi-transparent orange gradient over the image (tweak transparentize for opacity) #place(top + left, dx: -0.5 * space, dy: -1em, rect( width: 100% + space, height: 100% + 1em, fill: gradient.linear( title-color.lighten(16%).transparentize(100%), title-color.saturate(12%).transparentize(100%), angle: 40deg, ), stroke: none, )) #place(top + left, dx: -0.5 * space, dy: -1em, rect( width: 100% + space, height: 100% + 1em, fill: grain, stroke: none, )) #if corner-logo != none { place(top + right, dx: 0.1 * space, dy: -1em)[ #block( fill: white, radius: (top: 0pt, bottom: 1.25em), inset: (x: 0.55em, top: 0.45em, bottom: 0.55em), outset: (top: 0.6em), )[#box(width: 2.35cm, corner-logo)] ] } #align(left + bottom)[ #if logo != none { block( fill: white, radius: (top: 1.25em, bottom: 0pt), inset: (x: 0.9em, top: 0.5em, bottom: 0.55em), outset: (bottom: 0.6em), )[#box(width: 8.5cm, logo)] } else { text(2.0em, weight: "bold", fill: bg-color, title) } ] ] block( height: 40%, width: 100%, inset: (x: 0.5 * space, top: 0cm, bottom: 1em), if subtitle != none { [ #text(1.4em, fill: title-color, weight: "bold", subtitle) ] } + if subtitle != none and date != none { text(1.4em)[ \ ] } + if date != none { text(1.1em, date) } + align(left + bottom, if affiliations != none { affiliations } else { authors.join(", ", last: " & ") }), ) } // Outline if (toc == true) { outline() } // The body of the slides content }