Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_usetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from matplotlib.testing import _has_tex_package
from matplotlib.testing.decorators import check_figures_equal, image_comparison
from matplotlib.testing._markers import needs_usetex
from matplotlib.texmanager import TexManager
import matplotlib.pyplot as plt


Expand Down Expand Up @@ -138,3 +139,10 @@ def test_missing_psfont(fmt, monkeypatch):
ax.text(0.5, 0.5, 'hello')
with TemporaryFile() as tmpfile, pytest.raises(ValueError):
fig.savefig(tmpfile, format=fmt)


def test_ends_with_displaymath():
# Check that we do not include extra vspace after displaymath.
text = r'\begin{eqnarray*} foo \\ bar \end{eqnarray*}'
w, h, d = TexManager().get_text_width_height_descent(text, 12)
assert d == 0 # no extra descent on the last line.
2 changes: 1 addition & 1 deletion lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _get_tex_source(cls, tex, fontsize):
rf"\fontsize{{{fontsize}}}{{{baselineskip}}}%",
r"\ifdefined\psfrag\else\hbox{}\fi%",
rf"{{\obeylines{fontcmd} {tex}}}%",
r"\special{matplotlibbaselinemarker}%",
r"\vskip-\lastskip\special{matplotlibbaselinemarker}%",
r"\end{document}",
])

Expand Down