[Dev-luatex] How to insert at start of hlist/vlist?

Heiko Oberdiek oberdiek at uni-freiburg.de
Sat Dec 8 00:07:13 CET 2007


Hello,

I have some trouble to insert something at the start
of a list.

Example (complete example file after PS):

\setbox0=\hbox{XY}
\directlua0{
  do
    local hlist = tex.box[0]
    local pdf_literal = node.new(8,8)% \pdfliteral
    pdf_literal.mode = 2 % direct
    pdf_literal.data = "1 0 0 rg 1 0 0 RG"
    local head = hlist.list
    % local current = hlist.list.next % works
    local current = hlist.list % fails  
    hlist.list = node.insert_before(head, current, pdf_literal)  
  end
}

! LuaTeX error Attempt to node.insert_before() a non-existing node.

Have I misunderstood node.insert_before()?

Yours sincerely
  Heiko <oberdiek at uni-freiburg.de>

PS: Complete example file that can be used with
    iniTeX, plain-TeX and LaTeX:

\ifnum\catcode`\{=1
\else
  \catcode`\{=1
  \catcode`\}=2
  \hsize=6.5in
  \vsize=8.9in
  \parfillskip=0pt plus 1fil
\fi
\font\f=cmr10
\f
\pdfoutput=1

\setbox0=\hbox{XY}
\directlua0{
  do
    local hlist = tex.box[0]
    local pdf_literal = node.new(8,8)% \pdfliteral
    pdf_literal.mode = 2 % direct
    pdf_literal.data = "1 0 0 rg 1 0 0 RG"
    local head = hlist.list
    % local current = hlist.list.next % works
    local current = hlist.list % fails  
    hlist.list = node.insert_before(head, current, pdf_literal)  
  end
}
\shipout\hbox{[\box0]}

\csname @@end\endcsname
\end


More information about the dev-luatex mailing list