diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py
index 0b0d55858c5..e58182310f3 100644
--- a/sphinx/writers/html5.py
+++ b/sphinx/writers/html5.py
@@ -960,6 +960,7 @@ def visit_field(self, node: Element) -> None:
def visit_math(self, node: Element, math_env: str = '') -> None:
self.has_equations = True
+
# see validate_math_renderer
name: str = self.builder.math_renderer_name # type: ignore[assignment]
visit, _ = self.builder.app.registry.html_inline_math_renderers[name]
@@ -967,6 +968,7 @@ def visit_math(self, node: Element, math_env: str = '') -> None:
def depart_math(self, node: Element, math_env: str = '') -> None:
self.has_equations = True
+
# see validate_math_renderer
name: str = self.builder.math_renderer_name # type: ignore[assignment]
_, depart = self.builder.app.registry.html_inline_math_renderers[name]
@@ -974,12 +976,16 @@ def depart_math(self, node: Element, math_env: str = '') -> None:
depart(self, node)
def visit_math_block(self, node: Element, math_env: str = '') -> None:
+ self.has_equations = True
+
# see validate_math_renderer
name: str = self.builder.math_renderer_name # type: ignore[assignment]
visit, _ = self.builder.app.registry.html_block_math_renderers[name]
visit(self, node)
def depart_math_block(self, node: Element, math_env: str = '') -> None:
+ self.has_equations = True
+
# see validate_math_renderer
name: str = self.builder.math_renderer_name # type: ignore[assignment]
_, depart = self.builder.app.registry.html_block_math_renderers[name]