Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/format/typst/format-typst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function typstFormat(): Format {
"definitions.typ",
"typst-template.typ",
"typst-show.typ",
"typst-title.typ",
"notes.typ",
"biblio.typ",
].map((partial) => join(templateDir, partial)),
Expand Down
2 changes: 2 additions & 0 deletions src/resources/formats/typst/pandoc/quarto/template.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$definitions.typ()$

$typst-title.typ()$

$typst-template.typ()$

$for(header-includes)$
Expand Down
62 changes: 14 additions & 48 deletions src/resources/formats/typst/pandoc/quarto/typst-template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -39,55 +39,21 @@
font: font,
size: fontsize)
set heading(numbering: sectionnumbering)
if title != none {
align(center)[#block(inset: 2em)[
#set par(leading: heading-line-height)
#if (heading-family != none or heading-weight != "bold" or heading-style != "normal"
or heading-color != black or heading-decoration == "underline"
or heading-background-color != none) {
set text(font: heading-family, weight: heading-weight, style: heading-style, fill: heading-color)
text(size: title-size)[#title]
if subtitle != none {
parbreak()
text(size: subtitle-size)[#subtitle]
}
} else {
text(weight: "bold", size: title-size)[#title]
if subtitle != none {
parbreak()
text(weight: "bold", size: subtitle-size)[#subtitle]
}
}
]]
}

if authors != none {
let count = authors.len()
let ncols = calc.min(count, 3)
grid(
columns: (1fr,) * ncols,
row-gutter: 1.5em,
..authors.map(author =>
align(center)[
#author.name \
#author.affiliation \
#author.email
]
)
)
}

if date != none {
align(center)[#block(inset: 1em)[
#date
]]
}

if abstract != none {
block(inset: 2em)[
#text(weight: "semibold")[#abstract-title] #h(1em) #abstract
]
}
title_block(
title: title,
subtitle: subtitle,
authors: authors,
date: date,
abstract: abstract,
title-size: title-size,
subtitle-size: subtitle-size,
heading-family: heading-family,
heading-weight: heading-weight,
heading-style: heading-style,
heading-color: heading-color,
heading-line-height: heading-line-height
)

if toc {
let title = if toc_title == none {
Expand Down
65 changes: 65 additions & 0 deletions src/resources/formats/typst/pandoc/quarto/typst-title.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#let title_block(
title: none,
subtitle: none,
authors: none,
date: none,
abstract: none,
title-size: none,
subtitle-size: none,
heading-family: none,
heading-weight: none,
heading-style: none,
heading-color: none,
heading-line-height: none
) = {
if title != none {
align(center)[#block(inset: 2em)[
#set par(leading: heading-line-height)
#if (heading-family != none or heading-weight != "bold" or heading-style != "normal"
or heading-color != black or heading-decoration == "underline"
or heading-background-color != none) {
set text(font: heading-family, weight: heading-weight, style: heading-style, fill: heading-color)
text(size: title-size)[#title]
if subtitle != none {
parbreak()
text(size: subtitle-size)[#subtitle]
}
} else {
text(weight: "bold", size: title-size)[#title]
if subtitle != none {
parbreak()
text(weight: "bold", size: subtitle-size)[#subtitle]
}
}
]]
}

if authors != none {
let count = authors.len()
let ncols = calc.min(count, 3)
grid(
columns: (1fr,) * ncols,
row-gutter: 1.5em,
..authors.map(author =>
align(center)[
#author.name \
#author.affiliation \
#author.email
]
)
)
}

if date != none {
align(center)[#block(inset: 1em)[
#date
]]
}

if abstract != none {
block(inset: 2em)[
#text(weight: "semibold")[#abstract-title] #h(1em) #abstract
]
}
}

Loading