Rename margins to margin

This commit is contained in:
Laurenz 2022-11-19 23:33:33 +01:00
parent 565b1977ae
commit 8eeb4ad8f6
14 changed files with 26 additions and 27 deletions

View File

@ -21,7 +21,7 @@ impl PageNode {
/// The page's margins.
#[property(fold)]
pub const MARGINS: Sides<Option<Smart<Rel<Length>>>> = Sides::splat(Smart::Auto);
pub const MARGIN: Sides<Option<Smart<Rel<Length>>>> = Sides::splat(Smart::Auto);
/// How many columns the page has.
pub const COLUMNS: NonZeroUsize = NonZeroUsize::new(1).unwrap();
@ -77,7 +77,7 @@ impl PageNode {
// Determine the margins.
let default = Rel::from(0.1190 * min);
let padding = styles.get(Self::MARGINS).map(|side| side.unwrap_or(default));
let padding = styles.get(Self::MARGIN).map(|side| side.unwrap_or(default));
let mut child = self.0.clone();

View File

@ -148,8 +148,7 @@ fn config() -> Config {
let mut styles = typst_library::styles();
styles.set(PageNode::WIDTH, Smart::Custom(Abs::pt(120.0).into()));
styles.set(PageNode::HEIGHT, Smart::Auto);
styles
.set(PageNode::MARGINS, Sides::splat(Some(Smart::Custom(Abs::pt(10.0).into()))));
styles.set(PageNode::MARGIN, Sides::splat(Some(Smart::Custom(Abs::pt(10.0).into()))));
styles.set(TextNode::SIZE, TextSize(Abs::pt(10.0).into()));
// Hook up helpers into the global scope.

View File

@ -1,5 +1,5 @@
// Configuration with `page` and `font` functions.
#set page(width: 450pt, margins: 1cm)
#set page(width: 450pt, margin: 1cm)
// There are variables and they can take normal values like strings, ...
#let city = "Berlin"

View File

@ -1,4 +1,4 @@
#set page(width: 450pt, margins: 1cm)
#set page(width: 450pt, margin: 1cm)
*Technische Universität Berlin* #h(1fr) *WiSe 2019/2020* \
*Fakultät II, Institut for Mathematik* #h(1fr) Woche 3 \

View File

@ -25,7 +25,7 @@
---
// Test all three fit modes.
#set page(height: 50pt, margins: 0pt)
#set page(height: 50pt, margin: 0pt)
#grid(
columns: (1fr, 1fr, 1fr),
rows: 100%,

View File

@ -23,7 +23,7 @@
---
// Test square that is limited by region size.
#set page(width: 20pt, height: 10pt, margins: 0pt)
#set page(width: 20pt, height: 10pt, margin: 0pt)
#stack(dir: ltr, square(fill: forest), square(fill: conifer))
---
@ -35,7 +35,7 @@
---
// Test square that is overflowing due to its aspect ratio.
#set page(width: 40pt, height: 20pt, margins: 5pt)
#set page(width: 40pt, height: 20pt, margin: 5pt)
#square(width: 100%)
#square(width: 100%)[Hello]

View File

@ -31,7 +31,7 @@
)
---
#set page(height: 3cm, margins: 0pt)
#set page(height: 3cm, margin: 0pt)
#grid(
columns: (1fr,),
rows: (1fr, auto, 2fr),

View File

@ -23,7 +23,7 @@
---
// Test that all three kinds of rows use the correct bases.
#set page(height: 4cm, margins: 0cm)
#set page(height: 4cm, margin: 0cm)
#grid(
rows: (1cm, 1fr, 1fr, auto),
rect(height: 50%, width: 100%, fill: conifer),

View File

@ -3,7 +3,7 @@
---
// Set all margins at once.
[
#set page(height: 20pt, margins: 5pt)
#set page(height: 20pt, margin: 5pt)
#place(top + left)[TL]
#place(bottom + right)[BR]
]
@ -11,10 +11,10 @@
---
// Set individual margins.
#set page(height: 40pt)
[#set page(margins: (left: 0pt)); #align(left)[Left]]
[#set page(margins: (right: 0pt)); #align(right)[Right]]
[#set page(margins: (top: 0pt)); #align(top)[Top]]
[#set page(margins: (bottom: 0pt)); #align(bottom)[Bottom]]
[#set page(margin: (left: 0pt)); #align(left)[Left]]
[#set page(margin: (right: 0pt)); #align(right)[Right]]
[#set page(margin: (top: 0pt)); #align(top)[Top]]
[#set page(margin: (bottom: 0pt)); #align(bottom)[Bottom]]
// Ensure that specific margins override general margins.
[#set page(margins: (rest: 0pt, left: 20pt)); Overriden]
[#set page(margin: (rest: 0pt, left: 20pt)); Overriden]

View File

@ -1,6 +1,6 @@
#set page(
paper: "a8",
margins: (x: 15pt, y: 30pt),
margin: (x: 15pt, y: 30pt),
header: align(horizon, {
text(eastern)[*Typst*]
h(1fr)
@ -20,5 +20,5 @@ do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she
were! She speaks yet she says nothing: what of that? Her eye discourses; I will
answer it.
#set page(header: none, height: auto, margins: (top: 15pt, bottom: 25pt))
#set page(header: none, height: auto, margin: (top: 15pt, bottom: 25pt))
The END.

View File

@ -24,7 +24,7 @@
// Test page fill.
#set page(width: 80pt, height: 40pt, fill: eastern)
#text(15pt, "Roboto", fill: white, smallcaps[Typst])
#page(width: 40pt, fill: none, margins: (top: 10pt, rest: auto))[Hi]
#page(width: 40pt, fill: none, margin: (top: 10pt, rest: auto))[Hi]
---
// Just page followed by pagebreak.

View File

@ -16,12 +16,12 @@
(align(right, shaded(i, w)),)
}
#set page(width: 50pt, margins: 0pt)
#set page(width: 50pt, margin: 0pt)
#stack(dir: btt, ..items)
---
// Test spacing.
#set page(width: 50pt, margins: 0pt)
#set page(width: 50pt, margin: 0pt)
#let x = square(size: 10pt, fill: eastern)
#stack(
@ -33,7 +33,7 @@
---
// Test overflow.
#set page(width: 50pt, height: 30pt, margins: 0pt)
#set page(width: 50pt, height: 30pt, margin: 0pt)
#box(stack(
rect(width: 40pt, height: 20pt, fill: conifer),
rect(width: 30pt, height: 13pt, fill: forest),
@ -41,7 +41,7 @@
---
// Test aligning things in RTL stack with align function & fr units.
#set page(width: 50pt, margins: 5pt)
#set page(width: 50pt, margin: 5pt)
#set block(spacing: 5pt)
#set text(8pt)
#stack(dir: rtl, 1fr, [A], 1fr, [B], [C])

View File

@ -17,7 +17,7 @@
stroke: (left: 1.5pt + luma(180)),
)
#set page(margins: (top: 12pt))
#set page(margin: (top: 12pt))
#set par(justify: true)
This code tests `code`

View File

@ -2,7 +2,7 @@
---
// Test hanging punctuation.
#set page(width: 130pt, margins: 15pt)
#set page(width: 130pt, margin: 15pt)
#set par(justify: true, linebreaks: "simple")
#set text(size: 9pt)
#rect(fill: rgb(0, 0, 0, 0), width: 100%)[
@ -17,7 +17,7 @@
---
// Test that lone punctuation doesn't overhang into the margin.
#set page(margins: 0pt)
#set page(margin: 0pt)
#set par(align: end)
#set text(dir: rtl)
: