Skip to content

Commit 07c2384

Browse files
reknihlaurmaedje
andcommitted
Use set page(columns: n) in tutorial (#5228)
Co-authored-by: Laurenz <[email protected]>
1 parent 6d98a64 commit 07c2384

File tree

5 files changed

+284
-213
lines changed

5 files changed

+284
-213
lines changed

docs/guides/guide-for-latex-users.md

Lines changed: 80 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -325,62 +325,65 @@ function. The following example illustrates how it works:
325325
>>> abstract: [],
326326
>>> doc,
327327
>>> ) = {
328-
>>> set text(font: "Libertinus Serif", 11pt)
329-
>>> set par(justify: true)
330-
>>> set page(
331-
>>> "us-letter",
332-
>>> margin: auto,
333-
>>> header: align(
334-
>>> right + horizon,
335-
>>> title
336-
>>> ),
337-
>>> numbering: "1",
338-
>>> )
328+
>>> set text(font: "Libertinus Serif", 11pt)
329+
>>> set par(justify: true)
330+
>>> set page(
331+
>>> "us-letter",
332+
>>> margin: auto,
333+
>>> header: align(
334+
>>> right + horizon,
335+
>>> title
336+
>>> ),
337+
>>> numbering: "1",
338+
>>> columns: 2
339+
>>> )
339340
>>>
340-
>>> show heading.where(
341-
>>> level: 1
342-
>>> ): it => block(
343-
>>> align(center,
344-
>>> text(
345-
>>> 13pt,
346-
>>> weight: "regular",
347-
>>> smallcaps(it.body),
348-
>>> )
349-
>>> ),
350-
>>> )
351-
>>> show heading.where(
352-
>>> level: 2
353-
>>> ): it => box(
354-
>>> text(
355-
>>> 11pt,
356-
>>> weight: "regular",
357-
>>> style: "italic",
358-
>>> it.body + [.],
359-
>>> )
360-
>>> )
341+
>>> show heading.where(
342+
>>> level: 1
343+
>>> ): it => block(
344+
>>> align(center,
345+
>>> text(
346+
>>> 13pt,
347+
>>> weight: "regular",
348+
>>> smallcaps(it.body),
349+
>>> )
350+
>>> ),
351+
>>> )
352+
>>> show heading.where(
353+
>>> level: 2
354+
>>> ): it => box(
355+
>>> text(
356+
>>> 11pt,
357+
>>> weight: "regular",
358+
>>> style: "italic",
359+
>>> it.body + [.],
360+
>>> )
361+
>>> )
361362
>>>
362-
>>> set align(center)
363-
>>> text(17pt, title)
363+
>>> place(top, float: true, scope: "parent", {
364+
>>> set align(center)
365+
>>> text(17pt, title)
364366
>>>
365-
>>> let count = calc.min(authors.len(), 3)
366-
>>> grid(
367-
>>> columns: (1fr,) * count,
368-
>>> row-gutter: 24pt,
369-
>>> ..authors.map(author => [
370-
>>> #author.name \
371-
>>> #author.affiliation \
372-
>>> #link("mailto:" + author.email)
373-
>>> ]),
374-
>>> )
367+
>>> let count = calc.min(authors.len(), 3)
368+
>>> grid(
369+
>>> columns: (1fr,) * count,
370+
>>> row-gutter: 24pt,
371+
>>> ..authors.map(author => [
372+
>>> #author.name \
373+
>>> #author.affiliation \
374+
>>> #link("mailto:" + author.email)
375+
>>> ]),
376+
>>> )
375377
>>>
376-
>>> par(justify: false)[
377-
>>> *Abstract* \
378-
>>> #abstract
379-
>>> ]
378+
>>> par(justify: false)[
379+
>>> *Abstract* \
380+
>>> #abstract
381+
>>> ]
382+
>>> })
380383
>>>
381-
>>> set align(left)
382-
>>> columns(2, doc)
383-
>>>}
384+
>>> set align(left)
385+
>>> doc
386+
>>> }
384387
<<< #import "conf.typ": conf
385388
#show: conf.with(
386389
title: [
@@ -404,14 +407,34 @@ function. The following example illustrates how it works:
404407
Let's get started writing this
405408
article by putting insightful
406409
paragraphs right here!
410+
>>> #lorem(500)
407411
```
408412

409-
The [`{import}`]($scripting/#modules) statement makes
410-
[functions]($function) (and other definitions) from another file available.
411-
In this example, it imports the `conf` function from the `conf.typ` file. This
412-
function formats a document as a conference article. We use a show rule to apply
413-
it to the document and also configure some metadata of the article. After
414-
applying the show rule, we can start writing our article right away!
413+
The [`{import}`]($scripting/#modules) statement makes [functions]($function)
414+
(and other definitions) from another file available. In this example, it imports
415+
the `conf` function from the `conf.typ` file. This function formats a document
416+
as a conference article. We use a show rule to apply it to the document and also
417+
configure some metadata of the article. After applying the show rule, we can
418+
start writing our article right away!
419+
420+
You can also use templates from Typst Universe (which is Typst's equivalent of
421+
CTAN) using an import statement like this: `[#import
422+
"@preview/elsearticle:0.2.1": elsearticle]`. Check the documentation of an
423+
individual template to learn the name of its template function. Templates and
424+
packages from Typst Universe are automatically downloaded when you first use
425+
them.
426+
427+
In the web app, you can choose to create a project from a template on Typst
428+
Universe or even create your own using the template wizard. Locally, you can use
429+
the `typst init` CLI to create a new project from a template. Check out [the
430+
list of templates]($universe/search/?kind=templates) published on Typst
431+
Universe. You can also take a look at the [`awesome-typst`
432+
repository](https://github.com/qjcg/awesome-typst) to find community templates
433+
that aren't available through Universe.
434+
435+
You can also [create your own, custom templates.]($tutorial/making-a-template)
436+
They are shorter and more readable than the corresponding LaTeX `.sty` files by
437+
orders of magnitude, so give it a try!
415438

416439
<div class="info-box">
417440

@@ -428,18 +451,6 @@ function and pre-configures some if its arguments before passing it on to the
428451
show rule.
429452
</div>
430453

431-
In the web app, you can choose from predefined templates or even
432-
create your own using the template wizard. Locally, you can use the
433-
`typst init` CLI to create a new project from a template. Check out
434-
[the list of templates]($universe/search/?kind=templates) published on Typst
435-
Universe, our official package ecosystem. You can also take a look at the
436-
[`awesome-typst` repository](https://github.com/qjcg/awesome-typst) to find
437-
community templates that aren't yet available as packages.
438-
439-
You can also [create your own, custom templates.]($tutorial/making-a-template)
440-
They are shorter and more readable than the corresponding LaTeX `.sty` files by
441-
orders of magnitude, so give it a try!
442-
443454
## How do I load packages? { #packages }
444455
Typst is "batteries included," so the equivalent of many popular LaTeX packages
445456
is built right-in. Below, we compiled a table with frequently loaded packages

docs/guides/page-setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ frequently used for [figures]($figure.placement).
432432

433433
### Use columns anywhere in your document { #columns-anywhere }
434434
To create columns within a nested layout, e.g. within a rectangle, you can use
435-
the [`columns` function]($columns) directly. However, it should really only be
435+
the [`columns` function]($columns) directly. However, it really should only be
436436
used within nested layouts. At the page-level, the page set rule is preferrable
437437
because it has better interactions with things like page-level floats,
438438
footnotes, and line numbers.

docs/src/html.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html {
427427
document.pages.truncate(1);
428428
}
429429

430-
let hash = typst::utils::hash128(text);
430+
let hash = typst::utils::hash128(&(lang, text));
431431
resolver.example(hash, highlighted, &document)
432432
}
433433

0 commit comments

Comments
 (0)