some updates to the webpage
[PyX.git] / examples / text / valign.py
blob8a3691209026d472e554a4e4bee43aff62f57789
1 from pyx import *
3 c = canvas.canvas()
5 # apply global TeX setting
6 text.preamble(r"\parindent=0pt")
7 w = 1.2 # an appropriate parbox width for spam & eggs
9 # vertical alignments by margins
10 c.stroke(path.line(0, 4, 8, 4), [style.linewidth.THin])
11 c.text(0, 4, r"spam \& eggs", [text.parbox(w), text.valign.top])
12 c.text(3, 4, r"spam \& eggs", [text.parbox(w), text.valign.middle])
13 c.text(6, 4, r"spam \& eggs", [text.parbox(w), text.valign.bottom])
15 # vertical alignments by baselines
16 c.stroke(path.line(0, 2, 8, 2), [style.linewidth.THin])
17 c.text(0, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.top)])
18 c.text(3, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.middle)])
19 c.text(6, 2, r"spam \& eggs", [text.parbox(w, baseline=text.parbox.bottom)])
21 # vertical shifts
22 c.stroke(path.line(0, 0, 8, 0), [style.linewidth.THin])
23 c.text(0, 0, r"x=0", [text.mathmode, text.vshift.topzero])
24 c.text(2, 0, r"x=0", [text.mathmode, text.vshift.middlezero])
25 c.text(4, 0, r"x=0", [text.mathmode, text.vshift.bottomzero])
26 c.text(6, 0, r"x=0", [text.mathmode, text.vshift.mathaxis])
28 c.writeEPSfile("valign")
29 c.writePDFfile("valign")