[luatex] void box

Paul Isambert zappathustra at free.fr
Wed Feb 8 07:43:40 CET 2012

Andreas Matthias <andreas.matthias at gmail.com> a écrit:
> Patrick Gundlach wrote:
> > you can say: node.new("hlist")

Thank you Patrick, I always forget that.

> > 
> > 
> >> curr = list
> >> 
> >> for i=0,5 do
> >>    n = node.new(node.id('glyph'))
> >>    n.font=1
> >>    n.char=97+i
> >> 
> >>    curr.next = n
> >>    curr = n
> >> end
> > 
> Well, if the first node is missing, I have to check inside the
> loop for each created node whether or not it becomes the head
> of the list. I think the code is much clearer without additional
> if-clauses. And one can always remove the very first node
> afterwards. -- Okay, maybe not a big advantage. But this was
> the reason why I started to look for a suitable header of a
> node list, i.e. an empty or void box. And I was astonished to
> realize that I didn't know what a \voidb at x really was.

Actually, you can do without a dummy head and without conditionals:

local list
for i = 0, 5 do
  local n = node.new("glyph")
  n.font  = 1
  n.char  = 97+i
  list    = node.insert_after(list, nil, n)

That's because node.insert_after can take `nil' as its first argument
(in which case it simply returns the `added' node) ... a functionality
I didn't understand what it was good for until now!

(I've added local's because I didn't know whether you're naturally light
on them, which is *very bad*, or you just omit them for examples.)


More information about the luatex mailing list