[Tex/LaTex] Lua syntax for the listings package


I'm preparing some slides with Beamer and I've just discovered that the listings package, which otherwise does exactly what I want, is missing the syntax for the Lua language. How can I configure listings to highlight Lua?

Best Answer

The premise of your question is wrong. The listings package defines no fewer than three Lua "dialects" in the file lstdvrs.dtx: [5.0]Lua, [5.1]Lua, and [5.2]Lua. Pick whichever is appropriate. You may want to change the way things look, but you shouldn't have to redefine all the syntax from scratch.

enter image description here



  language         = {[5.0]Lua},
  basicstyle       = \ttfamily,
  showstringspaces = false,
  upquote          = true,


-- defines a factorial function
    function fact (n)
      if n == 0 then
        return 1
        return n * fact(n-1)

    print("enter a number:")
    a = io.read("*number")        -- read a number