Skip to content

Commit

Permalink
updated typst partials for quarto create extension
Browse files Browse the repository at this point in the history
addresses #11616
  • Loading branch information
gordonwoodhull committed Jan 3, 2025
1 parent f951dde commit 03face3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Typst custom formats typically consist of a 'typst-template.typ' (which is
// the source code for a typst template) and a 'typst-show.typ' which calls the
// template's function (forwarding Pandoc metadata values as required)
Expand All @@ -11,11 +12,13 @@
// documentation on creating typst templates here and some examples here:
// - https://typst.app/docs/tutorial/making-a-template/
// - https://github.com/typst/templates

#show: doc => article(
$if(title)$
title: [$title$],
$endif$
$if(subtitle)$
subtitle: [$subtitle$],
$endif$
$if(by-author)$
authors: (
$for(by-author)$
Expand Down Expand Up @@ -48,9 +51,33 @@ $if(papersize)$
$endif$
$if(mainfont)$
font: ("$mainfont$",),
$elseif(brand.typography.base.family)$
font: ("$brand.typography.base.family$",),
$endif$
$if(fontsize)$
fontsize: $fontsize$,
$elseif(brand.typography.base.size)$
fontsize: $brand.typography.base.size$,
$endif$
$if(title)$
$if(brand.typography.headings.family)$
heading-family: ("$brand.typography.headings.family$",),
$endif$
$if(brand.typography.headings.weight)$
heading-weight: $brand.typography.headings.weight$,
$endif$
$if(brand.typography.headings.style)$
heading-style: "$brand.typography.headings.style$",
$endif$
$if(brand.typography.headings.decoration)$
heading-decoration: "$brand.typography.headings.decoration$",
$endif$
$if(brand.typography.headings.color)$
heading-color: $brand.typography.headings.color$,
$endif$
$if(brand.typography.headings.line-height)$
heading-line-height: $brand.typography.headings.line-height$,
$endif$
$endif$
$if(section-numbering)$
sectionnumbering: "$section-numbering$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#let article(
title: none,
subtitle: none,
authors: none,
date: none,
abstract: none,
Expand All @@ -22,8 +23,15 @@
paper: "us-letter",
lang: "en",
region: "US",
font: (),
font: "linux libertine",
fontsize: 11pt,
title-size: 1.5em,
subtitle-size: 1.25em,
heading-family: "linux libertine",
heading-weight: "bold",
heading-style: "normal",
heading-color: black,
heading-line-height: 0.65em,
sectionnumbering: none,
toc: false,
toc_title: none,
Expand All @@ -42,10 +50,25 @@
font: font,
size: fontsize)
set heading(numbering: sectionnumbering)

if title != none {
align(center)[#block(inset: 2em)[
#text(weight: "bold", size: 1.5em)[#title]
#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]
}
}
]]
}

Expand Down

0 comments on commit 03face3

Please sign in to comment.