Fix #7: katex now work as expected

This commit is contained in:
slashformotion 2021-07-28 11:02:23 +02:00
parent 63de5c8780
commit 0299aa32d3
5 changed files with 27 additions and 29 deletions

View file

@ -21,7 +21,7 @@ This is a fork of the original [hugo-tufte](https://github.com/shawnohare/hugo-t
[katex](https://katex.org/) renders LaTeX written inside of markdown files. LaTeX can be
written more or less as normal. Some examples:
- This `\\( \frac{1}{2} \\)` will be rendered inline.
- This `$ \frac{1}{2} $` will be rendered inline.
- A simple displayed equation: `$$f(x, y) := e^{x^2 - y^2}.$$`
There currently seems to be some weirdness with other environments,
@ -33,12 +33,12 @@ Let $G$ be a finite group with exponent $2$. Then every element is
an involution, hence for any $x$, $y$ in $G$ we have:
<p>
\begin{align*}
\begin{aligned}
e &= (xy)^2 \\
&=xyxy \implies \\
y^{-1} &= xyx \implies \\
y^{-1}x^{-1} &= xy,
\end{align*}
\end{aligned*}
</p>
establishing that $G$ is abelian.
@ -104,7 +104,7 @@ support all the features present in the
```html
{{< epigraph pre="Author Writer, " cite="Math is Fun" >}}
This is an example of an epigraph with some math
\\( \mathbb N \subseteq \mathbb R \\)
$ \mathbb N \subseteq \mathbb R $
to start the beginning of a section.
{{< /epigraph >}}
```

View file

@ -4,12 +4,12 @@ meta = false
author = "AUTHOR NAME"
date = "2021-07-20T13:56:01-08:00"
type = "post"
title = "More math \\(\\xi_{(even-in-the-title-!)}\\)"
title = "More math $\\xi_{(even-in-the-title-!)}$"
subtitle = "Wow this really works ! "
toc = true
categories = ["katex", "latex", "tufte-css"]
+++
A compilation of \\(\LaTeX\\) formulas...
A compilation of $\LaTeX$ formulas...
<!--more-->
## Matrix

View file

@ -12,13 +12,13 @@ categories = ["katex", "latex", "tufte-css"]
+++
This is a quick demonstration post. It serves as an example of the features
of this theme. One of them is \\( \LaTeX \\) via [Katex](https://katex.org/).
of this theme. One of them is $ \LaTeX $ via [Katex](https://katex.org/).
{{< section "begin" >}}
## A Bit About Mathematics
{{< epigraph pre="Shawn O'Hare, " cite="Math is Fun" >}}
This is an example of an epigraph with some math
\\( \mathbb N \subseteq \mathbb R \\)
$ \mathbb N \subseteq \mathbb R $
to start the beginning of a section.
{{< /epigraph >}}
@ -27,20 +27,20 @@ to start the beginning of a section.
### Inline
Some inline math:
{{< marginnote "mn-example" >}}This is a margin note.{{< /marginnote >}}
\\(e^{i \pi} = -1\\)
and \\(\sqrt{-1} = i \\)
and \\( a_2 = 3 \\).
$e^{i \pi} = -1$
and $\sqrt{-1} = i $
and $ a_2 = 3 $.
### Display
And display math using escaped brackets `\\[`:
And display math using this symbol `$$`:
{{< sidenote "sn-example" >}}This is a sidenote!{{< /sidenote >}}
\\[
$$
-- \cdot_H -- \colon B(G,H) \times B(H, K) \to B(G, K), \quad ([X], [Y]) \mapsto [X \times_H Y].
\\]
$$
### Environments
Currently, certain \\(\LaTeX\\) environments need to be escaped so that
Currently, certain $\LaTeX$ environments need to be escaped so that
the markdown processor does not override Katex. Currently, display
environments should be enclosed in `<p>` tags and blank lines.
For instance:
@ -77,7 +77,7 @@ $$
### Blockquotes
Some blockquotes. But first, we try to manually cite via
<cite>This is between cite tags and has math: \\(e^x \\)</cite>
<cite>This is between cite tags and has math: $e^x $</cite>
{{< blockquote cite="www.shawnohare.com" footer="Shawn O'Hare" >}}
This is a blockquote with two paragraphs, that employs the

View file

@ -1,4 +1,4 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js"></script>

View file

@ -1,14 +1,12 @@
<script>
renderMathInElement(
renderMathInElement(
document.body,
{
{
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\[", right: "\\]", display: true},
{left: "$", right: "$", display: true},
{left: "\\(", right: "\\)", display: true}
],
displayMode: true
}
);
</script>
{ left: "$$", right: "$$", display: true },
{ left: "\\[", right: "\\]", display: true },
{ left: "$", right: "$", display: false },
{ left: "\\(", right: "\\)", display: false }
],
displayMode: true
}
);