Replies: 2 comments
-
@jez My take on CSS
Yes, you should be able to set multiple counters on an element with a rule such as:
I'm reluctant to dictate to users how they organize their HTML. |
Beta Was this translation helpful? Give feedback.
-
A few additions:
|
Beta Was this translation helpful? Give feedback.
-
This post is half question and half "here's something I learned, maybe it'll be useful to someone else."
I recently went through an upgrade from KaTeX v0.11.1 to v0.15.0. This range of revisions included this addition, which first landed in v0.13.0:
→ View commit
80b0e3dc2
The page I where use KaTeX defines its own CSS counters in addition to those that KaTeX defines. In old versions of my page, it also defined those counters on the
body
element.This caused a problem on my page: since the KaTeX stylesheet was loading after my personal CSS file, KaTeX's counters would overwrite my
counter-reset
definition onbody
:By the time you read this, I'll likely have worked around the problem (by moving my counters to be defined on
main
instead ofbody
), but if you're curious, you can see an example of the HTML structure my page uses here:https://jez.io/pandoc-markdown-css-theme/kitchen-sink/#side-notes
The
sidenote-counter
from the screenshot above powers the sidenote numbers you see in the page, which at the time I'm writing this post looks like this, where all the sidenote numbers read1
:My questions:
Is there some way when using CSS counters to allow multiple separate libraries to define counters with
counter-reset
on the same element? I have looked through thecounter-reset
docs but I don't see anything that looks likeIf something like this feature existed, KaTeX could use this on its
body
counter-reset
, which would then instruct the browser to merge KaTeX's counters with my counters.Is there any selector other than
body
that makes sense forKaTeX
to store its counters on? For example, I wonder if KaTeX users should be required to place aclass="katex-equation-container"
(or some other name) on some element in order to opt into KaTeX's equation numbering.This is just an idea—obviously doing something like this now would be a breaking change, and would be additional toil that KaTeX users would have to discover and implement before being able to use numbered equations. I'm not saying it's a perfect solution but merely presenting a possibility.
If you have any other thoughts on this issue I'd be curious to hear them. Again, in my CSS library I've worked around this by simply defining my
sidenote-counter
variable on themain
element, instead of on thebody
element, which luckily works for me (as there's always amain
element already wrapping every sidenote on the page). But I recognize that this solution might not be a possibility for other users of KaTeX, so I figured I would at least start the conversation in case it's useful for others to discover.Thanks in advance for your response, and thanks for your work on KaTeX, which has been an incredible library to use.
Beta Was this translation helpful? Give feedback.
All reactions