This document demonstrates how to use LaTeX equations in your Markdown files for AstroPaper. LaTeX is a powerful typesetting system often used for mathematical and scientific documents.
Table of contents
Instructions
In this section, you will find instructions on how to add support for LaTeX in your Markdown files for AstroPaper.
-
Install the necessary remark and rehype plugins by running
npm install rehype-katex remark-math katex
. -
Update the Astro configuration (
astro.config.ts
) to use the these plugins:
- Import KaTeX CSS in the main layout file
src/layouts/Layout.astro
And voilà, this setup allows you to write LaTeX equations in your Markdown files, which will be rendered properly when the site is built. Once you do it, the rest of the document will appear rendered correctly.
Inline Equations
Inline equations are written between single dollar signs $...$
. Here are some examples:
- The famous mass-energy equivalence formula:
$E = mc^2$
- The quadratic formula:
$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
- Euler’s identity:
$e^{i\pi} + 1 = 0$
Block Equations
For more complex equations or when you want the equation to be displayed on its own line, use double dollar signs $$...$$
:
The Gaussian integral:
The definition of the Riemann zeta function:
Maxwell’s equations in differential form:
Using Mathematical Symbols
LaTeX provides a wide range of mathematical symbols:
- Greek letters:
$\alpha$
,$\beta$
,$\gamma$
,$\delta$
,$\epsilon$
,$\pi$
- Operators:
$\sum$
,$\prod$
,$\int$
,$\partial$
,$\nabla$
- Relations:
$\leq$
,$\geq$
,$\approx$
,$\sim$
,$\propto$
- Logical symbols:
$\forall$
,$\exists$
,$\neg$
,$\wedge$
,$\vee$