PyX — Example: text/marker.py

0.4 KB
23.6 KB
22.2 KB
12.3 KB
13.3 KB

Using markers

marker.png
from pyx import *
unit.set(xscale=3)

c = canvas.canvas()
t = c.text(0, 0, r"Here\PyXMarker{id} is a marker.")
center = t.marker("id")
c.stroke(path.circle(center[0], center[1], 1), [color.rgb.red])
c.stroke(path.line(center[0]-1, center[1], center[0]+1, center[1]), [color.rgb.red])
c.stroke(path.line(center[0], center[1]-1, center[0], center[1]+1), [color.rgb.red])
c.writeEPSfile("marker")
c.writePDFfile("marker")
c.writeSVGfile("marker")

Description

The example shows how to obtain specific coordinates in a (La)TeX text. This allows to mark specific portions of text, setting arrows, braces and many more. A marker can be set with the command \PyXMarker which takes the name of the marker as an argument (id in the example code). The position of the marker can then be obtained from the textbox, which is returned by the canvas.text method.