Katex transform.ToMath throws error with valid syntax

I followed this guide https://gohugo.io/functions/transform/tomath/#example to render mathematical syntax using latex. It throws error for valid syntax. When i tried it with katex renderer online it works. Is there some kind of bug ? The latex syntax is as below

$$
\begin{matrix}
&&&2&3&4 \\
\times &7&6&5&& \\
\hline
\end{matrix}\\
{2}\times{5} = 10
$$

Error:

Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: template: _default/_markup/render-passthrough.html:2:23: executing "_default/_markup/render-passthrough.html" at <transform.ToMath>: error calling ToMath: not a function: see "~/Workspace/alvarorevuelta.com/content/posts/2024-04-26-fft-polynomials.md:0:1".

Not a solution, just some notes while tracking this…

This works (inline instead of block/display mode):

\(
\begin{matrix}
&&&2&3&4 \\
\times &7&6&5&& \\
\hline
\end{matrix}\\
{2}\times{5} = 10
\)

In block/display mode, if you remove the last line and the newline (\\) above it, no errors.

The latest version of katex.js throws this warning in the browser console:

LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does nothing in display mode [newLineInDisplayMode]

But it (sort of) works:

image

The right way to handle this with either MathJax or KaTeX is:

$$
\begin{aligned}
\begin{matrix}
&&&2&3&4 \\
\times &7&6&5&& \\
\hline
\end{matrix} \\
{2}\times{5} = 10
\end{aligned}
$$

Both MathJax and KaTeX render the above to:

image

Thank you . So it was my mistake . You are the best

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.