[luatex] LuaTeX warning: Misplaced \pdfrestore by (983040sp, 0sp)

Heiko Oberdiek heiko.oberdiek at googlemail.com
Thu Apr 25 20:03:42 CEST 2013


On 23.04.2013 14:21, Patrick Gundlach wrote:
> Hi,
> 
> when running the following code, I have a problem that subsequent boxes are misplaced. A warning is issued:
> 
> LuaTeX warning: Misplaced \pdfrestore by (983040sp, 0sp)
> 
> What am I doing wrong?
> 
> Patrick
> 
> 
> 
> \documentclass{article}
> 
> \begin{document}
> 
> \directlua{
>   local save,restore,set_matrix
>   save = node.new("whatsit","pdf_save")
>   restore = node.new("whatsit","pdf_restore")
>   set_matrix = node.new("whatsit", "pdf_setmatrix")
>   set_matrix.data = "5 0 0 5 "
> 
>   local rule = node.new("rule")
>   rule.width =  15*2^16
>   rule.height = 15*2^16
>   local hbox = node.hpack(rule)
>   hbox.head = node.insert_before(hbox.head,rule,save)
>   node.insert_after(hbox.head,save,set_matrix)
>   node.insert_after(hbox.head,rule,restore)
>   node.write(hbox)
> }

The pair \pdfsave and \pdfrestore must be at the same location. In your
code there is rule inbetween. There are two different coordinate
systems: PDF and TeX, \pdfrestore restores the graphics state including
the current transfer matrix to the state of \pdfsave in the PDF
coordinate system. But if the TeX position has moved away, the
two coordinate systems are out of sync. Therefore you get a warning
that you might shoot yourself in the foot.

There are several ways to do this, pseudo-code, e.g. going back via
\kern or:

  \hbox{%
    \pdfsave
    \pdfsetmatrix ...
    \hbox to 0pt{%
      \rule...
      \hss
    }%
    \pdfrestore
  }



More information about the luatex mailing list