{"route":"/en-US-v0.14.1/reference/introspection/counter/","title":"Counter","description":"Documentation for the Counter type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"accessing","name":"Accessing","children":[]},{"id":"displaying","name":"Displaying","children":[]},{"id":"modifying","name":"Modifying","children":[]},{"id":"page-counter","name":"Page counter","children":[]},{"id":"custom-counters","name":"Custom counters","children":[]},{"id":"how-to-step","name":"How to step","children":[]},{"id":"time-travel","name":"Time travel","children":[]},{"id":"other-state","name":"Other State","children":[]},{"id":"constructor","name":"Constructor","children":[{"id":"constructor-key","name":"key","children":[]}]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-get","name":"Get","children":[]},{"id":"definitions-display","name":"Display","children":[{"id":"definitions-display-numbering","name":"numbering","children":[]},{"id":"definitions-display-both","name":"both","children":[]}]},{"id":"definitions-at","name":"At","children":[{"id":"definitions-at-selector","name":"selector","children":[]}]},{"id":"definitions-final","name":"Final","children":[]},{"id":"definitions-step","name":"Step","children":[{"id":"definitions-step-level","name":"level","children":[]}]},{"id":"definitions-update","name":"Update","children":[{"id":"definitions-update-update","name":"update","children":[]}]}]}],"body":{"kind":"type","content":{"name":"counter","title":"Counter","keywords":[],"oneliner":"Counts through pages, elements, and more.","details":"<p>Counts through pages, elements, and more.</p>\n<p>With the counter function, you can access and modify counters for pages,\nheadings, figures, and more. Moreover, you can define custom counters for\nother things you want to count.</p>\n<p>Since counters change throughout the course of the document, their current\nvalue is <em>contextual.</em> It is recommended to read the chapter on <a href=\"/en-US-v0.14.1/reference/context/\" title=\"context\">context</a>\nbefore continuing here.</p>\n<h2 id=\"accessing\">Accessing a counter</h2>\n<p>To access the raw value of a counter, we can use the <a href=\"/en-US-v0.14.1/reference/introspection/counter/#definitions-get\"><code>get</code></a>\nfunction. This function returns an <a href=\"/en-US-v0.14.1/reference/foundations/array/\" title=\"array\">array</a>: Counters can have multiple\nlevels (in the case of headings for sections, subsections, and so on), and\neach item in the array corresponds to one level.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1.&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span>\nRaw value of heading counter is\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">get</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/8ea552ce797fc8605c34df5e705f0e54.png\" alt=\"Preview\"></div></div>\n<h2 id=\"displaying\">Displaying a counter</h2>\n<p>Often, we want to display the value of a counter in a more human-readable\nway. To do that, we can call the <a href=\"/en-US-v0.14.1/reference/introspection/counter/#definitions-display\"><code>display</code></a> function on\nthe counter. This function retrieves the current counter value and formats\nit either with a provided or with an automatically inferred <a href=\"/en-US-v0.14.1/reference/model/numbering/\" title=\"numbering\">numbering</a>.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1.&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span>\nSome text here.\n\n<span class=\"typ-heading\">= Background</span>\nThe current value is: <span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">}</span>\n\nOr in roman numerals: <span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;I&quot;</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/ec4522eb5a753d79b343291aff636a88.png\" alt=\"Preview\"></div></div>\n<h2 id=\"modifying\">Modifying a counter</h2>\n<p>To modify a counter, you can use the <code>step</code> and <code>update</code> methods:</p>\n<ul>\n<li>\n<p>The <code>step</code> method increases the value of the counter by one. Because\ncounters can have multiple levels , it optionally takes a <code>level</code>\nargument. If given, the counter steps at the given depth.</p>\n</li>\n<li>\n<p>The <code>update</code> method allows you to arbitrarily modify the counter. In its\nbasic form, you give it an integer (or an array for multiple levels). For\nmore flexibility, you can instead also give it a function that receives\nthe current value and returns a new value.</p>\n</li>\n</ul>\n<p>The heading counter is stepped before the heading is displayed, so\n<code>Analysis</code> gets the number seven even though the counter is at six after the\nsecond update.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1.&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Background</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">update</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">update</span><span class=\"typ-punct\">(</span>n <span class=\"typ-op\">=&gt;</span> n <span class=\"typ-op\">*</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Analysis</span>\nLet&#39;s skip 7.1.\n<span class=\"typ-func\">#</span><span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span>level<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">== Analysis</span>\nStill at <span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span>heading<span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">display</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/10e62abf96165699a2432049a18a6a40.png\" alt=\"Preview\"></div></div>\n<h2 id=\"page-counter\">Page counter</h2>\n<p>The page counter is special. It is automatically stepped at each pagebreak.\nBut like other counters, you can also step it manually. For example, you\ncould have Roman page numbers for your preface, then switch to Arabic page\nnumbers for your main content and reset the page counter to one.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;(i)&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Preface</span>\nThe preface is numbered with\nroman numerals.\n\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1 / 1&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><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\">update</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Main text</span>\nHere, the counter is reset to one.\nWe also display both the current\npage and total number of pages in\nArabic numbers.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/3c30a8aceea73d91286b71e31d456047-0.png\" alt=\"Preview page 1\"><img src=\"/en-US-v0.14.1/assets/3c30a8aceea73d91286b71e31d456047-1.png\" alt=\"Preview page 2\"></div></div>\n<h2 id=\"custom-counters\">Custom counters</h2>\n<p>To define your own counter, call the <code>counter</code> function with a string as a\nkey. This key identifies the counter globally.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> mine <span class=\"typ-op\">=</span> <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;mycounter&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> mine<span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> mine<span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">update</span><span class=\"typ-punct\">(</span>c <span class=\"typ-op\">=&gt;</span> c <span class=\"typ-op\">*</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> mine<span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/b15cb3320af269d859e669c3cddd652.png\" alt=\"Preview\"></div></div>\n<h2 id=\"how-to-step\">How to step</h2>\n<p>When you define and use a custom counter, in general, you should first step\nthe counter and then display it. This way, the stepping behaviour of a\ncounter can depend on the element it is stepped for. If you were writing a\ncounter for, let's say, theorems, your theorem's definition would thus first\ninclude the counter step and only then display the counter and the theorem's\ncontents.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> c <span class=\"typ-op\">=</span> <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;theorem&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-func\">theorem</span><span class=\"typ-punct\">(</span>it<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> <span class=\"typ-func\">block</span><span class=\"typ-punct\">[</span>\n  <span class=\"typ-pol\">#</span><span class=\"typ-pol\">c</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-strong\">*Theorem <span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> c<span class=\"typ-punct\">.</span><span class=\"typ-func\">display</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>:*</span>\n  <span class=\"typ-pol\">#</span><span class=\"typ-pol\">it</span>\n<span class=\"typ-punct\">]</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">theorem</span><span class=\"typ-punct\">[</span><span class=\"typ-math-delim\">$</span>1 = 1<span class=\"typ-math-delim\">$</span><span class=\"typ-punct\">]</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">theorem</span><span class=\"typ-punct\">[</span><span class=\"typ-math-delim\">$</span>2 &lt; 3<span class=\"typ-math-delim\">$</span><span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/69fe98ee7391fc895dbd81c85839a421.png\" alt=\"Preview\"></div></div>\n<p>The rationale behind this is best explained on the example of the heading\ncounter: An update to the heading counter depends on the heading's level. By\nstepping directly before the heading, we can correctly step from <code>1</code> to\n<code>1.1</code> when encountering a level 2 heading. If we were to step after the\nheading, we wouldn't know what to step to.</p>\n<p>Because counters should always be stepped before the elements they count,\nthey always start at zero. This way, they are at one for the first display\n(which happens after the first step).</p>\n<h2 id=\"time-travel\">Time travel</h2>\n<p>Counters can travel through time! You can find out the final value of the\ncounter before it is reached and even determine what the value was at any\nparticular location in the document.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> mine <span class=\"typ-op\">=</span> <span class=\"typ-func\">counter</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;mycounter&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Values</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</span> <span class=\"typ-punct\">[</span>\n  Value here: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">get</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n  At intro: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span><span class=\"typ-label\">&lt;intro&gt;</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n  Final value: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">final</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">]</span>\n\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">update</span><span class=\"typ-punct\">(</span>n <span class=\"typ-op\">=&gt;</span> n <span class=\"typ-op\">+</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span> <span class=\"typ-label\">&lt;intro&gt;</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">10</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">mine</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/c287511a94ac2600d9b5fb0c93f18d83.png\" alt=\"Preview\"></div></div>\n<h2 id=\"other-state\">Other kinds of state</h2>\n<p>The <code>counter</code> type is closely related to <a href=\"/en-US-v0.14.1/reference/introspection/state/\" title=\"state\">state</a> type. Read its\ndocumentation for more details on state management in Typst and why it\ndoesn't just use normal variables for counters.</p>","constructor":{"path":[],"name":"counter","title":"Construct","keywords":[],"oneliner":"Create a new counter identified by a key.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Create a new counter identified by a key.</p>"}],"self":false,"params":[{"name":"key","details":[{"kind":"html","content":"<p>The key that identifies this counter globally.</p>\n<ul>\n<li>If it is a string, creates a custom counter that is only affected\nby manual updates,</li>\n<li>If it is the <a href=\"/en-US-v0.14.1/reference/layout/page/\" title=\"`page`\"><code>page</code></a> function, counts through pages,</li>\n<li>If it is a <a href=\"/en-US-v0.14.1/reference/foundations/selector/\" title=\"selector\">selector</a>, counts through elements that match the\nselector. For example,\n<ul>\n<li>provide an element function: counts elements of that type,</li>\n<li>provide a <a href=\"/en-US-v0.14.1/reference/foundations/function/#definitions-where\"><code>where</code></a> selector:\ncounts a type of element with specific fields,</li>\n<li>provide a <a href=\"/en-US-v0.14.1/reference/foundations/label/\"><code><span class=\"typ-label\">&lt;label&gt;</span></code></a>: counts elements with that label.</li>\n</ul>\n</li>\n</ul>"}],"types":["str","label","selector","location","function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["counter"],"scope":[]},"scope":[{"path":["counter"],"name":"get","title":"Get","keywords":[],"oneliner":"Retrieves the value of the counter at the current location.","element":false,"contextual":true,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Retrieves the value of the counter at the current location. Always\nreturns an array of integers, even if the counter has just one number.</p>\n<p>This is equivalent to <code>counter<span class=\"typ-punct\">.</span><span class=\"typ-func\">at</span><span class=\"typ-punct\">(</span><span class=\"typ-func\">here</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code>.</p>"}],"self":true,"params":[],"returns":["int","array"],"scope":[]},{"path":["counter"],"name":"display","title":"Display","keywords":[],"oneliner":"Displays the current value of the counter with a numbering and returns the formatted output.","element":false,"contextual":true,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Displays the current value of the counter with a numbering and returns\nthe formatted output.</p>"}],"self":true,"params":[{"name":"numbering","details":[{"kind":"html","content":"<p>A <a href=\"/en-US-v0.14.1/reference/model/numbering/\">numbering pattern or a function</a>, which specifies how\nto display the counter. If given a function, that function receives\neach number of the counter as a separate argument. If the amount of\nnumbers varies, e.g. for the heading argument, you can use an\n<a href=\"/en-US-v0.14.1/reference/foundations/arguments/\">argument sink</a>.</p>\n<p>If this is omitted or set to <code><span class=\"typ-key\">auto</span></code>, displays the counter with the\nnumbering style for the counted element or with the pattern\n<code><span class=\"typ-str\">&quot;1.1&quot;</span></code> if no such style exists.</p>"}],"types":["auto","str","function"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":true,"named":false,"required":false,"variadic":false,"settable":false},{"name":"both","details":[{"kind":"html","content":"<p>If enabled, displays the current and final top-level count together.\nBoth can be styled through a single numbering pattern. This is used\nby the page numbering property to display the current and total\nnumber of pages when a pattern like <code><span class=\"typ-str\">&quot;1 / 1&quot;</span></code> is given.</p>"}],"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["counter"],"name":"at","title":"At","keywords":[],"oneliner":"Retrieves the value of the counter at the given location.","element":false,"contextual":true,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Retrieves the value of the counter at the given location. Always returns\nan array of integers, even if the counter has just one number.</p>\n<p>The <code>selector</code> must match exactly one element in the document. The most\nuseful kinds of selectors for this are <a href=\"/en-US-v0.14.1/reference/foundations/label/\">labels</a> and\n<a href=\"/en-US-v0.14.1/reference/introspection/location/\">locations</a>.</p>"}],"self":true,"params":[{"name":"selector","details":[{"kind":"html","content":"<p>The place at which the counter's value should be retrieved.</p>"}],"types":["label","selector","location","function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["int","array"],"scope":[]},{"path":["counter"],"name":"final","title":"Final","keywords":[],"oneliner":"Retrieves the value of the counter at the end of the document.","element":false,"contextual":true,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Retrieves the value of the counter at the end of the document. Always\nreturns an array of integers, even if the counter has just one number.</p>"}],"self":true,"params":[],"returns":["int","array"],"scope":[]},{"path":["counter"],"name":"step","title":"Step","keywords":[],"oneliner":"Increases the value of the counter by one.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Increases the value of the counter by one.</p>\n<p>The update will be in effect at the position where the returned content\nis inserted into the document. If you don't put the output into the\ndocument, nothing happens! This would be the case, for example, if you\nwrite <code><span class=\"typ-key\">let</span> _ <span class=\"typ-op\">=</span> <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\">step</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span></code>. Counter updates are always\napplied in layout order and in that case, Typst wouldn't know when to\nstep the counter.</p>"}],"self":true,"params":[{"name":"level","details":[{"kind":"html","content":"<p>The depth at which to step the counter. Defaults to <code><span class=\"typ-num\">1</span></code>.</p>"}],"types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">1</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["content"],"scope":[]},{"path":["counter"],"name":"update","title":"Update","keywords":[],"oneliner":"Updates the value of the counter.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Updates the value of the counter.</p>\n<p>Just like with <code>step</code>, the update only occurs if you put the resulting\ncontent into the document.</p>"}],"self":true,"params":[{"name":"update","details":[{"kind":"html","content":"<p>If given an integer or array of integers, sets the counter to that\nvalue. If given a function, that function receives the previous\ncounter value (with each number as a separate argument) and has to\nreturn the new value (integer or array).</p>"}],"types":["int","array","function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["content"],"scope":[]}]}}}