{"route":"/en-US-v0.14.1/tutorial/advanced-styling/","title":"Advanced Styling","description":"Typst's tutorial.","part":null,"outline":[{"id":"guidelines","name":"Guidelines","children":[]},{"id":"set-rules","name":"Set Rules","children":[]},{"id":"title-and-abstract","name":"Title And Abstract","children":[]},{"id":"columns-and-headings","name":"Columns And Headings","children":[]},{"id":"review","name":"Review","children":[]}],"body":{"kind":"html","content":"<h1>Advanced Styling</h1>\n<p>In the previous two chapters of this tutorial, you have learned how to write a\ndocument in Typst and how to change its formatting. The report you wrote\nthroughout the last two chapters got a straight A and your supervisor wants to\nbase a conference paper on it! The report will of course have to comply with the\nconference's style guide. Let's see how we can achieve that.</p>\n<p>Before we start, let's create a team, invite your supervisor and add them to the\nteam. You can do this by going back to the app dashboard with the back icon in\nthe top left corner of the editor. Then, choose the plus icon in the left\ntoolbar and create a team. Finally, click on the new team and go to its settings\nby clicking 'manage team' next to the team name. Now you can invite your\nsupervisor by email.</p>\n<p><img src=\"/en-US-v0.14.1/assets/3-advanced-team-settings.png\" alt=\"The team settings\" /></p>\n<p>Next, move your project into the team: Open it, going to its settings by\nchoosing the gear icon in the left toolbar and selecting your new team from the\nowners dropdown. Don't forget to save your changes!</p>\n<p>Now, your supervisor can also edit the project and you can both see the changes\nin real time. You can join our <a href=\"https://discord.gg/2uDybryKPe\">Discord server</a>\nto find other users and try teams with them!</p>\n<h2 id=\"guidelines\">The conference guidelines</h2>\n<p>The layout guidelines are available on the conference website. Let's take a look\nat them:</p>\n<ul>\n<li>The font should be an 11pt serif font</li>\n<li>The title should be in 17pt and bold</li>\n<li>The paper contains a single-column abstract and two-column main text</li>\n<li>The abstract should be centered</li>\n<li>The main text should be justified</li>\n<li>First level section headings should be 13pt, centered, and rendered in small\ncapitals</li>\n<li>Second level headings are run-ins, italicized and have the same size as the\nbody text</li>\n<li>Finally, the pages should be US letter sized, numbered in the center of the\nfooter and the top right corner of each page should contain the title of the\npaper</li>\n</ul>\n<p>We already know how to do many of these things, but for some of them, we'll need\nto learn some new tricks.</p>\n<h2 id=\"set-rules\">Writing the right set rules</h2>\n<p>Let's start by writing some set rules for the document.</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>\n  paper<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;us-letter&quot;</span><span class=\"typ-punct\">,</span>\n  header<span class=\"typ-punct\">:</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>right<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    A Fluid Dynamic Model for\n    Glacier Flow\n  <span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1&quot;</span><span class=\"typ-punct\">,</span>\n<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<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>\n  font<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;Libertinus Serif&quot;</span><span class=\"typ-punct\">,</span>\n  size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">11pt</span><span class=\"typ-punct\">,</span>\n<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\">600</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/39e9b50304410f17939935dca5419e30.png\" alt=\"Preview\"></div></div>\n<p>You are already familiar with most of what is going on here. We set the text\nsize to <code><span class=\"typ-num\">11pt</span></code> and the font to Libertinus Serif. We also enable paragraph\njustification and set the page size to US letter.</p>\n<p>The <code>header</code> argument is new: With it, we can provide content to fill the top\nmargin of every page. In the header, we specify our paper's title as requested\nby the conference style guide. We use the <code>align</code> function to align the text to\nthe right.</p>\n<p>Last but not least is the <code>numbering</code> argument. Here, we can provide a\n<a href=\"/en-US-v0.14.1/reference/model/numbering/\">numbering pattern</a> that defines how to number the pages. By\nsetting it to <code><span class=\"typ-str\">&quot;1&quot;</span></code>, Typst only displays the bare page number. Setting it to\n<code><span class=\"typ-str\">&quot;(1/1)&quot;</span></code> would have displayed the current page and total number of pages\nsurrounded by parentheses. And we could even have provided a completely custom\nfunction here to format things to our liking.</p>\n<h2 id=\"title-and-abstract\">Creating a title and abstract</h2>\n<p>Now, let's add a title and an abstract. We'll start with the title. Typst comes\nwith a <a href=\"/en-US-v0.14.1/reference/model/title/\" title=\"`title`\"><code>title</code></a> function. Let's start by providing our title as an argument:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">title</span><span class=\"typ-punct\">[</span>\n  A Fluid Dynamic Model\n  for Glacier Flow\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/7c3916cddb3a9663f05c41ab1762416b.png\" alt=\"Preview\"></div></div>\n<p>You can see that the title is already boldfaced and has some space around it.\nHowever, it is left-aligned and not exactly 17pt large. Hence, we need to adjust\nits appearance. The title function does not come with any arguments for\nfont or text size we could set. Instead, these properties are defined on the\n<code>text</code> and <code>align</code> functions.</p>\n<div class=\"info-box\">\n<p>What is the difference between what the <code>title</code> function inserted and the\nheadings we produced with equals signs?</p>\n<p>Headings, even first-level headings, can appear multiple times in your document\nwhereas a title only appears once, usually at the beginning. Differentiating\nbetween the two helps Typst make your document accessible for users of\nAssistive Technology such as screen readers.</p>\n</div>\n<p>When we want to customize the properties of some element inside of another kind\nof element, we can use show-set rules. First, we use <code>show</code> to select which\nelement we want to customize. We call this a <em>selector.</em> Then, we type a colon.\nNext, we write the set rule that should apply to elements matching the selector.\nSummarized, the syntax looks like this:</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">your-selector</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">some-element</span><span class=\"typ-punct\">(</span><span class=\"typ-comment\">/* ... */</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>Let's recall: We want to center-align the title and make it 17pt large. Hence,\nwe need two show-set rules:</p>\n<ul>\n<li>One with the selector <code>title</code> and the rule <code><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">17pt</span><span class=\"typ-punct\">)</span></code></li>\n<li>One with the selector <code>title</code> and the rule <code><span class=\"typ-key\">set</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span></code></li>\n</ul>\n<p>Our example now looks like this:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">title</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">17pt</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">title</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">title</span><span class=\"typ-punct\">[</span>\n  A Fluid Dynamic Model\n  for Glacier Flow\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/c2969040db7c93ade24a461b5ba45124.png\" alt=\"Preview\"></div></div>\n<p>This looks right. Let's also add the author list: Since we are writing this\npaper together with our supervisor, we'll add our own and their name.</p>\n<div class=\"previewed-code\"><pre><code>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">grid</span><span class=\"typ-punct\">(</span>\n  columns<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    Therese Tungsten <span class=\"typ-escape\">\\</span>\n    Artos Institute <span class=\"typ-escape\">\\</span>\n    <span class=\"typ-func\">#</span><span class=\"typ-func\">link</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;mailto:tung@artos.edu&quot;</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    Dr. John Doe <span class=\"typ-escape\">\\</span>\n    Artos Institute <span class=\"typ-escape\">\\</span>\n    <span class=\"typ-func\">#</span><span class=\"typ-func\">link</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;mailto:doe@artos.edu&quot;</span><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.14.1/assets/4790f48caf3dcd84b8fea8c0326a2aee.png\" alt=\"Preview\"></div></div>\n<p>The two author blocks are laid out next to each other. We use the <a href=\"/en-US-v0.14.1/reference/layout/grid/\" title=\"`grid`\"><code>grid</code></a>\nfunction to create this layout. With a grid, we can control exactly how large\neach column is and which content goes into which cell. The <code>columns</code> argument\ntakes an array of <a href=\"/en-US-v0.14.1/reference/layout/relative/\">relative lengths</a> or <a href=\"/en-US-v0.14.1/reference/layout/fraction/\">fractions</a>. In\nthis case, we passed it two equal fractional sizes, telling it to split the\navailable space into two equal columns. We then passed two content arguments to\nthe grid function. The first with our own details, and the second with our\nsupervisors'. We again use the <code>align</code> function to center the content within the\ncolumn. The grid takes an arbitrary number of content arguments specifying the\ncells. Rows are added automatically, but they can also be manually sized with\nthe <code>rows</code> argument.</p>\n<p>Looking at the authors and the title, they are a bit too close together. You can\naddress this by using another show-set rule to configure the space below the\ntitle. The title, the grid, paragraphs, and all other elements that Typst\narranges from the top to the bottom of the page are called <em>blocks.</em> Each block\nis controlled by the <a href=\"/en-US-v0.14.1/reference/layout/block/\" title=\"`block`\"><code>block</code></a> function. It controls behaviors like their\ndistance and whether a block can contain a page break. That means that we can\nwrite another show-set rule that selects the title to set the block spacing:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">title</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">17pt</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">title</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">title</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">block</span><span class=\"typ-punct\">(</span>below<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.2em</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">title</span><span class=\"typ-punct\">[</span>\n  A Fluid Dynamic Model\n  for Glacier Flow\n<span class=\"typ-punct\">]</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">grid</span><span class=\"typ-punct\">(</span>\n  <span class=\"typ-comment\">// ...</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/bba2b16bdf14870a0d236a8c3a62a89f.png\" alt=\"Preview\"></div></div>\n<p>With this show-set rule, we overrode the spacing below the title. We have used\nthe <code>em</code> unit: It allows us to express lengths as multiples of the font size.\nHere, we used it to space the title and the author list exactly 1.2× the font\nsize apart. Now, let's add the abstract. Remember that the conference wants the\nabstract to be set ragged and centered.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-escape\">...</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</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\">false</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-strong\">*Abstract*</span> <span class=\"typ-escape\">\\</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<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/41f337ec4affe1f096129a26c54f7f2e.png\" alt=\"Preview\"></div></div>\n<p>Well done! One notable thing is that we used a set rule within the content\nargument of <code>align</code> to turn off justification for the abstract. This does not\naffect the remainder of the document even though it was specified after the\nfirst set rule because content blocks <em>scope</em> styling. Anything set within a\ncontent block will only affect the content within that block.</p>\n<p>Another tweak could be to remove the duplication between the header and the\ntitle element's argument. Since they share the title, it would be convenient to\nstore it in a place designed to hold metadata about the document. We would then\nneed a way to retrieve the title in both places. The <code>document</code> element can help\nus with the former: By using it in a set rule, we can store document metadata\nlike title, description, and keywords.</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">document</span><span class=\"typ-punct\">(</span>title<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>A Fluid Dynamic Model for Glacier Flow<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>When exporting a PDF, the title set here will appear in the title bar of your\nPDF reader. Your operating system will also use this title to make the file\nretrievable with search. Last but not least, it contributes to making your\ndocument more accessible and is required if you choose to comply with PDF/UA, a\nPDF standard focused on accessibility.</p>\n<p>Now, we need a way to retrieve the value we set in the main title and the\nheader. Because the <code>title</code> function is designed to work together with the\n<code>document</code> element, calling it with no arguments will just print the title. For\nthe header, we will need to be more explicit: Because Typst has no way of\nknowing that we want to insert the title there, we will need to tell it to do so\nmanually.</p>\n<p>Using <em>context,</em> we can retrieve the contents of any values we have set on\nelements before. When we use the <code><span class=\"typ-key\">context</span></code> keyword, we can access any property\nof any element, including the document element's title property. Its use looks\nlike this:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">document</span><span class=\"typ-punct\">(</span>title<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>\n  A Fluid Dynamic Model\n  for Glacier Flow\n<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-escape\">...</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  header<span class=\"typ-punct\">:</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>\n    right <span class=\"typ-op\">+</span> horizon<span class=\"typ-punct\">,</span>\n    <span class=\"typ-comment\">// Retrieve the document</span>\n    <span class=\"typ-comment\">// element&#39;s title property.</span>\n    <span class=\"typ-key\">context</span> document<span class=\"typ-punct\">.</span>title<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-op\">..</span><span class=\"typ-punct\">.</span>\n<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">title</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-escape\">...</span>\n\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/15b893af691b49beed091b0e62baa2df.png\" alt=\"Preview\"></div></div>\n<p>First, notice how we called the title function with empty, round\nparentheses. Because no argument was passed, it defaulted to what we set for the\ndocument element above. The distinction between empty round and empty square\nbrackets is important: While empty round brackets show that you are passing\nnothing, empty square brackets mean that you are passing one argument: an empty\ncontent block. If called that way, the title would have no visible content.</p>\n<p>Next, take a look at the header. Instead of the title in square parentheses, we\nused the context keyword to access the document title. This inserted exactly\nwhat we set above. The role of context is not limited to accessing properties:\nWith it, you can check if some elements are present in the document, measure the\nphysical dimensions of others, and more. Using context, you can build powerful\ntemplates that react to the preferences of the end-user.</p>\n<div class=\"info-box\">\n<details>\n<summary>\nWhy is the context keyword required to access element properties?\n</summary>\n<p>Normally, when we access a variable, we know exactly what its value is going to\nbe:</p>\n<ul>\n<li>The variable could be a constant built into Typst, like <code><span class=\"typ-pol\">#</span><span class=\"typ-pol\">sym</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">pi</span></code></li>\n<li>The variable could be defined by an argument</li>\n<li>The variable could be defined or overwritten in the current scope</li>\n</ul>\n<p>However, sometimes, that's not enough. In this chapter of the tutorial, we have\ninserted a page header with the title. Even though we pass only one piece of\ncontent for the header, we may want different pages to have different headers.\nFor example, we may want to print the chapter name or use the page number. When\nwe use context, we can write a single context block that tells Typst to take a\nlook at where it's inserted, look for the last heading, the current page number,\nor anything else, and go from there. That means that the same context block,\ninserted on different pages, can produce different output.</p>\n<p>For more information, read up on context <a href=\"/en-US-v0.14.1/reference/context/\">in its docs</a> after\ncompleting this tutorial.</p>\n</details>\n</div>\n<h2 id=\"columns-and-headings\">Adding columns and headings</h2>\n<p>The paper above unfortunately looks like a wall of lead. To fix that, let's add\nsome headings and switch our paper to a two-column layout. Fortunately, that's\neasy to do: We just need to amend our <code>page</code> set rule with the <code>columns</code>\nargument.</p>\n<p>By adding <code>columns: <span class=\"typ-num\">2</span></code> to the argument list, we have wrapped the whole\ndocument in two columns. However, that would also affect the title and authors\noverview. To keep them spanning the whole page, we can wrap them in a function\ncall to <a href=\"/en-US-v0.14.1/reference/layout/place/\"><code>place</code></a>. Place expects an alignment and the content it\nshould place as positional arguments. Using the named <code>scope</code> argument, we can\ndecide if the items should be placed relative to the current column or its\nparent (the page). There is one more thing to configure: If no other arguments\nare provided, <code>place</code> takes its content out of the flow of the document and\npositions it over the other content without affecting the layout of other\ncontent in its container:</p>\n<div class=\"previewed-code\"><pre><code><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  <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> black<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\">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.14.1/assets/df4b3b714f57dfa956dbceab25713747.png\" alt=\"Preview\"></div></div>\n<p>If we hadn't used <code>place</code> here, the square would be in its own line, but here\nit overlaps the few lines of text following it. Likewise, that text acts as if\nthere was no square. To change this behavior, we can pass the argument\n<code>float: <span class=\"typ-key\">true</span></code> to ensure that the space taken up by the placed item at the top\nor bottom of the page is not occupied by any other content.</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>\n  paper<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;us-letter&quot;</span><span class=\"typ-punct\">,</span>\n  header<span class=\"typ-punct\">:</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>\n    right <span class=\"typ-op\">+</span> horizon<span class=\"typ-punct\">,</span>\n    <span class=\"typ-key\">context</span> document<span class=\"typ-punct\">.</span>title<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;1&quot;</span><span class=\"typ-punct\">,</span>\n  columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span>\n<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  clearance<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2em</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n  <span class=\"typ-escape\">...</span>\n\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">par</span><span class=\"typ-punct\">(</span>justify<span class=\"typ-punct\">:</span> <span class=\"typ-key\">false</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>\n    <span class=\"typ-strong\">*Abstract*</span> <span class=\"typ-escape\">\\</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  <span class=\"typ-punct\">]</span>\n<span class=\"typ-punct\">]</span>\n\n<span class=\"typ-heading\">= Introduction</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">300</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Related Work</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">200</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/7423f42127d2f3c6b66ce2764863df00.png\" alt=\"Preview\"></div></div>\n<p>In this example, we also used the <code>clearance</code> argument of the <code>place</code> function\nto provide the space between it and the body instead of using the <a href=\"/en-US-v0.14.1/reference/layout/v/\"><code>v</code></a>\nfunction. We can also remove the explicit <code><span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">,</span> <span class=\"typ-op\">..</span><span class=\"typ-punct\">)</span></code> calls around the\nvarious parts since they inherit the center alignment from the placement.</p>\n<p>Now there is only one thing left to do: Style our headings. We need to make them\ncentered and use small capitals. These properties are not available on the\n<code>heading</code> function, so we will need to write a few show-set rules and a show\nrule:</p>\n<ul>\n<li>A show-set rule to make headings center-aligned</li>\n<li>A show-set rule to make headings 13pt large and use the regular weight</li>\n<li>A show rule to wrap the headings in a call to the <code>smallcaps</code> function</li>\n</ul>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>\n  size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">13pt</span><span class=\"typ-punct\">,</span>\n  weight<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;regular&quot;</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">heading</span><span class=\"typ-punct\">:</span> <span class=\"typ-func\">smallcaps</span>\n\n<span class=\"typ-escape\">...</span>\n\n<span class=\"typ-heading\">= Introduction</span>\n<span class=\"typ-escape\">...</span>\n\n<span class=\"typ-heading\">== Motivation</span>\n<span class=\"typ-escape\">...</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/484bf0b02bc25230ddf8cb08f231826c.png\" alt=\"Preview\"></div></div>\n<p>This looks great! We used show rules that apply to all headings. In the final\nshow rule, we applied the <code>smallcaps</code> function to the complete heading. As we\nwill see in the next example, we can also provide a custom rule to completely\noverride the default look of headings.</p>\n<p>The only remaining problem is that all headings look the same now. The\n&quot;Motivation&quot; and &quot;Problem Statement&quot; subsections ought to be italic run-in\nheaders, but right now, they look indistinguishable from the section headings.\nWe can fix that by using a <code>where</code> selector on our show rule: This is a\n<a href=\"/en-US-v0.14.1/reference/scripting/#methods\">method</a> we can call on headings (and other elements) that\nallows us to filter them by their properties. We can use it to differentiate\nbetween section and subsection headings:</p>\n<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\">1</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">align</span><span class=\"typ-punct\">(</span>center<span class=\"typ-punct\">)</span>\n<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\">1</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>size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">13pt</span><span class=\"typ-punct\">,</span> weight<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;regular&quot;</span><span class=\"typ-punct\">)</span>\n<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\">1</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">:</span> <span class=\"typ-func\">smallcaps</span>\n\n<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>\n  size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">11pt</span><span class=\"typ-punct\">,</span>\n  weight<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;regular&quot;</span><span class=\"typ-punct\">,</span>\n  style<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;italic&quot;</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n<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> it <span class=\"typ-op\">=&gt;</span> <span class=\"typ-punct\">{</span>\n  it<span class=\"typ-punct\">.</span>body <span class=\"typ-op\">+</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/c988e50827cad35a48eef259d8ef12ae.png\" alt=\"Preview\"></div></div>\n<p>In this example, we first scope our previous rules to first-level headings by\nusing <code>.<span class=\"typ-func\">where</span><span class=\"typ-punct\">(</span>level<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span></code> to make the selector more specific. Then, we add a\nshow-set rule for the second heading level. Finally, we need a show rule with a\ncustom function: Headings enclose their contents with a block by default. This\nhas the effect that the heading gets its own line. However, we want it to run\ninto the text, so we need to provide our own show rule to get rid of this block.</p>\n<p>We provide the rule with a function that takes the heading as a parameter.\nThis parameter is conventionally called <code>it</code>, but can have another name. The\nparameter can be used as content and will just display the whole default\nheading. Alternatively, when we want to build our own heading instead, we can\nuse its fields like <code>body</code>, <code>numbering</code>, and <code>level</code> to compose a custom look.\nHere, we are just printing the body of the heading with a trailing dot and leave\nout the block that the built-in show rule produces. Note that this heading will\nno longer react to set rules for heading numbering and similar because we did\nnot explicitly use <code>it.numbering</code> in the show rule. If you are writing show\nrules like this and want the document to remain customizable, you will need to\ntake these fields into account.</p>\n<p>This looks great! We wrote show rules that selectively apply to the first and\nsecond level headings. We used a <code>where</code> selector to filter the headings by\ntheir level. We then rendered the subsection headings as run-ins. We\nalso automatically add a period to the end of the subsection headings.</p>\n<p>Let's review the conference's style guide:</p>\n<ul>\n<li>The font should be an 11pt serif font ✓</li>\n<li>The title should be in 17pt and bold ✓</li>\n<li>The paper contains a single-column abstract and two-column main text ✓</li>\n<li>The abstract should be centered ✓</li>\n<li>The main text should be justified ✓</li>\n<li>First level section headings should be centered, rendered in small caps and in\n13pt ✓</li>\n<li>Second level headings are run-ins, italicized and have the same size as the\nbody text ✓</li>\n<li>Finally, the pages should be US letter sized, numbered in the center and the\ntop right corner of each page should contain the title of the paper ✓</li>\n</ul>\n<p>We are now in compliance with all of these styles and can submit the paper to\nthe conference! The finished paper looks like this:</p>\n<p><img\n  src=\"/en-US-v0.14.1/assets/3-advanced-paper.png\"\n  alt=\"The finished paper\"\n  style=\"box-shadow: 0 4px 12px rgb(89 85 101 / 20%); width: 500px; max-width: 100%; display: block; margin: 24px auto;\"\n></p>\n<h2 id=\"review\">Review</h2>\n<p>You have now learned how to create titles, headers, and footers, how to use\nfunctions, show-set rules, and scopes to locally override styles, how to create\nmore complex layouts with the <a href=\"/en-US-v0.14.1/reference/layout/grid/\" title=\"`grid`\"><code>grid</code></a> function, how to access element\nproperties with context, and how to write show rules for individual functions,\nand the whole document. You also learned how to use the <a href=\"/en-US-v0.14.1/reference/styling/#show-rules\"><code>where</code>\nselector</a> to filter the headings by their level.</p>\n<p>The paper was a great success! You've met a lot of like-minded researchers at\nthe conference and are planning a project which you hope to publish at the same\nvenue next year. You'll need to write a new paper using the same style guide\nthough, so maybe now you want to create a time-saving template for you and your\nteam?</p>\n<p>In the next section, we will learn how to create templates that can be reused in\nmultiple documents. This is a more advanced topic, so feel free to come back\nto it later if you don't feel up to it right now.</p>"}}