FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

In usetex, remove vertical space inserted by TeX after displaymath. by anntzer · Pull Request #24011 · matplotlib/matplotlib · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_usetex.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL