For a package I'm writing, it would be very handy to use some programmed scripts, for example written in Python. Is there a way how I could add these to my .cls file?

And if not, what is the usual way to add scripts to a .cls?

  • Most people use Lua and Lua(La)TeX if they want to do that kind of scripting, but there are alternatives. Have you tried PythonTeX?
    – frabjous
    Mar 31, 2022 at 15:33
  • 1
    TeX itself is Turing complete, and you can "script" with it directly if you like; packages like expl3 make it easier. You can even call external programs with write18; see, e.g. here. But I can definitely see why someone might prefer Python, and that may include you. Should be do-able either way. Which do you prefer?
    – frabjous
    Mar 31, 2022 at 15:48
  • 2
    There's tex.stackexchange.com/questions/12668/… / tex.stackexchange.com/questions/4327/… (disclaimer, the second one is my answer) I have to warn that TeX is a very inconvenient programming language though.
    – user202729
    Mar 31, 2022 at 15:50
  • 2
    @TiMauzi if your users use --shell-escape commandline option then you can run any command from within your class including deleting all their files. For good reason users are strongly advised not to use --shell-escape on random tex code they find on the internet, so you can do this if you really need it (eg the minted package uses the python pygments library for code syntax highlighting) but be aware that it severely limits the usability of your class. Mar 31, 2022 at 16:40
  • 3
    @user202729 that is not how you spell enjoyable Mar 31, 2022 at 16:42


You must log in to answer this question.

Browse other questions tagged .