{"route":"/en-US-v0.13.1/reference/layout/h/","title":"Spacing (H)","description":"Documentation for the `h` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"fractional-spacing","name":"Fractional spacing","children":[]},{"id":"math-spacing","name":"Math Spacing","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-amount","name":"amount","children":[]},{"id":"parameters-weak","name":"weak","children":[]}]}],"body":{"kind":"func","content":{"path":[],"name":"h","title":"Spacing (H)","keywords":[],"oneliner":"Inserts horizontal spacing into a paragraph.","element":true,"contextual":false,"deprecation":null,"details":"<p>Inserts horizontal spacing into a paragraph.</p>\n<p>The spacing can be absolute, relative, or fractional. In the last case, the\nremaining space on the line is distributed among all fractional spacings\naccording to their relative fractions.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code>First <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1cm</span><span class=\"typ-punct\">)</span> Second <span class=\"typ-escape\">\\</span>\nFirst <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">30%</span><span class=\"typ-punct\">)</span> Second\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/f302fec582d1e98ecc2e5a6822e5ffbc.png\" alt=\"Preview\"></div></div>\n<h2 id=\"fractional-spacing\">Fractional spacing</h2>\n<p>With fractional spacing, you can align things within a line without forcing\na paragraph break (like <a href=\"/en-US-v0.13.1/reference/layout/align/\" title=\"`align`\"><code>align</code></a> would). Each fractionally sized element\ngets space based on the ratio of its fraction to the sum of all fractions.</p>\n<div class=\"previewed-code\"><pre><code>First <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span> Second <span class=\"typ-escape\">\\</span>\nFirst <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span> Second <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span> Third <span class=\"typ-escape\">\\</span>\nFirst <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">2fr</span><span class=\"typ-punct\">)</span> Second <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1fr</span><span class=\"typ-punct\">)</span> Third\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/a410aa858f4085ebab8e7cf2d9580f06.png\" alt=\"Preview\"></div></div>\n<h2 id=\"math-spacing\">Mathematical Spacing</h2>\n<p>In <a href=\"/en-US-v0.13.1/reference/math/\">mathematical formulas</a>, you can additionally use these\nconstants to add spacing between elements: <code>thin</code> (1/6 em), <code>med</code> (2/9 em),\n<code>thick</code> (5/18 em), <code>quad</code> (1 em), <code>wide</code> (2 em).</p>","example":null,"self":false,"params":[{"name":"amount","details":"<p>How much spacing to insert.</p>","example":null,"types":["relative","fraction"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"weak","details":"<p>If <code><span class=\"typ-key\">true</span></code>, the spacing collapses at the start or end of a paragraph.\nMoreover, from multiple adjacent weak spacings all but the largest one\ncollapse.</p>\n<p>Weak spacing in markup also causes all adjacent markup spaces to be\nremoved, regardless of the amount of spacing inserted. To force a space\nnext to weak spacing, you can explicitly write <code><span class=\"typ-str\">#</span><span class=\"typ-str\">&quot; &quot;</span></code> (for a normal\nspace) or <code><span class=\"typ-escape\">~</span></code> (for a non-breaking space). The latter can be useful to\ncreate a construct that always attaches to the preceding word with one\nnon-breaking space, independently of whether a markup space existed in\nfront or not.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1cm</span><span class=\"typ-punct\">,</span> weak<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span>\nWe identified a group of <span class=\"typ-emph\">_weak_</span>\nspecimens that fail to manifest\nin most cases. However, when\n<span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">8pt</span><span class=\"typ-punct\">,</span> weak<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span> supported\n<span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">8pt</span><span class=\"typ-punct\">,</span> weak<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span> on both sides,\nthey do show up.\n\nFurther <span class=\"typ-func\">#</span><span class=\"typ-func\">h</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">0pt</span><span class=\"typ-punct\">,</span> weak<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span> more,\neven the smallest of them swallow\nadjacent markup spaces.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/73fedbffd595e924c21761117468697d.png\" alt=\"Preview\"></div></div>","types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true}],"returns":["content"],"scope":[]}}}