Is possible to use LaTeX macros in pythonTeX pyblock environment and use/store theyre output on python side of pythonTeX?

Following MWE should completely illustrate my question:





mytext = \lipsum[4]


For document compilation I am using LuaLatex, so making this possible with lua as "middle man" wuold be for me perfectly acceptable.

Note: Apparently python is interpretting \ as line continuation character, naively trying to escape it \\ led to no success ...


The PythonTeX environments (pyblock and pycode) do not support LaTeX macros. The commands (\pyb and \pyc) do, however, so something like this might be an option:

\pyc{mytext = """\lipsum[4]"""}


It should be possible to create an environment that would expand macros and then pass the result on to PythonTeX. I've never really looked into that since the commands do expand macros and since an environment that expands macros could involve a lot of extra escaping between Python and LaTeX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.