Hello I just got Obsidian.md and want a nice way to caption and keep track of figures. I am a novice with HTML and CSS but have been stumbling through. I am making figures using HTML and would like to prepend my figure captions with 'Fig. X' where X is the figure's number in my note and I wrote this snippet
<style>
/* initialise the counter */
body { counter-reset: figureCounter; }
/* increment the counter for every instance of a figure even if it doesn't have a caption */
figure { counter-increment: figureCounter; }
/* prepend the counter to the figcaption content */
figure figcaption:before {
content: "Fig " counter(figureCounter) ": "
}
</style>
Unfortunately it seems like every figure got 'Fig. 1'. Does anyone know why my code seems to be "forgetting" how many figures there were? I tested wrapping my figures in a body and this correctly creates Fig. 1 and Fig. 2, but I don't want to wrap my whole note in a .
<body>
<figure>
<img src = "link" width = 250>
<figcaption>This is the caption</figcaption>
</figure>
<figure>
<img src = "link" width = 250>
<figcaption>This is the caption</figcaption>
</figure>
</body>
Any help would be appreciated, thanks in advance!