[luatex] Strange behaviour of node.insert_after

Vianney le Clément vleclement at gmail.com
Sun Sep 22 11:56:25 CEST 2013


Hi all,

I am trying to build boxes entirely in Lua using the
node.insert_before and node.insert_after utility functions. I have
notices a strange behaviour of node.insert_after that sometimes return
a wrong head.

Consider this MWE:

\directlua{
  local GLUE, GLUE_SPEC = node.id('glue'), node.id('glue_spec')
  local function append_skip(head, tail, width)
    local n = node.new(GLUE, 0)
    n.spec = node.new(GLUE_SPEC)
    n.spec.width = width
    return node.insert_after(head, tail, n)
  end

  local vhead1 = append_skip(nil, nil, 200)
  local vhead2 = append_skip(nil, nil, 300)

  local head, tail
  head, tail = node.insert_after(head, tail, node.vpack(vhead1))
  head, tail = append_skip(head, tail, 100)
  texio.write_nl("Head before:", tostring(head))
  head, tail = node.insert_after(head, tail, node.vpack(vhead2))
  texio.write_nl("Head after:", tostring(head))
}
\end

Output: [[
Head before:
<node    nil <    207 >    216 : vlist 0>
Head after:
<node    207 <    216 >    224 : glue 0> )
]]

The head before the last insert_after is indeed the first node of the
list (prev is nil), but the last insert_after returns the second node
of the list as head. Am I missing something or is node.insert_after
not supposed to be used like this?

BTW, this is with LuaTeX beta-0.76.0-2013061708 (TeX Live 2013).

Thanks for any insight,
Vianney


More information about the luatex mailing list