aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristopher T. Kenny <[email protected]>2025-09-02 03:25:39 -0400
committerGitHub <[email protected]>2025-09-02 09:25:39 +0200
commit6070ad29cd75e09bc8f4c3e2ed32062055993556 (patch)
tree7d94eeae92fe233474855a0a4749fd5a1fb97223 /test
parent3551e21206e8152f295c154c9446e319eb1ed632 (diff)
Add features to typst base template (take 2).
New template variables supported: `thanks`, `abstract-title`, `linestretch`, `mathfont`, `codefont`, `linkcolor`, `filecolor`, `citecolor`. Closes #9956, #11076. (This is a new version of f000fa168bd122fee6e67f5a67bdd6d42d173261 which was reverted.)
Diffstat (limited to 'test')
-rw-r--r--test/writer.typst103
1 files changed, 66 insertions, 37 deletions
diff --git a/test/writer.typst b/test/writer.typst
index 5ff3051d4..8b30a3bf5 100644
--- a/test/writer.typst
+++ b/test/writer.typst
@@ -39,7 +39,9 @@
authors: (),
keywords: (),
date: none,
+ abstract-title: none,
abstract: none,
+ thanks: none,
cols: 1,
margin: (x: 1.25in, y: 1.25in),
paper: "us-letter",
@@ -47,66 +49,92 @@
region: "US",
font: (),
fontsize: 11pt,
+ mathfont: none,
+ codefont: none,
+ linestretch: 1,
sectionnumbering: none,
+ linkcolor: none,
+ citecolor: none,
+ filecolor: none,
pagenumbering: "1",
doc,
) = {
set document(
title: title,
- author: authors.map(author => content-to-string(author.name)),
keywords: keywords,
)
+ set document(
+ author: authors.map(author => content-to-string(author.name)).join(", ", last: " & "),
+ ) if authors != none and authors != ()
set page(
paper: paper,
margin: margin,
numbering: pagenumbering,
- columns: cols,
- )
- set par(justify: true)
+ )
+
+ set par(
+ justify: true,
+ leading: linestretch * 0.65em
+ )
set text(lang: lang,
region: region,
font: font,
size: fontsize)
+
+ show math.equation: set text(font: mathfont) if mathfont != none
+ show raw: set text(font: codefont) if codefont != none
+
set heading(numbering: sectionnumbering)
- place(top, float: true, scope: "parent", clearance: 4mm)[
- #if title != none {
- align(center)[#block(inset: 2em)[
- #text(weight: "bold", size: 1.5em)[#title]
- #(if subtitle != none {
- parbreak()
- text(weight: "bold", size: 1.25em)[#subtitle]
- })
- ]]
+ show link: set text(fill: rgb(content-to-string(linkcolor))) if linkcolor != none
+ show ref: set text(fill: rgb(content-to-string(citecolor))) if citecolor != none
+ show link: this => {
+ if filecolor != none and type(this.dest) == label {
+ text(this, fill: rgb(content-to-string(filecolor)))
+ }
}
- #if authors != none and authors != [] {
- 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
- ]
+ block(below: 4mm)[
+ #if title != none {
+ align(center)[#block(inset: 2em)[
+ #text(weight: "bold", size: 1.5em)[#title #if thanks != none {
+ footnote(thanks, numbering: "*")
+ counter(footnote).update(n => n - 1)
+ }]
+ #(
+ if subtitle != none {
+ parbreak()
+ text(weight: "bold", size: 1.25em)[#subtitle]
+ }
+ )
+ ]]
+ }
+
+ #if authors != none and authors != [] {
+ 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 date != none {
+ align(center)[#block(inset: 1em)[
+ #date
+ ]]
+ }
- #if abstract != none {
- block(inset: 2em)[
- #text(weight: "semibold")[Abstract] #h(1em) #abstract
- ]
- }
+ #if abstract != none {
+ block(inset: 2em)[
+ #text(weight: "semibold")[#abstract-title] #h(1em) #abstract
+ ]
+ }
]
doc
@@ -122,6 +150,7 @@
email: "" ),
),
date: [July 17, 2006],
+ abstract-title: [Abstract],
pagenumbering: "1",
cols: 1,
doc,