Math Equations
Render beautiful mathematical equations in your documentation using KaTeX
Overview
KaTeX is a fast, easy-to-use JavaScript library for rendering TeX math notation on the web. This site integrates KaTeX to enable beautiful mathematical equations in documentation.
Features
- Fast rendering - KaTeX is significantly faster than MathJax
- High quality - Produces crisp output at any zoom level
- Self-contained - No dependencies on external fonts or stylesheets
- Server-side rendering - Works without JavaScript enabled
- TeX/LaTeX syntax - Familiar notation for mathematicians
Basic Usage
Inline Math
Wrap inline equations with single dollar signs $...$:
The Pythagorean theorem states that $c = \pm\sqrt{a^2 + b^2}$ for a right triangle.The Pythagorean theorem states that for a right triangle.
Block Math
Use code blocks with the math language identifier or wrap with double dollar signs $$...$$:
```math
c = \pm\sqrt{a^2 + b^2}
```Or using double dollar signs:
$$
E = mc^2
$$Common Examples
Algebra
Quadratic Formula:
Binomial Theorem:
Calculus
Fundamental Theorem of Calculus:
Partial Derivatives:
Limit Definition:
Linear Algebra
Matrix Multiplication:
Determinant:
Statistics & Probability
Normal Distribution:
Bayes' Theorem:
Complex Analysis
Taylor Series Expansion:
The Taylor expansion expresses a holomorphic function as a power series:
Euler's Formula:
Physics
Schrödinger Equation:
Maxwell's Equations:
Lagrangian Mechanics:
The action functional is defined as:
Advanced Features
Multi-line Equations
Use aligned environment for aligned equations:
Cases and Piecewise Functions
Fractions and Continued Fractions
Greek Letters and Symbols
Common symbols used in mathematics:
- Greek:
- Operators:
- Relations:
- Sets:
- Logic:
Subscripts and Superscripts
Large Operators
Summation:
Product:
Integration:
Special Formatting
Colored Equations
KaTeX supports color through the \textcolor and \colorbox commands:
Sizing
Control the size of your equations:
Spacing
Fine-tune spacing in equations:
Best Practices
Keep It Readable
Use clear variable names and proper spacing:
Cramped or unclear notation:
Use Display Style for Complex Equations
For complex fractions and large operators, use \displaystyle:
Break Long Equations
For very long equations, use multiple lines with aligned:
Label Important Equations
Use text annotations to explain components:
Common Syntax Reference
Basic Operations
| Syntax | Result | Description |
|---|---|---|
x + y | Addition | |
x - y | Subtraction | |
x \times y | Multiplication | |
x \div y | Division | |
\frac{x}{y} | Fraction | |
x^y | Superscript | |
x_y | Subscript | |
\sqrt{x} | Square root | |
\sqrt[n]{x} | nth root |
Delimiters
| Syntax | Result | Description |
|---|---|---|
(x) | Parentheses | |
[x] | Brackets | |
\{x\} | Braces | |
\langle x \rangle | Angle brackets | |
\lvert x \rvert | Absolute value | |
\lVert x \rVert | Norm |
Troubleshooting
Equation Not Rendering
- Check that
katex/dist/katex.cssis imported in your layout - Verify the TeX syntax is valid
- Ensure
remark-mathandrehype-katexare configured correctly - Use the KaTeX Live Demo to test syntax
Missing Symbols
- Not all LaTeX commands are supported by KaTeX
- Check the KaTeX Support Table
- Consider using alternative notation
Escaping Special Characters
Use backslash to escape special characters:
Use \$ for a dollar sign, not $\$$ in math mode.Pro Tip
You can copy equations from Wikipedia - they're already in LaTeX format and work directly with KaTeX!
Try it: Visit any Wikipedia math article, right-click an equation, and select "Copy LaTeX code".
Resources
- KaTeX Official Documentation
- KaTeX Support Table - Complete list of supported functions
- KaTeX Live Demo - Test equations in real-time
- LaTeX Math Symbols - Comprehensive symbol reference
- Detexify - Draw a symbol to find its LaTeX command
- Fumadocs Math Guide
Next Steps
- Experiment with different equation types
- Check out the KaTeX support table for all available commands
- Review our Mermaid Diagrams feature for visual diagrams
- Explore Documentation Guide for general writing tips