Ejemplo n.º 1
0
from gram import Gram
myText = r"""This is some\\ multi-line text that
does not work so well.\\ With $\alpha$  unusual $\beta$ characters."""

if 1:  # This works
    gr = Gram()
    gr.baseName = 'minipage'
    stuff = r"\begin{minipage}{12cm}%s\end{minipage}" % myText
    g = gr.text(stuff, 1, 2)
    g.anchor = 'south west'
    gr.pdflatexOutputGoesToDevNull = False
    gr.pdf()

if 0:  # This does not work
    gr = Gram()
    gr.baseName = 'varwidth'
    stuff = r"\begin{varwidth}{12cm}%s\end{varwidth}" % myText
    g = gr.text(stuff, 1, 2)
    g.anchor = 'south west'
    gr.latexUsePackages.append("varwidth")
    gr.pdflatexOutputGoesToDevNull = False
    gr.pdf()

if 0:  # This does not work
    gr = Gram()
    gr.baseName = 'pbox'
    stuff = r"\pbox{12cm}{%s}" % myText
    g = gr.text(stuff, 1, 2)
    g.anchor = 'south west'
    gr.latexUsePackages.append("pbox")
    gr.pdflatexOutputGoesToDevNull = False
Ejemplo n.º 2
0
from gram import Gram, GramCoord, GramGrid, GramText

gr = Gram()
gr.baseName = 'anchors'
gr.font = 'helvetica'
gr.defaultInnerSep = 0.1
g = GramGrid(0, 1, 8, 7)
gr.graphics.append(g)

##    _goodAnchors = ['west', 'north west', 'north', 'north east', 'east',
##                        'base', 'base west', 'base east',
##                        'south west', 'south', 'south east',
##                        #'mid', 'mid west', 'mid east',
##                        'center'] # center seems to be the default

nnDict = {}
nn = []
for i in range(3):
    for j in range(4):
        indx = (i * 4) + j
        refPt = gr.goodAnchors[indx]
        print indx, refPt
        n = GramCoord((2 * j) + 1, (2 * i) + 1, refPt)
        nnDict[refPt] = n
        nn.append(n)
        gr.graphics.append(n)

myStr = 'Xxy'
theTextSize = 'normalsize'
for i in range(12):
    anch = gr.goodAnchors[i]
Ejemplo n.º 3
0
from gram import Gram
gr1 = Gram()
gr1.font = 'helvetica'
gr1.baseName = 'gramInGram'
gr1.text("Embedding gram", 0, 0)
gr2 = Gram()
g = gr2.text("Embedded gram", 0, 0)
gr2.gX = 0.3
gr2.gY = 0.5
gr1.grams.append(gr2)
gr1.pdf()
gr1.svg()