Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\documentclass{memoir}
\usepackage[ocgcolorlinks]{hyperref}

\usepackage{tikz}
\usetikzlibrary{patterns}


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

\begin{document}
\frontmatter
\maketitle
\listoffigures
\mainmatter
\chapter{first}
\section{first}
Some figure
\begin{figure}%
\centering
\begin{tikzpicture}
\draw[fill,pattern=north east lines,thick] (0,0) rectangle (5cm,2cm);
\end{tikzpicture}
\caption{Some caption}%
\label{fig:a1}%
\end{figure}
\end{document}

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

share|improve this question
    
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
add comment

1 Answer 1

up vote 11 down vote accepted

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.

share|improve this answer
    
Thank you for the details. –  percusse Sep 23 '12 at 8:42
    
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. –  Andrew Uzzell 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). –  Heiko Oberdiek Oct 31 '12 at 10:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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