TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

TeX is frustrating me. It has only the basics - and even then, I have to search how to divide two numbers.

The question is this: can I write my macros in more convenient language like Ruby or Lisp?

UPD: I will explain my situation. I'm writing a rulebook for my RPG module, and I need to construct an equipment table. Problem is, my rules are not the simplest ones:


I want nice fonts, so I use XeLaTeX. I am Russian, so I need polyglossia or babel.

Please note that every suggestion is tested against XeLaTeX, not LaTeX.

share|improve this question
Broad answer 'no', but look at LaTeX3's expl3 language as a richer set of tools built on top of TeX. – Joseph Wright Oct 16 '12 at 11:22
Or switch to LuaTeX and use lua. – Loop Space Oct 16 '12 at 11:25
May you show an example of a situation in which such programming features are needed? – egreg Oct 16 '12 at 11:43
up vote 12 down vote accepted

My PythonTeX package is another Python-based option. PythonTeX was primarily developed for mathematical and scientific applications, but it's also suitable for much general-purpose work. I've included a few basic examples of creating macros with PythonTeX below. You do have to be careful about catcodes if you are working with special characters.



Basic math:  \py{5324/251}

Macros that more closely interact with TeX:


\reverse{A sentence!}

    \py{'&'.join("#1".split(','))} \\

\listtotabular{First, Second, Third, Fourth}


enter image description here

In addition to the examples above, and the examples included with the documentation, you might also look at the following examples.

share|improve this answer
It's very buggy. Did you know that 'newfloat' package is actially distributed as 'caption'? I couldn't run the example, some obscure pgf error (pgfopts is installed) about /PYTX. – Alexander Yakovlev Oct 17 '12 at 2:35
I'd overlooked that you need XeLaTeX. The example above works with XeLaTeX (at least with Windows with a fresh TeX Live 2012 installation). But the example file from GitHub won't work, unless you remove the inputenc and fontenc packages, load fontspec and use \defaultfontfeatures{Ligatures=TeX}, and run xelatex with the -8bit option. The -8bit option is needed for handling tabs; see this. – G. Poore Oct 17 '12 at 5:06
Thanks; it gave me a mountain of errors, but worked. Seems like it needs strict TL2012. – Alexander Yakovlev Oct 17 '12 at 7:45
share|improve this answer
PerlTeX is not working with XeTeX, and LuaLaTeX has known issues with non-Latin languages. I couldn't start python package, it gives a "can't find file `test.py.out'." error, but I'll keep digging that way. – Alexander Yakovlev Oct 17 '12 at 2:09

While I haven't tried, you might be able to use bashful to interact with programs written in other languages via stdin and stdout.

I had no problems with a simple example as long as I compiled with -shell-escape:



I am not sure about the polyglossia issue that is mentioned in the documentation.

share|improve this answer
Seems like it hacks Polyglossia, causing it to use latin monospaced font. Also gives me an error because "File test.stdout was empty" – Alexander Yakovlev Oct 17 '12 at 2:19
@AlexanderYakovlev I could get a simple example running no problem – StrongBad Oct 17 '12 at 13:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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