diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py index 6cd328244c97..f9e2f062005f 100644 --- a/lib/matplotlib/tests/test_usetex.py +++ b/lib/matplotlib/tests/test_usetex.py @@ -30,6 +30,12 @@ def test_usetex(): ax.set_yticks([]) +@check_figures_equal() +def test_empty(fig_test, fig_ref): + mpl.rcParams['text.usetex'] = True + fig_test.text(.5, .5, "% a comment") + + @check_figures_equal() def test_unicode_minus(fig_test, fig_ref): mpl.rcParams['text.usetex'] = True diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index fb23212febf8..91aac1f6cf3e 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -214,7 +214,8 @@ def make_tex(self, tex, fontsize): \usepackage[papersize={72in,72in},body={70in,70in},margin={1in,1in}]{geometry} \pagestyle{empty} \begin{document} -\fontsize{%f}{%f}%s +%% The empty hbox ensures that a page is printed even for empty inputs. +\fontsize{%f}{%f}\hbox{}%s \end{document} """ % (self._get_preamble(), fontsize, fontsize * 1.25, fontcmd % tex), encoding='utf-8')