diff --git a/slide.typ b/slide.typ index 60c0f0af5..32b6ee500 100644 --- a/slide.typ +++ b/slide.typ @@ -323,9 +323,43 @@ return (result-arr, max-repetitions) } +#let _get-negative-pad(self) = { + let margin = self.page-args.margin + if type(margin) != dictionary and type(margin) != length and type(margin) != relative { + return it => it + } + let cell = block.with(width: 100%, height: 100%, above: 0pt, below: 0pt, breakable: false) + if type(margin) == length or type(margin) == relative { + return it => pad(x: -margin, cell(it)) + } + let pad-args = (:) + if "x" in margin { + pad-args.x = -margin.x + } + if "left" in margin { + pad-args.left = -margin.left + } + if "right" in margin { + pad-args.right = -margin.right + } + if "rest" in margin { + pad-args.rest = -margin.rest + } + it => pad(..pad-args, cell(it)) +} + #let _get-header-footer(self) = { let header = utils.call-or-display(self, self.page-args.at("header", default: none)) let footer = utils.call-or-display(self, self.page-args.at("footer", default: none)) + if self.full-header or self.full-footer { + let negative-pad = _get-negative-pad(self) + if self.full-header { + header = negative-pad(header) + } + if self.full-footer { + footer = negative-pad(footer) + } + } (header, footer) } @@ -341,9 +375,6 @@ ..bodies, ) = { assert(bodies.named().len() == 0, message: "unexpected named arguments:" + repr(bodies.named().keys())) - let setting-with-pad(body) = { - pad(..self.padding, setting(body)) - } let composer-with-side-by-side(..args) = { if type(composer) == function { composer(..args) @@ -407,9 +438,10 @@ if repeat == none { return { header = _update-states(1) + header - page(..(self.page-args + (header: header, footer: footer)), setting-with-pad( + set page(..(self.page-args + (header: header, footer: footer))) + setting( page-preamble(1) + composer-with-side-by-side(..bodies) - )) + ) } } @@ -417,9 +449,10 @@ self.subslide = repeat let (conts, _) = _parse-content(self: self, index: repeat, ..bodies) header = _update-states(1) + header - page(..(self.page-args + (header: header, footer: footer)), setting-with-pad( + set page(..(self.page-args + (header: header, footer: footer))) + setting( page-preamble(1) + composer-with-side-by-side(..conts) - )) + ) } else { // render all the subslides let result = () @@ -433,10 +466,10 @@ if i == 1 { new-header = _update-states(repeat) + new-header } - result.push(page( - ..(self.page-args + (header: new-header, footer: footer)), - setting-with-pad(page-preamble(i) + composer-with-side-by-side(..conts)), - )) + result.push({ + set page(..(self.page-args + (header: new-header, footer: footer))) + setting(page-preamble(i) + composer-with-side-by-side(..conts)) + }) } // return the result result.sum() @@ -593,8 +626,11 @@ header: none, footer: none, fill: rgb("#ffffff"), + margin: (x: 7%, y: 12%), ), - padding: (x: 0em, y: 0em), + // full header / footer + full-header: true, + full-footer: true, // datetime format datetime-format: auto, // register the methods diff --git a/themes/aqua.typ b/themes/aqua.typ index b631b22c2..60fcc6d43 100644 --- a/themes/aqua.typ +++ b/themes/aqua.typ @@ -194,11 +194,15 @@ circle(radius: 13pt, fill: white)) } let header(self) = { - place(center + top, dy: 45%, - rect(width: 100%, height: 100%, fill: self.colors.primary)) - place(left + top, line(start: (30%, 30%), end: (27%, 200%), stroke: 7pt + white)) - place(left + bottom, dx: 4%, dy: 15%, - text(fill:white, self.aqua-title)) + place(center + top, dy: .5em, + rect( + width: 100%, + height: 1.8em, + fill: self.colors.primary, + align(left + horizon, h(1.5em) + text(fill:white, self.aqua-title)) + ) + ) + place(left + top, line(start: (30%, 0%), end: (27%, 100%), stroke: .5em + white)) } let footer(self) = { set text(size: 0.8em) @@ -206,11 +210,10 @@ } self.page-args += ( paper: "presentation-" + aspect-ratio, - margin: (x: 0em, top: 10%, bottom: 10%), + margin: (x: 2em, top: 3.5em, bottom: 2em), header: header, footer: footer, ) - self.padding += (x: 5%, top: 7%) self.methods.init = (self: none, body) => { set text(size: 20pt) body diff --git a/themes/dewdrop.typ b/themes/dewdrop.typ index dbbdb1cbd..94d395947 100644 --- a/themes/dewdrop.typ +++ b/themes/dewdrop.typ @@ -278,13 +278,12 @@ header-ascent: 0em, footer-descent: 0em, ) + if navigation == "sidebar" {( - margin: (top: 2em, bottom: 1em, x: 0em), + margin: (top: 2em, bottom: 1em, x: sidebar.width), )} else if navigation == "mini-slides" {( - margin: (top: mini-slides.height, bottom: 2em, x: 0em), + margin: (top: mini-slides.height, bottom: 2em, x: mini-slides.x), )} else {( - margin: (top: 2em, bottom: 2em, x: 0em), + margin: (top: 2em, bottom: 2em, x: mini-slides.x), )} - self.padding = (x: if navigation == "sidebar" { sidebar.width } else { mini-slides.x }, y: 0em) // register methods self.methods.slide = slide self.methods.title-slide = title-slide diff --git a/themes/metropolis.typ b/themes/metropolis.typ index ed9c712f2..cb967e079 100644 --- a/themes/metropolis.typ +++ b/themes/metropolis.typ @@ -167,9 +167,8 @@ footer: footer, header-ascent: 30%, footer-descent: 30%, - margin: (top: 3em, bottom: 1.5em, x: 0em), + margin: (top: 3em, bottom: 1.5em, x: 2em), ) - self.padding = (x: 2em, y: 0em) // register methods self.methods.slide = slide self.methods.title-slide = title-slide diff --git a/themes/simple.typ b/themes/simple.typ index abe3dc0b1..0267cc6f8 100644 --- a/themes/simple.typ +++ b/themes/simple.typ @@ -18,7 +18,7 @@ } #let centered-slide(self: none, section: none, ..args) = { - self = utils.empty-page(self) + self = utils.empty-page(self, margin: none) (self.methods.touying-slide)(self: self, repeat: none, section: section, ..args.named(), align(center + horizon, if section != none { heading(level: 1, utils.unify-section(section).title) } + args.pos().sum(default: [])) ) @@ -33,7 +33,7 @@ } #let focus-slide(self: none, background: auto, foreground: white, body) = { - self = utils.empty-page(self) + self = utils.empty-page(self, margin: none) self.page-args.fill = if background == auto { self.colors.primary } else { background } set text(fill: foreground, size: 1.5em) centered-slide(self: self, align(center + horizon, body)) @@ -75,6 +75,8 @@ footer-descent: 1em, header-ascent: 1em, ) + self.full-header = false + self.full-footer = false // register methods self.methods.slide = slide self.methods.title-slide = title-slide diff --git a/themes/university.typ b/themes/university.typ index e0beca4a9..6e759f3fd 100644 --- a/themes/university.typ +++ b/themes/university.typ @@ -262,9 +262,8 @@ footer: footer, header-ascent: 0em, footer-descent: 0em, - margin: (top: 2.5em, bottom: 1em, x: 0em), + margin: (top: 2.5em, bottom: 1em, x: 2em), ) - self.padding = (x: 2em, y: 0em) // register methods self.methods.slide = slide self.methods.title-slide = title-slide diff --git a/utils/utils.typ b/utils/utils.typ index 631258fc3..4839e6146 100644 --- a/utils/utils.typ +++ b/utils/utils.typ @@ -7,13 +7,14 @@ } // OOP: empty page -#let empty-page(self) = { +#let empty-page(self, margin: (x: 0em, y: 0em)) = { self.page-args += ( header: none, footer: none, - margin: (x: 0em, y: 0em), ) - self.padding = (x: 0em, y: 0em) + if margin != none { + self.page-args += (margin: margin) + } self }