I have stripped down to the following MWE after some experimentation. As it is, it works without any problems.



\author{The author}
\title{Some title}

Some figure
\draw[fill,pattern=north east lines,thick] (0,0) rectangle (5cm,2cm);
\caption{Some caption}%

Notice the coloring and the weight of the font on LoF entries:

enter image description here

But when I change the location of the hyperref declaration to somewhere after TikZ and its library declaration, the whole figure environment just vanishes (but LoF still knows that it's there) also LoF entry loses its color(I guess!).

enter image description here

If I remove the patterns library dependence (fill=yellow or anything else) the second picture above is obtained and the TikZ picture is rendered correctly regardless of the declaring order. This suggests that the second image is the correct one and something fishy is going on either in the pattern library or ocgcolorlinks option. Does anyone know why? Or is it a bug?

I work with MikTeX 2.9, TikZ/PGF 2.10, hyperref6.83c

  • I couldn't replicate it here but in my original big file, the resulting PDF triggers a corrupted file error on Adobe Acrobat X on the pages where I have patterns in TikZ figures. Is it possible that ocg mechanism throws everything to another layer? I didn't test it but maybe if I print it, the story gets more mysterious.
    – percusse
    Sep 22 '12 at 23:56

Both packages need access to the same data structures in PDF. There is nothing that manages the global resources of the PDF format. Thus the current situation is that the packages overwrite each other. At TeX macro level some kind of PDF kernel is needed, like the LaTeX kernel manages global resources like various counter registers.

Update: After a closer look I found that both packages overwrite the token register \pdfpageresources with deleting the previous contents. Of course there are problems, if the same keys are set by different packages. In this case however, TikZ sets /ColorSpace, /Pattern and /ExtGState, whereas hyperref puts key /Properties there. Therefore I will update hyperref to preserve the previous contents of \pdfpageresources. Then the example will work, if hyperref is loaded after pgf. The current situation is that either the TikZ's patterns or hyperrefs ocgcolorlinks are broken.

  • When I load hyperref version 6.83k with option ocgcolorlinks after loading tikz, I get a warning: Package hyperref Warning: The PDF version number could not be set, because some PDF objects are already written: 3 PDF objects The version should be set as early as possible: \pdfminorversion=5\relax. Oct 31 '12 at 10:38
  • 2
    @AndrewUzzell Just do thus. Put \pdfminorversion=5\relax at the beginning before \documentclass (or before the first PDF object is written). Oct 31 '12 at 10:40

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.