Skip to content

Commit 12560f2

Browse files
committed
Fix multi-line math blocks losing indentation in LaTeX
Multi-line math content (e.g. \begin{align}...\end{align}) from doxygen XML was emitted as: .. math:: \begin{align} \mathbf{v} = \mathbf{u} + ... \end{align} RST requires directive body content to be indented. The continuation lines at column 0 were parsed as regular text by docutils, producing garbled LaTeX output with "Runaway argument" and "Missing $" errors — 164 LaTeX errors on the Notation page alone. Fix: in visit_formula, detect multi-line math text and emit it as a properly indented block: .. math:: \begin{align} \mathbf{v} = \mathbf{u} + ... \end{align} Single-line math is unchanged (stays on the .. math:: line). After fix: `make latexpdf` LaTeX errors drop from 164 to 10. The remaining 10 are unrelated (9 Unicode Greek characters in source comments that pdflatex cannot render, 1 duplicate label).
1 parent 37e7c73 commit 12560f2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/_ext/autodoc_doxygen/xmlutils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,14 @@ def visit_formula(self, node):
683683
if len(self.math_labels) > 0:
684684
self.emit_math_labels()
685685

686-
#self.lines.append('')
687686
self.blank_line()
688-
self.lines.append('.. math:: ' + text)
687+
if '\n' in text:
688+
self.lines.append('.. math::')
689+
self.lines.append('')
690+
for mathline in text.split('\n'):
691+
self.lines.append(' ' + mathline)
692+
else:
693+
self.lines.append('.. math:: ' + text)
689694
self.blank_line()
690695
# Math blocks require an explicit blank line as well?
691696
#self.lines.append('')

0 commit comments

Comments
 (0)