Skip to content

Commit

Permalink
feat: add ability to select us-letter with correct margins (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikRe authored Jan 21, 2025
1 parent 95e6b16 commit 7ebaeb4
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
22 changes: 18 additions & 4 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions metadata.toml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion template/cv.typ
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion template/letter.typ
Original file line number Diff line number Diff line change
@@ -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")


Expand Down
3 changes: 3 additions & 0 deletions template/metadata.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/certificates.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/education.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/professional.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/projects.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/publications.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion template/modules_en/skills.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/certificates.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/education.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/professional.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/projects.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/publications.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion template/modules_fr/skills.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/certificates.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/education.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/professional.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/projects.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/publications.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion template/modules_zh/skills.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "brilliant-cv"
version = "2.0.3"
version = "2.0.4"
entrypoint = "lib.typ"
authors = ["Yunan Wang <https://github.com/mintyfrankie>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 7ebaeb4

Please sign in to comment.