Closed Makogan closed 3 years ago
The answer is to make all the text operations prior to creating the canvas.
This is correct. When a canvas in created, it can get a textengine as a constructor argument. If nothing is set, it uses the defaulttextengine from the text module as set at this point in time. If you configure it later, this is not seen from within the canvas.
This works:
from pyx import *
text.set(engine=text.LatexEngine)
c = canvas.canvas()
c.text(0, 0, r'$\frac{1}{2}$')
but doing it the other way around it fails:
from pyx import *
c = canvas.canvas()
text.set(engine=text.LatexEngine)
c.text(0, 0, r'$\frac{1}{2}$')
However, you can insert text instead of using the internal textengine of the canvas. Than it starts to work again:
from pyx import *
c = canvas.canvas()
text.set(engine=text.LatexEngine)
c.insert(text.text(0, 0, r'$\frac{1}{2}$'))
I am trying to render a fracion with pyx:
from pyx import * from pyx import text
But I am getting an error:
The documentation says that the string is passed directly onto the LateX engine, and to my knowledge the engine should be able to handle the
frac
command, so I am a bit confused.