feat: add tex(?) formula support
This commit is contained in:
parent
414cd7d3d7
commit
d6e1a9dd94
5 changed files with 145 additions and 1 deletions
|
@ -246,4 +246,35 @@ X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
|
|||
|
||||
Press <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd> to end the session.
|
||||
|
||||
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
|
||||
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
|
||||
|
||||
### Formulas
|
||||
Thanks to the [remark-math](https://github.com/remarkjs/remark-math) and [KaTeX](https://katex.org/) , you can write mathematical formulas using LaTeX syntax.
|
||||
|
||||
Both inline and block formulas are supported (see example below). Inline formulas can be written like `$$L$$` or `$L$`,
|
||||
|
||||
while block formulas can be written like this:
|
||||
|
||||
```latex
|
||||
$$
|
||||
-\frac{\hbar^2}{2m}\nabla^2\psi + V\psi = E\psi
|
||||
$$
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
````markdown
|
||||
```math
|
||||
-\frac{\hbar^2}{2m}\nabla^2\psi + V\psi = E\psi
|
||||
```
|
||||
````
|
||||
|
||||
By default, the reader can copy the formulas in LaTeX format by copy the rendered formulas, unless you set `noClientJavaScript` to `true` in the `config.ts` file.
|
||||
|
||||
|
||||
Lift($$L$$) can be determined by Lift Coefficient ($$C_L$$) like the following
|
||||
equation:
|
||||
|
||||
$$
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
$$
|
|
@ -9,6 +9,7 @@ import ReplyViaEmail from "../../components/ReplyViaEmail.astro";
|
|||
import { ExtractFirstImage } from '../../plugins/extract-images';
|
||||
import AuthorInfo from "../../components/helper/authors/Info.astro";
|
||||
import TableOfContents from "../../components/TableOfContents.astro";
|
||||
import "katex/dist/katex.css"
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('posts');
|
||||
|
@ -62,6 +63,11 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `
|
|||
<br>
|
||||
<a href="/blog">← Back to posts</a>
|
||||
{noscript && <h2>Comments</h2> <Comments path={`blog/${slug}`} />}
|
||||
{!noscript &&
|
||||
<script>
|
||||
import "katex/dist/contrib/copy-tex.js"
|
||||
</script>
|
||||
}
|
||||
</div>
|
||||
|
||||
</Layout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue