1

I want create a new command in python, in https://tex.stackexchange.com/a/234232/153360 add the command sage to pythontex. How can I change or add a command which output a string instead of a latex code? I try whith

SubCodeEngine('python', 'sage', language='sage', extension='.sage',
              template=python_template.replace('{future}', ''),
              extend = 'pytex.formatter = str',
              commands='{sage} {file}.sage')

But when I run the code, the programm says that the control sequence is undefined.

Edit

I can partial solve it. If we change, in the pythontex_engines.py, the sage code for:

SubCodeEngine('python', 'sage', language='sage', extension='.sage',
                 template=python_template.replace('{future}', ''),
                 extend = 'pytex.formatter',
                 commands='{sage} {file}.sage')

When we use sage{somecode} we get a string code for us expressions, and for the command sage{latex(somecode)} we get the latex code of this.

Maybe it help anyone.

ODA Oda
  • 11
  • 2

0 Answers0