diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index be878d0a7dc7..3727aa434925 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -11,6 +11,12 @@ help figure out possible sources of the changes you are experiencing. For new features that were added to matplotlib, please see :ref:`whats-new`. +Changes in 2.0.x +================ + +* The spacing commands in mathtext have been changed to more closely + match vanilla TeX. + Changes in 1.4.x ================ diff --git a/lib/matplotlib/_mathtext_data.py b/lib/matplotlib/_mathtext_data.py index 9354c71dc330..d564c7265526 100644 --- a/lib/matplotlib/_mathtext_data.py +++ b/lib/matplotlib/_mathtext_data.py @@ -1946,7 +1946,6 @@ 'boxminus' : 8863, 'equiv' : 8801, 'Lleftarrow' : 8666, - 'thinspace' : 8201, 'll' : 8810, 'Cup' : 8915, 'measeq' : 8798, @@ -2169,7 +2168,6 @@ 'cdots' : 8943, 'hat' : 770, 'eqgtr' : 8925, - 'enspace' : 8194, 'psi' : 968, 'frown' : 8994, 'acute' : 769, diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index 6ff3b4445e6c..e3da2e4d24ee 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -2431,13 +2431,18 @@ def _make_space(self, percentage): self._em_width_cache[key] = width return Kern(width * percentage) - _space_widths = { r'\ ' : 0.3, - r'\,' : 0.4, - r'\;' : 0.8, - r'\quad' : 1.6, - r'\qquad' : 3.2, - r'\!' : -0.4, - r'\/' : 0.4 } + _space_widths = { r'\,' : 0.16667, # 3/18 em = 3 mu + r'\thinspace' : 0.16667, # 3/18 em = 3 mu + r'\/' : 0.16667, # 3/18 em = 3 mu + r'\>' : 0.22222, # 4/18 em = 4 mu + r'\:' : 0.22222, # 4/18 em = 4 mu + r'\;' : 0.27778, # 5/18 em = 5 mu + r'\ ' : 0.33333, # 6/18 em = 6 mu + r'\enspace' : 0.5, # 9/18 em = 9 mu + r'\quad' : 1, # 1 em = 18 mu + r'\qquad' : 2, # 2 em = 36 mu + r'\!' : -0.16667, # -3/18 em = -3 mu + } def space(self, s, loc, toks): assert(len(toks)==1) num = self._space_widths[toks[0]] diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.pdf b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.pdf new file mode 100644 index 000000000000..7bb1e1a9d190 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.png b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.png new file mode 100644 index 000000000000..55986a513061 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.svg b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.svg new file mode 100644 index 000000000000..ea4591841c6d --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_68.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.pdf b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.pdf new file mode 100644 index 000000000000..0cef8edf4c97 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.png b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.png new file mode 100644 index 000000000000..4c8eeab5035c Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.svg b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.svg new file mode 100644 index 000000000000..7c4e65dc5827 --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stix_68.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.pdf b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.pdf new file mode 100644 index 000000000000..40eed4df1063 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.png b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.png new file mode 100644 index 000000000000..2c86c67da769 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.svg b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.svg new file mode 100644 index 000000000000..603294c36659 --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_stixsans_68.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py index 744da15a1377..45a8db074ed3 100644 --- a/lib/matplotlib/tests/test_mathtext.py +++ b/lib/matplotlib/tests/test_mathtext.py @@ -90,7 +90,8 @@ r"$\left(2 \, a=b\right)$", # Sage bug #8125 r"$? ! &$", # github issue #466 r'$\operatorname{cos} x$', # github issue #553 - r'$\sum _{\genfrac{}{}{0}{}{0\leq i\leq m}{0 M \: M \; M \ M \enspace M \quad M \qquad M \! M$' ] digits = "0123456789"