9

Consider the following class.cls:

\LoadClass{article}
\RequirePackage{tikz}

and the following test.tex:

\documentclass{class}
\begin{document}
Test 
\end{document}

With pdftex (TeXLive 2016), I do:

pdftex -ini -jobname="test-fmt-pdftex" "&pdflatex" mylatexformat.ltx """test.tex"""
pdftex -fmt=test-fmt-pdftex.fmt test.tex

It works with no problem.

With luatex (TeXLive 2016), I do:

luatex -ini -jobname="test-fmt-luatex" "&lualatex" mylatexformat.ltx """test.tex"""
luatex -fmt=test-fmt-luatex.fmt test.tex

The second line ends up with an error:

! error:  (pdf backend): referenced object has wrong type others; should be obj
!  ==> Fatal error occurred, no output PDF file produced!

I know that I cannot dump in a luatex format lua code or opentype fonts but I think that tikz does not do that. There must be an other reason. Do you have any ideas?


I investigated a bit.

As far as I understand, there has been an updated version of pgfsys-luatex.def to comply with the changes made in luatex related to \pdf... primitives. This is one hint I can think of.

There is also this in the luatex manual:

One change involves the so called xforms and ximages. In pdfTEX these are implemented as so called whatsits. But contrary to other whatsits they have dimensions that need to be taken into account when for instance calculating optimal line breaks. In LuaTEX these are now promoted to normal nodes, which simplifies code that needs those dimensions.

But I must admit I don't really understand all that.

13
  • In your comment there, you said that it would not work due to the use of pdftexcmds. Do you no longer think that's true?
    – cfr
    Aug 27, 2016 at 12:42
  • 1
    It uses directlua in various places, including pgfutil-common, which I'm guessing gets loaded by tikz although I didn't trace all this through.
    – cfr
    Aug 27, 2016 at 12:59
  • 1
    Also the RCS stuff uses directlua and the code for TikZ comments that \usepgflibrary is provided by pgfutil-common. So TikZ definitely relies on \directlua and the Lua code it loads.
    – cfr
    Aug 27, 2016 at 13:02
  • @cfr Thanks for investigating. It's been a while since I read the code. Do you see any mean to circumvent the situation?
    – cjorssen
    Aug 27, 2016 at 13:07
  • 2
    pgfsys-luatex.def calls at the end two commands \pgfutil@setuppdfresources and \pgfutil@addpdfresource@colorspaces. If you remove these calls your example works. The commands call the code in \pgf@sys@setuppdfresources@plain and this set up pdf objects: disabling the obj in \pgfutil@everyby avoids the error too. I don't know why the similar code doesn't give an error with pdflatex but I would avoid to move the creation of objects to the format with pdflatex too. Aug 27, 2016 at 17:21

1 Answer 1

6
+250

pgfsys-luatex.def calls at the end two commands

  • \pgfutil@setuppdfresources and
  • \pgfutil@addpdfresource@colorspaces.

If you remove these calls your example works. So there is somewhere the source of the problem. The commands call the code in \pgf@sys@setuppdfresources@plain and this set up pdf objects: disabling the obj in \pgfutil@everyby avoids the error too.

Boiling everthing a bit down one can create the following (senseless!!) minimal document:

\documentclass{book}
\usepackage{ifluatex}
\ifluatex
\pdfextension obj  reserveobjnum \edef\myobjnum{\the\numexpr\pdffeedback lastobj\relax}
\else
\pdfobj reserveobjnum \edef\myobjnum{\the\pdflastobj}
\fi
%\makeatother
\begin{document}
\ifluatex
\immediate \pdfextension obj  useobjnum \myobjnum {<</pgfprgb [/Pattern /DeviceRGB]>>}
\else
\immediate \pdfobj  useobjnum \myobjnum {<</pgfprgb [/Pattern /DeviceRGB]>>}
\fi
blub
\end{document}

It compiles fine with pdflatex and lualatex and one can open the pdf in the adobe reader (which means that it is not completly broken). With pdflatex you can put the preamble in a custom format using your compilation steps. But a compilation with luatex -fmt=myfmt.fmt test-utf8 ends with

! error:  (pdf backend): cannot find referenced object
!  ==> Fatal error occurred, no output PDF file produced!

It looks as if luatex doesn't like it if one tries to reserve objects in the format. I can't tell you if this is intended, or some side effect, or even a bug: you will have to ask on the luatex list.

Even if it works with pdftex: I would avoid to put objects in a format anyway (and so not move tikz there).

1
  • Thanks to you, Ulrike, we now have an analysis of what's going on here. In addition, I've been able to code a dirty workaround to include tikz (and others) in my format. I'm going to post on luatex list: maybe devs will tell us if it's a bug. Thanks again!
    – cjorssen
    Sep 2, 2016 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.