summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/asymptote
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/asymptote')
-rw-r--r--Master/texmf-dist/tex/latex/asymptote/asycolors.sty72
-rw-r--r--Master/texmf-dist/tex/latex/asymptote/asymptote.sty394
-rw-r--r--Master/texmf-dist/tex/latex/asymptote/latexmkrc4
-rw-r--r--Master/texmf-dist/tex/latex/asymptote/ocg.sty127
4 files changed, 597 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/asymptote/asycolors.sty b/Master/texmf-dist/tex/latex/asymptote/asycolors.sty
new file mode 100644
index 00000000000..31031c730fd
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asymptote/asycolors.sty
@@ -0,0 +1,72 @@
+\usepackage{color}
+\definecolor{cyan}{cmyk}{1,0,0,0}
+\definecolor{magenta}{cmyk}{0,1,0,0}
+\definecolor{yellow}{cmyk}{0,0,1,0}
+\definecolor{black}{cmyk}{0,0,0,1}
+
+\definecolor{white}{cmyk}{0,0,0,0}
+\definecolor{gray}{cmyk}{0,0,0,0.5}
+
+\definecolor{red}{cmyk}{0,1,1,0}
+\definecolor{green}{cmyk}{1,0,1,0}
+\definecolor{blue}{cmyk}{1,1,0,0}
+
+\definecolor{palered}{cmyk}{0,0.25,0.25,0}
+\definecolor{palegreen}{cmyk}{0.25,0,0.25,0}
+\definecolor{paleblue}{cmyk}{0.25,0.25,0,0}
+\definecolor{palecyan}{cmyk}{0.25,0,0,0}
+\definecolor{palemagenta}{cmyk}{0,0.25,0,0}
+\definecolor{paleyellow}{cmyk}{0,0,0.25,0}
+\definecolor{palegray}{cmyk}{0,0,0,0.05}
+\definecolor{lightred}{cmyk}{0,0.5,0.5,0}
+\definecolor{lightgreen}{cmyk}{0.5,0,0.5,0}
+\definecolor{lightblue}{cmyk}{0.5,0.5,0,0}
+\definecolor{lightcyan}{cmyk}{0.5,0,0,0}
+\definecolor{lightmagenta}{cmyk}{0,0.5,0,0}
+\definecolor{lightyellow}{cmyk}{0,0,0.5,0}
+\definecolor{lightgray}{cmyk}{0,0,0,0.1}
+\definecolor{mediumred}{cmyk}{0,0.75,0.75,0}
+\definecolor{mediumgreen}{cmyk}{0.75,0,0.75,0}
+\definecolor{mediumblue}{cmyk}{0.75,0.75,0,0}
+\definecolor{mediumcyan}{cmyk}{0.75,0,0,0}
+\definecolor{mediummagenta}{cmyk}{0,0.75,0,0}
+\definecolor{mediumyellow}{cmyk}{0,0,0.75,0}
+\definecolor{mediumgray}{cmyk}{0,0,0,0.25}
+\definecolor{heavyred}{cmyk}{0,1,1,0.25}
+\definecolor{heavygreen}{cmyk}{1,0,1,0.25}
+\definecolor{heavyblue}{cmyk}{1,1,0,0.25}
+\definecolor{heavycyan}{cmyk}{1,0,0,0.25}
+\definecolor{heavymagenta}{cmyk}{0,1,0,0.25}
+\definecolor{lightolive}{cmyk}{0,0,1,0.25}
+\definecolor{heavygray}{cmyk}{0,0,0,0.75}
+\definecolor{deepred}{cmyk}{0,1,1,0.5}
+\definecolor{deepgreen}{cmyk}{1,0,1,0.5}
+\definecolor{deepblue}{cmyk}{1,1,0,0.5}
+\definecolor{deepcyan}{cmyk}{1,0,0,0.5}
+\definecolor{deepmagenta}{cmyk}{0,1,0,0.5}
+\definecolor{olive}{cmyk}{0,0,1,0.5}
+\definecolor{deepgray}{cmyk}{0,0,0,0.9}
+\definecolor{darkred}{cmyk}{0,1,1,0.75}
+\definecolor{darkgreen}{cmyk}{1,0,1,0.75}
+\definecolor{darkblue}{cmyk}{1,1,0,0.75}
+\definecolor{darkcyan}{cmyk}{1,0,0,0.75}
+\definecolor{darkmagenta}{cmyk}{0,1,0,0.75}
+\definecolor{darkolive}{cmyk}{0,0,1,0.75}
+\definecolor{darkgray}{cmyk}{0,0,0,0.95}
+\definecolor{orange}{cmyk}{0,0.5,1,0}
+\definecolor{fuchsia}{cmyk}{0,1,0.5,0}
+\definecolor{chartreuse}{cmyk}{0.5,0,1,0}
+\definecolor{springgreen}{cmyk}{1,0,0.5,0}
+\definecolor{purple}{cmyk}{0.5,1,0,0}
+\definecolor{royalblue}{cmyk}{1,0.5,0,0}
+\definecolor{salmon}{cmyk}{0,0.5,0.5,0}
+\definecolor{brown}{cmyk}{0,1,1,0.5}
+\definecolor{darkbrown}{cmyk}{0,1,1,0.75}
+\definecolor{pink}{cmyk}{0,0.25,0,0}
+\definecolor{palegrey}{cmyk}{0,0,0,0.05}
+\definecolor{lightgrey}{cmyk}{0,0,0,0.1}
+\definecolor{mediumgrey}{cmyk}{0,0,0,0.25}
+\definecolor{grey}{cmyk}{0,0,0,0.5}
+\definecolor{heavygrey}{cmyk}{0,0,0,0.5}
+\definecolor{deepgrey}{cmyk}{0,0,0,0.9}
+\definecolor{darkgrey}{cmyk}{0,0,0,0.95}
diff --git a/Master/texmf-dist/tex/latex/asymptote/asymptote.sty b/Master/texmf-dist/tex/latex/asymptote/asymptote.sty
new file mode 100644
index 00000000000..4433f6d607e
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asymptote/asymptote.sty
@@ -0,0 +1,394 @@
+%%
+%% This is file `asymptote.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% asy-latex.dtx (with options: `pkg')
+%% ____________________________
+%% The ASYMPTOTE package
+%%
+%% (C) 2003 Tom Prince
+%% (C) 2003-2010 John Bowman
+%% (C) 2010 Will Robertson
+%%
+%% Adapted from comment.sty
+%%
+%% Licence: GPL2+
+%%
+\ProvidesPackage{asymptote}
+ [2011/11/29 v1.26 Asymptote style file for LaTeX]
+\def\Asymptote{{\tt Asymptote}}
+\InputIfFileExists{\jobname.pre}{}{}
+\newbox\ASYbox
+\newcounter{asy}
+\newwrite\AsyStream
+\newwrite\AsyPreStream
+\newif\ifASYinline
+\newif\ifASYattach
+\newif\ifASYkeepAspect
+\ASYkeepAspecttrue
+\RequirePackage{keyval}
+\RequirePackage{ifthen}
+\RequirePackage{color,graphicx}
+\IfFileExists{ifpdf.sty}{
+ \RequirePackage{ifpdf}
+}{
+ \expandafter\newif\csname ifpdf\endcsname
+ \ifx\pdfoutput\@undefined\else
+ \ifcase\pdfoutput\else
+ \pdftrue
+ \fi
+ \fi
+}
+\IfFileExists{ifxetex.sty}{
+ \RequirePackage{ifxetex}
+}{
+ \expandafter\newif\csname ifxetex\endcsname
+ \ifx\XeTeXversion\@undefined\else
+ \xetextrue
+ \fi
+}
+\IfFileExists{catchfile.sty}{
+ \RequirePackage{catchfile}
+}{
+ \newcommand\CatchFileDef[3]{%
+ \begingroup
+ \everyeof{%
+ \ENDCATCHFILEMARKER
+ \noexpand
+ }%
+ \long\def\@tempa####1\ENDCATCHFILEMARKER{%
+ \endgroup
+ \def##1{####1}%
+ }%
+ ##3%
+ \expandafter\@tempa\@@input ##2\relax
+ }
+}
+\newif\if@asy@attachfile@loaded
+\AtBeginDocument{%
+ \@ifpackageloaded{attachfile2}{\@asy@attachfile@loadedtrue}{}%
+ \let\asy@check@attachfile\asy@check@attachfile@loaded
+}
+\newcommand\asy@check@attachfile@loaded{%
+ \if@asy@attachfile@loaded\else
+ \PackageError{asymptote}{You must load the attachfile2 package}{^^J%
+ You have requested the [attach] option for some or all of your^^J%
+ Asymptote graphics, which requires the attachfile2 package.^^J%
+ Please load it in the document preamble.^^J%
+ }%
+ \fi
+}
+\newcommand\asy@check@attachfile{%
+ \AtBeginDocument{\asy@check@attachfile@loaded}%
+ \let\asy@check@attachfile\@empty
+}
+\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
+\DeclareOption{inline}{%
+ \ASYinlinetrue
+}
+\DeclareOption{attach}{%
+ \asy@check@attachfile
+ \ASYattachtrue
+}
+\ProcessOptions*
+\def\asydir{}
+\def\ASYprefix{}
+\newif\ifASYPDF
+\ifxetex
+ \ASYPDFtrue
+\else
+ \ifpdf
+ \ASYPDFtrue
+ \fi
+\fi
+\ifASYPDF
+ \def\AsyExtension{pdf}
+\else
+ \def\AsyExtension{eps}
+\fi
+\def\unquoteJobname#1"#2"#3\relax{%
+ \def\rawJobname{#1}%
+ \ifx\rawJobname\empty
+ \def\rawJobname{#2}%
+ \fi
+}
+\expandafter\unquoteJobname\jobname""\relax
+\def\fixstar#1*#2\relax{%
+ \def\argtwo{#2}%
+ \ifx\argtwo\empty
+ \gdef\Jobname{#1}%
+ \else
+ \fixstar#1-#2\relax
+ \fi
+}
+\expandafter\fixstar\rawJobname*\relax
+\def\Ginclude@eps#1{%
+ \message{<#1>}%
+ \bgroup
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width
+ \dimen@ii.1bp\relax
+ \divide\dimen@\dimen@ii
+ \@tempdima\Gin@req@height
+ \divide\@tempdima\dimen@ii
+ \special{PSfile=#1\space
+ llx=\Gin@llx\space
+ lly=\Gin@lly\space
+ urx=\Gin@urx\space
+ ury=\Gin@ury\space
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
+ \ifGin@clip clip\fi}%
+ \egroup
+}
+\immediate\openout\AsyPreStream=\jobname.pre\relax
+\AtEndDocument{\immediate\closeout\AsyPreStream}
+\def\WriteAsyLine#1{%
+ \immediate\write\AsyStream{\detokenize{#1}}%
+}
+\def\globalASYdefs{}
+\def\WriteGlobalAsyLine#1{%
+ \expandafter\g@addto@macro
+ \expandafter\globalASYdefs
+ \expandafter{\detokenize{#1^^J}}%
+}
+\def\ProcessAsymptote#1{%
+ \begingroup
+ \def\CurrentAsymptote{#1}%
+ \let\do\@makeother \dospecials
+ \@makeother\^^L% and whatever other special cases
+ \catcode`\ =10
+ \endlinechar`\^^M \catcode`\^^M=12 \xAsymptote
+}
+\begingroup
+ \catcode`\^^M=12 \endlinechar=-1\relax%
+ \gdef\xAsymptote{%
+ \expandafter\ProcessAsymptoteLine%
+ }
+ \gdef\ProcessAsymptoteLine#1^^M{%
+ \def\@tempa{#1}%
+ {%
+ \escapechar=-1\relax%
+ \xdef\@tempb{\string\\end\string\{\CurrentAsymptote\string\}}%
+ }%
+ \ifx\@tempa\@tempb%
+ \edef\next{\endgroup\noexpand\end{\CurrentAsymptote}}%
+ \else%
+ \ThisAsymptote{#1}%
+ \let\next\ProcessAsymptoteLine%
+ \fi%
+ \next%
+ }
+\endgroup
+\newcommand\asy[1][]{%
+ \stepcounter{asy}%
+ \setkeys{ASYkeys}{#1}%
+ \ifASYattach
+ \ASYinlinefalse
+ \fi
+ \ifx\asydir\empty\else
+ \def\ASYprefix{\asydir/}%
+ \fi
+ \immediate\write\AsyPreStream{%
+ \noexpand\InputIfFileExists{%
+ \ASYprefix\noexpand\jobname-\the\c@asy.pre}{}{}%
+ }
+ \asy@write@graphic@header
+ \let\ThisAsymptote\WriteAsyLine
+ \ProcessAsymptote{asy}%
+}
+\def\endasy{%
+ \asy@finalise@stream
+ \asy@input@graphic
+}
+\def\asy@write@graphic@header{%
+ \immediate\openout\AsyStream=\ASYprefix\jobname-\the\c@asy.asy\relax
+ \gdef\AsyFile{\ASYprefix\Jobname-\the\c@asy}%
+ \immediate\write\AsyStream{%
+ if(!settings.multipleView) settings.batchView=false;^^J%
+ \ifxetex
+ settings.tex="xelatex";^^J%
+ \else\ifASYPDF
+ settings.tex="pdflatex";^^J%
+ \fi\fi
+ \ifASYinline
+ settings.inlinetex=true;^^J%
+ deletepreamble();^^J%
+ \fi
+ defaultfilename="\Jobname-\the\c@asy";^^J%
+ if(settings.render < 0) settings.render=4;^^J%
+ settings.outformat="";^^J%
+ \ifASYattach
+ settings.inlineimage=false;^^J%
+ settings.embed=false;^^J%
+ settings.toolbar=true;^^J%
+ \else
+ settings.inlineimage=true;^^J%
+ settings.embed=true;^^J%
+ settings.toolbar=false;^^J%
+ viewportmargin=(2,2);^^J%
+ \fi
+ \globalASYdefs
+ }%
+}
+\def\asy@expand@keepAspect{%
+ \ifASYkeepAspect keepAspect=true%
+ \else keepAspect=false%
+ \fi%
+}
+\def\asy@finalise@stream{%
+ \ifx\ASYwidth\@empty
+ \ifx\ASYheight\@empty
+ % write nothing!
+ \else
+ \immediate\write\AsyStream{size(0,\ASYheight,\asy@expand@keepAspect);}%
+ \fi
+ \else
+ \ifx\ASYheight\@empty
+ \immediate\write\AsyStream{size(\ASYwidth,0,\asy@expand@keepAspect);}%
+ \else
+ \immediate\write\AsyStream{size(\ASYwidth,\ASYheight,\asy@expand@keepAspect);}%
+ \fi
+ \fi
+ \ifx\ASYviewportwidth\@empty
+ \ifx\ASYviewportheight\@empty
+ % write nothing!
+ \else
+ \immediate\write\AsyStream{viewportsize=(0,\ASYviewportheight);}%
+ \fi
+ \else
+ \ifx\ASYviewportheight\@empty
+ \immediate\write\AsyStream{viewportsize=(\ASYviewportwidth,0);}%
+ \else
+ \immediate\write\AsyStream{%
+ viewportsize=(\ASYviewportwidth,\ASYviewportheight);}%
+ \fi
+ \fi
+ \immediate\closeout\AsyStream
+}
+\def\asy@input@graphic{%
+ \ifASYinline
+ \IfFileExists{"\AsyFile.tex"}{%
+ \catcode`:=12\relax
+ \@@input"\AsyFile.tex"\relax
+ }{%
+ \PackageWarning{asymptote}{file `\AsyFile.tex' not found}%
+ }%
+ \else
+ \IfFileExists{"\AsyFile.\AsyExtension"}{%
+ \ifASYattach
+ \ifASYPDF
+ \IfFileExists{"\AsyFile+0.pdf"}{%
+ \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile+0".pdf}}%
+ }{%
+ \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile".pdf}}%
+ }%
+ \else
+ \setbox\ASYbox=\hbox{\includegraphics[hiresbb]{"\AsyFile.eps"}}%
+ \fi
+ \textattachfile{\AsyFile.\AsyExtension}{\phantom{\copy\ASYbox}}%
+ \vskip-\ht\ASYbox
+ \indent
+ \box\ASYbox
+ \else
+ \ifASYPDF
+ \includegraphics[hiresbb]{"\AsyFile".pdf}%
+ \else
+ \includegraphics[hiresbb]{"\AsyFile.eps"}%
+ \fi
+ \fi
+ }{%
+ \IfFileExists{"\AsyFile.tex"}{%
+ \catcode`:=12
+ \@@input"\AsyFile.tex"\relax
+ }{%
+ \PackageWarning{asymptote}{%
+ file `\AsyFile.\AsyExtension' not found%
+ }%
+ }%
+ }%
+ \fi
+}
+\def\asydef{%
+ \let\ThisAsymptote\WriteGlobalAsyLine
+ \ProcessAsymptote{asydef}%
+}
+\newcommand\asyinclude[2][]{%
+ \begingroup
+ \stepcounter{asy}%
+ \setkeys{ASYkeys}{#1}%
+ \ifASYattach
+ \ASYinlinefalse
+ \fi
+ \ifx\asydir\empty\else
+ \def\ASYprefix{\asydir/}%
+ \fi
+ \immediate\write\AsyPreStream{%
+ \noexpand\InputIfFileExists{%
+ \ASYprefix\noexpand\jobname-\the\c@asy.pre}{}{}%
+ }%
+ \asy@write@graphic@header
+ \IfFileExists{#2.asy}{%
+ \CatchFileDef\@tempa{#2.asy}{%
+ \let\do\@makeother
+ \dospecials
+ \endlinechar=10\relax
+ }%
+ }{%
+ \IfFileExists{#2}{%
+ \CatchFileDef\@tempa{#2}{%
+ \let\do\@makeother
+ \dospecials
+ \endlinechar=10\relax
+ }%
+ }{%
+ \PackageWarning{asymptote}{file #2 not found}%
+ }%
+ }%
+ \immediate\write\AsyStream{\unexpanded\expandafter{\@tempa}}%
+ \asy@finalise@stream
+ \asy@input@graphic
+ \endgroup
+}
+\newcommand{\ASYanimategraphics}[5][]{%
+ \IfFileExists{_#3.pdf}{%
+ \animategraphics[{#1}]{#2}{_#3}{#4}{#5}%
+ }{}%
+}
+\newcommand\asysetup[1]{\setkeys{ASYkeys}{#1}}
+\define@key{ASYkeys}{dir}{%
+ \def\asydir{#1}%
+}
+\def\ASYwidth{}
+\define@key{ASYkeys}{width}{%
+ \edef\ASYwidth{\the\dimexpr#1\relax}%
+}
+\def\ASYheight{}
+\define@key{ASYkeys}{height}{%
+ \edef\ASYheight{\the\dimexpr#1\relax}%
+}
+\define@key{ASYkeys}{keepAspect}[true]{%
+ \ifthenelse{\equal{#1}{true}}
+ {\ASYkeepAspecttrue}
+ {\ASYkeepAspectfalse}%
+}
+\def\ASYviewportwidth{}
+\define@key{ASYkeys}{viewportwidth}{%
+ \edef\ASYviewportwidth{\the\dimexpr#1\relax}%
+}
+\def\ASYviewportheight{}
+\define@key{ASYkeys}{viewportheight}{%
+ \edef\ASYviewportheight{\the\dimexpr#1\relax}%
+}
+\define@key{ASYkeys}{inline}[true]{%
+ \ifthenelse{\equal{#1}{true}}
+ {\ASYinlinetrue}
+ {\ASYinlinefalse}%
+}
+\define@key{ASYkeys}{attach}[true]{%
+ \ifthenelse{\equal{#1}{true}}
+ {\ASYattachtrue}
+ {\ASYattachfalse}%
+}
diff --git a/Master/texmf-dist/tex/latex/asymptote/latexmkrc b/Master/texmf-dist/tex/latex/asymptote/latexmkrc
new file mode 100644
index 00000000000..1cca8732e94
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asymptote/latexmkrc
@@ -0,0 +1,4 @@
+sub asy {return system("asy '$_[0]'");}
+add_cus_dep("asy","eps",0,"asy");
+add_cus_dep("asy","pdf",0,"asy");
+add_cus_dep("asy","tex",0,"asy");
diff --git a/Master/texmf-dist/tex/latex/asymptote/ocg.sty b/Master/texmf-dist/tex/latex/asymptote/ocg.sty
new file mode 100644
index 00000000000..3ba555b58e8
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/asymptote/ocg.sty
@@ -0,0 +1,127 @@
+%% Copyright (C) 2007 by Michael Ritzert <michael.ritz...@gmail.com>
+%% Spurious spaces removed by John Bowman [2009/06/01].
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{ocg}[2009/06/01]
+
+\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}%
+ \ignorespaces
+}{%
+ \pdfliteral{EMC}%
+ %\unskip%
+ %\endgroup%
+ \ignorespacesafterend
+}