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

Skip to content

Commit 19bd05a

Browse files
committed
mathtext2 - added support for complex sub/superscripts (i.e.fractions etc.)
svn path=/trunk/matplotlib/; revision=2715
1 parent 2d59dd1 commit 19bd05a

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2006-08-28 mathtext2.py: Sub/superscripts can now be complex (i.e.
2+
fractions etc.). The demo is also updated - ES
3+
14
2006-08-28 font_manager.py: Added /usr/local/share/fonts to list of
25
X11 font directories - DSD
36

examples/mathtext2_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#xlabel(r'$\Delta_i^j$', fontsize=20)
5656
#ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
5757
#tex = r'$\cal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\rm{sin}(2 \pi f x_i)$'
58-
#tex = ur"$1^2_3$"
58+
tex = ur"$1^j_3$"
5959
#tex = ur"$Tj_1j_jj_gT$"
6060
#tex = ur"$F_1^1y_{1_{2_{3_2\sum_1^2{4}^6}}3}1_23$"
6161
#tex = ur"$x_2{\cal TRALALA}\sum_1^2$"
@@ -64,10 +64,10 @@
6464
#tex = ur"$Tutinjac\ fff\sin\exp$"
6565
#tex = ur"$\sin\exp{\rm sin\ exp}$"
6666
#tex = ur"$a^{\sin x}\sin b\sin(x/x), {\rm sin}(x/x){\rm sin\ }(x/x)$"
67-
tex = ur"$1\frac {\int_{-\infty}^\infty} 22$"
67+
#tex = ur"$1\frac {\int_{-\infty}^\infty} 22$"
6868
#tex = ur"$\frac{\int_{-\infty}^\infty} 2$"
6969
#tex = ur"$1_\frac{\sum^2_{i_{23}=0}} 2678$"
70-
#tex = ur"$1_{\frac{\sum^2_{i_{23}=0}} 2 345}678$"
70+
tex = ur"$1_{\frac{\sum^2_{i_{23}=0}}{\sum_{i=\frac94}^\infty} 345}678$"
7171
text(0.5, 2., tex, fontsize=20)
7272
tex = r'${\cal R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin\exp(2 \pi f x_i)$'
7373
text(1, 1.9, tex, fontsize=20)

lib/matplotlib/mathtext2.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* commands for typesetting functions (\sin, \cos etc.),
66
* commands for changing the current font (\rm, \cal etc.),
77
* Space/kern commands "\ ", \thinspace
8+
* \frac
89
910
Small TO-DO's:
1011
--------------
@@ -16,9 +17,7 @@
1617
1718
TO-DO's:
1819
--------
19-
* \frac, \over, \above, \choose etc.
20-
* Implement classes for Line, Fraction etc
21-
* Change env to be a new class, not a dict.
20+
* \over, \above, \choose etc.
2221
* Add support for other backends
2322
2423
"""
@@ -425,12 +424,19 @@ def __init__(self, env, nuc=None, type="ord", sub=None,
425424
# below the origin of the nucleus (the descent of the letter "j").
426425
# TO-DO: Change with a better alternative. Not working: F_1^1y_1
427426
c = TexCharClass(env, "j")
427+
C = TexCharClass(env, "M")
428+
428429
self.subpad = c.height - c.bearingy
430+
# If subscript is complex (i.e. a large Hbox - fraction etc.)
431+
# we have to aditionaly lower the subscript
432+
if sub.ymax > (C.height/2.1 + self.subpad):
433+
self.subpad = sub.ymax - C.height/2.1
434+
429435
#self.subpad = max(self.subpad)
430436
#self.subpad = 0.5*sub.height
431437
# Similar for the superscript
432-
C = TexCharClass(env, "M")
433-
self.suppad = max(nuc.height/2., C.ymax/2.)# - C.bearingy
438+
self.suppad = max(nuc.height/1.9, C.ymax/1.9) - sup.ymin# - C.bearingy
439+
434440

435441
#self.advance = nuc.advance + max((sub.advance, sup.advance))
436442

0 commit comments

Comments
 (0)