{"route":"/en-US-v0.13.1/reference/model/heading/","title":"Heading","description":"Documentation for the `heading` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"syntax","name":"Syntax","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-level","name":"level","children":[]},{"id":"parameters-depth","name":"depth","children":[]},{"id":"parameters-offset","name":"offset","children":[]},{"id":"parameters-numbering","name":"numbering","children":[]},{"id":"parameters-supplement","name":"supplement","children":[]},{"id":"parameters-outlined","name":"outlined","children":[]},{"id":"parameters-bookmarked","name":"bookmarked","children":[]},{"id":"parameters-hanging-indent","name":"hanging-indent","children":[]},{"id":"parameters-body","name":"body","children":[]}]}],"body":{"kind":"func","content":{"path":[],"name":"heading","title":"Heading","keywords":[],"oneliner":"A section heading.","element":true,"contextual":false,"deprecation":null,"details":"<p>A section heading.</p>\n<p>With headings, you can structure your document into sections. Each heading\nhas a <em>level,</em> which starts at one and is unbounded upwards. This level\nindicates the logical role of the following content (section, subsection,\netc.) A top-level heading indicates a top-level section of the document\n(not the document's title).</p>\n<p>Typst can automatically number your headings for you. To enable numbering,\nspecify how you want your headings to be numbered with a\n<a href=\"/en-US-v0.13.1/reference/model/numbering/\">numbering pattern or function</a>.</p>\n<p>Independently of the numbering, Typst can also automatically generate an\n<a href=\"/en-US-v0.13.1/reference/model/outline/\" title=\"outline\">outline</a> of all headings for you. To exclude one or more headings from this\noutline, you can set the <code>outlined</code> parameter to <code><span class=\"typ-key\">false</span></code>.</p>\n<h2 id=\"example\">Example</h2>\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.a)&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span>\nIn recent years, <span class=\"typ-escape\">...</span>\n\n<span class=\"typ-heading\">== Preliminaries</span>\nTo start, <span class=\"typ-escape\">...</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/3da8ed6c330c3767836190a4021f5927.png\" alt=\"Preview\"></div></div>\n<h2 id=\"syntax\">Syntax</h2>\n<p>Headings have dedicated syntax: They can be created by starting a line with\none or multiple equals signs, followed by a space. The number of equals\nsigns determines the heading's logical nesting depth. The <code>offset</code> field\ncan be set to configure the starting depth.</p>","example":null,"self":false,"params":[{"name":"level","details":"<p>The absolute nesting depth of the heading, starting from one. If set\nto <code><span class=\"typ-key\">auto</span></code>, it is computed from <code>offset <span class=\"typ-op\">+</span> depth</code>.</p>\n<p>This is primarily useful for usage in <a href=\"/en-US-v0.13.1/reference/styling/#show-rules\">show rules</a>\n(either with <a href=\"/en-US-v0.13.1/reference/foundations/function/#definitions-where\"><code>where</code></a> selectors or by accessing the\nlevel directly on a shown heading).</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> heading<span class=\"typ-punct\">.</span><span class=\"typ-func\">where</span><span class=\"typ-punct\">(</span>level<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Level 1</span>\n<span class=\"typ-heading\">== Level 2</span>\n\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>offset<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-heading\">= Also level 2</span>\n<span class=\"typ-heading\">== Level 3</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/fe90e6f8fd396e0fe319b97dbaf1a394.png\" alt=\"Preview\"></div></div>","types":["auto","int"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"depth","details":"<p>The relative nesting depth of the heading, starting from one. This is\ncombined with <code>offset</code> to compute the actual <code>level</code>.</p>\n<p>This is set by the heading syntax, such that <code><span class=\"typ-heading\">== Heading</span></code> creates a\nheading with logical depth of 2, but actual level <code>offset <span class=\"typ-op\">+</span> <span class=\"typ-num\">2</span></code>. If you\nconstruct a heading manually, you should typically prefer this over\nsetting the absolute level.</p>","example":null,"types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">1</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"offset","details":"<p>The starting offset of each heading's <code>level</code>, used to turn its\nrelative <code>depth</code> into its absolute <code>level</code>.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-heading\">= Level 1</span>\n\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>offset<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1</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-heading\">= Level 2</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>offset<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> depth<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n  I&#39;m level 4\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/84ab568a4e7e1f030c7a3a8ec0354a2c.png\" alt=\"Preview\"></div></div>","types":["int"],"strings":[],"default":"<code><span class=\"typ-num\">0</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"numbering","details":"<p>How to number the heading. Accepts a\n<a href=\"/en-US-v0.13.1/reference/model/numbering/\">numbering pattern or function</a>.</p>","example":"<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.a.&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= A section</span>\n<span class=\"typ-heading\">== A subsection</span>\n<span class=\"typ-heading\">=== A sub-subsection</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/76d21794ff33145e127cdaac70f78b6c.png\" alt=\"Preview\"></div></div>","types":["none","str","function"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"supplement","details":"<p>A supplement for the heading.</p>\n<p>For references to headings, this is added before the referenced number.</p>\n<p>If a function is specified, it is passed the referenced heading and\nshould return content.</p>","example":"<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> supplement<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>Chapter<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Introduction</span> <span class=\"typ-label\">&lt;intro&gt;</span>\nIn <span class=\"typ-ref\">@intro</span>, we see how to turn\nSections into Chapters. And\nin <span class=\"typ-ref\">@intro<span class=\"typ-punct\">[</span>Part<span class=\"typ-punct\">]</span></span>, it is done\nmanually.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/3993144e7996642b7d2f45d44c369199.png\" alt=\"Preview\"></div></div>","types":["none","auto","content","function"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"outlined","details":"<p>Whether the heading should appear in the <a href=\"/en-US-v0.13.1/reference/model/outline/\" title=\"outline\">outline</a>.</p>\n<p>Note that this property, if set to <code><span class=\"typ-key\">true</span></code>, ensures the heading is also\nshown as a bookmark in the exported PDF's outline (when exporting to\nPDF). To change that behavior, use the <code>bookmarked</code> property.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">outline</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">[</span>Normal<span class=\"typ-punct\">]</span>\nThis is a normal heading.\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>outlined<span class=\"typ-punct\">:</span> <span class=\"typ-key\">false</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>Hidden<span class=\"typ-punct\">]</span>\nThis heading does not appear\nin the outline.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/ab747af34dccbfd0fc8693f1e700f84e.png\" alt=\"Preview\"></div></div>","types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">true</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"bookmarked","details":"<p>Whether the heading should appear as a bookmark in the exported PDF's\noutline. Doesn't affect other export formats, such as PNG.</p>\n<p>The default value of <code><span class=\"typ-key\">auto</span></code> indicates that the heading will only\nappear in the exported PDF's outline if its <code>outlined</code> property is set\nto <code><span class=\"typ-key\">true</span></code>, that is, if it would also be listed in Typst's <a href=\"/en-US-v0.13.1/reference/model/outline/\" title=\"outline\">outline</a>.\nSetting this property to either <code><span class=\"typ-key\">true</span></code> (bookmark) or <code><span class=\"typ-key\">false</span></code> (don't\nbookmark) bypasses that behavior.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">[</span>Normal heading<span class=\"typ-punct\">]</span>\nThis heading will be shown in\nthe PDF&#39;s bookmark outline.\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">(</span>bookmarked<span class=\"typ-punct\">:</span> <span class=\"typ-key\">false</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>Not bookmarked<span class=\"typ-punct\">]</span>\nThis heading won&#39;t be\nbookmarked in the resulting\nPDF.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/fd4bcc50364eb53747e22f371da7368b.png\" alt=\"Preview\"></div></div>","types":["auto","bool"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"hanging-indent","details":"<p>The indent all but the first line of a heading should have.</p>\n<p>The default value of <code><span class=\"typ-key\">auto</span></code> indicates that the subsequent heading\nlines will be indented based on the width of the numbering.</p>","example":"<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<span class=\"typ-func\">#</span><span class=\"typ-func\">heading</span><span class=\"typ-punct\">[</span>A very, very, very, very, very, very long heading<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/df90e0df8906fbbae0d7e445a7c15a22.png\" alt=\"Preview\"></div></div>","types":["auto","length"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"body","details":"<p>The heading's title.</p>","example":null,"types":["content"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["content"],"scope":[]}}}