Open jxpeng98 opened 11 months ago
This might be related https://github.com/KaTeX/KaTeX/issues/2380
It probably comes from the fact that previous slides are hidden (not in the DOM), so CSS numbering is offset. Currently, I guess slidev would need to :
counter-reset: katexEqnNo 42
in every slideI try to add
<style>
body{
counter-reset: katexEqnNo 42;
}
</style>
to each page. But it did not work.
It can only have
If add a number after counter-increment: katexEqnNo
, it can change the equation number. For example, I add 5
:
I also found that the equation number is correct in the preview:
But if you click the specific page, the equation will be reset to 1:
Nice, I did not though this could be a workaround (especially if there are not too many slides).
You need to put the reset on the slide for it to take precedence :
<style>
.slidev-layout, .slide-container {
counter-reset: katexEqnNo 42;
}
</style>
(for some reason I need to restart slidev to get it to take inline style at the moment)
that being said, the subject of your slides seem to be very interesting!
@twitwi
Thanks for your reply. This is the introduction to statistics.
Yes, your method works. However, it is inconvenient to set for each page if you build the project as a static page.
PDF version and HTML preview can work well since the project is rendered as a single page. However, the web will be refreshed when you jump to the next page. \
May I know if there is a way to store the equation number from the previous slide and continue the equation number on the current page?
Many thanks!
Found a workaround... The difficulty lies in the fact that we cannot read the css counter and it's not trivial to reset it from vue variable. But if you add the following global-top.vue component in your project, it should correct the equation number. Their also a trick to have correct number in overview.
global-top.vue
<script setup>
import {ref, watch} from 'vue'
import {showOverview} from "@slidev/client/state/index.ts"
let neq = ref(0)
let pages = undefined
function update_value()
{
let p = $slidev.nav.currentPage
// trick to have counter at zero at the end of the slide in overview mode
neq.value = showOverview.value ? -(pages[p+1] -pages[p]) ?? 0 : pages[p];
}
function update()
{
pages = {}
let nbeq = 0
for (const i of Array($slidev?.nav?.total ?? 0).keys())
{
pages[i] = nbeq;
nbeq += (document.getElementsByClassName("slidev-page-"+i)[0]?.getElementsByClassName("eqn-num") ?? []).length
}
pages[$slidev?.nav?.total ?? 0] = nbeq;
update_value()
}
update()
watch([$page,showOverview], (a) => {
update_value()
} )
</script>
<template>
<component :is="'style'" type="text/css"><!-- v-if="!showOverview"-->
#page-root .slidev-page {
--eqn-val: {{neq}};
counter-set: katexEqnNo var(--eqn-val);
}
</component>
<!--component :is="'style'" type="text/css" v-if="showOverview">
/* alternative overview reset, but overview did not have any id to reset on but grid... */
.grid {
counter-reset: katexEqnNo 0;
}
</component-->
</template>
Describe the bug If I have various equations in multi pages. The equation number will always start from (1) for every page. For example, In the first page, I have
On the next page,
To Reproduce Steps to reproduce the behavior: add any two equations on different pages by using
And render the file. The bug will appear.
Desktop (please complete the following information):