From 145723b1ef4fa23f1f6665b8907dfe79d0bf83cf Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 27 Feb 2024 11:05:16 +0100 Subject: New context system (#3497) --- docs/guides/guide-for-latex-users.md | 4 ++-- docs/guides/page-setup.md | 45 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) (limited to 'docs/guides') diff --git a/docs/guides/guide-for-latex-users.md b/docs/guides/guide-for-latex-users.md index 4b8c43b1..d991ef78 100644 --- a/docs/guides/guide-for-latex-users.md +++ b/docs/guides/guide-for-latex-users.md @@ -603,7 +603,7 @@ The example below This should be a good starting point! If you want to go further, why not create a reusable template? -## Bibliographies { #bibliographies } +## Bibliographies Typst includes a fully-featured bibliography system that is compatible with BibTeX files. You can continue to use your `.bib` literature libraries by loading them with the [`bibliography`]($bibliography) function. Another @@ -627,7 +627,7 @@ use in prose (cf. `\citet` and `\textcite`) are available with You can find more information on the documentation page of the [`bibliography`]($bibliography) function. -## Installation { #installation } +## Installation You have two ways to use Typst: In [our web app](https://typst.app/signup/) or by [installing the compiler](https://github.com/typst/typst/releases) on your computer. When you use the web app, we provide a batteries-included diff --git a/docs/guides/page-setup.md b/docs/guides/page-setup.md index 046bf9f4..a70f025f 100644 --- a/docs/guides/page-setup.md +++ b/docs/guides/page-setup.md @@ -174,13 +174,13 @@ conditionally remove the header on the first page: ```typ >>> #set page("a5", margin: (x: 2.5cm, y: 3cm)) -#set page(header: locate(loc => { - if counter(page).at(loc).first() > 1 [ +#set page(header: context { + if counter(page).get().first() > 1 [ _Lisa Strassner's Thesis_ #h(1fr) National Academy of Sciences ] -})) +}) #lorem(150) ``` @@ -206,12 +206,12 @@ such a label exists on the current page: ```typ >>> #set page("a5", margin: (x: 2.5cm, y: 3cm)) -#set page(header: locate(loc => { - let page-counter = counter(page) - let matches = query(, loc) - let current = page-counter.at(loc) +#set page(header: context { + let page-counter = + let matches = query() + let current = counter(page).get() let has-table = matches.any(m => - page-counter.at(m.location()) == current + counter(page).at(m.location()) == current ) if not has-table [ @@ -291,7 +291,7 @@ a custom footer with page numbers and more. ```example >>> #set page("iso-b6", margin: 1.75cm) -#set page(footer: [ +#set page(footer: context [ *American Society of Proceedings* #h(1fr) #counter(page).display( @@ -314,21 +314,20 @@ circle for each page. ```example >>> #set page("iso-b6", margin: 1.75cm) -#set page(footer: [ +#set page(footer: context [ *Fun Typography Club* #h(1fr) - #counter(page).display(num => { - let circles = num * ( - box(circle( - radius: 2pt, - fill: navy, - )), - ) - box( - inset: (bottom: 1pt), - circles.join(h(1pt)) - ) - }) + #let (num,) = counter(page).get() + #let circles = num * ( + box(circle( + radius: 2pt, + fill: navy, + )), + ) + #box( + inset: (bottom: 1pt), + circles.join(h(1pt)) + ) ]) This page has a custom footer. @@ -382,7 +381,7 @@ page counter, you can use the [`page`]($locate) method on the argument of the // This returns one even though the // page counter was incremented by 5. -#locate(loc => loc.page()) +#context here().page() ``` You can also obtain the page numbering pattern from the `{locate}` closure -- cgit v1.2.3