This code seems to work well on my end for applying styling specifically to “block LaTeX”:
.latex[alt*="displaymath"], .latex[alt*="$$"] {
display: block;
margin-left: auto;
margin-right: auto;
}
Explanation: I checked the HTML and noticed that the alt
attribute in the LaTeX images contains certain text like "displaymath"
or "$$"
when block LaTeX is used. The CSS uses a partial match selector ([alt*=""]
) to target these cases.
While this worked in my testing, it might not cover every scenario. If needed, you can use this add-on to inspect the alt
attribute and tweak the selector: AnkiWeb - AnkiWebView Inspector Add-on.