A Quick How-to on using LuaTeX with ConTeXt

Published: 2010-09-15 by Pradeep Gowda.

LuaTeX is an extended version of pdfTeX using Lua as an embedded scripting language.

ConTeXt is a document processing system based on TeX.

This is a short how-to on how to embed Lua code into TeX.

Hello World

  -- A lua comment
   tex.print("This is printed.")
  local t = {1,2,3,4}
   tex.print("length " .. #t)

  {local t = {1,2,3,4}
   tex.print("length " .. \string#t)}


Compile(!) the .tex file:

    $ texexec --luatex hello

You can open hello.pdf to see the results, which should be:

Hello World
length 4