{"route":"/en-US-v0.14.1/guides/for-latex-users/","title":"For LaTeX Users","description":"Are you a LaTeX user? This guide explains the differences and\nsimilarities between Typst and LaTeX so you can get started quickly.\n","part":null,"outline":[{"id":"installation","name":"Installation","children":[]},{"id":"getting-started","name":"Getting Started","children":[]},{"id":"elements","name":"Elements","children":[]},{"id":"commands","name":"Commands","children":[{"id":"arguments","name":"Arguments","children":[]},{"id":"data-types","name":"Data types","children":[]},{"id":"rules","name":"Rules","children":[]}]},{"id":"templates","name":"Templates","children":[]},{"id":"packages","name":"Packages","children":[]},{"id":"maths","name":"Maths","children":[]},{"id":"latex-look","name":"Latex Look","children":[]},{"id":"bibliographies","name":"Bibliographies","children":[]},{"id":"limitations","name":"Limitations","children":[]}],"body":{"kind":"html","content":"<h1>Guide for LaTeX Users</h1>\n<p>This page is a good starting point if you have used LaTeX before and want to try\nout Typst. We will explore the main differences between these two systems from a\nuser perspective. Although Typst is not built upon LaTeX and has a different\nsyntax, you will learn how to use your LaTeX skills to get a head start.</p>\n<p>Just like LaTeX, Typst is a markup-based typesetting system: You compose your\ndocument in a text file and mark it up with commands and other syntax. Then, you\nuse a compiler to typeset the source file into a PDF. However, Typst also\ndiffers from LaTeX in several aspects: For one, Typst uses more dedicated syntax\n(like you may know from Markdown) for common tasks. Typst's commands are also\nmore principled: They all work the same, so unlike in LaTeX, you just need to\nunderstand a few general concepts instead of learning different conventions for\neach package. Moreover Typst compiles faster than LaTeX: Compilation usually\ntakes milliseconds, not seconds, so the web app and the compiler can both\nprovide instant previews.</p>\n<p>In the following, we will cover some of the most common questions a user\nswitching from LaTeX will have when composing a document in Typst. If you prefer\na step-by-step introduction to Typst, check out our <a href=\"/en-US-v0.14.1/tutorial/\" title=\"tutorial\">tutorial</a>.</p>\n<h2 id=\"installation\">Installation</h2>\n<p>You have two ways to use Typst: In <a href=\"https://typst.app/signup/\">our web app</a> or\nby <a href=\"https://github.com/typst/typst/releases\">installing the compiler</a> on your\ncomputer. When you use the web app, we provide a batteries-included\ncollaborative editor and run Typst in your browser, no installation required.</p>\n<p>If you choose to use Typst on your computer instead, you can download the\ncompiler as a single, small binary which any user can run, no root privileges\nrequired. Unlike popular LaTeX distributions such as TeX Live, packages are\ndownloaded when you first use them and then cached locally, keeping your Typst\ninstallation lean. You can use your own editor and decide where to store your\nfiles with the local compiler.</p>\n<h2 id=\"getting-started\">How do I create a new, empty document?</h2>\n<p>That's easy. You just create a new, empty text file (the file extension is\n<code>.typ</code>). No boilerplate is needed to get started. Simply start by writing your\ntext. It will be set on an empty A4-sized page. If you are using the web app,\nclick &quot;+ Empty document&quot; to create a new project with a file and enter the\neditor. <a href=\"/en-US-v0.14.1/reference/model/parbreak/\">Paragraph breaks</a> work just as they do in LaTeX, just use a\nblank line.</p>\n<div class=\"previewed-code\"><pre><code>Hey there!\n\nHere are two paragraphs. The\noutput is shown to the right.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/d576b17fe173f96eda81c5ea2a62f28d.png\" alt=\"Preview\"></div></div>\n<p>If you want to start from an preexisting LaTeX document instead, you can use\n<a href=\"https://pandoc.org\">Pandoc</a> to convert your source code to Typst markup. This\nconversion is also built into our web app, so you can upload your <code>.tex</code> file to\nstart your project in Typst.</p>\n<h2 id=\"elements\">How do I create section headings, emphasis, ...?</h2>\n<p>LaTeX uses the command <code>\\section</code> to create a section heading. Nested headings\nare indicated with <code>\\subsection</code>, <code>\\subsubsection</code>, etc. Depending on your\ndocument class, there is also <code>\\part</code> or <code>\\chapter</code>.</p>\n<p>In Typst, <a href=\"/en-US-v0.14.1/reference/model/heading/\">headings</a> are less verbose: You prefix the line with the\nheading on it with an equals sign and a space to get a first-order heading:\n<code><span class=\"typ-heading\">= Introduction</span></code>. If you need a second-order heading, you use two equals\nsigns: <code><span class=\"typ-heading\">== In this paper</span></code>. You can nest headings as deeply as you'd like by\nadding more equals signs.</p>\n<p>Emphasis (usually rendered as italic text) is expressed by enclosing text in\n<code><span class=\"typ-emph\">_underscores_</span></code> and strong emphasis (usually rendered in boldface) by using\n<code><span class=\"typ-strong\">*stars*</span></code> instead.</p>\n<p>Here is a list of common markup commands used in LaTeX and their Typst\nequivalents. You can also check out the <a href=\"/en-US-v0.14.1/reference/syntax/\">full syntax cheat sheet</a>.</p>\n<table><thead><tr><th style=\"text-align: left\">Element</th><th style=\"text-align: left\">LaTeX</th><th style=\"text-align: left\">Typst</th><th style=\"text-align: left\">See</th></tr></thead><tbody>\n<tr><td style=\"text-align: left\">Strong emphasis</td><td style=\"text-align: left\"><code>\\textbf{strong}</code></td><td style=\"text-align: left\"><code><span class=\"typ-strong\">*strong*</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/strong/\" title=\"`strong`\"><code>strong</code></a></td></tr>\n<tr><td style=\"text-align: left\">Emphasis</td><td style=\"text-align: left\"><code>\\emph{emphasis}</code></td><td style=\"text-align: left\"><code><span class=\"typ-emph\">_emphasis_</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/emph/\" title=\"`emph`\"><code>emph</code></a></td></tr>\n<tr><td style=\"text-align: left\">Link</td><td style=\"text-align: left\"><code>\\url{https://typst.app}</code></td><td style=\"text-align: left\"><code><span class=\"typ-link\">https://typst.app/</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/link/\" title=\"`link`\"><code>link</code></a></td></tr>\n<tr><td style=\"text-align: left\">Label</td><td style=\"text-align: left\"><code>\\label{intro}</code></td><td style=\"text-align: left\"><code><span class=\"typ-label\">&lt;intro&gt;</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/foundations/label/\" title=\"`label`\"><code>label</code></a></td></tr>\n<tr><td style=\"text-align: left\">Reference</td><td style=\"text-align: left\"><code>\\ref{intro}</code></td><td style=\"text-align: left\"><code><span class=\"typ-ref\">@intro</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/ref/\" title=\"`ref`\"><code>ref</code></a></td></tr>\n<tr><td style=\"text-align: left\">Citation</td><td style=\"text-align: left\"><code>\\cite{humphrey97}</code></td><td style=\"text-align: left\"><code><span class=\"typ-ref\">@humphrey97</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/cite/\" title=\"`cite`\"><code>cite</code></a></td></tr>\n<tr><td style=\"text-align: left\">Monospace (typewriter)</td><td style=\"text-align: left\"><code>\\texttt{mono}</code></td><td style=\"text-align: left\"><code>text</code> or <code>mono</code> functions</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/text/\" title=\"`text`\"><code>text</code></a>, <a href=\"/en-US-v0.14.1/reference/math/variants/#functions-mono\"><code>mono</code></a></td></tr>\n<tr><td style=\"text-align: left\">Code</td><td style=\"text-align: left\"><code>lstlisting</code> environment</td><td style=\"text-align: left\"><code><span class=\"typ-raw\">`print(f&quot;{x}&quot;)`</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/raw/\" title=\"`raw`\"><code>raw</code></a></td></tr>\n<tr><td style=\"text-align: left\">Verbatim</td><td style=\"text-align: left\"><code>verbatim</code> environment</td><td style=\"text-align: left\"><code><span class=\"typ-raw\">`#typst-code()`</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/raw/\" title=\"`raw`\"><code>raw</code></a></td></tr>\n<tr><td style=\"text-align: left\">Bullet list</td><td style=\"text-align: left\"><code>itemize</code> environment</td><td style=\"text-align: left\"><code><span class=\"typ-marker\">-</span> List</code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/list/\" title=\"`list`\"><code>list</code></a></td></tr>\n<tr><td style=\"text-align: left\">Numbered list</td><td style=\"text-align: left\"><code>enumerate</code> environment</td><td style=\"text-align: left\"><code><span class=\"typ-marker\">+</span> List</code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/enum/\" title=\"`enum`\"><code>enum</code></a></td></tr>\n<tr><td style=\"text-align: left\">Term list</td><td style=\"text-align: left\"><code>description</code> environment</td><td style=\"text-align: left\"><code><span class=\"typ-marker\">/</span> <span class=\"typ-term\">Term</span><span class=\"typ-punct\">:</span> List</code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/terms/\" title=\"`terms`\"><code>terms</code></a></td></tr>\n<tr><td style=\"text-align: left\">Figure</td><td style=\"text-align: left\"><code>figure</code> environment</td><td style=\"text-align: left\"><code>figure</code> function</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/figure/\" title=\"`figure`\"><code>figure</code></a></td></tr>\n<tr><td style=\"text-align: left\">Table</td><td style=\"text-align: left\"><code>table</code> environment</td><td style=\"text-align: left\"><code>table</code> function</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/table/\" title=\"`table`\"><code>table</code></a></td></tr>\n<tr><td style=\"text-align: left\">Equation</td><td style=\"text-align: left\"><code>$x$</code>, <code>align</code> / <code>equation</code> environments</td><td style=\"text-align: left\"><code><span class=\"typ-math-delim\">$</span>x<span class=\"typ-math-delim\">$</span></code>, <code><span class=\"typ-math-delim\">$</span> x = y <span class=\"typ-math-delim\">$</span></code></td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/math/equation/\"><code>equation</code></a></td></tr>\n</tbody></table>\n<p><a href=\"/en-US-v0.14.1/reference/model/list/\">Lists</a> do not rely on environments in Typst. Instead, they have\nlightweight syntax like headings. To create an unordered list (<code>itemize</code>),\nprefix each line of an item with a hyphen:</p>\n<div class=\"previewed-code\"><pre><code>To write this list in Typst<span class=\"typ-escape\">...</span>\n\n<span class=\"typ-raw\">```latex\n\\begin{itemize}\n  \\item Fast\n  \\item Flexible\n  \\item Intuitive\n\\end{itemize}\n```</span>\n\n<span class=\"typ-escape\">...</span>just type this:\n\n<span class=\"typ-marker\">-</span> Fast\n<span class=\"typ-marker\">-</span> Flexible\n<span class=\"typ-marker\">-</span> Intuitive\n\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/12dc490699b39fe43771a51e9bcf6639.png\" alt=\"Preview\"></div></div>\n<p>Nesting lists works just by using proper indentation. Adding a blank line in\nbetween items results in a more <a href=\"/en-US-v0.14.1/reference/model/list/#parameters-tight\">widely</a> spaced list.</p>\n<p>To get a <a href=\"/en-US-v0.14.1/reference/model/enum/\">numbered list</a> (<code>enumerate</code>) instead, use a <code>+</code> instead of the\nhyphen. For a <a href=\"/en-US-v0.14.1/reference/model/terms/\">term list</a> (<code>description</code>), write <code><span class=\"typ-marker\">/</span> <span class=\"typ-term\">Term</span><span class=\"typ-punct\">:</span> Description</code>\ninstead.</p>\n<p>Note that the <a href=\"/en-US-v0.14.1/reference/text/raw/\"><code>raw</code> function</a> and syntax (e.g. <code><span class=\"typ-raw\">`raw`</span></code>) only work for\nverbatim (unformatted) text. If you require formatting, you can use the\n<a href=\"/en-US-v0.14.1/reference/text/text/\"><code>text</code> function</a> with a monospace font instead, like in the example\nbelow:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>\n  font<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;DejaVu Sans Mono&quot;</span><span class=\"typ-punct\">,</span>\n  size<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0.8em</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>monospace <span class=\"typ-strong\">*bold*</span><span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/1c8b7b315c9a9231ec2f8ee31b5cc24.png\" alt=\"Preview\"></div></div>\n<h2 id=\"commands\">How do I use a command?</h2>\n<p>LaTeX heavily relies on commands (prefixed by backslashes). It uses these\n<em>macros</em> to affect the typesetting process and to insert and manipulate content.\nSome commands accept arguments, which are most frequently enclosed in curly\nbraces: <code>\\cite{rasmus}</code>.</p>\n<p>Typst differentiates between <a href=\"/en-US-v0.14.1/reference/scripting/#blocks\">markup mode and code mode</a>.\nThe default is markup mode, where you compose text and apply syntactic\nconstructs such as <code><span class=\"typ-strong\">*stars for bold text*</span></code>. Code mode, on the other hand,\nparallels programming languages like Python, providing the option to input and\nexecute segments of code.</p>\n<p>Within Typst's markup, you can switch to code mode for a single command (or\nrather, <em>expression</em>) using a hash (<code>#</code>). This is how you call functions to, for\nexample, split your project into different <a href=\"/en-US-v0.14.1/reference/scripting/#modules\">files</a> or\nrender text based on some <a href=\"/en-US-v0.14.1/reference/scripting/#conditionals\">condition</a>. Within code\nmode, it is possible to include normal markup <a href=\"/en-US-v0.14.1/reference/foundations/content/\"><em>content</em></a> by using\nsquare brackets. Within code mode, this content is treated just as any other\nnormal value for a variable.</p>\n<div class=\"previewed-code\"><pre><code>First, a rectangle:\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span>\n\nLet me show how to do\n<span class=\"typ-func\">#</span><span class=\"typ-func\">underline</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">[</span><span class=\"typ-emph\">_underlined_</span> text<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\nWe can also do some maths:\n<span class=\"typ-pol\">#</span><span class=\"typ-pol\">calc</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">max</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span> <span class=\"typ-op\">*</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span>\n\nAnd finally a little loop:\n<span class=\"typ-key\">#</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\">3</span><span class=\"typ-punct\">)</span> <span class=\"typ-punct\">[</span>\n  Hi <span class=\"typ-pol\">#</span><span class=\"typ-pol\">x</span>.\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/61187e014908ab80b5988f03553820b3.png\" alt=\"Preview\"></div></div>\n<p>A function call always involves the name of the function (<a href=\"/en-US-v0.14.1/reference/visualize/rect/\" title=\"`rect`\"><code>rect</code></a>,\n<a href=\"/en-US-v0.14.1/reference/text/underline/\" title=\"`underline`\"><code>underline</code></a>, <a href=\"/en-US-v0.14.1/reference/foundations/calc/#functions-max\"><code>calc.max</code></a>, <a href=\"/en-US-v0.14.1/reference/foundations/array/#definitions-range\"><code>range</code></a>) followed by\nparentheses (as opposed to LaTeX where the square brackets and curly braces are\noptional if the macro requires no arguments). The expected list of arguments\npassed within those parentheses depends on the concrete function and is\nspecified in the <a href=\"/en-US-v0.14.1/reference/\" title=\"reference\">reference</a>.</p>\n<h3 id=\"arguments\">Arguments</h3>\n<p>A function can have multiple arguments. Some arguments are positional, i.e., you\njust provide the value: The function <code><span class=\"typ-func\">#</span><span class=\"typ-func\">lower</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;SCREAM&quot;</span><span class=\"typ-punct\">)</span></code> returns its argument\nin all-lowercase. Many functions use named arguments instead of positional\narguments to increase legibility. For example, the dimensions and stroke of a\nrectangle are defined with named arguments:</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\">2cm</span><span class=\"typ-punct\">,</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1cm</span><span class=\"typ-punct\">,</span>\n  stroke<span class=\"typ-punct\">:</span> red<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/aa17a54d4d9e1338642f4ce9fff72220.png\" alt=\"Preview\"></div></div>\n<p>You specify a named argument by first entering its name (above, it's <code>width</code>,\n<code>height</code>, and <code>stroke</code>), then a colon, followed by the value (<code>2cm</code>, <code>1cm</code>,\n<code>red</code>). You can find the available named arguments in the <a href=\"/en-US-v0.14.1/reference/\">reference\npage</a> for each function or in the autocomplete panel when typing.\nNamed arguments are similar to how some LaTeX environments are configured, for\nexample, you would type <code>\\begin{enumerate}[label={\\alph*)}]</code> to start a list\nwith the labels <code>a)</code>, <code>b)</code>, and so on.</p>\n<p>Often, you want to provide some <a href=\"/en-US-v0.14.1/reference/foundations/content/\" title=\"content\">content</a> to a function. For example, the LaTeX\ncommand <code>\\underline{Alternative A}</code> would translate to\n<code><span class=\"typ-func\">#</span><span class=\"typ-func\">underline</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">[</span>Alternative A<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span></code> in Typst. The square brackets indicate that a\nvalue is <a href=\"/en-US-v0.14.1/reference/foundations/content/\" title=\"content\">content</a>. Within these brackets, you can use normal markup.\nHowever, that's a lot of parentheses for a pretty simple construct. This is why\nyou can also move trailing content arguments after the parentheses (and omit the\nparentheses if they would end up empty).</p>\n<div class=\"previewed-code\"><pre><code>Typst is an <span class=\"typ-func\">#</span><span class=\"typ-func\">underline</span><span class=\"typ-punct\">[</span>alternative<span class=\"typ-punct\">]</span>\nto LaTeX.\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-punct\">[</span>Get started here!<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/997bfedfa9b70b688ba2c04b2313231f.png\" alt=\"Preview\"></div></div>\n<h3 id=\"data-types\">Data types</h3>\n<p>You likely already noticed that the arguments have distinctive data types. Typst\nsupports many <a href=\"/en-US-v0.14.1/reference/foundations/type/\">data types</a>. Below, there is a table with some of the most\nimportant ones and how to write them. In order to specify values of any of these\ntypes, you have to be in code mode!</p>\n<table><thead><tr><th style=\"text-align: left\">Data type</th><th style=\"text-align: left\">Example</th></tr></thead><tbody>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/foundations/content/\">Content</a></td><td style=\"text-align: left\"><code><span class=\"typ-punct\">[</span><span class=\"typ-strong\">*fast*</span> typesetting<span class=\"typ-punct\">]</span></code></td></tr>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/foundations/str/\">String</a></td><td style=\"text-align: left\"><code><span class=\"typ-str\">&quot;Pietro S. Author&quot;</span></code></td></tr>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/foundations/int/\">Integer</a></td><td style=\"text-align: left\"><code><span class=\"typ-num\">23</span></code></td></tr>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/foundations/float/\">Floating point number</a></td><td style=\"text-align: left\"><code><span class=\"typ-num\">1.459</span></code></td></tr>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/layout/length/\">Absolute length</a></td><td style=\"text-align: left\"><code><span class=\"typ-num\">12pt</span></code>, <code><span class=\"typ-num\">5in</span></code>, <code><span class=\"typ-num\">0.3cm</span></code>, ...</td></tr>\n<tr><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/layout/ratio/\">Relative length</a></td><td style=\"text-align: left\"><code><span class=\"typ-num\">65%</span></code></td></tr>\n</tbody></table>\n<p>The difference between content and string is that content can contain markup,\nincluding function calls, while a string really is just a plain sequence of\ncharacters.</p>\n<p>Typst provides <a href=\"/en-US-v0.14.1/reference/scripting/#conditionals\">control flow constructs</a> and\n<a href=\"/en-US-v0.14.1/reference/scripting/#operators\">operators</a> such as <code>+</code> for adding things or <code>==</code> for\nchecking equality between two variables.</p>\n<p>You can also store values, including functions, in your own\n<a href=\"/en-US-v0.14.1/reference/scripting/#bindings\">variables</a>. This can be useful to perform computations on\nthem, create reusable automations, or reference a value multiple times. The\nvariable binding is accomplished with the let keyword, which works similar to\n<code>\\newcommand</code>:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-comment\">// Store the integer `5`.</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> five <span class=\"typ-op\">=</span> <span class=\"typ-num\">5</span>\n\n<span class=\"typ-comment\">// Define a function that</span>\n<span class=\"typ-comment\">// increments a value.</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-func\">inc</span><span class=\"typ-punct\">(</span>i<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> i <span class=\"typ-op\">+</span> <span class=\"typ-num\">1</span>\n\n<span class=\"typ-comment\">// Reference the variables.</span>\nI have <span class=\"typ-pol\">#</span><span class=\"typ-pol\">five</span> fingers.\n\nIf I had one more, I&#39;d have\n<span class=\"typ-func\">#</span><span class=\"typ-func\">inc</span><span class=\"typ-punct\">(</span>five<span class=\"typ-punct\">)</span> fingers. Whoa!\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/74df77f136dbc2c18c9af4c5f847ac7.png\" alt=\"Preview\"></div></div>\n<h3 id=\"rules\">Commands to affect the remaining document</h3>\n<p>In LaTeX, some commands like <code>\\textbf{bold text}</code> receive an argument in curly\nbraces and only affect that argument. Other commands such as <code>\\bfseries bold text</code> act as switches (LaTeX calls this a declaration), altering the appearance\nof all subsequent content within the document or current scope.</p>\n<p>In Typst, the same function can be used both to affect the appearance for the\nremainder of the document, a block (or scope), or just its arguments. For\nexample, <code><span class=\"typ-func\">#</span><span class=\"typ-func\">text</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>bold text<span class=\"typ-punct\">]</span></code> will only embolden its argument,\nwhile <code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</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></code> will embolden any text until the end of the\ncurrent block, or the end of the document, if there is none. The effects of a\nfunction are immediately obvious based on whether it is used in a call or a\n<a href=\"/en-US-v0.14.1/reference/styling/#set-rules\">set rule.</a></p>\n<div class=\"previewed-code\"><pre><code>I am starting out with small text.\n\n<span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">14pt</span><span class=\"typ-punct\">)</span>\n\nThis is a bit <span class=\"typ-func\">#</span><span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">18pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>larger,<span class=\"typ-punct\">]</span>\ndon&#39;t you think?\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/697fb062ab8493b7a41dd016706677fb.png\" alt=\"Preview\"></div></div>\n<p>Set rules may appear anywhere in the document. They can be thought of as\ndefault argument values of their respective function:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">enum</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;I.&quot;</span><span class=\"typ-punct\">)</span>\n\nGood results can only be obtained by\n<span class=\"typ-marker\">+</span> following best practices\n<span class=\"typ-marker\">+</span> being aware of current results\n  of other researchers\n<span class=\"typ-marker\">+</span> checking the data for biases\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/153ce40293ed8439477687e95828e77f.png\" alt=\"Preview\"></div></div>\n<p>The <code>+</code> is syntactic sugar (think of it as an abbreviation) for a call to the\n<a href=\"/en-US-v0.14.1/reference/model/enum/\"><code>enum</code></a> function, to which we apply a set rule above.\n<a href=\"/en-US-v0.14.1/reference/syntax/\">Most syntax is linked to a function in this way.</a> If you need to style\nan element beyond what its arguments enable, you can completely redefine its\nappearance with a <a href=\"/en-US-v0.14.1/reference/styling/#show-rules\">show rule</a> (somewhat comparable to\n<code>\\renewcommand</code>).</p>\n<p>You can achieve the effects of LaTeX commands like <code>\\textbf</code>, <code>\\textsf</code>,\n<code>\\rmfamily</code>, <code>\\mdseries</code>, and <code>\\itshape</code> with the <a href=\"/en-US-v0.14.1/reference/text/text/#parameters-font\"><code>font</code></a>,\n<a href=\"/en-US-v0.14.1/reference/text/text/#parameters-style\"><code>style</code></a>, and <a href=\"/en-US-v0.14.1/reference/text/text/#parameters-weight\"><code>weight</code></a> arguments of the <code>text</code>\nfunction. The text function can be used in a set rule (declaration style) or\nwith a content argument. To replace <code>\\textsc</code>, you can use the <a href=\"/en-US-v0.14.1/reference/text/smallcaps/\" title=\"`smallcaps`\"><code>smallcaps</code></a>\nfunction, which renders its content argument as smallcaps. Should you want to\nuse it declaration style (like <code>\\scshape</code>), you can use an\n<a href=\"/en-US-v0.14.1/reference/styling/#show-rules\"><em>everything</em> show rule</a> that applies the function to the\nrest of the scope:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">show</span><span class=\"typ-punct\">:</span> <span class=\"typ-func\">smallcaps</span>\n\nBoisterous Accusations\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/b8a51164b74a742d89b2c318c55936b1.png\" alt=\"Preview\"></div></div>\n<h2 id=\"templates\">How do I load a document class?</h2>\n<p>In LaTeX, you start your main <code>.tex</code> file with the <code>\\documentclass{article}</code>\ncommand to define how your document is supposed to look. In that command, you\nmay have replaced <code>article</code> with another value such as <code>report</code> and <code>amsart</code> to\nselect a different look.</p>\n<p>When using Typst, you style your documents with <a href=\"/en-US-v0.14.1/reference/foundations/function/\">functions</a>.\nTypically, you use a template that provides a function that styles your whole\ndocument. First, you import the function from a template file. Then, you apply\nit to your whole document. This is accomplished with a\n<a href=\"/en-US-v0.14.1/reference/styling/#show-rules\">show rule</a> that wraps the following document in a given\nfunction. The following example illustrates how it works:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">import</span> <span class=\"typ-str\">&quot;conf.typ&quot;</span><span class=\"typ-punct\">:</span> conf\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span><span class=\"typ-punct\">:</span> conf<span class=\"typ-punct\">.</span><span class=\"typ-func\">with</span><span class=\"typ-punct\">(</span>\n  title<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>\n    Towards Improved Modelling\n  <span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  authors<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>\n    <span class=\"typ-punct\">(</span>\n      name<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;Theresa Tungsten&quot;</span><span class=\"typ-punct\">,</span>\n      affiliation<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;Artos Institute&quot;</span><span class=\"typ-punct\">,</span>\n      email<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;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-punct\">(</span>\n      name<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;Eugene Deklan&quot;</span><span class=\"typ-punct\">,</span>\n      affiliation<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;Honduras State&quot;</span><span class=\"typ-punct\">,</span>\n      email<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;e.deklan@hstate.hn&quot;</span><span class=\"typ-punct\">,</span>\n    <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  abstract<span class=\"typ-punct\">:</span> <span class=\"typ-func\">lorem</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">80</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n\nLet&#39;s get started writing this\narticle by putting insightful\nparagraphs right here!\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/938ed1adbadc6f39a4ce5faec4677570.png\" alt=\"Preview\"></div></div>\n<p>The <a href=\"/en-US-v0.14.1/reference/scripting/#modules\"><code><span class=\"typ-key\">import</span></code></a> statement makes <a href=\"/en-US-v0.14.1/reference/foundations/function/\">functions</a>\n(and other definitions) from another file available. In this example, it imports\nthe <code>conf</code> function from the <code>conf.typ</code> file. This function formats a document\nas a conference article. We use a show rule to apply it to the document and also\nconfigure some metadata of the article. After applying the show rule, we can\nstart writing our article right away!</p>\n<p>You can also use templates from Typst Universe (which is Typst's equivalent of\nCTAN) using an import statement like this: <code><span class=\"typ-key\">#</span><span class=\"typ-key\">import</span> <span class=\"typ-str\">&quot;@preview/elsearticle:0.2.1&quot;</span><span class=\"typ-punct\">:</span> elsearticle</code>. Check the documentation of an\nindividual template to learn the name of its template function. Templates and\npackages from Typst Universe are automatically downloaded when you first use\nthem.</p>\n<p>In the web app, you can choose to create a project from a template on Typst\nUniverse or even create your own using the template wizard. Locally, you can use\nthe <code>typst init</code> CLI to create a new project from a template. Check out <a href=\"https://typst.app/universe/search/?kind=templates\">the\nlist of templates</a> published on Typst\nUniverse. You can also take a look at the <a href=\"https://github.com/qjcg/awesome-typst\"><code>awesome-typst</code>\nrepository</a> to find community templates\nthat aren't available through Universe.</p>\n<p>You can also <a href=\"/en-US-v0.14.1/tutorial/making-a-template/\">create your own, custom templates.</a>\nThey are shorter and more readable than the corresponding LaTeX <code>.sty</code> files by\norders of magnitude, so give it a try!</p>\n<div class=\"info-box\">\n<p>Functions are Typst's &quot;commands&quot; and can transform their arguments to an output\nvalue, including document <em>content.</em> Functions are &quot;pure&quot;, which means that they\ncannot have any effects beyond creating an output value / output content. This\nis in stark contrast to LaTeX macros that can have arbitrary effects on your\ndocument.</p>\n<p>To let a function style your whole document, the show rule processes everything\nthat comes after it and calls the function specified after the colon with the\nresult as an argument. The <code>.with</code> part is a <em>method</em> that takes the <code>conf</code>\nfunction and pre-configures some of its arguments before passing it on to the\nshow rule.</p>\n</div>\n<h2 id=\"packages\">How do I load packages?</h2>\n<p>Typst is &quot;batteries included,&quot; so the equivalent of many popular LaTeX packages\nis built right-in. Below, we compiled a table with frequently loaded packages\nand their corresponding Typst functions.</p>\n<table><thead><tr><th style=\"text-align: left\">LaTeX Package</th><th style=\"text-align: left\">Typst Alternative</th></tr></thead><tbody>\n<tr><td style=\"text-align: left\">graphicx, svg</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/visualize/image/\" title=\"`image`\"><code>image</code></a> function</td></tr>\n<tr><td style=\"text-align: left\">tabularx, tabularray</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/table/\" title=\"`table`\"><code>table</code></a>, <a href=\"/en-US-v0.14.1/reference/layout/grid/\" title=\"`grid`\"><code>grid</code></a> functions</td></tr>\n<tr><td style=\"text-align: left\">fontenc, inputenc, unicode-math</td><td style=\"text-align: left\">Just start writing!</td></tr>\n<tr><td style=\"text-align: left\">babel, polyglossia</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/text/#parameters-lang\"><code>text</code></a> function: <code><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;zh&quot;</span><span class=\"typ-punct\">)</span></code></td></tr>\n<tr><td style=\"text-align: left\">amsmath</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/math/\">Math mode</a></td></tr>\n<tr><td style=\"text-align: left\">amsfonts, amssymb</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/symbols/\"><code>sym</code></a> module and <a href=\"/en-US-v0.14.1/reference/syntax/#math\">syntax</a></td></tr>\n<tr><td style=\"text-align: left\">geometry, fancyhdr</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/layout/page/\" title=\"`page`\"><code>page</code></a> function</td></tr>\n<tr><td style=\"text-align: left\">xcolor</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/text/#parameters-fill\"><code>text</code></a> function: <code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rgb</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;#0178A4&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code></td></tr>\n<tr><td style=\"text-align: left\">hyperref</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/link/\" title=\"`link`\"><code>link</code></a> function</td></tr>\n<tr><td style=\"text-align: left\">bibtex, biblatex, natbib</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/cite/\" title=\"`cite`\"><code>cite</code></a>, <a href=\"/en-US-v0.14.1/reference/model/bibliography/\" title=\"`bibliography`\"><code>bibliography</code></a> functions</td></tr>\n<tr><td style=\"text-align: left\">lstlisting, minted</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/text/raw/\" title=\"`raw`\"><code>raw</code></a> function and syntax</td></tr>\n<tr><td style=\"text-align: left\">parskip</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/layout/block/#parameters-spacing\"><code>block</code></a> and <a href=\"/en-US-v0.14.1/reference/model/par/#parameters-first-line-indent\"><code>par</code></a> functions</td></tr>\n<tr><td style=\"text-align: left\">csquotes</td><td style=\"text-align: left\">Set the <a href=\"/en-US-v0.14.1/reference/text/text/#parameters-lang\"><code>text</code></a> language and type <code>&quot;</code> or <code>&#39;</code></td></tr>\n<tr><td style=\"text-align: left\">caption</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/figure/\" title=\"`figure`\"><code>figure</code></a> function</td></tr>\n<tr><td style=\"text-align: left\">enumitem</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/model/list/\" title=\"`list`\"><code>list</code></a>, <a href=\"/en-US-v0.14.1/reference/model/enum/\" title=\"`enum`\"><code>enum</code></a>, <a href=\"/en-US-v0.14.1/reference/model/terms/\" title=\"`terms`\"><code>terms</code></a> functions</td></tr>\n<tr><td style=\"text-align: left\">nicefrac</td><td style=\"text-align: left\"><a href=\"/en-US-v0.14.1/reference/math/frac/#parameters-style\"><code>frac.style</code></a> property</td></tr>\n</tbody></table>\n<p>Although <em>many</em> things are built-in, not everything can be. That's why Typst has\nits own <a href=\"https://typst.app/universe/\">package ecosystem</a> where the community share its creations\nand automations. Let's take, for instance, the <em>CeTZ</em> package: This package\nallows you to create complex drawings and plots. To use CeTZ in your document,\nyou can just write:</p>\n<pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">import</span> <span class=\"typ-str\">&quot;@preview/cetz:0.4.1&quot;</span>\n</code></pre>\n<p>(The <code>@preview</code> is a <em>namespace</em> that is used while the package manager is still\nin its early and experimental state. It will be replaced in the future.)</p>\n<p>Aside from the official package hub, you might also want to check out the\n<a href=\"https://github.com/qjcg/awesome-typst\">awesome-typst repository</a>, which\ncompiles a curated list of resources created for Typst.</p>\n<p>If you need to load functions and variables from another file within your\nproject, for example to use a template, you can use the same\n<a href=\"/en-US-v0.14.1/reference/scripting/#modules\"><code>import</code></a> statement with a file name rather than a\npackage specification. To instead include the textual content of another file,\nyou can use an <a href=\"/en-US-v0.14.1/reference/scripting/#modules\"><code>include</code></a> statement. It will retrieve\nthe content of the specified file and put it in your document.</p>\n<h2 id=\"maths\">How do I input maths?</h2>\n<p>To enter math mode in Typst, just enclose your equation in dollar signs. You can\nenter display mode by adding spaces or newlines between the equation's contents\nand its enclosing dollar signs.</p>\n<div class=\"previewed-code\"><pre><code>The sum of the numbers from\n<span class=\"typ-math-delim\">$</span>1<span class=\"typ-math-delim\">$</span> to <span class=\"typ-math-delim\">$</span>n<span class=\"typ-math-delim\">$</span> is:\n\n<span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">sum</span><span class=\"typ-math-op\">_</span><span class=\"typ-punct\">(</span>k=1<span class=\"typ-punct\">)</span><span class=\"typ-math-op\">^</span>n k = <span class=\"typ-punct\">(</span>n(n+1)<span class=\"typ-punct\">)</span><span class=\"typ-math-op\">/</span>2 <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/fdc410cc7972bde4bafc1a195e7cf341.png\" alt=\"Preview\"></div></div>\n<p><a href=\"/en-US-v0.14.1/reference/math/\">Math mode</a> works differently than regular markup or code mode.\nNumbers and single characters are displayed verbatim, while multiple consecutive\n(non-number) characters will be interpreted as Typst variables.</p>\n<p>Typst pre-defines a lot of useful variables in math mode. All Greek (<code>alpha</code>,\n<code>beta</code>, ...) and some Hebrew letters (<code>alef</code>, <code>bet</code>, ...) are available through\ntheir name. Some symbols are additionally available through shorthands, such as\n<code>&lt;=</code>, <code>&gt;=</code>, and <code>-&gt;</code>.</p>\n<p>Refer to the <a href=\"/en-US-v0.14.1/reference/symbols/\">symbol pages</a> for a full list of the symbols.\nIf a symbol is missing, you can also access it through a\n<a href=\"/en-US-v0.14.1/reference/syntax/#escapes\">Unicode escape sequence</a>.</p>\n<p>Alternate and related forms of symbols can often be selected by\n<a href=\"/en-US-v0.14.1/reference/foundations/symbol/\">appending a modifier</a> after a period. For example,\n<code>arrow.l.squiggly</code> inserts a squiggly left-pointing arrow. If you want to insert\nmultiletter text in your expression instead, enclose it in double quotes:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">delta</span> <span class=\"typ-str\">&quot;if&quot;</span> x <span class=\"typ-escape\">&lt;=</span> 5 <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/8e4d6c1b9942b3e650facda75cd4db4f.png\" alt=\"Preview\"></div></div>\n<p>In Typst, delimiters will scale automatically for their expressions, just as if\n<code>\\left</code> and <code>\\right</code> commands were implicitly inserted in LaTeX. You can\ncustomize delimiter behaviour using the <a href=\"/en-US-v0.14.1/reference/math/lr/#functions-lr\"><code>lr</code> function</a>. To\nprevent a pair of delimiters from scaling, you can escape them with backslashes.</p>\n<p>Typst will automatically set terms around a slash <code>/</code> as a fraction while\nhonoring operator precedence. All round parentheses not made redundant by the\nfraction will appear in the output.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> f(x) = <span class=\"typ-punct\">(</span>x + 1<span class=\"typ-punct\">)</span> <span class=\"typ-math-op\">/</span> x <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/856a459b559bdc89f7dac4bf484207be.png\" alt=\"Preview\"></div></div>\n<p><a href=\"/en-US-v0.14.1/reference/math/attach/#functions-attach\">Sub- and superscripts</a> work similarly in Typst and LaTeX.\n<code><span class=\"typ-math-delim\">$</span>x<span class=\"typ-math-op\">^</span>2<span class=\"typ-math-delim\">$</span></code> will produce a superscript, <code><span class=\"typ-math-delim\">$</span>x<span class=\"typ-math-op\">_</span>2<span class=\"typ-math-delim\">$</span></code> yields a subscript. If you want\nto include more than one value in a sub- or superscript, enclose their contents\nin parentheses: <code><span class=\"typ-math-delim\">$</span>x<span class=\"typ-math-op\">_</span><span class=\"typ-punct\">(</span>a <span class=\"typ-escape\">-&gt;</span> <span class=\"typ-pol\">epsilon</span><span class=\"typ-punct\">)</span><span class=\"typ-math-delim\">$</span></code>.</p>\n<p>Since variables in math mode do not need to be prepended with a <code>#</code> (or a <code>\\</code>\nlike in LaTeX), you can also call functions without these special characters:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> f(x, y) <span class=\"typ-escape\">:=</span> <span class=\"typ-func\">cases</span><span class=\"typ-punct\">(</span>\n  1 <span class=\"typ-str\">&quot;if&quot;</span> <span class=\"typ-punct\">(</span>x <span class=\"typ-pol\">dot</span> y<span class=\"typ-punct\">)</span><span class=\"typ-math-op\">/</span>2 <span class=\"typ-escape\">&lt;=</span> 0<span class=\"typ-punct\">,</span>\n  2 <span class=\"typ-str\">&quot;if&quot;</span> x <span class=\"typ-str\">&quot;is even&quot;</span><span class=\"typ-punct\">,</span>\n  3 <span class=\"typ-str\">&quot;if&quot;</span> x <span class=\"typ-pol\">in</span> <span class=\"typ-pol\">NN</span><span class=\"typ-punct\">,</span>\n  4 <span class=\"typ-str\">&quot;else&quot;</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span> <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/d17d4014f0e278177d8e26b02a9734f8.png\" alt=\"Preview\"></div></div>\n<p>The above example uses the <a href=\"/en-US-v0.14.1/reference/math/cases/\"><code>cases</code> function</a> to describe f. Within\nthe cases function, arguments are delimited using commas and the arguments are\nalso interpreted as math. If you need to interpret arguments as Typst\nvalues instead, prefix them with a <code>#</code>:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> (a + b)<span class=\"typ-math-op\">^</span>2\n  = a<span class=\"typ-math-op\">^</span>2\n  + <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> <span class=\"typ-pol\">#</span><span class=\"typ-pol\">maroon</span><span class=\"typ-punct\">,</span> 2 a b<span class=\"typ-punct\">)</span>\n  + b<span class=\"typ-math-op\">^</span>2 <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/5a6c74c1c15e1b29279ef445bfc6c8e5.png\" alt=\"Preview\"></div></div>\n<p>You can use all Typst functions within math mode and insert any content. If you\nwant them to work normally, with code mode in the argument list, you can prefix\ntheir call with a <code>#</code>. Nobody can stop you from using rectangles or emoji as\nyour variables anymore:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">sum</span><span class=\"typ-math-op\">^</span>10<span class=\"typ-math-op\">_</span><span class=\"typ-punct\">(</span>🤓=1<span class=\"typ-punct\">)</span>\n  <span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4mm</span><span class=\"typ-punct\">,</span> height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2mm</span><span class=\"typ-punct\">)</span><span class=\"typ-math-op\">/</span>🤓\n  = 🧠 <span class=\"typ-pol\">maltese</span> <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/1f4eb28a5c2927fe2ba512666ced7169.png\" alt=\"Preview\"></div></div>\n<p>If you'd like to enter your mathematical symbols directly as Unicode, that is\npossible, too!</p>\n<p>Math calls can have two-dimensional argument lists using <code>;</code> as a delimiter. The\nmost common use for this is the <a href=\"/en-US-v0.14.1/reference/math/mat/\"><code>mat</code> function</a> that creates\nmatrices:</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-math-delim\">$</span> <span class=\"typ-func\">mat</span><span class=\"typ-punct\">(</span>\n  1<span class=\"typ-punct\">,</span> 2<span class=\"typ-punct\">,</span> <span class=\"typ-escape\">...</span><span class=\"typ-punct\">,</span> 10<span class=\"typ-punct\">;</span>\n  2<span class=\"typ-punct\">,</span> 2<span class=\"typ-punct\">,</span> <span class=\"typ-escape\">...</span><span class=\"typ-punct\">,</span> 10<span class=\"typ-punct\">;</span>\n  <span class=\"typ-pol\">dots</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">v</span><span class=\"typ-punct\">,</span> <span class=\"typ-pol\">dots</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">v</span><span class=\"typ-punct\">,</span> <span class=\"typ-pol\">dots</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">down</span><span class=\"typ-punct\">,</span> <span class=\"typ-pol\">dots</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">v</span><span class=\"typ-punct\">;</span>\n  10<span class=\"typ-punct\">,</span> 10<span class=\"typ-punct\">,</span> <span class=\"typ-escape\">...</span><span class=\"typ-punct\">,</span> 10<span class=\"typ-punct\">;</span>\n<span class=\"typ-punct\">)</span> <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/ca24a2958190d70441a482b738ddf8f4.png\" alt=\"Preview\"></div></div>\n<h2 id=\"latex-look\">How do I get the &quot;LaTeX look?&quot;</h2>\n<p>Papers set in LaTeX have an unmistakeable look. This is mostly due to their\nfont, Computer Modern, justification, narrow line spacing, and wide margins.</p>\n<p>The example below</p>\n<ul>\n<li>sets wide <a href=\"/en-US-v0.14.1/reference/layout/page/#parameters-margin\">margins</a></li>\n<li>enables <a href=\"/en-US-v0.14.1/reference/model/par/#parameters-justify\">justification</a>, <a href=\"/en-US-v0.14.1/reference/model/par/#parameters-leading\">tighter lines</a> and\n<a href=\"/en-US-v0.14.1/reference/model/par/#parameters-first-line-indent\">first-line-indent</a></li>\n<li><a href=\"/en-US-v0.14.1/reference/text/text/#parameters-font\">sets the font</a> to &quot;New Computer Modern&quot;, an OpenType derivative of\nComputer Modern for both text and <a href=\"/en-US-v0.14.1/reference/text/raw/\">code blocks</a></li>\n<li>disables paragraph <a href=\"/en-US-v0.14.1/reference/layout/block/#parameters-spacing\">spacing</a></li>\n<li>increases <a href=\"/en-US-v0.14.1/reference/layout/block/#parameters-spacing\">spacing</a> around <a href=\"/en-US-v0.14.1/reference/model/heading/\">headings</a></li>\n</ul>\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-num\">1.75in</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>leading<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0.55em</span><span class=\"typ-punct\">,</span> spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0.55em</span><span class=\"typ-punct\">,</span> first-line-indent<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.8em</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>font<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;New Computer Modern&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">raw</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>font<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;New Computer Modern Mono&quot;</span><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\">block</span><span class=\"typ-punct\">(</span>above<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1.4em</span><span class=\"typ-punct\">,</span> below<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1em</span><span class=\"typ-punct\">)</span>\n</code></pre>\n<p>This should be a good starting point! If you want to go further, why not create\na reusable template?</p>\n<h2 id=\"bibliographies\">Bibliographies</h2>\n<p>Typst includes a fully-featured bibliography system that is compatible with\nBibTeX files. You can continue to use your <code>.bib</code> literature libraries by\nloading them with the <a href=\"/en-US-v0.14.1/reference/model/bibliography/\" title=\"`bibliography`\"><code>bibliography</code></a> function. Another possibility is to use\n<a href=\"https://github.com/typst/hayagriva/blob/main/docs/file-format.md\">Typst's YAML-based native format</a>.</p>\n<p>Typst uses the Citation Style Language to define and process citation and\nbibliography styles. You can compare CSL files to BibLaTeX's <code>.bbx</code> files.\nThe compiler already includes <a href=\"/en-US-v0.14.1/reference/model/bibliography/#parameters-style\">over 80 citation styles</a>,\nbut you can use any CSL-compliant style from the\n<a href=\"https://github.com/citation-style-language/styles\">CSL repository</a> or write\nyour own.</p>\n<p>You can cite an entry in your bibliography or reference a label in your document\nwith the same syntax: <code><span class=\"typ-ref\">@key</span></code> (this would reference an entry called <code>key</code>).\nAlternatively, you can use the <a href=\"/en-US-v0.14.1/reference/model/cite/\" title=\"`cite`\"><code>cite</code></a> function.</p>\n<p>Alternative forms for your citation, such as year only and citations for natural\nuse in prose (cf. <code>\\citet</code> and <code>\\textcite</code>) are available with\n<a href=\"/en-US-v0.14.1/reference/model/cite/#parameters-form\"><code><span class=\"typ-func\">#</span><span class=\"typ-func\">cite</span><span class=\"typ-punct\">(</span><span class=\"typ-label\">&lt;key&gt;</span><span class=\"typ-punct\">,</span> form<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;prose&quot;</span><span class=\"typ-punct\">)</span></code></a>.</p>\n<p>You can find more information on the documentation page of the <a href=\"/en-US-v0.14.1/reference/model/bibliography/\" title=\"`bibliography`\"><code>bibliography</code></a>\nfunction.</p>\n<h2 id=\"limitations\">What limitations does Typst currently have compared to LaTeX?</h2>\n<p>Although Typst can be a LaTeX replacement for many today, there are still\nfeatures that Typst does not (yet) support. Here is a list of them which, where\napplicable, contains possible workarounds.</p>\n<ul>\n<li>\n<p><strong>Well-established plotting ecosystem.</strong> LaTeX users often create elaborate\ncharts along with their documents in PGF/TikZ. The Typst ecosystem does not\nyet offer the same breadth of available options, but the ecosystem around the\n<a href=\"https://typst.app/universe/package/cetz\"><code>cetz</code> package</a> is catching up\nquickly.</p>\n</li>\n<li>\n<p><strong>Change page margins without a pagebreak.</strong> In LaTeX, margins can always be\nadjusted, even without a pagebreak. To change margins in Typst, you use the\n<a href=\"/en-US-v0.14.1/reference/layout/page/\"><code>page</code> function</a> which will force a page break. If you just want a few\nparagraphs to stretch into the margins, then reverting to the old margins, you\ncan use the <a href=\"/en-US-v0.14.1/reference/layout/pad/\"><code>pad</code> function</a> with negative padding.</p>\n</li>\n</ul>"}}