[{"data":1,"prerenderedAt":524},["ShallowReactive",2],{"guide-markdown-math-equations":3},{"id":4,"title":5,"body":6,"date":516,"description":517,"extension":518,"meta":519,"navigation":54,"path":520,"readingTime":70,"seo":521,"stem":522,"__hash__":523},"guides\u002Fguides\u002Fmarkdown-math-equations.md","Writing Math Equations in Markdown",{"type":7,"value":8,"toc":510},"minimark",[9,18,23,26,73,98,101,105,108,246,249,284,291,324,328,331,345,355,427,430,434,437,495,498,506],[10,11,12,13,17],"p",{},"Writing mathematical equations in plain text has always been frustrating. You either settle for awkward approximations like ",[14,15,16],"code",{},"x^2 + y^2 = r^2"," or embed screenshots of formulas. Markdown solves this by supporting LaTeX math notation through rendering engines like KaTeX and MathJax, letting you write beautiful equations that display cleanly in browsers, documentation sites, and note-taking apps.",[19,20,22],"h2",{"id":21},"inline-and-display-math-syntax","Inline and Display Math Syntax",[10,24,25],{},"LaTeX math in Markdown uses two delimiter styles. Inline math wraps expressions in single dollar signs and renders within a paragraph, while display math uses double dollar signs and renders on its own centered line.",[27,28,33],"pre",{"className":29,"code":30,"language":31,"meta":32,"style":32},"language-markdown shiki shiki-themes github-light github-dark","The quadratic formula is $x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$, which\nsolves any quadratic equation $ax^2 + bx + c = 0$.\n\n$$\n\\int_{0}^{\\infty} e^{-x^2} \\, dx = \\frac{\\sqrt{\\pi}}{2}\n$$\n","markdown","",[14,34,35,43,49,56,62,68],{"__ignoreMap":32},[36,37,40],"span",{"class":38,"line":39},"line",1,[36,41,42],{},"The quadratic formula is $x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$, which\n",[36,44,46],{"class":38,"line":45},2,[36,47,48],{},"solves any quadratic equation $ax^2 + bx + c = 0$.\n",[36,50,52],{"class":38,"line":51},3,[36,53,55],{"emptyLinePlaceholder":54},true,"\n",[36,57,59],{"class":38,"line":58},4,[36,60,61],{},"$$\n",[36,63,65],{"class":38,"line":64},5,[36,66,67],{},"\\int_{0}^{\\infty} e^{-x^2} \\, dx = \\frac{\\sqrt{\\pi}}{2}\n",[36,69,71],{"class":38,"line":70},6,[36,72,61],{},[10,74,75,76,79,80,83,84,79,87,90,91,79,94,97],{},"Some parsers also support ",[14,77,78],{},"\\("," and ",[14,81,82],{},"\\)"," for inline math, and ",[14,85,86],{},"\\[",[14,88,89],{},"\\]"," for display math. If you are writing for GitHub, stick with dollar signs — GitHub Flavored Markdown only recognizes ",[14,92,93],{},"$...$",[14,95,96],{},"$$...$$"," delimiters since its native math support launched in 2022.",[10,99,100],{},"A common pitfall is escaping. Markdown processors sometimes interpret underscores inside math as emphasis italics. To avoid this, wrap your math blocks in backticks or use a renderer that processes math before other Markdown transformations.",[19,102,104],{"id":103},"common-latex-math-commands","Common LaTeX Math Commands",[10,106,107],{},"The subset of LaTeX used in Markdown math is extensive but you will reach for the same commands repeatedly. Here is a practical reference for the most useful ones:",[109,110,111,127],"table",{},[112,113,114],"thead",{},[115,116,117,121,124],"tr",{},[118,119,120],"th",{},"Category",[118,122,123],{},"Syntax",[118,125,126],{},"Output",[128,129,130,144,161,174,187,200,213,233],"tbody",{},[115,131,132,136,141],{},[133,134,135],"td",{},"Fractions",[133,137,138],{},[14,139,140],{},"\\frac{a}{b}",[133,142,143],{},"a\u002Fb stacked",[115,145,146,149,158],{},[133,147,148],{},"Square root",[133,150,151,154,155],{},[14,152,153],{},"\\sqrt{x}"," or ",[14,156,157],{},"\\sqrt[n]{x}",[133,159,160],{},"radical",[115,162,163,166,171],{},[133,164,165],{},"Superscript",[133,167,168],{},[14,169,170],{},"x^{2}",[133,172,173],{},"squared",[115,175,176,179,184],{},[133,177,178],{},"Subscript",[133,180,181],{},[14,182,183],{},"x_{i}",[133,185,186],{},"indexed",[115,188,189,192,197],{},[133,190,191],{},"Summation",[133,193,194],{},[14,195,196],{},"\\sum_{i=0}^{n}",[133,198,199],{},"sigma notation",[115,201,202,205,210],{},[133,203,204],{},"Integral",[133,206,207],{},[14,208,209],{},"\\int_{a}^{b}",[133,211,212],{},"integral with bounds",[115,214,215,218,230],{},[133,216,217],{},"Greek letters",[133,219,220,223,224,223,227],{},[14,221,222],{},"\\alpha",", ",[14,225,226],{},"\\beta",[14,228,229],{},"\\gamma",[133,231,232],{},"Greek symbols",[115,234,235,238,243],{},[133,236,237],{},"Matrix",[133,239,240],{},[14,241,242],{},"\\begin{pmatrix}...\\end{pmatrix}",[133,244,245],{},"matrix layout",[10,247,248],{},"Matrices deserve special attention because their syntax is verbose:",[27,250,254],{"className":251,"code":252,"language":253,"meta":32,"style":32},"language-latex shiki shiki-themes github-light github-dark","$$\nA = \\begin{pmatrix}\na_{11} & a_{12} \\\\\na_{21} & a_{22}\n\\end{pmatrix}\n$$\n","latex",[14,255,256,260,265,270,275,280],{"__ignoreMap":32},[36,257,258],{"class":38,"line":39},[36,259,61],{},[36,261,262],{"class":38,"line":45},[36,263,264],{},"A = \\begin{pmatrix}\n",[36,266,267],{"class":38,"line":51},[36,268,269],{},"a_{11} & a_{12} \\\\\n",[36,271,272],{"class":38,"line":58},[36,273,274],{},"a_{21} & a_{22}\n",[36,276,277],{"class":38,"line":64},[36,278,279],{},"\\end{pmatrix}\n",[36,281,282],{"class":38,"line":70},[36,283,61],{},[10,285,286,287,290],{},"For aligned equations spanning multiple lines, use the ",[14,288,289],{},"aligned"," environment inside display math:",[27,292,294],{"className":251,"code":293,"language":253,"meta":32,"style":32},"$$\n\\begin{aligned}\nf(x) &= (x+1)^2 \\\\\n     &= x^2 + 2x + 1\n\\end{aligned}\n$$\n",[14,295,296,300,305,310,315,320],{"__ignoreMap":32},[36,297,298],{"class":38,"line":39},[36,299,61],{},[36,301,302],{"class":38,"line":45},[36,303,304],{},"\\begin{aligned}\n",[36,306,307],{"class":38,"line":51},[36,308,309],{},"f(x) &= (x+1)^2 \\\\\n",[36,311,312],{"class":38,"line":58},[36,313,314],{},"     &= x^2 + 2x + 1\n",[36,316,317],{"class":38,"line":64},[36,318,319],{},"\\end{aligned}\n",[36,321,322],{"class":38,"line":70},[36,323,61],{},[19,325,327],{"id":326},"katex-vs-mathjax-rendering","KaTeX vs MathJax Rendering",[10,329,330],{},"KaTeX and MathJax are the two dominant rendering engines, and they differ in meaningful ways.",[10,332,333,334,223,337,340,341,344],{},"KaTeX, developed by Khan Academy, prioritizes speed. It renders math server-side or client-side with no reflow, making it ideal for pages with many equations. However, KaTeX supports a smaller subset of LaTeX commands. Advanced features like ",[14,335,336],{},"\\cancel",[14,338,339],{},"\\phase",", and some ",[14,342,343],{},"tikz-cd"," diagrams are unsupported.",[10,346,347,348,223,351,354],{},"MathJax, the older and more complete engine, supports nearly the full LaTeX math vocabulary including ",[14,349,350],{},"\\require",[14,352,353],{},"\\newcommand",", and automatic equation numbering. The tradeoff is rendering speed — MathJax processes equations asynchronously, which can cause visible reflow on long documents.",[109,356,357,370],{},[112,358,359],{},[115,360,361,364,367],{},[118,362,363],{},"Feature",[118,365,366],{},"KaTeX",[118,368,369],{},"MathJax",[128,371,372,383,394,405,416],{},[115,373,374,377,380],{},[133,375,376],{},"Rendering speed",[133,378,379],{},"Very fast",[133,381,382],{},"Moderate",[115,384,385,388,391],{},[133,386,387],{},"LaTeX coverage",[133,389,390],{},"~90% of common commands",[133,392,393],{},"Near-complete",[115,395,396,399,402],{},[133,397,398],{},"Equation numbering",[133,400,401],{},"Manual",[133,403,404],{},"Automatic",[115,406,407,410,413],{},[133,408,409],{},"Server-side rendering",[133,411,412],{},"Supported",[133,414,415],{},"Limited",[115,417,418,421,424],{},[133,419,420],{},"Bundle size",[133,422,423],{},"~300 KB",[133,425,426],{},"~1 MB",[10,428,429],{},"For static documentation sites built with Hugo, Docusaurus, or Nuxt Content, KaTeX is usually the better choice. The faster renders and smaller bundle improve page load metrics, and the missing LaTeX features rarely matter for technical documentation. For academic papers or interactive textbooks where equation numbering and macros are essential, MathJax remains the right tool.",[19,431,433],{"id":432},"setting-up-math-in-popular-platforms","Setting Up Math in Popular Platforms",[10,435,436],{},"Most modern platforms support math out of the box or with minimal configuration:",[438,439,440,453,463,469,482],"ul",{},[441,442,443,447,448,79,450,452],"li",{},[444,445,446],"strong",{},"GitHub",": Native ",[14,449,93],{},[14,451,96],{}," support in READMEs, issues, and discussions since 2022. Rendered with MathJax.",[441,454,455,458,459,462],{},[444,456,457],{},"VS Code",": Install the Markdown Math extension for live preview of LaTeX math in ",[14,460,461],{},".md"," files.",[441,464,465,468],{},[444,466,467],{},"Obsidian",": Built-in math rendering using MathJax. No plugins needed.",[441,470,471,474,475,154,478,481],{},[444,472,473],{},"Hugo",": Add the ",[14,476,477],{},"katex",[14,479,480],{},"mathjax"," shortcode to your templates.",[441,483,484,487,488,79,491,494],{},[444,485,486],{},"Docusaurus",": Enable the ",[14,489,490],{},"remark-math",[14,492,493],{},"rehype-katex"," plugins in your configuration.",[10,496,497],{},"When testing your math locally, use a Markdown preview tool that matches your production renderer. Syntax that works in Obsidian might render differently on GitHub if KaTeX and MathJax handle an edge case differently.",[10,499,500,501,505],{},"One reliable workflow is to compose and preview your Markdown with math in a dedicated editor like our Markdown preview tool, which renders equations in real time so you can catch delimiter errors before publishing. Try it at ",[502,503,504],"a",{"href":504},"\u002Ftools\u002Fmarkdown-preview"," to verify your LaTeX expressions render correctly across different contexts.",[507,508,509],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":32,"searchDepth":45,"depth":45,"links":511},[512,513,514,515],{"id":21,"depth":45,"text":22},{"id":103,"depth":45,"text":104},{"id":326,"depth":45,"text":327},{"id":432,"depth":45,"text":433},"2026-05-28","How to write LaTeX math expressions in Markdown documents with KaTeX and MathJax rendering.","md",{},"\u002Fguides\u002Fmarkdown-math-equations",{"title":5,"description":517},"guides\u002Fmarkdown-math-equations","NQMRKKA0ljh53gVDm93K5LLZBoI2L5x-WNhj6sbZUt8",1780401335091]