Menu

Mastering Math Styling in Markdown

Mastering Math Styling in Markdown

Mathematics on the web doesn’t have to be boring. While standard LaTeX rendering is great for accuracy, sometimes you want your equations to pop, your matrices to shine, and your systems to tell a story.

In this guide, I’ll show you how to use our new suite of Astro components to bring your mathematical content to life directly within your Markdown files.

1. The Matrix Component

Matrices are fundamental to linear algebra. Our <Matrix /> component allows you to render them with various styles and animations.

Basic Usage

You can render a simple matrix by passing a 2D array to the data prop.

<Matrix data={[[1, 2], [3, 4]]} />
1
2
3
4

Styles

We support several styles to match the aesthetic of your content.

Glass Style

Perfect for modern, sleek interfaces.

<Matrix data={[[1, 0], [0, 1]]} style="glass" />
1
0
0
1

Neon Style

For a cyber-punk or high-contrast look.

<Matrix data={[[2, 4], [6, 8]]} style="neon" />
2
4
6
8

Chalk Style

Gives a hand-drawn, classroom feel.

<Matrix data={[[1, 2, 3], [4, 5, 6]]} style="chalk" />
1
2
3
4
5
6

Special Types

You can highlight specific matrix properties using the type prop.

Identity Matrix

Highlights the diagonal ones.

<Matrix 
  data={[[1, 0, 0], [0, 1, 0], [0, 0, 1]]} 
  type="identity" 
  style="glass"
/>
1
0
0
0
1
0
0
0
1

Diagonal Matrix

Fades out non-diagonal elements.

<Matrix 
  data={[[5, 0, 0], [0, 3, 0], [0, 0, 9]]} 
  type="diagonal" 
/>
5
0
0
0
3
0
0
0
9

Animations

Bring your matrices to life with entrance animations.

<Matrix 
  data={[[1, 2], [3, 4]]} 
  animate={true} 
  animationType="fade-in" 
/>
1
2
3
4

2. The Equation Component

For general mathematical formulas, the <Equation /> component wraps KaTeX rendering with container styling and animations.

Styles

Boxed

<Equation formula="E = mc^2" style="box" />
E=mc2E = mc^2

Glass

<Equation formula="\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}" style="glass" />
ex2dx=π\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}

Animations

Typewriter Effect

Great for revealing complex formulas step-by-step.

<Equation 
  formula="f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x-a)^n" 
  style="neon"
  animate={true} 
  animationType="typewriter" 
/>
f(x)=n=0f(n)(a)n!(xa)nf(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x-a)^n

3. Visualizing Systems

The <System /> component helps visualize linear systems of the form Ax=bAx = b.

<System 
  A={[[1, 2], [3, 4]]} 
  x={['x', 'y']} 
  b={[5, 11]} 
  style="glass"
  animate={true}
/>
1
2
3
4
A
x
y
x
=
5
11
b

4. Determinants

Visualize the calculation of a determinant, especially useful for teaching 2x2 matrices.

<Determinant 
  data={[[2, 5], [1, 3]]} 
  style="cross" 
  animate={true} 
/>
2
5
1
3
(2 × 3) (5 × 1) = 1

Conclusion

With these components, you can transform your mathematical content from static text into engaging, visual elements. Mix and match styles to fit your theme, and use animations to guide your reader’s attention.