11

I want to avoid to recompile large tikz graphics and therefore I compile them as a standalone pdf file. This file contains some OCG layers which I want to use in the main file, but the OCG layer are ignored in the main file.

OCG file (ocg-pdf.pdf):

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{ocgx}

\begin{document}
    \begin{tikzpicture}
        \begin{scope}[ocg={name=Layer1,ref=l1,status=visible}]
                \filldraw[color=red] (0,0) rectangle (1,1);
        \end{scope}
        \begin{scope}[ocg={name=Layer2,ref=l2,status=visible}]
                \filldraw[color=blue] (2,2) rectangle (3,3);
        \end{scope}
    \end{tikzpicture}
\end{document}    

Main file:

\documentclass{scrartcl}

\usepackage{graphicx}

\begin{document}
    \includegraphics{ocg-pdf}
\end{document}

Has anyone an idea?

10

There is currently no way to do this with standard pdfTeX/XeTeX/LuaTeX, as there is no way to wire the OCGs in the included PDFs with the OCGs in the including document (this may be doable with the new PDF library in LuaTeX, though - but nobody has done that yet).

I solved this some years ago in a version of pdfTeX available here; there is some documentation on this here.

That version is not maintained anymore and the work has not been incorporated into any stable engine, though.

  • Is this a pdfTeX/LuaTeX limitation or essentially a PDF one? – Joseph Wright Oct 28 '14 at 7:47
  • @JosephWright: It's a problem of the engines (and not well designed in PDF) - it's more difficult than "just" including a PDF page. – Martin Schröder Oct 28 '14 at 11:04
  • 1
    @MartinSchröder: is it possible that your solution could somehow be merged into the official branch of TeX? – Martin Heller Nov 15 '14 at 23:01
  • @MartinHeller: I think patches for LuaTeX would be welcomed. I'm not involved with pdfTeX anymore. – Martin Schröder Nov 15 '14 at 23:03
  • 1
    @MartinSchröder: please consider submitting the patch to LuaTeX. I think the OP is not the only one who would like to see this feature included. – Martin Heller Nov 15 '14 at 23:26

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.