{"route":"/en-US-v0.13.1/reference/model/numbering/","title":"Numbering","description":"Documentation for the `numbering` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"numbering-patterns-and-numbering-functions","name":"Numbering patterns and numbering functions","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-numbering","name":"numbering","children":[]},{"id":"parameters-numbers","name":"numbers","children":[]}]}],"body":{"kind":"func","content":{"path":[],"name":"numbering","title":"Numbering","keywords":[],"oneliner":"Applies a numbering to a sequence of numbers.","element":false,"contextual":false,"deprecation":null,"details":"<p>Applies a numbering to a sequence of numbers.</p>\n<p>A numbering defines how a sequence of numbers should be displayed as\ncontent. It is defined either through a pattern string or an arbitrary\nfunction.</p>\n<p>A numbering pattern consists of counting symbols, for which the actual\nnumber is substituted, their prefixes, and one suffix. The prefixes and the\nsuffix are repeated as-is.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">numbering</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;1.1)&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">numbering</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;1.a.i&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">numbering</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;I – 1&quot;</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">12</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">numbering</span><span class=\"typ-punct\">(</span>\n  <span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>nums<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=&gt;</span> nums\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">pos</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">map</span><span class=\"typ-punct\">(</span>str<span class=\"typ-punct\">)</span>\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">join</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;.&quot;</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">+</span> <span class=\"typ-str\">&quot;)&quot;</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/5623388f19513634c27192c702a4d0b1.png\" alt=\"Preview\"></div></div>\n<h2 id=\"numbering-patterns-and-numbering-functions\">Numbering patterns and numbering functions</h2>\n<p>There are multiple instances where you can provide a numbering pattern or\nfunction in Typst. For example, when defining how to number\n<a href=\"/en-US-v0.13.1/reference/model/heading/\">headings</a> or <a href=\"/en-US-v0.13.1/reference/model/figure/\">figures</a>. Every time, the expected format\nis the same as the one described below for the\n<a href=\"/en-US-v0.13.1/reference/model/numbering/#parameters-numbering\"><code>numbering</code></a> parameter.</p>\n<p>The following example illustrates that a numbering function is just a\nregular <a href=\"/en-US-v0.13.1/reference/foundations/function/\" title=\"function\">function</a> that accepts numbers and returns <a href=\"/en-US-v0.13.1/reference/foundations/content/\" title=\"`content`\"><code>content</code></a>.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-func\">unary</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span><span class=\"typ-punct\">,</span> last<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> <span class=\"typ-str\">&quot;|&quot;</span> <span class=\"typ-op\">*</span> last\n<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> unary<span class=\"typ-punct\">)</span>\n<span class=\"typ-heading\">= First heading</span>\n<span class=\"typ-heading\">= Second heading</span>\n<span class=\"typ-heading\">= Third heading</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/cb7636c53e8f2982779c917acbd6dc3f.png\" alt=\"Preview\"></div></div>","example":null,"self":false,"params":[{"name":"numbering","details":"<p>Defines how the numbering works.</p>\n<p><strong>Counting symbols</strong> are <code>1</code>, <code>a</code>, <code>A</code>, <code>i</code>, <code>I</code>, <code>α</code>, <code>Α</code>, <code>一</code>, <code>壹</code>,\n<code>あ</code>, <code>い</code>, <code>ア</code>, <code>イ</code>, <code>א</code>, <code>가</code>, <code>ㄱ</code>, <code>*</code>, <code>١</code>, <code>۱</code>, <code>१</code>, <code>১</code>, <code>ক</code>,\n<code>①</code>, and <code>⓵</code>. They are replaced by the number in the sequence,\npreserving the original case.</p>\n<p>The <code>*</code> character means that symbols should be used to count, in the\norder of <code>*</code>, <code>†</code>, <code>‡</code>, <code>§</code>, <code>¶</code>, <code>‖</code>. If there are more than six\nitems, the number is represented using repeated symbols.</p>\n<p><strong>Suffixes</strong> are all characters after the last counting symbol. They are\nrepeated as-is at the end of any rendered number.</p>\n<p><strong>Prefixes</strong> are all characters that are neither counting symbols nor\nsuffixes. They are repeated as-is at in front of their rendered\nequivalent of their counting symbol.</p>\n<p>This parameter can also be an arbitrary function that gets each number\nas an individual argument. When given a function, the <code>numbering</code>\nfunction just forwards the arguments to that function. While this is not\nparticularly useful in itself, it means that you can just give arbitrary\nnumberings to the <code>numbering</code> function without caring whether they are\ndefined as a pattern or function.</p>","example":null,"types":["str","function"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"numbers","details":"<p>The numbers to apply the numbering to. Must be positive.</p>\n<p>If <code>numbering</code> is a pattern and more numbers than counting symbols are\ngiven, the last counting symbol with its prefix is repeated.</p>","example":null,"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false}],"returns":["any"],"scope":[]}}}