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

Patrick Gundlach patrick at gundla.ch
Thu Apr 25 22:08:16 CEST 2013

Hello Heiko,

>> 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?

> 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.

I my case, I did get garbled output, so the warning was very good.

Thanks for your comment. This is what I have now:

local function scalebox(scalefactor,box)
    local pdf_save, pdf_restore, pdf_setmatrix
    pdf_save = node.new("whatsit","pdf_save")
    pdf_restore = node.new("whatsit","pdf_restore")
    pdf_setmatrix = node.new("whatsit","pdf_setmatrix")
    pdf_setmatrix.data=string.format("%.4g 0 0 %.4g",scalefactor,scalefactor)

    local hbox = node.hpack(box)
    hbox = node.insert_before(hbox,hbox,pdf_setmatrix)
    hbox = node.insert_before(hbox,pdf_setmatrix,pdf_save)

    hbox = node.hpack(hbox)
    hbox.height = box.height * scalefactor
    hbox.width = box.width * scalefactor
    hbox.depth = 0

    local newbox = node.vpack(hbox)
    return newbox

which seems to work because the box doesn't have any depth. 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20130425/337fca5f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nodes.png
Type: image/png
Size: 69769 bytes
Desc: not available
URL: <http://tug.org/pipermail/luatex/attachments/20130425/337fca5f/attachment-0001.png>

More information about the luatex mailing list