mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4729 from jfbu/latex_equation_nophantom
Fix vertical space before equation in latex (closes: #4574)
This commit is contained in:
commit
e1e46cdf8b
@ -85,6 +85,7 @@ class MathDomain(Domain):
|
||||
newnode['target'] = target
|
||||
return newnode
|
||||
else:
|
||||
# TODO: perhaps use rather a sphinx-core provided prefix here?
|
||||
node_id = make_id('equation-%s' % target)
|
||||
if env.config.math_numfig and env.config.numfig:
|
||||
if docname in env.toc_fignumbers:
|
||||
|
@ -1959,6 +1959,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
if id.startswith('index-'):
|
||||
return
|
||||
|
||||
# equations also need no extra blank line nor hypertarget
|
||||
# TODO: fix this dependency on mathbase extension internals
|
||||
if id.startswith('equation-'):
|
||||
return
|
||||
|
||||
# insert blank line, if the target follows a paragraph node
|
||||
index = node.parent.index(node)
|
||||
if index > 0 and isinstance(node.parent[index - 1], nodes.paragraph):
|
||||
|
5
tests/roots/test-latex-equations/conf.py
Normal file
5
tests/roots/test-latex-equations/conf.py
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'equations'
|
||||
extensions = ['sphinx.ext.imgmath']
|
||||
|
21
tests/roots/test-latex-equations/equations.rst
Normal file
21
tests/roots/test-latex-equations/equations.rst
Normal file
@ -0,0 +1,21 @@
|
||||
test-latex-equation
|
||||
===================
|
||||
|
||||
Equation without a label.
|
||||
|
||||
.. math::
|
||||
|
||||
E = mc^2
|
||||
|
||||
Equation with label.
|
||||
|
||||
.. math:: E = hv
|
||||
:label: test
|
||||
|
||||
Second equation without label.
|
||||
|
||||
.. math::
|
||||
|
||||
c^2 = a^2 + b^2
|
||||
|
||||
Equation with label :eq:`test` is important.
|
13
tests/roots/test-latex-equations/expects/latex-equations.tex
Normal file
13
tests/roots/test-latex-equations/expects/latex-equations.tex
Normal file
@ -0,0 +1,13 @@
|
||||
Equation without a label.
|
||||
\begin{equation*}
|
||||
\begin{split}E = mc^2\end{split}
|
||||
\end{equation*}
|
||||
Equation with label.
|
||||
\begin{equation}\label{equation:equations:test}
|
||||
\begin{split}E = hv\end{split}
|
||||
\end{equation}
|
||||
Second equation without label.
|
||||
\begin{equation*}
|
||||
\begin{split}c^2 = a^2 + b^2\end{split}
|
||||
\end{equation*}
|
||||
Equation with label \eqref{equation:equations:test} is important.
|
@ -1134,6 +1134,16 @@ def test_latex_index(app, status, warning):
|
||||
assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-equations')
|
||||
def test_latex_equations(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||
expected = (app.srcdir / 'expects' / 'latex-equations.tex').text().strip()
|
||||
|
||||
assert expected in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='image-in-parsed-literal')
|
||||
def test_latex_image_in_parsed_literal(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
Loading…
Reference in New Issue
Block a user