[{"data":1,"prerenderedAt":29},["ShallowReactive",2],{"post:rendering-math":3},{"meta":4,"html":19,"headings":20,"hasMath":9,"prev":25},{"slug":5,"title":6,"created":7,"url":8,"draft":9,"categories":10},"rendering-math","Rendering Mathematics at Build Time","2024-06-01T00:00:00.000Z","\u002Fpost\u002Frendering-math",false,[11,15],{"slug":12,"title":13,"url":14},"code","Code","\u002Fcategories\u002Fcode",{"slug":16,"title":17,"url":18},"mathematics","Mathematics","\u002Fcategories\u002Fmathematics","\u003Cp>Typesetting mathematics in the browser costs about a megabyte of JavaScript and shows the reader raw\nTeX until it finishes. Doing it at build time costs nothing at all.\u003C\u002Fp>\n\u003Cp>The catch is that equation numbering is document-scoped, so the whole article has to be rendered in\none pass.\u003C\u002Fp>\n\u003C!--more-->\n\u003Ch2 id=\"why-one-pass\">Why one pass\u003Ca class=\"heading-anchor\" href=\"#why-one-pass\" aria-hidden=\"true\" tabindex=\"-1\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>An equation counter that restarts at every expression is useless, and a forward reference cannot\nresolve if the target has not been parsed yet. Rendering the assembled document once solves both.\u003C\u002Fp>\n\u003Cfigure class=\"code-block\" data-lang=\"ts\">\u003Cfigcaption class=\"code-caption\">math.ts\u003C\u002Ffigcaption>\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">const\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> doc\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> mathjax.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">document\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(html, { InputJax: tex, OutputJax: chtml });\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">doc.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">render\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">();\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Ffigure>\n\u003Cp>The trap is that the TeX input jax carries counter state \u003Cem>between\u003C\u002Fem> documents. Without a reset, every\npost after the first is silently misnumbered.\u003C\u002Fp>\n\u003Cp>See \u003Ca href=\"\u002Fpost\u002Ffundamental-theorem\">the fundamental theorem\u003C\u002Fa> for a worked example.\u003C\u002Fp>\n",[21],{"level":22,"text":23,"id":24},2,"Why one pass","why-one-pass",{"slug":26,"title":27,"url":28},"fundamental-theorem","The Fundamental Theorem of Calculus","\u002Fpost\u002Ffundamental-theorem",1786249448752]