Dear Jose,
I tried your code on my machine (Linux) and it works as expected. Maybe you
have a problem with your LaTeX-Installation? What is in the file
errordetail.full? Is the package color installed correctly?
--Michael
Am 05.02.2018 um 12:50 schrieb José María Miotto:
> Hi, I'm having problems with text in color. I solved this issue years ago
> on my old machine, but now I bought a new laptop, and I installed
> everything from scratch (windows os, texlive, anaconda, pyx), and I don't
> have a clue of how I solved it before.
>
> Basically, the code is this
>
> from pyx import *
> text.set(text.LatexRunner)
> text.preamble(r'\usepackage{color}')
>
> c = canvas.canvas()
> a = '\\textcolor[rgb]{1,0,0}{x}'
> c.text(0, 0, a)
> c.writePDFfile('./plots/test')
>
> and this code fails, although is very similar to the example in the
> documentation. The full output is this:
>
>
> Still waiting for LaTeX after 5 (of 60) seconds...
> Still waiting for LaTeX after 10 (of 60) seconds...
> Still waiting for LaTeX after 15 (of 60) seconds...
> Still waiting for LaTeX after 20 (of 60) seconds...
> Still waiting for LaTeX after 25 (of 60) seconds...
> Still waiting for LaTeX after 30 (of 60) seconds...
> Still waiting for LaTeX after 35 (of 60) seconds...
> Still waiting for LaTeX after 40 (of 60) seconds...
> Still waiting for LaTeX after 45 (of 60) seconds...
> Still waiting for LaTeX after 50 (of 60) seconds...
> Still waiting for LaTeX after 55 (of 60) seconds...
> The timeout of 60 seconds expired and LaTeX did not respond.
> Traceback (most recent call last):
> File "C:\Program Files\JetBrains\PyCharm
> 2017.3.3\helpers\pydev\pydev_run_in_console.py",
> line 53, in run_file
> pydev_imports.execfile(file, globals, locals) # execute the script
> File "C:\Program Files\JetBrains\PyCharm
> 2017.3.3\helpers\pydev\_pydev_imps\_pydev_execfile.py",
> line 18, in execfile
> exec(compile(contents+"\n", file, 'exec'), glob, loc)
> File "C:/Users/José/PycharmProjects/anomalies/test.py", line 3, in
> <module>
> text.preamble(r'\usepackage{color}')
> File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\text.py", line 1454,
> in preamble
> self.instance.preamble(expr, texmessages)
> File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\text.py", line 1245,
> in preamble
> self.do_preamble(expr, texmessages)
> File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\text.py", line 1196,
> in do_preamble
> self._execute(expr, texmessages, STATE_PREAMBLE, STATE_PREAMBLE)
> File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\text.py", line 1125,
> in _execute
> raise e
> File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\text.py", line 1083,
> in _execute
> raise TexResultError("TeX didn't respond as expected within the timeout
> period.")
> pyx.text.TexResultError: TeX didn't respond as expected within the timeout
> period.
> The expression passed to TeX was:
> \usepackage{color}%
> \PyXInput{4}%
> After parsing the return message from TeX, the following was left:
> *
> *(c:/texlive/2017/texmf-dist/tex/latex/graphics/color.sty
> (c:/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg)
> ! Missing \endcsname inserted.
> <to be read again>
> (cut after 5 lines; use errordetail.full for all output)
>
>
> I tried the other option for the preamble that is mentioned in the
> documentation,
>
> from pyx import *
> text.set(text.LatexRunner, pyxgraphics=0)
> text.preamble(r'\usepackage[pyx]{color}')
>
> c = canvas.canvas()
> a = '\\textcolor[rgb]{1,0,0}{x}'
> c.text(0, 0, a)
> c.writePDFfile('./plots/test')
>
>
> which also fails, probably because I did not copy the mentioned files in
> the respective paths, which is something I would like to avoid. The full
> output is
>
> ignoring special 'color push rgb 1 0 0'
> ignoring special 'color pop'
>
> and it actually prints a pdf, but with no color, just in black (because is
> ignoring the tex color statements).
>
> What is the solution for this problem? To be honest I don't even understand
> what the problem is.
>
> thanks a lot,
> Jose Miotto
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user