Some math formulas can not be displayed
What happened?
I published a blog with lots of block math. Strangely, some of them can not be showed properly.
A test blog is published to show this problem: https://pixelock.github.io/p/math-typesetting/
Two blocks are not showed correctly. Details in .md
$$
\begin{aligned}
& \mathbf{q}_t = W_Q \mathbf{h}_t \\
& \mathbf{k}_t = W_K \mathbf{h}_t \\
& \mathbf{v}_t = W_V \mathbf{h}_t
\end{aligned}
$$
在 MHA 中, $\mathbf{q}_t, \mathbf{k}_t, \mathbf{v}_t$ 被拆分为 $n_h$ 个 heads, 然后每个 head 中进行 attention 计算:
$$
\mathbf{q}_t + \mathbf{q}_{1}
$$
每个 head 计算得到的结果再拼接起来, 经过参数矩阵 $W_O \in \mathbb{R}^{d \times d_h n_h}$ 得到 MHA 的输出张量.
$$
\begin{aligned}
& {\left[\mathbf{q}_{t, 1} ; \mathbf{q}_{t, 2} ; \ldots ; \mathbf{q}_{t, n_h}\right]=\mathbf{q}_t,} \\
& {\left[\mathbf{k}_{t, 1} ; \mathbf{k}_{t, 2} ; \ldots ; \mathbf{k}_{t, n_h}\right]=\mathbf{k}_t,} \\
& {\left[\mathbf{v}_{t, 1} ; \mathbf{v}_{t, 2} ; \ldots ; \mathbf{v}_{t, n_h}\right]=\mathbf{v}_t,} \\
& \mathbf{o}_{t, i}=\sum_{j=1}^t \operatorname{Softmax}_j\left(\frac{\mathbf{q}_{t, i}^T \mathbf{k}_{j, i}}{\sqrt{d_h}}\right) \mathbf{v}_{j, i}, \\
& \mathbf{u}_t=W^O\left[\mathbf{o}_{t, 1} ; \mathbf{o}_{t, 2} ; \ldots ; \mathbf{o}_{t, n_h}\right]
\end{aligned}
$$
same latex math code can be show properly in another blog pubulish framework, so the math code itself is correct:
Can you help to find the cause of this problem, thx!
Hugo version
0.125.7
Theme version
3.26.0
What browsers are you seeing the problem on?
Chrome
More information about the browser
No response
Relevant log output
No response
Link to Minimal Reproducible Example
https://github.com/pixelock/blogtest
I find that either inline math or block math with _{ or \{ will cause this problem. Manually change them into \_{ or \\{ to show properly.
How to fix it in the theme?
@pixelock alright, i think some features in this theme is kinda... outdated :) you can find fix in https://gohugo.io/content-management/mathematics/
@pixelock alright, i think some features in this theme is kinda... outdated :) you can find fix in https://gohugo.io/content-management/mathematics/
i'll try. thanks for helping!
@pixelock alright, i think some features in this theme is kinda... outdated :) you can find fix in https://gohugo.io/content-management/mathematics/
I've added config files by following the two steps and it works, thanks
I have added this configuration to the starter template so it will work in the future, thanks for all the feedback!