From 7ebaeb4902081aa05580bd778d0026ffa6e632a6 Mon Sep 17 00:00:00 2001 From: MaikRe <87246463+MaikRe@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:44:43 +0100 Subject: [PATCH] feat: add ability to select us-letter with correct margins (#79) --- README.md | 2 +- lib.typ | 22 ++++++++++++++++++---- metadata.toml.schema.json | 5 +++++ template/cv.typ | 2 +- template/letter.typ | 2 +- template/metadata.toml | 3 +++ template/modules_en/certificates.typ | 2 +- template/modules_en/education.typ | 2 +- template/modules_en/professional.typ | 2 +- template/modules_en/projects.typ | 2 +- template/modules_en/publications.typ | 2 +- template/modules_en/skills.typ | 2 +- template/modules_fr/certificates.typ | 2 +- template/modules_fr/education.typ | 2 +- template/modules_fr/professional.typ | 2 +- template/modules_fr/projects.typ | 2 +- template/modules_fr/publications.typ | 2 +- template/modules_fr/skills.typ | 2 +- template/modules_zh/certificates.typ | 2 +- template/modules_zh/education.typ | 2 +- template/modules_zh/professional.typ | 2 +- template/modules_zh/projects.typ | 2 +- template/modules_zh/publications.typ | 2 +- template/modules_zh/skills.typ | 2 +- typst.toml | 2 +- 25 files changed, 48 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 11f19ad..30de066 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ It is recommended to: For the time being, upgrade can be achieved by manually "find and replace" the import statements in batch in your favorite IDE. For example: ```typst -#import "@preview/brilliant-cv:2.0.0" -> #import "@preview/brilliant-cv:2.0.3" +#import "@preview/brilliant-cv:2.0.0" -> #import "@preview/brilliant-cv:2.0.4" ``` **Make sure you read the release notes to notice any breaking changes. We estimate that there would still be some as Typst has not reached to a stable release neither.** diff --git a/lib.typ b/lib.typ index 0773aa8..b4efc26 100644 --- a/lib.typ +++ b/lib.typ @@ -29,9 +29,16 @@ // Page layout set text(font: fontList, weight: "regular", size: 9pt) set align(left) + let paper_size = metadata.layout.at("paper_size", default: "a4") set page( - paper: "a4", - margin: (left: 1.4cm, right: 1.4cm, top: 1cm, bottom: 1cm), + paper: {paper_size}, + margin: { + if paper_size == "us-letter" { + (left: 2cm, right: 1.4cm, top: 1.2cm, bottom: 1.2cm) + } else { + (left: 1.4cm, right: 1.4cm, top: 1cm, bottom: 1cm) + } + }, footer: _cvFooter(metadata), ) @@ -61,9 +68,16 @@ // Page layout set text(font: fontList, weight: "regular", size: 9pt) set align(left) + let paper_size = metadata.layout.at("paper_size", default: "a4") set page( - paper: "a4", - margin: (left: 1.4cm, right: 1.4cm, top: 1cm, bottom: 1cm), + paper: {paper_size}, + margin: { + if paper_size == "us-letter" { + (left: 2cm, right: 2cm, top: 1.2cm, bottom: 1.2cm) + } else { + (left: 1.4cm, right: 1.4cm, top: 1cm, bottom: 1cm) + } + }, footer: _letterFooter(metadata), ) set text(size: 12pt) diff --git a/metadata.toml.schema.json b/metadata.toml.schema.json index 748caab..3de2df0 100644 --- a/metadata.toml.schema.json +++ b/metadata.toml.schema.json @@ -31,6 +31,11 @@ "description": "Spacing before entry descriptions", "pattern": "^[0-9]+pt$" }, + "paper_size" : { + "type": "string", + "description": "Sets paper size and standard marigins, Optional values: us-letter. Default is a4.", + "pattern": "^(a4|us-letter|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}))$" + }, "fonts": { "type": "object", "properties": { diff --git a/template/cv.typ b/template/cv.typ index b71707b..844765f 100644 --- a/template/cv.typ +++ b/template/cv.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cv +#import "@preview/brilliant-cv:2.0.4": cv #let metadata = toml("./metadata.toml") #let importModules(modules, lang: metadata.language) = { for module in modules { diff --git a/template/letter.typ b/template/letter.typ index 8328364..7c602c5 100644 --- a/template/letter.typ +++ b/template/letter.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": letter +#import "@preview/brilliant-cv:2.0.4": letter #let metadata = toml("./metadata.toml") diff --git a/template/metadata.toml b/template/metadata.toml index 0b013c6..90664a0 100644 --- a/template/metadata.toml +++ b/template/metadata.toml @@ -14,6 +14,9 @@ language = "en" before_entry_skip = "1pt" before_entry_description_skip = "1pt" + # Optional: sets paper size and margins. Possible values: a4 (default), us-letter + paper_size = "a4" + [layout.fonts] regular_fonts = ["Source Sans Pro", "Source Sans 3"] header_font = "Roboto" diff --git a/template/modules_en/certificates.typ b/template/modules_en/certificates.typ index 98cc2f9..066d257 100644 --- a/template/modules_en/certificates.typ +++ b/template/modules_en/certificates.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvHonor +#import "@preview/brilliant-cv:2.0.4": cvSection, cvHonor #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvHonor = cvHonor.with(metadata: metadata) diff --git a/template/modules_en/education.typ b/template/modules_en/education.typ index a0fe959..a72e664 100644 --- a/template/modules_en/education.typ +++ b/template/modules_en/education.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_en/professional.typ b/template/modules_en/professional.typ index b40aa17..780726d 100644 --- a/template/modules_en/professional.typ +++ b/template/modules_en/professional.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_en/projects.typ b/template/modules_en/projects.typ index c4a635c..4478495 100644 --- a/template/modules_en/projects.typ +++ b/template/modules_en/projects.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_en/publications.typ b/template/modules_en/publications.typ index cb5030b..e78bae1 100644 --- a/template/modules_en/publications.typ +++ b/template/modules_en/publications.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvPublication +#import "@preview/brilliant-cv:2.0.4": cvSection, cvPublication #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/template/modules_en/skills.typ b/template/modules_en/skills.typ index 086373e..59dd33c 100644 --- a/template/modules_en/skills.typ +++ b/template/modules_en/skills.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvSkill, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvSkill, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/template/modules_fr/certificates.typ b/template/modules_fr/certificates.typ index c334b8d..a8ef453 100644 --- a/template/modules_fr/certificates.typ +++ b/template/modules_fr/certificates.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvHonor +#import "@preview/brilliant-cv:2.0.4": cvSection, cvHonor #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvHonor = cvHonor.with(metadata: metadata) diff --git a/template/modules_fr/education.typ b/template/modules_fr/education.typ index 6a8678c..c2739de 100644 --- a/template/modules_fr/education.typ +++ b/template/modules_fr/education.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_fr/professional.typ b/template/modules_fr/professional.typ index bc95de1..59dc6d6 100644 --- a/template/modules_fr/professional.typ +++ b/template/modules_fr/professional.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_fr/projects.typ b/template/modules_fr/projects.typ index 59208c5..5c8ddcb 100644 --- a/template/modules_fr/projects.typ +++ b/template/modules_fr/projects.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_fr/publications.typ b/template/modules_fr/publications.typ index cb5030b..e78bae1 100644 --- a/template/modules_fr/publications.typ +++ b/template/modules_fr/publications.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvPublication +#import "@preview/brilliant-cv:2.0.4": cvSection, cvPublication #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/template/modules_fr/skills.typ b/template/modules_fr/skills.typ index be0a75c..ce35593 100644 --- a/template/modules_fr/skills.typ +++ b/template/modules_fr/skills.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvSkill, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvSkill, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/template/modules_zh/certificates.typ b/template/modules_zh/certificates.typ index e5aeb1e..74ed8d0 100644 --- a/template/modules_zh/certificates.typ +++ b/template/modules_zh/certificates.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvHonor +#import "@preview/brilliant-cv:2.0.4": cvSection, cvHonor #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvHonor = cvHonor.with(metadata: metadata) diff --git a/template/modules_zh/education.typ b/template/modules_zh/education.typ index e9d9037..7127650 100644 --- a/template/modules_zh/education.typ +++ b/template/modules_zh/education.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_zh/professional.typ b/template/modules_zh/professional.typ index d9c7378..dca1553 100644 --- a/template/modules_zh/professional.typ +++ b/template/modules_zh/professional.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_zh/projects.typ b/template/modules_zh/projects.typ index 383fe3d..37d0719 100644 --- a/template/modules_zh/projects.typ +++ b/template/modules_zh/projects.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvEntry +#import "@preview/brilliant-cv:2.0.4": cvSection, cvEntry #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) #let cvEntry = cvEntry.with(metadata: metadata) diff --git a/template/modules_zh/publications.typ b/template/modules_zh/publications.typ index 68aa8a1..e1a5e72 100644 --- a/template/modules_zh/publications.typ +++ b/template/modules_zh/publications.typ @@ -1,5 +1,5 @@ // Imports -#import "@preview/brilliant-cv:2.0.3": cvSection, cvPublication +#import "@preview/brilliant-cv:2.0.4": cvSection, cvPublication #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/template/modules_zh/skills.typ b/template/modules_zh/skills.typ index dd7c843..1e96163 100644 --- a/template/modules_zh/skills.typ +++ b/template/modules_zh/skills.typ @@ -1,5 +1,5 @@ // Import -#import "@preview/brilliant-cv:2.0.3": cvSection, cvSkill, hBar +#import "@preview/brilliant-cv:2.0.4": cvSection, cvSkill, hBar #let metadata = toml("../metadata.toml") #let cvSection = cvSection.with(metadata: metadata) diff --git a/typst.toml b/typst.toml index d21fde3..229ce43 100644 --- a/typst.toml +++ b/typst.toml @@ -1,6 +1,6 @@ [package] name = "brilliant-cv" -version = "2.0.3" +version = "2.0.4" entrypoint = "lib.typ" authors = ["Yunan Wang "] license = "Apache-2.0"