{"route":"/en-US-v0.14.1/reference/math/equation/","title":"Equation","description":"Documentation for the `equation` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"syntax","name":"Syntax","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-block","name":"block","children":[]},{"id":"parameters-numbering","name":"numbering","children":[]},{"id":"parameters-number-align","name":"number-align","children":[]},{"id":"parameters-supplement","name":"supplement","children":[]},{"id":"parameters-alt","name":"alt","children":[]},{"id":"parameters-body","name":"body","children":[]}]}],"body":{"kind":"func","content":{"path":["math"],"name":"equation","title":"Equation","keywords":[],"oneliner":"A mathematical equation.","element":true,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>A mathematical equation.</p>\n<p>Can be displayed inline with text or as a separate block. An equation\nbecomes block-level through the presence of whitespace after the opening\ndollar sign and whitespace before the closing dollar sign.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><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\nLet <span class=\"typ-math-delim\">$</span>a<span class=\"typ-math-delim\">$</span>, <span class=\"typ-math-delim\">$</span>b<span class=\"typ-math-delim\">$</span>, and <span class=\"typ-math-delim\">$</span>c<span class=\"typ-math-delim\">$</span> be the side\nlengths of right-angled triangle.\nThen, we know that:\n<span class=\"typ-math-delim\">$</span> a<span class=\"typ-math-op\">^</span>2 + b<span class=\"typ-math-op\">^</span>2 = c<span class=\"typ-math-op\">^</span>2 <span class=\"typ-math-delim\">$</span>\n\nProve by induction:\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/26dc4e81002bbeca5f9a64ad97cfb7fe.png\" alt=\"Preview\"></div></div>\n<p>By default, block-level equations will not break across pages. This can be\nchanged through <code><span class=\"typ-key\">show</span> math<span class=\"typ-punct\">.</span><span class=\"typ-func\">equation</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">block</span><span class=\"typ-punct\">(</span>breakable<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">)</span></code>.</p>\n<h2 id=\"syntax\">Syntax</h2>\n<p>This function also has dedicated syntax: Write mathematical markup within\ndollar signs to create an equation. Starting and ending the equation with\nwhitespace lifts it into a separate block that is centered horizontally.\nFor more details about math syntax, see the\n<a href=\"/en-US-v0.14.1/reference/math/\">main math page</a>.</p>"}],"self":false,"params":[{"name":"block","details":[{"kind":"html","content":"<p>Whether the equation is displayed as a separate block.</p>"}],"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"numbering","details":[{"kind":"html","content":"<p>How to number block-level equations. Accepts a\n<a href=\"/en-US-v0.14.1/reference/model/numbering/\">numbering pattern or function</a> taking a single number.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> math<span class=\"typ-punct\">.</span><span class=\"typ-func\">equation</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;(1)&quot;</span><span class=\"typ-punct\">)</span>\n\nWe define:\n<span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">phi</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">alt</span> <span class=\"typ-escape\">:=</span> <span class=\"typ-punct\">(</span>1 + <span class=\"typ-func\">sqrt</span><span class=\"typ-punct\">(</span>5<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> <span class=\"typ-math-op\">/</span> 2 <span class=\"typ-math-delim\">$</span> <span class=\"typ-label\">&lt;ratio&gt;</span>\n\nWith <span class=\"typ-ref\">@ratio</span>, we get:\n<span class=\"typ-math-delim\">$</span> F<span class=\"typ-math-op\">_</span>n = <span class=\"typ-func\">floor</span><span class=\"typ-punct\">(</span>1 <span class=\"typ-math-op\">/</span> <span class=\"typ-func\">sqrt</span><span class=\"typ-punct\">(</span>5<span class=\"typ-punct\">)</span> <span class=\"typ-pol\">phi</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">alt</span><span class=\"typ-math-op\">^</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/202911378a85036c27dd557f74625c28.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["none","str","function"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"number-align","details":[{"kind":"html","content":"<p>The alignment of the equation numbering.</p>\n<p>By default, the alignment is <code>end <span class=\"typ-op\">+</span> horizon</code>. For the horizontal\ncomponent, you can use <code>right</code>, <code>left</code>, or <code>start</code> and <code>end</code>\nof the text direction; for the vertical component, you can use\n<code>top</code>, <code>horizon</code>, or <code>bottom</code>.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> math<span class=\"typ-punct\">.</span><span class=\"typ-func\">equation</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;(1)&quot;</span><span class=\"typ-punct\">,</span> number-align<span class=\"typ-punct\">:</span> bottom<span class=\"typ-punct\">)</span>\n\nWe can calculate:\n<span class=\"typ-math-delim\">$</span> E <span class=\"typ-math-op\">&amp;</span>= <span class=\"typ-func\">sqrt</span><span class=\"typ-punct\">(</span>m<span class=\"typ-math-op\">_</span>0<span class=\"typ-math-op\">^</span>2 + p<span class=\"typ-math-op\">^</span>2<span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n    <span class=\"typ-math-op\">&amp;</span><span class=\"typ-pol\">approx</span> 125 <span class=\"typ-str\">&quot;GeV&quot;</span> <span class=\"typ-math-delim\">$</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/12340ab301fe38101ce51c2197eed635.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["alignment"],"strings":[],"default":"<code>end <span class=\"typ-op\">+</span> horizon</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"supplement","details":[{"kind":"html","content":"<p>A supplement for the equation.</p>\n<p>For references to equations, this is added before the referenced number.</p>\n<p>If a function is specified, it is passed the referenced equation and\nshould return content.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> math<span class=\"typ-punct\">.</span><span class=\"typ-func\">equation</span><span class=\"typ-punct\">(</span>numbering<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;(1)&quot;</span><span class=\"typ-punct\">,</span> supplement<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">[</span>Eq.<span class=\"typ-punct\">]</span><span class=\"typ-punct\">)</span>\n\nWe define:\n<span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">phi</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">alt</span> <span class=\"typ-escape\">:=</span> <span class=\"typ-punct\">(</span>1 + <span class=\"typ-func\">sqrt</span><span class=\"typ-punct\">(</span>5<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> <span class=\"typ-math-op\">/</span> 2 <span class=\"typ-math-delim\">$</span> <span class=\"typ-label\">&lt;ratio&gt;</span>\n\nWith <span class=\"typ-ref\">@ratio</span>, we get:\n<span class=\"typ-math-delim\">$</span> F<span class=\"typ-math-op\">_</span>n = <span class=\"typ-func\">floor</span><span class=\"typ-punct\">(</span>1 <span class=\"typ-math-op\">/</span> <span class=\"typ-func\">sqrt</span><span class=\"typ-punct\">(</span>5<span class=\"typ-punct\">)</span> <span class=\"typ-pol\">phi</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">alt</span><span class=\"typ-math-op\">^</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/2ecbd21a7ecd72183675d76fdf30c1b4.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["none","auto","content","function"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"alt","details":[{"kind":"html","content":"<p>An alternative description of the mathematical equation.</p>\n<p>This should describe the full equation in natural language and will be\nmade available to Assistive Technology. You can learn more in the\n<a href=\"/en-US-v0.14.1/guides/accessibility/#textual-representations\">Textual Representations section of the Accessibility\nGuide</a>.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-pol\">#</span><span class=\"typ-pol\">math</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">equation</span><span class=\"typ-punct\">(</span>\n  alt<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot;integral from 1 to infinity of a x squared plus b with respect to x&quot;</span><span class=\"typ-punct\">,</span>\n  block<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-math-delim\">$</span> <span class=\"typ-pol\">integral</span><span class=\"typ-math-op\">_</span>1<span class=\"typ-math-op\">^</span><span class=\"typ-pol\">oo</span> a x<span class=\"typ-math-op\">^</span>2 + b <span class=\"typ-pol\">dif</span> x <span class=\"typ-math-delim\">$</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/d037917bdb97008b79597f14dcd3d6b5.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["none","str"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"body","details":[{"kind":"html","content":"<p>The contents of the equation.</p>"}],"types":["content"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["content"],"scope":[]}}}