summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-27 12:26:24 +0200
committerLaurenz <laurmaedje@gmail.com>2023-03-27 12:26:24 +0200
commitdd33a211880752aad01ba8c7c0b8f51c5d003003 (patch)
tree9db594786f465d2ec5c6bfc43911f1d76ddef292
parenta5c88c19b300c64fafd6a19e3f5f2fe6422a7b67 (diff)
Documentation for location methods
Fixes #308.
-rw-r--r--library/src/meta/context.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/library/src/meta/context.rs b/library/src/meta/context.rs
index 376456b8..e36e6b28 100644
--- a/library/src/meta/context.rs
+++ b/library/src/meta/context.rs
@@ -6,6 +6,35 @@ use crate::prelude::*;
/// [counters]($func/counter), [state]($func/state), and [links]($func/link).
/// See their documentation for more details.
///
+/// ```example
+/// #locate(loc => [
+/// My locatation: \
+/// #loc.position()!
+/// ])
+/// ```
+///
+/// ## Methods
+/// ### page()
+/// Return the page number for this location.
+///
+/// Note that this does not return the value of the [page counter]($func/counter)
+/// at this location, but the true page number (starting from one).
+///
+/// If you want to know the value of the page counter, use
+/// `{counter(page).at(loc)}` instead.
+///
+/// - returns: integer
+///
+/// ### position()
+/// Return a dictionary with the page number and the x, y position for this
+/// location. The page number starts at one and the coordinates are measured
+/// from the top-left of the page.
+///
+/// If you only need the page number, use `page()` instead as it allows Typst
+/// to skip unnecessary work.
+///
+/// - returns: dictionary
+///
/// Display: Locate
/// Category: meta
/// Returns: content