summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--doc/intl.rst19
-rw-r--r--sphinx/ext/mathbase.py1
-rw-r--r--sphinx/writers/latex.py5
-rw-r--r--tests/roots/test-latex-equations/conf.py5
-rw-r--r--tests/roots/test-latex-equations/equations.rst21
-rw-r--r--tests/roots/test-latex-equations/expects/latex-equations.tex13
-rw-r--r--tests/test_build_latex.py10
8 files changed, 73 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 5e3957b76..fb9c429a8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -26,6 +26,7 @@ Bugs fixed
* #4727: Option clash for package textcomp
* #4725: Sphinx does not work with python 3.5.0 and 3.5.1
* #4716: Generation PDF file with TexLive on Windows, file not found error
+* #4574: vertical space before equation in latex
Testing
--------
diff --git a/doc/intl.rst b/doc/intl.rst
index dacced65b..870d06240 100644
--- a/doc/intl.rst
+++ b/doc/intl.rst
@@ -113,12 +113,27 @@ This section describe an easy way to translate with sphinx-intl.
#. make translated document.
You need a :confval:`language` parameter in ``conf.py`` or you may also
- specify the parameter on the command line:
+ specify the parameter on the command line (for BSD/GNU make):
.. code-block:: console
$ make -e SPHINXOPTS="-D language='de'" html
+ command line (for Windows cmd.exe):
+
+ .. code-block:: console
+
+ > set SPHINXOPTS=-D language='de'
+ > .\make.bat html
+
+ command line (for PowerShell):
+
+ .. code-block:: console
+
+ > Set-Item env:SPHINXOPTS "-D language='de'"
+ > .\make.bat html
+
+
Congratulations! You got the translated documentation in the ``_build/html``
directory.
@@ -263,7 +278,7 @@ easy to fetch and push translations.
...
Done.
- Invoke make html:
+ Invoke make html (for BSD/GNU make):
.. code-block:: console
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py
index 24c10df3c..3cc734537 100644
--- a/sphinx/ext/mathbase.py
+++ b/sphinx/ext/mathbase.py
@@ -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:
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index b425f79e6..ab15ec8b5 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -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):
diff --git a/tests/roots/test-latex-equations/conf.py b/tests/roots/test-latex-equations/conf.py
new file mode 100644
index 000000000..6122e9212
--- /dev/null
+++ b/tests/roots/test-latex-equations/conf.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+
+master_doc = 'equations'
+extensions = ['sphinx.ext.imgmath']
+
diff --git a/tests/roots/test-latex-equations/equations.rst b/tests/roots/test-latex-equations/equations.rst
new file mode 100644
index 000000000..2eef2f2a4
--- /dev/null
+++ b/tests/roots/test-latex-equations/equations.rst
@@ -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.
diff --git a/tests/roots/test-latex-equations/expects/latex-equations.tex b/tests/roots/test-latex-equations/expects/latex-equations.tex
new file mode 100644
index 000000000..ce07a0128
--- /dev/null
+++ b/tests/roots/test-latex-equations/expects/latex-equations.tex
@@ -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.
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index 4b02b7c54..602429a96 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -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()