Skip to content

Odd Katex rendering #671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mtseng15 opened this issue Dec 15, 2024 · 5 comments
Open

Odd Katex rendering #671

mtseng15 opened this issue Dec 15, 2024 · 5 comments

Comments

@mtseng15
Copy link

Hello Everyone,

First of all, I wanted to say THANK YOU for this lovely theme and excellent documentation. This is awesome work and I am very grateful.

This may be a weird configuration thing on my side, but I noticed that some of my latex equations are rendering oddly. Specifically, there is something with the vertical margins on overlines, underlines and super scripts. For example, the equation:

\overline{x}'(t) = \underline{A}\overline{x}(t), \;\; \overline{x}(0) = \overline{b}

renders just fine in the online Katex demo

Screenshot 2024-12-14 at 6 46 20 PM

But in the book theme it looks like:

Screenshot 2024-12-14 at 6 42 03 PM

where the overlines are too low and the underlines are too high.

Does anyone have any ideas how I can fix this? It looks this could be a different font and I know Katex supports three different fonts so it makes me wonder if that is it.

I should also add this is my first time using Hugo and I'm still a little shaky on how all the templating works.

Thanks a lot!

@alex-shpak
Copy link
Owner

Hi! Do you have any CSS overrides? I tried your snipped, and got this
Image

@mtseng15
Copy link
Author

mtseng15 commented Jan 31, 2025

@alex-shpak Thank you for responding and your awesome theme!

Interesting! So I started from scratch again and added pieces back in. I found that following the instructions here to let $$ and $ be used to denote equations is what caused the issue. I'm still very new do Hugo so I have no clue why it is affecting it.

Do you have any thoughts? Or advise? I would really like to use $$ and $ to denote equations since that's what I'm used to in my normal note taking.

I would also appreciate an explanation on why it is happening too for my own education and learning.

Thanks a lot!
Micah

@alex-shpak
Copy link
Owner

Hm, try this:

  1. put {{<katex />}} at the beginning of the page
  2. use $$\overline{x}'(t) = \underline{A}\overline{x}(t), \;\; \overline{x}(0) = \overline{b}$$

@alex-shpak
Copy link
Owner

I will take a look at passthrough, might be a plug-and-play replacement

@mtseng15
Copy link
Author

Hello @alex-shpak,

Thank you very much for taking a look at this. I apologize for the delay in responding.

It seems like using the Goldmark pass through from the Hugo documentation that I was using as referenced in the issue linked above does not use the Katex in the shortcode of the book theme (at the moment, I don't know how the pass through works). So I ripped out and started over :)

By just adding the short code {{<katex />}} to the begining of the page, the overline latex does render correctly now (yay! Thank you).

However, now my matrices are not rendering correctly:

The matrix:

$$
\underline{A} = 
\begin{bmatrix}
1 & i2 & 3 \\
-i2 & -9 & -i3 \\
3 & i3 & 2
\end{bmatrix}
$$

renders as:
Image

The Katex demo renders like this:

Image

If I wrap the matrix in {{< katex display=true >}} and {{< /katex >}} then it renders correctly.

I am sure, this is something stupid I am doing with the short codes. Do you have any thoughts?

Thank you very much! I owe you for such a nice theme and all your help.

Micah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants