szcf-weiya / ESL-CN

The Elements of Statistical Learning (ESL)的中文翻译、代码实现及其习题解答。
https://esl.hohoweiya.xyz
GNU General Public License v3.0
2.4k stars 588 forks source link

mathjax link to equation #173

Closed szcf-weiya closed 3 years ago

szcf-weiya commented 5 years ago

sometimes the link locates a wrong position, for example, (3.65) and (3.66), as shown in the following gif, https://esl.hohoweiya.xyz/03-Linear-Methods-for-Regression/3.7-Multiple-Outcome-Shrinkage-and-Selection/index.html#mjx-eqn-3.66 Peek 2021-01-06 20-54

szcf-weiya commented 3 years ago

also reported in http://disq.us/p/2e8ldh3

also, find a similar issue reported in https://stackoverflow.com/questions/39372511/mathjax-add-offset-for-the-target-eqref-link-of-equation-when-there-is-a-to

szcf-weiya commented 3 years ago

method 1 (not proper)

use padding-top and margin-top (https://www.cnblogs.com/shenjp/p/11088344.html), and the results is image

method 2 (not proper)

https://www.cnblogs.com/shenjp/p/11088344.html

.mjx-mtd:target {
  padding-top: 50px;  
}

image

method 3 (not work)

https://stackoverflow.com/questions/10732690/offsetting-an-html-anchor-to-adjust-for-fixed-header

:target::before {
    content: '';
    display: block;
    height:      180px;
    margin-top: -180px;
}

image

szcf-weiya commented 3 years ago

so I try this method, and finally, it works. But at first, it still fails, Peek 2021-01-07 11-17 and it is so strange that only negative values work!

then I found there is an argument, overflow for the whole mathjax display,

Peek 2021-01-07 11-21

without this option, it works well!

Also check that only remove overflow is not enough.

And also find that the latest mkdocs-material does not have such setting for mathjax.

image