From 533be2b190a255d396fb074a83f9d234665f330f Mon Sep 17 00:00:00 2001 From: sujaykumar03 Date: Fri, 13 Jun 2025 19:12:15 +0530 Subject: [PATCH] DOC: dynamically size math symbol tables (closes #26143) --- doc/sphinxext/math_symbol_table.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/sphinxext/math_symbol_table.py b/doc/sphinxext/math_symbol_table.py index a143326ab75b..a0ac96d16cdd 100644 --- a/doc/sphinxext/math_symbol_table.py +++ b/doc/sphinxext/math_symbol_table.py @@ -1,4 +1,5 @@ import re +import math from docutils.parsers.rst import Directive from matplotlib import _mathtext, _mathtext_data @@ -86,7 +87,7 @@ def render_symbol(sym, ignore_variant=False): return f'\\{sym}' if sym in ('\\', '|', '+', '-', '*') else sym lines = [] - for category, columns, syms in symbols: + for category, _columns, syms in symbols: syms = sorted(syms, # Sort by Unicode and place variants immediately # after standard versions. @@ -94,7 +95,7 @@ def render_symbol(sym, ignore_variant=False): sym.startswith(r"\var")), reverse=(category == "Hebrew")) # Hebrew is rtl rendered_syms = [f"{render_symbol(sym)} ``{sym}``" for sym in syms] - columns = min(columns, len(syms)) + columns = max(3, int(math.ceil(math.sqrt(len(syms))))) lines.append("**%s**" % category) lines.append('') max_width = max(map(len, rendered_syms))