dsrkafuu / hugo-theme-fuji

A minimal Hugo theme with nice theme color. | 一个主题色极简 Hugo 主题。
https://github.dsrkafuu.net/hugo-theme-fuji/
Apache License 2.0
366 stars 97 forks source link

katex rendering failed with *aligned* macro #40

Closed OneForward closed 3 years ago

OneForward commented 4 years ago

I've tried to render this demo equation in markdown but the local hugo server failed to render it properly. Normal katex equations can be rendered very nicely, though.

$$
\begin{aligned}
   a&=b+c \\
   d+e&=f
\end{aligned}
$$
dsrkafuu commented 4 years ago

I've tested some other demos and found the same problem. It seems that Hugo itself and its markdown parser Goldenmark were the cause. Hugo will render a <br /> which will mess with the katex, and single \\ will be rendered to \ as escape characters.

You can write the katex code in one line and use \\\\ to render as \\ directly in markdown file.

$$
\begin{matrix}
  a & b \\\\ c & d
\end{matrix}
$$

Or you can try updating the theme to use the new math shortcode I just committed:

-> display style

{{< math >}}
\begin{matrix}
a & b \\
c & d
\end{matrix}
{{</ math >}}

-> inline style

{{< math "inline" >}}
\begin{matrix}
a & b \\
c & d
\end{matrix}
{{</ math >}}
rexarski commented 3 years ago

I had the exact same issue today and \\\\ won't make it right in the {aligned} environment. Tried to replace \\ with \cr and it worked. It's not an elegant solution though. @OneForward