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

The header blocks the target mathematical equation after clicking on an equation reference #437

Closed
searene opened this issue Jul 21, 2023 · 4 comments
Labels

Comments

@searene
Copy link

searene commented Jul 21, 2023

Here is a sample markdown text for illustrating my point:

But how to prove that? We can use the following logic: Since `count` drops to 0 in the $k$-th iteration and the first number is $m$, we know that the number of $m$ in the first $k$ numbers is exactly $\frac{k}{2}$. To prove $m$ is also the majority in the remaining $n - k$ numbers, we need to prove

$$(c - \frac{k}{2}) \cdot 2 > n - k \label{1} \tag{1}$$

Which is equivalent to

$$2c - k > n - k$$

Which is equivalent to

$$2c > n$$

That is true by the definition of $m$. So we know that the equation $\eqref{1}$ holds. Following the previous logic, we know that it means the algorithm works when the first number is the majority.

The $\eqref{1}$ part is a link, when the user clicks on the link, the webpage should jump to the equation marked with \tag{1}. It works as expected, only that the target equation is at the top of the page, and the header is also at the top of the page, so the header blocks the target equation.

There is no such problem when clicking on markdown headers, it might have been fixed with issues like #158. Could this issue be solved in the same way?

I recorded a video to illustrate my point:

Screen.Recording.2023-07-21.at.08.52.17.mov

You can also find those texts on this webpage for testing.

Thanks in advance!

@reuixiy
Copy link
Owner

reuixiy commented Jul 21, 2023

I have reproduced this in my Chrome browser.

But it shouldn't happen, the latest fix for #158 is

/* Scrolling fix for anchors being hidden below the header */
*[id] {
scroll-margin-top: var(--header-height);
}

Using scroll-margin-top for all HTML elements have id attribute to fix the problem. As shown in the screenshot below, the <mjx-mtd> element also has id attribute, but this CSS rule doesn't apply!

Arc 2023-07-21 at 09 21 12@2x

Then I tested this in my Safari browser and it works normally. So I think this is a upstream browser bug which caused scroll-margin-top doesn't apply to custom HTML elements.

@searene
Copy link
Author

searene commented Jul 21, 2023

@reuixiy Thanks for the reply! I actually ran the webpage in Edge, and it didn't work either. Maybe it's because Edge and Chrome are the same at the core. Considering that most upstream browsers usually take a long time to fix a bug, I don't expect this bug to be fixed by them soon. So maybe we can find a way to work around the problem in the meantime. For example, can we give the user an option to stop fixing the header at the top? It could be like the header in Hacker News, the header won't move along when the user scrolls up or down. It's just like other parts of the webpage, when the user scrolls away, it disappears. It has two advantages:

  1. The header won't block the text anymore, because it's always appearing above any contents.
  2. It can be taken as another style of the website, giving the user another option, even if the user is not bothered by the current issue.

Please kindly consider this suggestion :)

@reuixiy
Copy link
Owner

reuixiy commented Jul 21, 2023

Yes you can customize it by yourself, simply adding

.header {
    position: relative;
}

.main {
    padding-top: 3em;
}

to your ~/blog/assets/scss/custom/_custom.scss file.

See https://github.com/reuixiy/hugo-theme-meme#customize-meme

@searene
Copy link
Author

searene commented Jul 22, 2023

@reuixiy I just tried it, and it worked! Thanks for the solution!

@searene searene closed this as completed Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants