{"route":"/en-US-v0.13.1/guides/page-setup-guide/","title":"Page setup guide","description":"An in-depth guide to setting page dimensions, margins, and page numbers in\nTypst. Learn how to create appealing and clear layouts and get there quickly.\n","part":null,"outline":[{"id":"customize-margins","name":"Customize Margins","children":[{"id":"change-margins","name":"Change Margins","children":[]},{"id":"alternating-margins","name":"Alternating Margins","children":[]}]},{"id":"headers-and-footers","name":"Headers And Footers","children":[{"id":"specific-pages","name":"Specific Pages","children":[]},{"id":"specific-elements","name":"Specific Elements","children":[]}]},{"id":"page-numbers","name":"Page Numbers","children":[{"id":"custom-footer-with-page-numbers","name":"Custom footer with page numbers","children":[]},{"id":"skip-pages","name":"Skip Pages","children":[]}]},{"id":"columns","name":"Columns","children":[{"id":"columns-anywhere","name":"Columns Anywhere","children":[]},{"id":"balanced-columns","name":"Balanced columns","children":[]}]},{"id":"one-off-modifications","name":"One-off modifications","children":[]}],"body":{"kind":"html","content":"<h1>Page setup guide</h1>\n<p>Your page setup is a big part of the first impression your document gives. Line\nlengths, margins, and columns influence\n<a href=\"https://practicaltypography.com/page-margins.html\">appearance</a> and\n<a href=\"https://designregression.com/article/line-length-revisited-following-the-research\">legibility</a>\nwhile the right headers and footers will help your reader easily navigate your\ndocument. This guide will help you to customize pages, margins, headers,\nfooters, and page numbers so that they are the right fit for your content and\nyou can get started with writing.</p>\n<p>In Typst, each page has a width, a height, and margins on all four sides. The\ntop and bottom margins may contain a header and footer. The set rule of the\n<a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> element is where you control all of the page setup. If you\nmake changes with this set rule, Typst will ensure that there is a new and\nconforming empty page afterward, so it may insert a page break. Therefore, it is\nbest to specify your <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule at the start of your document or\nin your template.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>\n  width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100%</span><span class=\"typ-punct\">,</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100%</span><span class=\"typ-punct\">,</span>\n  inset<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4pt</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>\n  paper<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;iso-b7&quot;</span><span class=\"typ-punct\">,</span>\n  header<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> aqua<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>Header<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  footer<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> aqua<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>Footer<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  number-align<span class=\"typ-punct\">:</span> center<span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> aqua<span class=\"typ-punct\">.</span><span class=\"typ-func\">lighten</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">40%</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/7fe9722cc3b9bdd5ee00ca23dbcb3702.png\" alt=\"Preview\"></div></div>\n<p>This example visualizes the dimensions for page content, headers, and footers.\nThe page content is the page size (ISO B7) minus each side's default margin. In\nthe top and the bottom margin, there are stroked rectangles visualizing the\nheader and footer. They do not touch the main content, instead, they are offset\nby 30% of the respective margin. You can control this offset by specifying the\n<a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-header-ascent\"><code>header-ascent</code></a> and\n<a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-footer-descent\"><code>footer-descent</code></a> arguments.</p>\n<p>Below, the guide will go more into detail on how to accomplish common page setup\nrequirements with examples.</p>\n<h2 id=\"customize-margins\">Customize page size and margins</h2>\n<p>Typst's default page size is A4 paper. Depending on your region and your use\ncase, you will want to change this. You can do this by using the\n<a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule and passing it a string argument to use a common page\nsize. Options include the complete ISO 216 series (e.g. <code>&quot;a4&quot;</code> and <code>&quot;iso-c2&quot;</code>),\ncustomary US formats like <code>&quot;us-legal&quot;</code> or <code>&quot;us-letter&quot;</code>, and more. Check out the\nreference for the <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-paper\">page's paper argument</a> to learn about all\navailable options.</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><span class=\"typ-str\">&quot;us-letter&quot;</span><span class=\"typ-punct\">)</span>\n\nThis page likes freedom.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/4246fd7d86f948c7c3689eb7698c9c4f.png\" alt=\"Preview\"></div></div>\n<p>If you need to customize your page size to some dimensions, you can specify the\nnamed arguments <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-width\"><code>width</code></a> and <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-height\"><code>height</code></a> instead.</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>width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">12cm</span><span class=\"typ-punct\">,</span> height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">12cm</span><span class=\"typ-punct\">)</span>\n\nThis page is a square.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/465b6b3f98e32a2fea10d872f41f87c9.png\" alt=\"Preview\"></div></div>\n<h3 id=\"change-margins\">Change the page's margins</h3>\n<p>Margins are a vital ingredient for good typography:\n<a href=\"http://webtypography.net/2.1.2\">Typographers consider lines that fit between 45 and 75 characters best length\nfor legibility</a> and your margins and\n<a href=\"#columns\">columns</a> help define line widths. By default, Typst will create\nmargins proportional to the page size of your document. To set custom margins,\nyou will use the <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-margin\"><code>margin</code></a> argument in the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set\nrule.</p>\n<p>The <code>margin</code> argument will accept a length if you want to set all margins to the\nsame width. However, you often want to set different margins on each side. To do\nthis, you can pass a dictionary:</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>margin<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>\n  top<span class=\"typ-punct\">:</span> <span class=\"typ-num\">3cm</span><span class=\"typ-punct\">,</span>\n  bottom<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2cm</span><span class=\"typ-punct\">,</span>\n  x<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.5cm</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">100</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/c896f60e6558035f03087583440e7441.png\" alt=\"Preview\"></div></div>\n<p>The page margin dictionary can have keys for each side (<code>top</code>, <code>bottom</code>, <code>left</code>,\n<code>right</code>), but you can also control left and right together by setting the <code>x</code>\nkey of the margin dictionary, like in the example. Likewise, the top and bottom\nmargins can be adjusted together by setting the <code>y</code> key.</p>\n<p>If you do not specify margins for all sides in the margin dictionary, the old\nmargins will remain in effect for the unset sides. To prevent this and set all\nremaining margins to a common size, you can use the <code>rest</code> key. For example,\n<code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>margin<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>left<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.5in</span><span class=\"typ-punct\">,</span> rest<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1in</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code> will set the left margin to 1.5\ninches and the remaining margins to one inch.</p>\n<h3 id=\"alternating-margins\">Different margins on alternating pages</h3>\n<p>Sometimes, you'll need to alternate horizontal margins for even and odd pages,\nfor example, to have more room towards the spine of a book than on the outsides\nof its pages. Typst keeps track of whether a page is to the left or right of the\nbinding. You can use this information and set the <code>inside</code> or <code>outside</code> keys of\nthe margin dictionary. The <code>inside</code> margin points towards the spine, and the\n<code>outside</code> margin points towards the edge of the bound book.</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>margin<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>inside<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2.5cm</span><span class=\"typ-punct\">,</span> outside<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2cm</span><span class=\"typ-punct\">,</span> y<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.75cm</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>Typst will assume that documents written in Left-to-Right scripts are bound on\nthe left while books written in Right-to-Left scripts are bound on the right.\nHowever, you will need to change this in some cases: If your first page is\noutput by a different app, the binding is reversed from Typst's perspective.\nAlso, some books, like English-language Mangas are customarily bound on the\nright, despite English using Left-to-Right script. To change the binding side\nand explicitly set where the <code>inside</code> and <code>outside</code> are, set the\n<a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-binding\"><code>binding</code></a> argument in the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule.</p>\n<pre><code><span class=\"typ-comment\">// Produce a book bound on the right,</span>\n<span class=\"typ-comment\">// even though it is set in Spanish.</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>lang<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;es&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>binding<span class=\"typ-punct\">:</span> right<span class=\"typ-punct\">)</span>\n</code></pre>\n<p>If <code>binding</code> is <code>left</code>, <code>inside</code> margins will be on the left on odd pages, and\nvice versa.</p>\n<h2 id=\"headers-and-footers\">Add headers and footers</h2>\n<p>Headers and footers are inserted in the top and bottom margins of every page.\nYou can add custom headers and footers or just insert a page number.</p>\n<p>In case you need more than just a page number, the best way to insert a header\nand a footer are the <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-header\"><code>header</code></a> and <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-footer\"><code>footer</code></a>\narguments of the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule. You can pass any content as their\nvalues:</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>header<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>\n  <span class=\"typ-emph\">_Lisa Strassner&#39;s Thesis_</span>\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span>\n  National Academy of Sciences\n<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">150</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/f0814aae5cf80934a96205a02aad36b4.png\" alt=\"Preview\"></div></div>\n<p>Headers are bottom-aligned by default so that they do not collide with the top\nedge of the page. You can change this by wrapping your header in the\n<a href=\"/en-US-v0.13.1/reference/layout/align/\"><code>align</code></a> function.</p>\n<h3 id=\"specific-pages\">Different header and footer on specific pages</h3>\n<p>You'll need different headers and footers on some pages. For example, you may\nnot want a header and footer on the title page. The example below shows how to\nconditionally remove the header on the first page:</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>header<span class=\"typ-punct\">:</span> <span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-key\">if</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\">get</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">first</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">&gt;</span> <span class=\"typ-num\">1</span> <span class=\"typ-punct\">[</span>\n    <span class=\"typ-emph\">_Lisa Strassner&#39;s Thesis_</span>\n    <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span>\n    National Academy of Sciences\n  <span class=\"typ-punct\">]</span>\n<span class=\"typ-punct\">}</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">150</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>This example may look intimidating, but let's break it down: By using the\n<code><span class=\"typ-key\">context</span></code> keyword, we are telling Typst that the header depends on where we\nare in the document. We then ask Typst if the page <a href=\"/en-US-v0.13.1/reference/introspection/counter/\" title=\"counter\">counter</a> is larger than one\nat our (context-dependent) current position. The page counter starts at one, so\nwe are skipping the header on a single page. Counters may have multiple levels.\nThis feature is used for items like headings, but the page counter will always\nhave a single level, so we can just look at the first one.</p>\n<p>You can, of course, add an <code>else</code> to this example to add a different header to\nthe first page instead.</p>\n<h3 id=\"specific-elements\">Adapt headers and footers on pages with specific elements</h3>\n<p>The technique described in the previous section can be adapted to perform more\nadvanced tasks using Typst's labels. For example, pages with big tables could\nomit their headers to help keep clutter down. We will mark our tables with a\n<code>&lt;big-table&gt;</code> <a href=\"/en-US-v0.13.1/reference/foundations/label/\" title=\"label\">label</a> and use the <a href=\"/en-US-v0.13.1/reference/introspection/query/\">query system</a> to find out if such a\nlabel exists on the current page:</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>header<span class=\"typ-punct\">:</span> <span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-key\">let</span> page-counter <span class=\"typ-op\">=</span>\n  <span class=\"typ-key\">let</span> matches <span class=\"typ-op\">=</span> <span class=\"typ-func\">query</span><span class=\"typ-punct\">(</span><span class=\"typ-label\">&lt;big-table&gt;</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-key\">let</span> current <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\">get</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-key\">let</span> has-table <span class=\"typ-op\">=</span> matches<span class=\"typ-punct\">.</span><span class=\"typ-func\">any</span><span class=\"typ-punct\">(</span>m <span class=\"typ-op\">=&gt;</span>\n    <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>m<span class=\"typ-punct\">.</span><span class=\"typ-func\">location</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">==</span> current\n  <span class=\"typ-punct\">)</span>\n\n  <span class=\"typ-key\">if</span> <span class=\"typ-key\">not</span> has-table <span class=\"typ-punct\">[</span>\n    <span class=\"typ-emph\">_Lisa Strassner&#39;s Thesis_</span>\n    <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span>\n    National Academy of Sciences\n  <span class=\"typ-punct\">]</span>\n<span class=\"typ-punct\">}</span><span class=\"typ-punct\">)</span>)\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">100</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">pagebreak</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">table</span><span class=\"typ-punct\">(</span>\n  columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span> <span class=\"typ-op\">*</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">[</span>A<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">[</span>B<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">[</span>C<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">[</span>D<span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span> <span class=\"typ-label\">&lt;big-table&gt;</span>\n</code></pre>\n<p>Here, we query for all instances of the <code>&lt;big-table&gt;</code> label. We then check that\nnone of the tables are on the page at our current position. If so, we print the\nheader. This example also uses variables to be more concise. Just as above, you\ncould add an <code>else</code> to add another header instead of deleting it.</p>\n<h2 id=\"page-numbers\">Add and customize page numbers</h2>\n<p>Page numbers help readers keep track of and reference your document more easily.\nThe simplest way to insert page numbers is the <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-numbering\"><code>numbering</code></a>\nargument of the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule. You can pass a\n<a href=\"/en-US-v0.13.1/reference/model/numbering/#parameters-numbering\"><em>numbering pattern</em></a> string that shows how you want your\npages to be numbered.</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;1&quot;</span><span class=\"typ-punct\">)</span>\n\nThis is a numbered page.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/b48b5390c93bf60c40473268b2bc55b2.png\" alt=\"Preview\"></div></div>\n<p>Above, you can check out the simplest conceivable example. It adds a single\nArabic page number at the center of the footer. You can specify other characters\nthan <code>&quot;1&quot;</code> to get other numerals. For example, <code>&quot;i&quot;</code> will yield lowercase Roman\nnumerals. Any character that is not interpreted as a number will be output\nas-is. For example, put dashes around your page number by typing this:</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;— 1 —&quot;</span><span class=\"typ-punct\">)</span>\n\nThis is a — numbered — page.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/d7f4767d2392e3a857f037af58edd21f.png\" alt=\"Preview\"></div></div>\n<p>You can add the total number of pages by entering a second number character in\nthe string.</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;1 of 1&quot;</span><span class=\"typ-punct\">)</span>\n\nThis is one of many numbered pages.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/cbb2198058d0bedc9aabffd8b12f7c30.png\" alt=\"Preview\"></div></div>\n<p>Go to the <a href=\"/en-US-v0.13.1/reference/model/numbering/#parameters-numbering\"><code>numbering</code> function reference</a> to learn more\nabout the arguments you can pass here.</p>\n<p>In case you need to right- or left-align the page number, use the\n<a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-number-align\"><code>number-align</code></a> argument of the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule.\nAlternating alignment between even and odd pages is not currently supported\nusing this property. To do this, you'll need to specify a custom footer with\nyour footnote and query the page counter as described in the section on\nconditionally omitting headers and footers.</p>\n<h3 id=\"custom-footer-with-page-numbers\">Custom footer with page numbers</h3>\n<p>Sometimes, you need to add other content than a page number to your footer.\nHowever, once a footer is specified, the <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-numbering\"><code>numbering</code></a> argument\nof the <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> set rule is ignored. This section shows you how to add\na custom footer with page numbers and more.</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>footer<span class=\"typ-punct\">:</span> <span class=\"typ-key\">context</span> <span class=\"typ-punct\">[</span>\n  <span class=\"typ-strong\">*American Society of Proceedings*</span>\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</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\">display</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-str\">&quot;1/1&quot;</span><span class=\"typ-punct\">,</span>\n    both<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\nThis page has a custom footer.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/a5ae057e4480999f126c73098458484c.png\" alt=\"Preview\"></div></div>\n<p>First, we add some strongly emphasized text on the left and add free space to\nfill the line. Then, we call <code>counter(page)</code> to retrieve the page counter and\nuse its <code>display</code> function to show its current value. We also set <code>both</code> to\n<code><span class=\"typ-key\">true</span></code> so that our numbering pattern applies to the current <em>and</em> final page\nnumber.</p>\n<p>We can also get more creative with the page number. For example, let's insert a\ncircle for each page.</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>footer<span class=\"typ-punct\">:</span> <span class=\"typ-key\">context</span> <span class=\"typ-punct\">[</span>\n  <span class=\"typ-strong\">*Fun Typography Club*</span>\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-punct\">(</span>num<span class=\"typ-punct\">,</span><span class=\"typ-punct\">)</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\">get</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> circles <span class=\"typ-op\">=</span> num <span class=\"typ-op\">*</span> <span class=\"typ-punct\">(</span>\n    <span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span><span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>\n      radius<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2pt</span><span class=\"typ-punct\">,</span>\n      fill<span class=\"typ-punct\">:</span> navy<span class=\"typ-punct\">,</span>\n    <span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span>\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>\n    inset<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>bottom<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n    circles<span class=\"typ-punct\">.</span><span class=\"typ-func\">join</span><span class=\"typ-punct\">(</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\nThis page has a custom footer.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/3f1e0c8050c6661e537d30705124bf28.png\" alt=\"Preview\"></div></div>\n<p>In this example, we use the number of pages to create an array of\n<a href=\"/en-US-v0.13.1/reference/visualize/circle/\">circles</a>. The circles are wrapped in a <a href=\"/en-US-v0.13.1/reference/layout/box/\" title=\"box\">box</a> so they can all appear on\nthe same line because they are blocks and would otherwise create paragraph\nbreaks. The length of this <a href=\"/en-US-v0.13.1/reference/foundations/array/\" title=\"array\">array</a> depends on the current page number.</p>\n<p>We then insert the circles at the right side of the footer, with 1pt of space\nbetween them. The join method of an array will attempt to\n<a href=\"/en-US-v0.13.1/reference/scripting/#blocks\"><em>join</em></a> the different values of an array into a single\nvalue, interspersed with its argument. In our case, we get a single content\nvalue with circles and spaces between them that we can use with the align\nfunction. Finally, we use another box to ensure that the text and the circles\ncan share a line and use the <a href=\"/en-US-v0.13.1/reference/layout/box/#parameters-inset\"><code>inset</code> argument</a> to raise the circles\na bit so they line up nicely with the text.</p>\n<h3 id=\"skip-pages\">Reset the page number and skip pages</h3>\n<p>Do you, at some point in your document, need to reset the page number? Maybe you\nwant to start with the first page only after the title page. Or maybe you need\nto skip a few page numbers because you will insert pages into the final printed\nproduct.</p>\n<p>The right way to modify the page number is to manipulate the page <a href=\"/en-US-v0.13.1/reference/introspection/counter/\" title=\"counter\">counter</a>. The\nsimplest manipulation is to set the counter back to 1.</p>\n<pre><code><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</code></pre>\n<p>This line will reset the page counter back to one. It should be placed at the\nstart of a page because it will otherwise create a page break. You can also\nupdate the counter given its previous value by passing a function:</p>\n<pre><code><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>n <span class=\"typ-op\">=&gt;</span> n <span class=\"typ-op\">+</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>In this example, we skip five pages. <code>n</code> is the current value of the page\ncounter and <code>n + 5</code> is the return value of our function.</p>\n<p>In case you need to retrieve the actual page number instead of the value of the\npage counter, you can use the <a href=\"/en-US-v0.13.1/reference/introspection/location/#definitions-page\"><code>page</code></a> method on the return\nvalue of the <a href=\"/en-US-v0.13.1/reference/introspection/here/\" title=\"`here`\"><code>here</code></a> function:</p>\n<div class=\"previewed-code\"><pre><code><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>n <span class=\"typ-op\">=&gt;</span> n <span class=\"typ-op\">+</span> <span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-comment\">// This returns one even though the</span>\n<span class=\"typ-comment\">// page counter was incremented by 5.</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">context</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</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/d3dcad44515b9bf64e2f18e46b5e67fd.png\" alt=\"Preview\"></div></div>\n<p>You can also obtain the page numbering pattern from the location returned by\n<code>here</code> with the <a href=\"/en-US-v0.13.1/reference/introspection/location/#definitions-page-numbering\"><code>page-numbering</code></a> method.</p>\n<h2 id=\"columns\">Add columns</h2>\n<p>Add columns to your document to fit more on a page while maintaining legible\nline lengths. Columns are vertical blocks of text which are separated by some\nwhitespace. This space is called the gutter.</p>\n<p>To lay out your content in columns, just specify the desired number of columns\nin a <a href=\"/en-US-v0.13.1/reference/layout/page/#parameters-columns\"><code>page</code></a> set rule. To adjust the amount of space between\nthe columns, add a set rule on the <a href=\"/en-US-v0.13.1/reference/layout/columns/\"><code>columns</code> function</a>, specifying\nthe <code>gutter</code> parameter.</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>columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">columns</span><span class=\"typ-punct\">(</span>gutter<span class=\"typ-punct\">:</span> <span class=\"typ-num\">12pt</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">30</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/160439991e4175b3b075a3ef990b2cfb.png\" alt=\"Preview\"></div></div>\n<p>Very commonly, scientific papers have a single-column title and abstract, while\nthe main body is set in two-columns. To achieve this effect, Typst's <a href=\"/en-US-v0.13.1/reference/layout/place/\"><code>place</code>\nfunction</a> can temporarily escape the two-column layout by specifying\n<code>float: <span class=\"typ-key\">true</span></code> and <code>scope: <span class=\"typ-str\">&quot;parent&quot;</span></code>:</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>columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">par</span><span class=\"typ-punct\">(</span>justify<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">place</span><span class=\"typ-punct\">(</span>\n  top <span class=\"typ-op\">+</span> center<span class=\"typ-punct\">,</span>\n  float<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">,</span>\n  scope<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;parent&quot;</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1.4em</span><span class=\"typ-punct\">,</span> weight<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;bold&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    Impacts of Odobenidae\n  <span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">== About seals in the wild</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">80</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/af081b829515e76f76dc6155ffd6c211.png\" alt=\"Preview\"></div></div>\n<p><em>Floating placement</em> refers to elements being pushed to the top or bottom of the\ncolumn or page, with the remaining content flowing in between. It is also\nfrequently used for <a href=\"/en-US-v0.13.1/reference/model/figure/#parameters-placement\">figures</a>.</p>\n<h3 id=\"columns-anywhere\">Use columns anywhere in your document</h3>\n<p>To create columns within a nested layout, e.g. within a rectangle, you can use\nthe <a href=\"/en-US-v0.13.1/reference/layout/columns/\"><code>columns</code> function</a> directly. However, it really should only be\nused within nested layouts. At the page-level, the page set rule is preferable\nbecause it has better interactions with things like page-level floats,\nfootnotes, and line numbers.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>\n  width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">6cm</span><span class=\"typ-punct\">,</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">3.5cm</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">columns</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> gutter<span class=\"typ-punct\">:</span> <span class=\"typ-num\">12pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    In the dimly lit gas station,\n    a solitary taxi stood silently,\n    its yellow paint fading with\n    time. Its windows were dark,\n    its engine idle, and its tires\n    rested on the cold concrete.\n  <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/e1a95ddb12510e9685331557bbb6a251.png\" alt=\"Preview\"></div></div>\n<h3 id=\"balanced-columns\">Balanced columns</h3>\n<p>If the columns on the last page of a document differ greatly in length, they may\ncreate a lopsided and unappealing layout. That's why typographers will often\nequalize the length of columns on the last page. This effect is called balancing\ncolumns. Typst cannot yet balance columns automatically. However, you can\nbalance columns manually by placing <a href=\"/en-US-v0.13.1/reference/layout/colbreak/\"><code><span class=\"typ-func\">#</span><span class=\"typ-func\">colbreak</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span></code></a> at an\nappropriate spot in your markup, creating the desired column break manually.</p>\n<h2 id=\"one-off-modifications\">One-off modifications</h2>\n<p>You do not need to override your page settings if you need to insert a single\npage with a different setup. For example, you may want to insert a page that's\nflipped to landscape to insert a big table or change the margin and columns for\nyour title page. In this case, you can call <a href=\"/en-US-v0.13.1/reference/layout/page/\"><code>page</code></a> as a function with\nyour content as an argument and the overrides as the other arguments. This will\ninsert enough new pages with your overridden settings to place your content on\nthem. Typst will revert to the page settings from the set rule after the call.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>flipped<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n  <span class=\"typ-heading\">= Multiplication table</span>\n\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">table</span><span class=\"typ-punct\">(</span>\n    columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">5</span> <span class=\"typ-op\">*</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n    <span class=\"typ-op\">..</span><span class=\"typ-key\">for</span> x <span class=\"typ-key\">in</span> <span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">10</span><span class=\"typ-punct\">)</span> <span class=\"typ-punct\">{</span>\n      <span class=\"typ-key\">for</span> y <span class=\"typ-key\">in</span> <span class=\"typ-func\">range</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">6</span><span class=\"typ-punct\">)</span> <span class=\"typ-punct\">{</span>\n        <span class=\"typ-punct\">(</span><span class=\"typ-func\">str</span><span class=\"typ-punct\">(</span>x<span class=\"typ-op\">*</span>y<span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span><span class=\"typ-punct\">)</span>\n      <span class=\"typ-punct\">}</span>\n    <span class=\"typ-punct\">}</span>\n  <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/539141c80d3b642706762cd1fd76ed13.png\" alt=\"Preview\"></div></div>"}}