diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-01 00:47:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-01 00:47:16 +0000 |
commit | aec2bbc3994991ebc6c5f4dbc90ad15c55f1a1fb (patch) | |
tree | 8940f33f6b173fb5cc630cc58ed4b791ad29e3fe /Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty | |
parent | 868233e6288b5e35a7d7aabd79bf8e56a802bc12 (diff) |
pgfplots 1.5 (29jul11)
git-svn-id: svn://tug.org/texlive/trunk@23292 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty')
-rw-r--r-- | Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty b/Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty new file mode 100644 index 00000000000..84cefdddb45 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots_ocg_copy.sty @@ -0,0 +1,125 @@ +%% Copyright (C) 2007 by Michael Ritzert <michael.ritz...@gmail.com> + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{pgfplots_ocg_copy}[2007/10/14] + +\RequirePackage{ifpdf} +\ifpdf +\else + \PackageWarningNoLine{ocg}{% + Loading aborted, because pdfTeX is not running in PDF mode% + }% + \expandafter\endinput +\fi + +\DeclareOption*{}\ProcessOptions*\relax %allow anything as option for the moment + +%testing for correct pdfTeX version +%TODO: find out minimum required version! +\ifnum\pdftexversion<120 + \PackageError{ocg}{% + pdfeTeX, version >= 1.20, required% + }{% + Install a newer version!% + }% +\fi + +% Next OCG id -- TODO: autogenerate. but keep possibility to reopen an OCG. +\newcount\@ocg@num\@ocg@num=0 + +\gdef\@ocg@layersnames{} + +% called from the aux file +\def\@ocg@makeknown#1#2#3{% #1: OCG name, #2: OC id, #3: on/off + \@ifundefined{OCG#2}{% + \message{OCG#2} + \expandafter\gdef\csname OCG#2\endcsname{#1}% + \immediate\pdfobj{<< /Type /OCG /Name (#1) >>}% new ocg + \xdef\@ocg@curocg{\the\pdflastobj\space 0 R}% reference to id + \xdef\@ocg@ocgs{\@ocg@ocgs\space\@ocg@curocg}% list of all OCGs in "first defined" order + \ifnum#3=1 %on + \xdef\@ocg@ocgson{\@ocg@ocgson\space\@ocg@curocg}% list of all default-on OCGs + \else% + \xdef\@ocg@ocgsoff{\@ocg@ocgsoff\space\@ocg@curocg}% list of all default-off OCGs + \fi% + \xdef\@ocg@layersnames{% + \@ocg@layersnames\space/OC#2\space\@ocg@curocg% name-to-id mapping + }% + }{% + \message{OCG#2 reopened} + % layer reopened + } +} + +\AtBeginDocument{% + % the auxfile has been read if available. register the OCGs in the page resources. + \@ocg@addresource + \let\@ocg@makeknown\@gobble +} + +% set page resources to include the layers defined in the aux file +\def\@ocg@addresource{% + \immediate\pdfobj{<<\@ocg@layersnames\space>>}% + \xdef\@ocg@namesobj{\the\pdflastobj\space 0 R}% + % append to pageresources + \begingroup + \edef\x{\endgroup + \pdfpageresources{% + \the\pdfpageresources + /Properties \@ocg@namesobj% + }% + }% + \x +} + +\newcount\@ocg@@ocgs +\pdfobj reserveobjnum +\@ocg@@ocgs=\pdflastobj + +\newcount\@ocg@@layersconfig +\pdfobj reserveobjnum +\@ocg@@layersconfig=\pdflastobj + +\pdfcatalog{% + /OCProperties << + /OCGs \the\@ocg@@ocgs\space0 R\space + /D \the\@ocg@@layersconfig\space0 R\space + >>% +} +\def\@ocg@ocgs{} +\def\@ocg@ocgson{} +\def\@ocg@ocgsoff{} +\AtEndDocument{% + \immediate\pdfobj useobjnum \@ocg@@ocgs {% + [\@ocg@ocgs\space]% + }% + \immediate\pdfobj useobjnum \@ocg@@layersconfig {% + << + /Order [\@ocg@ocgs\space] + /ON [\@ocg@ocgson\space] + /OFF [\@ocg@ocgsoff\space] + >>% + }% +}% + +% schedule a OCG for creation on the next pdflatex run (via the auxfile) +\def\@ocg@newocg#1#2#3{% #1:name, #2:num, #3:on + \if@filesw% + \immediate\write\@auxout{% + \string\@ocg@makeknown{#1}{#2}{#3}% + }% + \fi% +} + +% TODO: Are nested OCGs allowed? +\newenvironment{ocg}[3]{% + \@ocg@newocg{#1}{#2}{#3}% + \gdef\@ocg@curnum{#2}% + \pdfliteral{/OC /OC\@ocg@curnum\space BDC}% + \message{/OC\@ocg@curnum} +}{% + \pdfliteral{EMC}% + %\unskip% + %\endgroup% +} + |