[luatex] Multiple tex.sprint() calls in a Lua function called from \directlua

Tassilo Horn tsdh at gnu.org
Wed Jul 30 17:35:38 CEST 2014

Hi all,

I'm pretty new to LuaTeX, but I enjoy the fact that I can call Lua
functions from it that are easier for me to write than plain TeX

Ok, now here's my problem.  I have this Lua function

--8<---------------cut here---------------start------------->8---
function index_protocol_methods(ns, str)
   -- str is a sigs string such as
   -- "(create-element! model class),(create-element! model class prop-map)"
   local known = {}
   for method in str:gmatch("%(([a-zA-Z0-9_!?-]+) ") do
      if (not known[method]) then
      known[method] = true;
--8<---------------cut here---------------end--------------->8---

which is called from my tex document using this macro:

--8<---------------cut here---------------start------------->8---
    index_protocol_methods("#1", "#2");}}
--8<---------------cut here---------------end--------------->8---

The problem is that the tex.sprint() calls I do in the loop above don't
make it into my document.  I have other functions that just do one
tex.sprint() as last statement, and those do show up fine.  I verified
that the pattern matches and also removed the if-statement to print
unconditionally, but still nothing.

So is there some limitation I'm not aware of, e.g., tex.sprint() calls
must be the last statement in a function?


More information about the luatex mailing list