s-spavound / blogcomments

blog comments repo for utterances.es
0 stars 0 forks source link

posts/2020/09/equations-with-katex-in-hugo/ #1

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Equations with KaTeX in Hugo :: Simon Spavound — Data Scientist

This blog is built with Hugo, using the Hello Friend NG theme developed by Djordje Atlialp. One thing that it does not support natively is equations. There are multiple ways of including equations in a statically generated site like this, so this post is as much for my future reference as anything else. The two main options available are Mathjax and KaTeX. I wanted to use (\KaTeX) due to its faster rendering speed, however, I did not want to change the default renderer in Hugo, Goldmark, to an alternative such as MMark (which many other posts suggest although it is deprecated).

https://www.simonspavound.com/posts/2020/09/equations-with-katex-in-hugo/

mar0093 commented 2 years ago

Loved the article!

For me personally, I use the 'hugo-theme-learn' as my theme. The only point of difference I had was the template which renders posts was called 'list.html' rather than 'single.html'. Which had me scratching my head a little, especially when I have a file called 'single.html' that on first look, appears to also render content in posts haha.

But I love the parameter option, this is article helped me reach my solution fast, so thank you!

chrisoffner3d commented 2 years ago

Hey Simon, thank you for this nice tutorial, very helpful.

Any idea why I can't write two underbrace-Statements in the same $$ expression?

$$\overbrace{a}^{b} - \overbrace{c}^{d}$$  <!-- this works fine -->

$$\underbrace{a}_{b}$$  <!-- this works fine -->

$$\underbrace{a}_{b} - \underbrace{c}_{d}$$  <!-- this doesn't render as LaTex at all -->
dkarkada commented 2 years ago

Super helpful, thanks!!

canmetan commented 2 years ago

Thanks for the article. As of now KaTeX 16.2 is supported which can be found here which can be used with like this

However as @chrisoffner pointed out, some functionalities won't work. I've made a post regarding this issue. Hopefully it will be resolved.

Fanisting commented 1 year ago

Hi, is there any way to include the inline math as $x$ instead of \x\?

canmetan commented 1 year ago

Hi, is there any way to include the inline math as x instead of \x\?

Try the double $ sign "$$" instead of the single one.