error in documentation corrected
[PyX/mjg.git] / manual / tex2.py
blobe9fcf425fd44c70c0b0742a970d74baef1664544
1 #!/usr/bin/env python
2 import sys
3 sys.path[:0] = [".."]
4 from pyx import *
5 from pyx import tex
7 c = canvas.canvas()
8 t = c.insert(tex.tex())
9 t.text(0, 0, "Hello, world!")
10 t.text(0, -0.5, "Hello, world!", tex.fontsize.large)
11 t.text(0, -1.5,
12 r"\sum_{n=1}^{\infty} {1\over{n^2}} = {{\pi^2}\over 6}",
13 tex.style.math)
15 c.stroke(path.line(5, -0.5, 9, -0.5))
16 c.stroke(path.line(5, -1, 9, -1))
17 c.stroke(path.line(5, -1.5, 9, -1.5))
18 c.stroke(path.line(7, -1.5, 7, 0))
19 t.text(7, -0.5, "left aligned") # default is tex.halign.left
20 t.text(7, -1, "center aligned", tex.halign.center)
21 t.text(7, -1.5, "right aligned", tex.halign.right)
23 c.stroke(path.line(0, -4, 2, -4))
24 c.stroke(path.line(0, -2.5, 0, -5.5))
25 c.stroke(path.line(2, -2.5, 2, -5.5))
26 t.text(0, -4,
27 "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",
28 tex.valign.top(2))
29 c.stroke(path.line(2.5, -4, 4.5, -4))
30 c.stroke(path.line(2.5, -2.5, 2.5, -5.5))
31 c.stroke(path.line(4.5, -2.5, 4.5, -5.5))
32 t.text(2.5, -4,
33 "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",
34 tex.valign.bottom(2))
36 c.stroke(path.line(5, -4, 9, -4))
37 c.stroke(path.line(7, -5.5, 7, -2.5))
38 t.text(7, -4, "horizontal")
39 t.text(7, -4, "vertical", tex.direction.vertical)
40 t.text(7, -4, "rvertical", tex.direction.rvertical)
41 t.text(7, -4, "upsidedown", tex.direction.upsidedown)
42 t.text(7.5, -3.5, "45", tex.direction(45))
43 t.text(6.5, -3.5, "135", tex.direction(135))
44 t.text(6.5, -4.5, "225", tex.direction(225))
45 t.text(7.5, -4.5, "315", tex.direction(315))
47 t.text(0, -6, "red", color.rgb.red)
48 t.text(3, -6, "green", color.rgb.green)
49 t.text(6, -6, "blue", color.rgb.blue)
50 c.writetofile("tex2.eps")