Skip to content

Commit d446cde

Browse files
Miscellaneous minor docs improvements (typst#6651)
Co-authored-by: Laurenz <[email protected]>
1 parent a4d4dfb commit d446cde

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

crates/typst-library/src/introspection/counter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ impl Counter {
412412
/// - If it is a string, creates a custom counter that is only affected
413413
/// by manual updates,
414414
/// - If it is the [`page`] function, counts through pages,
415-
/// - If it is a [selector], counts through elements that matches with the
415+
/// - If it is a [selector], counts through elements that match the
416416
/// selector. For example,
417417
/// - provide an element function: counts elements of that type,
418+
/// - provide a [`where`]($function.where) selector:
419+
/// counts a type of element with specific fields,
418420
/// - provide a [`{<label>}`]($label): counts elements with that label.
419421
key: CounterKey,
420422
) -> Counter {

crates/typst-library/src/layout/page.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,15 @@ impl LocalName for PageElem {
397397
/// == Compound Theory
398398
/// In 1984, the first ...
399399
/// ```
400+
///
401+
/// Even without manual page breaks, content will be automatically paginated
402+
/// based on the configured page size. You can set [the page height]($page.height)
403+
/// to `{auto}` to let the page grow dynamically until a manual page break
404+
/// occurs.
405+
///
406+
/// Pagination tries to avoid single lines of text at the top or bottom of a
407+
/// page (these are called _widows_ and _orphans_). You can adjust the
408+
/// [`text.costs`]($text.costs) parameter to disable this behavior.
400409
#[elem(title = "Page Break")]
401410
pub struct PagebreakElem {
402411
/// If `{true}`, the page break is skipped if the current page is already

crates/typst-library/src/model/figure.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,39 @@ pub struct FigureElem {
189189
/// supplement: [Atom],
190190
/// )
191191
/// ```
192+
///
193+
/// If you want to modify a counter to skip a number or reset the counter,
194+
/// you can access the [counter] of each kind of figure with a
195+
/// [`where`]($function.where) selector:
196+
///
197+
/// - For [tables]($table): `{counter(figure.where(kind: table))}`
198+
/// - For [images]($image): `{counter(figure.where(kind: image))}`
199+
/// - For a custom kind: `{counter(figure.where(kind: kind))}`
200+
///
201+
/// ```example
202+
/// #figure(
203+
/// table(columns: 2, $n$, $1$),
204+
/// caption: [The first table.],
205+
/// )
206+
///
207+
/// #counter(
208+
/// figure.where(kind: table)
209+
/// ).update(41)
210+
///
211+
/// #figure(
212+
/// table(columns: 2, $n$, $42$),
213+
/// caption: [The 42nd table],
214+
/// )
215+
///
216+
/// #figure(
217+
/// rect[Image],
218+
/// caption: [Does not affect images],
219+
/// )
220+
/// ```
221+
///
222+
/// To conveniently use the correct counter in a show rule, you can access
223+
/// the `counter` field. There is an example of this in the documentation
224+
/// [of the `figure.caption` element's `body` field]($figure.caption.body).
192225
pub kind: Smart<FigureKind>,
193226

194227
/// The figure's supplement.
@@ -228,8 +261,8 @@ pub struct FigureElem {
228261
/// Convenience field to get access to the counter for this figure.
229262
///
230263
/// The counter only depends on the `kind`:
231-
/// - For (tables)[@table]: `{counter(figure.where(kind: table))}`
232-
/// - For (images)[@image]: `{counter(figure.where(kind: image))}`
264+
/// - For [tables]($table): `{counter(figure.where(kind: table))}`
265+
/// - For [images]($image): `{counter(figure.where(kind: image))}`
233266
/// - For a custom kind: `{counter(figure.where(kind: kind))}`
234267
///
235268
/// These are the counters you'll need to modify if you want to skip a

crates/typst-library/src/text/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,19 @@ pub struct TextElem {
411411
/// = Einleitung
412412
/// In diesem Dokument, ...
413413
/// ```
414+
///
415+
/// The language code is case-insensitive, and will be lowercased when
416+
/// accessed through [context]($context).
414417
#[default(Lang::ENGLISH)]
415418
#[ghost]
416419
pub lang: Lang,
417420

418421
/// An [ISO 3166-1 alpha-2 region code.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
419422
///
420423
/// This lets the text processing pipeline make more informed choices.
424+
///
425+
/// The region code is case-insensitive, and will be uppercased when
426+
/// accessed through [context]($context).
421427
#[ghost]
422428
pub region: Option<Region>,
423429

docs/reference/library/symbols.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ with a normal keyboard. Alternatively, you can also always directly enter
33
Unicode symbols into your text and formulas. In addition to the symbols listed
44
below, math mode defines `dif` and `Dif`. These are not normal symbol values
55
because they also affect spacing and font style.
6+
7+
You can define custom symbols with the constructor function of the
8+
[symbol]($symbol) type.

0 commit comments

Comments
 (0)