Skip to content
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

multiline math was not displayed correctly #28

Open
FlyGinger opened this issue Jun 17, 2022 · 11 comments
Open

multiline math was not displayed correctly #28

FlyGinger opened this issue Jun 17, 2022 · 11 comments

Comments

@FlyGinger
Copy link

hi, I want to migrate my blog to minima but I found something unexpected.

$$
\begin{aligned}
T(n) & = c_1 n + c_2 (n - 1) + c_3 (n - 1) + c_4 \sum_{j = 2}^n t_j \\
& + c_5 \sum_{j = 2}^n (t_j - 1) + c_6 \sum_{j = 2}^n (t_j - 1) + c_7 (n - 1)
\end{aligned}
$$

Above math equations were displayed in a single line, and \\ was ignored.

So would you fix this, or there is another way to type a newline?

@FlyGinger
Copy link
Author

I found that \\\\ can make a linebreak.

It's not cool......

@memclutter
Copy link
Contributor

I'm not very familiar with this syntax. But could you please provide steps on how to reproduce this locally?

@FlyGinger
Copy link
Author

aligned is used to display multiline math equations, and \\ is used to make a linebreak. For example,

$$
\begin{aligned}
a \\
b
\end{aligned}
$$

This should be rendered as something like

a
b

But now it is

ab

This means that \\ does not make a linebreak correctly. I found that \\\\ can make a linebreak, so there may be extra interpreting step before math render engine (or framework that deals with math).

\\\\ works but is annoying, because I have to use \\\\ to make math display correct on my website, but at the same time it make two linebreak in other place.

@mivinci
Copy link
Owner

mivinci commented Nov 13, 2022

It is an issue I hadn't solved since I started using Hugo. It is likely that the markdown engine Hugo uses takes every heading \ as an escape character :(

@FlyGinger
Copy link
Author

ok 😃
At least we have a solution \\\\.

@memclutter
Copy link
Contributor

i found these https://github.com/xsro/xsro.github.io/blob/hugo/layouts/partials/extend_head.html#L1-L24

I have one idea, I'll try to make a pull... but first I need to update the theme for my site 😄

@mivinci
Copy link
Owner

mivinci commented Nov 14, 2022

\cr might be the most compatible solution by far, also works with other math frameworks.

$$
\begin{aligned}
a \cr
b
\end{aligned}
$$

is also rendered as:

$$ \begin{aligned} a \cr b \end{aligned} $$

@szw0407
Copy link

szw0407 commented Nov 2, 2023

About one year ago GitHub does the same thing when I type math equations. \ was always escaped until one day they fixed this problem, along with the problem of rendering \{ directly into { before Katex was able to touch the code, consequently making many equations incorrectly shown, and I now recommend using \newline and \lbrace instead. If the issue is fixed someday, tex codes using \\\\ due to the current FEATURE will not be shown as you expect, but those things would be shown properly under most circumstances.

@szw0407
Copy link

szw0407 commented Nov 2, 2023

i found these https://github.com/xsro/xsro.github.io/blob/hugo/layouts/partials/extend_head.html#L1-L24

I have one idea, I'll try to make a pull... but first I need to update the theme for my site 😄

Seems interesting. However, this script could only be used when Hugo has such FEATURE, is that so?

@szw0407
Copy link

szw0407 commented Nov 2, 2023

It is an issue I hadn't solved since I started using Hugo. It is likely that the markdown engine Hugo uses takes every heading \ as an escape character :(

Perhaps it is caused by the backslashLineBreak being true in blackfriday. I shall check it later today.

Katex itself supports \\. In many other places such equations are shown correctly using Katex.

Ref: (both written in zh_CN)

https://hugocn.netlify.app/configuration.html#%E9%85%8D%E7%BD%AE%E6%B8%B2%E6%9F%93%E5%BC%95%E6%93%8Eblackfriday%EF%BC%89

https://byteprince.com/posts/2d4e6e67/

@mivinci
Copy link
Owner

mivinci commented Nov 7, 2023

i found these https://github.com/xsro/xsro.github.io/blob/hugo/layouts/partials/extend_head.html#L1-L24
I have one idea, I'll try to make a pull... but first I need to update the theme for my site 😄

Seems interesting. However, this script could only be used when Hugo has such FEATURE, is that so?

Sadly I guess so 😪

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

4 participants