{"route":"/en-US-v0.14.1/reference/svg/","title":"SVG","description":"Documentation for functions related to SVG in Typst.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"exporting-as-svg","name":"Exporting as SVG","children":[{"id":"command-line","name":"Command Line","children":[]},{"id":"web-app","name":"Web App","children":[]}]}],"body":{"kind":"category","content":{"name":"svg","title":"SVG","details":"<p>Instead of creating a PDF, Typst can also directly render pages to scalable\nvector graphics (SVGs), which are the preferred format for embedding vector\ngraphics in web pages. Like PDF files, SVGs display your document exactly how\nyou have laid it out in Typst. Likewise, they share the benefit of not being\nbound to a specific resolution. Hence, you can print or view SVG files on any\ndevice without incurring a loss of quality. (Note that font printing quality may\nbe better with a PDF.) In contrast to a PDF, an SVG cannot contain multiple\npages. When exporting a multi-page document, Typst will emit multiple SVGs.</p>\n<p>SVGs can represent text in two ways: By embedding the text itself and rendering\nit with the fonts available on the viewer's computer or by embedding the shapes\nof each glyph in the font used to create the document. To ensure that the SVG\nfile looks the same across all devices it is viewed on, Typst chooses the latter\nmethod. This means that the text in the SVG cannot be extracted automatically,\nfor example by copy/paste or a screen reader. If you need the text to be\naccessible, export a PDF or HTML file instead.</p>\n<p>SVGs can have transparent backgrounds. By default, Typst will output an SVG with\nan opaque white background. You can make the background transparent using\n<code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">page</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> <span class=\"typ-key\">none</span><span class=\"typ-punct\">)</span></code>. Learn more on the\n<a href=\"/en-US-v0.14.1/reference/layout/page/#parameters-fill\"><code>page</code> function's reference page</a>.</p>\n<h2 id=\"exporting-as-svg\">Exporting as SVG</h2>\n<h3 id=\"command-line\">Command Line</h3>\n<p>Pass <code>--format svg</code> to the <code>compile</code> or <code>watch</code> subcommand or provide an output\nfile name that ends with <code>.svg</code>.</p>\n<p>If your document has more than one page, Typst will create multiple image files.\nThe output file name must then be a template string containing at least one of</p>\n<ul>\n<li><code>{p}</code>, which will be replaced by the page number</li>\n<li><code>{0p}</code>, which will be replaced by the zero-padded page number (so that all\nnumbers have the same length)</li>\n<li><code>{t}</code>, which will be replaced by the total number of pages</li>\n</ul>\n<p>When exporting to SVG, you have the following configuration options:</p>\n<ul>\n<li>Which pages to export by specifying <code>--pages</code> followed by a comma-separated\nlist of numbers or dash-separated number ranges. Ranges can be half-open.\nExample: <code>2,3,7-9,11-</code>.</li>\n</ul>\n<h3 id=\"web-app\">Web App</h3>\n<p>Click &quot;File&quot; &gt; &quot;Export as&quot; &gt; &quot;SVG&quot; or click the downwards-facing arrow next to\nthe quick download button and select &quot;Export as SVG&quot;. When exporting to SVG, you\nhave the following configuration options:</p>\n<ul>\n<li>Which pages to export. Valid options are &quot;All pages&quot;, &quot;Current page&quot;, and\n&quot;Custom ranges&quot;. Custom ranges are a comma-separated list of numbers or\ndash-separated number ranges. Ranges can be half-open. Example: <code>2,3,7-9,11-</code>.</li>\n</ul>","items":[],"shorthands":null}}}