add INSTALL and CHANGES files
[PyX/mjg.git] / manual / tex.py
blob82a8b9a1847985a3b87daf6358f03cd25c222d19
1 #!/usr/bin/env python
2 import sys
3 sys.path.append("..")
4 from pyx import *
7 c = canvas.canvas()
8 t = c.insert(tex.tex())
9 t.text(0, 0, "Hello, world!")
10 print "width:", t.textwd("Hello, world!")
11 print "height:", t.textht("Hello, world!")
12 print "depth:", t.textdp("Hello, world!")
13 c.writetofile("tex1")
16 c = canvas.canvas()
17 t = c.insert(tex.tex())
18 t.text(0, 0, "Hello, world!")
19 t.text(0, -0.5, "Hello, world!", tex.fontsize.large)
20 t.text(0, -1.5,
21 r"\sum_{n=1}^{\infty} {1\over{n^2}} = {{\pi^2}\over 6}",
22 tex.style.math)
24 c.stroke(path.line(5, -0.5, 9, -0.5))
25 c.stroke(path.line(5, -1, 9, -1))
26 c.stroke(path.line(5, -1.5, 9, -1.5))
27 c.stroke(path.line(7, -1.5, 7, 0))
28 t.text(7, -0.5, "left aligned") # default is tex.halign.left
29 t.text(7, -1, "center aligned", tex.halign.center)
30 t.text(7, -1.5, "right aligned", tex.halign.right)
32 c.stroke(path.line(0, -4, 2, -4))
33 c.stroke(path.line(0, -2.5, 0, -5.5))
34 c.stroke(path.line(2, -2.5, 2, -5.5))
35 t.text(0, -4,
36 "a b c d e f g h i j k l m n o p q r s t u v w x y z",
37 tex.valign.top(2))
38 c.stroke(path.line(2.5, -4, 4.5, -4))
39 c.stroke(path.line(2.5, -2.5, 2.5, -5.5))
40 c.stroke(path.line(4.5, -2.5, 4.5, -5.5))
41 t.text(2.5, -4,
42 "a b c d e f g h i j k l m n o p q r s t u v w x y z",
43 tex.valign.bottom(2))
45 c.stroke(path.line(5, -4, 9, -4))
46 c.stroke(path.line(7, -5.5, 7, -2.5))
47 t.text(7, -4, "horizontal")
48 t.text(7, -4, "vertical", tex.direction.vertical)
49 t.text(7, -4, "rvertical", tex.direction.rvertical)
50 t.text(7, -4, "upsidedown", tex.direction.upsidedown)
51 t.text(7.5, -3.5, "45", tex.direction(45))
52 t.text(6.5, -3.5, "135", tex.direction(135))
53 t.text(6.5, -4.5, "225", tex.direction(225))
54 t.text(7.5, -4.5, "315", tex.direction(315))
56 t.text(0, -6, "red", color.rgb.red)
57 t.text(3, -6, "green", color.rgb.green)
58 t.text(6, -6, "blue", color.rgb.blue)
59 c.writetofile("tex2")