Skip to content

Commit 0de8b75

Browse files
committed
Add MathJax configuration and copy code script to head.html + example post
1 parent 0cf29a7 commit 0de8b75

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

_includes/head.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{%endif%}
1212
<link rel="stylesheet" href="{{site.baseurl}}/assets/css/common.css" />
1313
<script src="{{site.baseurl}}/assets/js/categories.js"></script>
14+
<script src="{{site.baseurl}}/assets/js/copy-code.js"></script>
1415
<script>
1516
const currentTheme = localStorage.getItem("theme");
1617
if (currentTheme) {
@@ -23,4 +24,30 @@
2324
{% if page.layout == "post" %}
2425
<script defer src="{{site.baseurl}}/assets/js/lbox.js"></script>
2526
{% endif %}
27+
28+
<!-- MathJax Configuration -->
29+
<script type="text/javascript">
30+
window.MathJax = {
31+
tex: {
32+
inlineMath: [
33+
["$", "$"],
34+
["\\(", "\\)"],
35+
],
36+
displayMath: [
37+
["$$", "$$"],
38+
["\\[", "\\]"],
39+
],
40+
processEscapes: true,
41+
},
42+
svg: {
43+
fontCache: "global",
44+
},
45+
};
46+
</script>
47+
<script
48+
type="text/javascript"
49+
id="MathJax-script"
50+
async
51+
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
52+
></script>
2653
</head>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
layout: post
3+
title: Math Examples
4+
date: 2023-03-18
5+
categories: [tutorial]
6+
---
7+
8+
# Math Support in Markdown
9+
10+
This page demonstrates how to use math expressions in Markdown.
11+
12+
## Inline Math
13+
14+
- Einstein's famous equation: $E = mc^2$
15+
- The Pythagorean theorem: $a^2 + b^2 = c^2$
16+
- A simple fraction: $\frac{1}{2}$
17+
18+
## Display Math
19+
20+
The quadratic formula:
21+
22+
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
23+
24+
Maxwell's Equations:
25+
26+
$$
27+
\begin{align}
28+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
29+
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
30+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
31+
\nabla \cdot \vec{\mathbf{B}} & = 0
32+
\end{align}
33+
$$
34+
35+
A matrix:
36+
37+
$$
38+
\begin{pmatrix}
39+
a & b & c \\
40+
d & e & f \\
41+
g & h & i
42+
\end{pmatrix}
43+
$$
44+
45+
## Usage Instructions
46+
47+
You can write math expressions in your Markdown files using:
48+
49+
1. Inline math: `$...$` or `\(...\)`
50+
2. Display math: `$$...$$` or `\[...\]`
51+
52+
For example, to write Einstein's equation inline, type `$E = mc^2$`.
53+
54+
For a block equation like the quadratic formula, use:
55+
56+
```
57+
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
58+
```

0 commit comments

Comments
 (0)