Does ghost natively support latex syntax?
To enable MathJax rendering in Ghost using Code Injection, you need to add the following code in the Site Header (found in Ghost Admin > Settings > Code Injection > Site Header):
<!-- MathJax CDN for Ghost rendering -->
<script>
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
},
options: {
ignoreHtmlClass: 'no-mathjax',
processHtmlClass: 'mathjax'
}
};
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>Now, you can write LaTeX using $...$ for inline and $$...$$ for display equations in your Ghost posts.
Example: Calculation for a Rectangular Beam
Given:
- $M_{max}$ = maximum bending moment
- $b$ = width of rectangular section
- $h$ = height of rectangular section
Calculate moment of inertia:
$$
I = \frac{b h^3}{12}
$$
Extreme fiber distance:
$$
c = \frac{h}{2}
$$
Maximum tensile stress:
$$
\sigma_{max} = \frac{M_{max} \cdot c}{I} = \frac{M_{max} \cdot \frac{h}{2}}{\frac{b h^3}{12}} = \frac{6 M_{max}}{b h^2}
$$
Piecewise Form (for tension and compression):
$$
\sigma(y) =
\begin{cases}
+\frac{M y}{I} & \text{below the neutral axis (tension)} \
-\frac{M y}{I} & \text{above the neutral axis (compression)}
\end{cases}
$$