diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index 6dc1c7323..8ede05b87 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -34,16 +34,19 @@ def wrap_displaymath(math, label, numbering): for i, part in enumerate(parts): if not part.strip(): continue - if label is not None and i == 0: - ret.append('\\begin{split}%s\\end{split}' % part + - (label and '\\label{'+label+'}' or '')) - else: - ret.append(r'\begin{split}%s\end{split}' % part) - if not numbering: - ret.append(r'\notag') + ret.append(r'\begin{split}%s\end{split}' % part) if not ret: return '' - return '\\begin{gather}\n' + '\\\\'.join(ret) + '\n\\end{gather}' + if label is not None or numbering: + env_begin = r'\begin{align}' + if label is not None: + env_begin += r'\label{%s}' % label + env_end = r'\end{align}' + else: + env_begin = r'\begin{align*}' + env_end = r'\end{align*}' + return ('%s\\begin{aligned}\n%s\\end{aligned}%s') % ( + env_begin, '\\\\\n'.join(ret), env_end) def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): diff --git a/tests/roots/test-ext-math/conf.py b/tests/roots/test-ext-math/conf.py index f81c30bc4..3fe886c17 100644 --- a/tests/roots/test-ext-math/conf.py +++ b/tests/roots/test-ext-math/conf.py @@ -1,3 +1,6 @@ # -*- coding: utf-8 -*- master_doc = 'index' + +latex_documents = [ + (master_doc, 'test.tex', 'Math Extension Testing', 'Sphinx', 'report')] diff --git a/tests/roots/test-ext-math/index.rst b/tests/roots/test-ext-math/index.rst index 491edda95..02f50c20a 100644 --- a/tests/roots/test-ext-math/index.rst +++ b/tests/roots/test-ext-math/index.rst @@ -8,3 +8,11 @@ Inline :math:`E=mc^2` Second math .. math:: e^{i\pi}+1=0 + +Multi math equations + +.. math:: + + S &= \pi r^2 + + V &= \frac{4}{3} \pi r^3 diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 84bca95a3..d72da7934 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -53,3 +53,10 @@ def test_math_number_all(app, status, warning): html = (r'