{"route":"/en-US-v0.14.1/reference/introspection/location/","title":"Location","description":"Documentation for the Location type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"locatable","name":"Locatable","children":[]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-page","name":"Page","children":[]},{"id":"definitions-position","name":"Position","children":[]},{"id":"definitions-page-numbering","name":"Page Numbering","children":[]}]}],"body":{"kind":"type","content":{"name":"location","title":"Location","keywords":[],"oneliner":"Identifies an element in the document.","details":"<p>Identifies an element in the document.</p>\n<p>A location uniquely identifies an element in the document and lets you\naccess its absolute position on the pages. You can retrieve the current\nlocation with the <a href=\"/en-US-v0.14.1/reference/introspection/here/\" title=\"`here`\"><code>here</code></a> function and the location of a queried or shown\nelement with the <a href=\"/en-US-v0.14.1/reference/foundations/content/#definitions-location\"><code>location()</code></a> method on content.</p>\n<h2 id=\"locatable\">Locatable elements</h2>\n<p>Elements that are automatically assigned a location are called <em>locatable.</em>\nFor efficiency reasons, not all elements are locatable.</p>\n<ul>\n<li>\n<p>In the <a href=\"/en-US-v0.14.1/reference/model/\">Model category</a>, most elements are locatable.\nThis is because semantic elements like <a href=\"/en-US-v0.14.1/reference/model/heading/\">headings</a> and\n<a href=\"/en-US-v0.14.1/reference/model/figure/\">figures</a> are often used with introspection.</p>\n</li>\n<li>\n<p>In the <a href=\"/en-US-v0.14.1/reference/text/\">Text category</a>, the <a href=\"/en-US-v0.14.1/reference/text/raw/\" title=\"`raw`\"><code>raw</code></a> element, and the\ndecoration elements <a href=\"/en-US-v0.14.1/reference/text/underline/\" title=\"`underline`\"><code>underline</code></a>, <a href=\"/en-US-v0.14.1/reference/text/overline/\" title=\"`overline`\"><code>overline</code></a>, <a href=\"/en-US-v0.14.1/reference/text/strike/\" title=\"`strike`\"><code>strike</code></a>, and\n<a href=\"/en-US-v0.14.1/reference/text/highlight/\" title=\"`highlight`\"><code>highlight</code></a> are locatable as these are also quite semantic in nature.</p>\n</li>\n<li>\n<p>In the <a href=\"/en-US-v0.14.1/reference/introspection/\">Introspection category</a>, the <a href=\"/en-US-v0.14.1/reference/introspection/metadata/\" title=\"`metadata`\"><code>metadata</code></a>\nelement is locatable as being queried for is its primary purpose.</p>\n</li>\n<li>\n<p>In the other categories, most elements are not locatable. Exceptions are\n<a href=\"/en-US-v0.14.1/reference/math/equation/\" title=\"`math.equation`\"><code>math.equation</code></a> and <a href=\"/en-US-v0.14.1/reference/visualize/image/\" title=\"`image`\"><code>image</code></a>.</p>\n</li>\n</ul>\n<p>To find out whether a specific element is locatable, you can try to\n<a href=\"/en-US-v0.14.1/reference/introspection/query/\" title=\"`query`\"><code>query</code></a> for it.</p>\n<p>Note that you can still observe elements that are not locatable in queries\nthrough other means, for instance, when they have a label attached to them.</p>","constructor":null,"scope":[{"path":["location"],"name":"page","title":"Page","keywords":[],"oneliner":"Returns the page number for this location.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the page number for this location.</p>\n<p>Note that this does not return the value of the <a href=\"/en-US-v0.14.1/reference/introspection/counter/\">page counter</a>\nat this location, but the true page number (starting from one).</p>\n<p>If you want to know the value of the page counter, use\n<code><span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>page<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span>loc<span class=\"typ-punct\">)</span></code> instead.</p>\n<p>Can be used with <a href=\"/en-US-v0.14.1/reference/introspection/here/\" title=\"`here`\"><code>here</code></a> to retrieve the physical page position\nof the current context:</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-punct\">[</span>\n  I am located on\n  page <span class=\"typ-func\">#</span><span class=\"typ-func\">here</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/d13a1548b2d47ac4cb904c3f62c9c993.png\" alt=\"Preview\"></div></div>","title":null}}],"self":true,"params":[],"returns":["int"],"scope":[]},{"path":["location"],"name":"position","title":"Position","keywords":[],"oneliner":"Returns a dictionary with the page number and the x, y position for this location.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns a dictionary with the page number and the x, y position for this\nlocation. The page number starts at one and the coordinates are measured\nfrom the top-left of the page.</p>\n<p>If you only need the page number, use <code>page()</code> instead as it allows\nTypst to skip unnecessary work.</p>"}],"self":true,"params":[],"returns":["dictionary"],"scope":[]},{"path":["location"],"name":"page-numbering","title":"Page Numbering","keywords":[],"oneliner":"Returns the page numbering pattern of the page at this location.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the page numbering pattern of the page at this location. This\ncan be used when displaying the page counter in order to obtain the\nlocal numbering. This is useful if you are building custom indices or\noutlines.</p>\n<p>If the page numbering is set to <code><span class=\"typ-key\">none</span></code> at that location, this function\nreturns <code><span class=\"typ-key\">none</span></code>.</p>"}],"self":true,"params":[],"returns":["none","str","function"],"scope":[]}]}}}