Skip to content

Commit 97d8be5

Browse files
committed
Support ~ as nonbreaking space in mathtext.
... consistently with TeX. (AFAICT we never break mathtext over multiple lines so it's just a normal space for us.) See e.g. https://tex.stackexchange.com/a/74354/4101 for reference.
1 parent 99d8900 commit 97d8be5

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``~`` now interpreted as space in mathtext
2+
``````````````````````````````````````````
3+
In constructs such as ``"$1~2$"``, mathtext now interprets the tilde as a
4+
space, consistently with TeX (this was previously a parse error).

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,7 @@ def _make_space(self, percentage):
26962696
r'\:' : 0.22222, # 4/18 em = 4 mu
26972697
r'\;' : 0.27778, # 5/18 em = 5 mu
26982698
r'\ ' : 0.33333, # 6/18 em = 6 mu
2699+
r'~' : 0.33333, # 6/18 em = 6 mu, nonbreakable
26992700
r'\enspace' : 0.5, # 9/18 em = 9 mu
27002701
r'\quad' : 1, # 1 em = 18 mu
27012702
r'\qquad' : 2, # 2 em = 36 mu

0 commit comments

Comments
 (0)