Using LaTeX Math in Astro Markdown - iPad edit
Astro with the remark-math
and rehype-katex
plugins allows you to write beautiful mathematical equations directly in your markdown files. Let’s explore how to use inline and block math.
Inline Math
You can write inline mathematical expressions using single dollar signs. For example, the quadratic formula is .
Here are some more examples:
- The area of a circle is
- The Pythagorean theorem states
- Euler’s identity:
Block Math
For larger equations that should be displayed on their own line, use double dollar signs:
Here’s the famous Maxwell’s equations:
Common Mathematical Symbols
Greek Letters
Operators
- (summation)
- (product)
- (integral)
- (derivative)
Matrices
Code Example
Here’s how you would write the quadratic formula in your markdown:
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.
For block math:
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
Tips for Writing Math
- Use proper spacing: LaTeX handles spacing automatically, but you can add
\,
for small spaces or\quad
for larger spaces - Group expressions: Use
{}
to group parts of your expression:e^{2x}
vse^2x
- Common functions: Use
\sin
,\cos
,\log
,\ln
,\exp
for proper formatting - Fractions: Use
\frac{numerator}{denominator}
for fractions
Example: Complex Number Operations
Let’s work with complex numbers. If and , then:
The complex conjugate is , and we have .
Conclusion
With LaTeX support in your Astro blog, you can now write beautiful mathematical content that renders perfectly on the web. Whether you’re writing about physics, mathematics, engineering, or any field that uses mathematical notation, this setup will serve you well!
Remember to use single $
for inline math and double $$
for block math equations.