summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ocg-p
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/ocg-p
Initial commit
Diffstat (limited to 'macros/latex/contrib/ocg-p')
-rw-r--r--macros/latex/contrib/ocg-p/README31
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_1.pdfbin0 -> 44653 bytes
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_1.tex27
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_2.pdfbin0 -> 60271 bytes
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_2.tex36
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_3.pdfbin0 -> 61522 bytes
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_3.tex57
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_4.pdfbin0 -> 74902 bytes
-rw-r--r--macros/latex/contrib/ocg-p/examples/ocg-p_example_4.tex116
-rw-r--r--macros/latex/contrib/ocg-p/ocg-p.pdfbin0 -> 463136 bytes
-rw-r--r--macros/latex/contrib/ocg-p/ocg-p.sty478
-rw-r--r--macros/latex/contrib/ocg-p/ocg-p.tex630
12 files changed, 1375 insertions, 0 deletions
diff --git a/macros/latex/contrib/ocg-p/README b/macros/latex/contrib/ocg-p/README
new file mode 100644
index 0000000000..39d135507a
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/README
@@ -0,0 +1,31 @@
+% ocg-p
+% %%%%%
+%
+% LaTeX package to use OCG (Optional Content Groups) within a PDF document.
+% OCGs are layers which can be included into PDFs and be displayed or not.
+% Replacement and enhancement for ocg.sty from the asymptote package.
+% While ocg.sty can only be used with pdflatex, the ocg-p package can also be used with xelatex.
+% Additionally nested OCGs are handled as such.
+%
+% files
+% %%%%%
+%
+% ocg-p.sty main package file
+% ocg-p.tex documentation source
+% ocg-p.pdf documentation
+% README this readme
+% examples/ocg-p_example_1.tex example source
+% examples/ocg-p_example_1.pdf example
+% examples/ocg-p_example_2.tex example source
+% examples/ocg-p_example_2.pdf example
+% examples/ocg-p_example_3.tex example source
+% examples/ocg-p_example_3.pdf example
+% examples/ocg-p_example_4.tex example source
+% examples/ocg-p_example_4.pdf example
+%
+% license
+% %%%%%%%
+% Copyright (C) 2012 by Werner Moshammer
+%
+% This file may be distributed and/or modified under the LaTeX Project Public License.
+
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.pdf b/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.pdf
new file mode 100644
index 0000000000..29360735d2
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.tex b/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.tex
new file mode 100644
index 0000000000..ce361e0180
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_1.tex
@@ -0,0 +1,27 @@
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage{ocg-p}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+
+\title{\pkg{OCG-P} package, example 1}
+
+\begin{document}
+
+\maketitle
+
+\begin{ocg}{First layer}{oc1}{1}
+ The first Layer is visible at start.
+\end{ocg}
+
+\begin{ocg}{Second layer}{oc2}{0}
+ The second layer is not visible at start.
+\end{ocg}
+
+\begin{ocg}{Third layer}{oc3}{1}
+ The third layer is visible at start.
+\end{ocg}
+
+This text is not inside of a layer and always visible.
+
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.pdf b/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.pdf
new file mode 100644
index 0000000000..e2cfa0f571
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.tex b/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.tex
new file mode 100644
index 0000000000..b72835cdd2
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_2.tex
@@ -0,0 +1,36 @@
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage{ocg-p}
+\usepackage{tikz}
+\usetikzlibrary{arrows,automata}
+
+\newcommand{\TikZ}{Ti\emph{k}Z}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+
+\title{\pkg{OCG-P} package, example 2}
+
+\begin{document}
+
+\maketitle
+
+\begin{tikzpicture}[node distance=3cm,every state/.style={fill=green!20},auto]
+\begin{ocg}{grid}{ocgridid}{1}
+ \draw[black!20] (-1,-1) grid (4,2);
+\end{ocg}
+
+\begin{ocg}{states}{ocstatesid}{1}
+ \node[state] (q_a) {$q_a$};
+ \node[state] (q_b) [right of=q_a] {$q_b$};
+\end{ocg}
+
+\begin{ocg}{edges}{ocedgesid}{1}
+ \path[->]
+ (q_a) edge node {0} (q_b)
+ edge [loop above] node {0} ()
+ (q_b) edge [loop above] node {1} ();
+\end{ocg}
+\end{tikzpicture}
+
+This text is not inside of a layer and always visible.
+
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.pdf b/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.pdf
new file mode 100644
index 0000000000..53bc6f8adc
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.tex b/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.tex
new file mode 100644
index 0000000000..fdc8c8c7e2
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_3.tex
@@ -0,0 +1,57 @@
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage{ocg-p}
+\usepackage{tikz}
+\usetikzlibrary{arrows,automata}
+\usepackage{color}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+
+\title{\pkg{OCG-P} package, example 3}
+
+\begin{document}
+
+\maketitle
+
+\section{Text layers changed by clicking on a link element}
+The following text can be toggled:
+\begin{tikzpicture}[baseline=0]
+\tikzstyle{nome}=[anchor=base,outer sep=0,inner sep=0,minimum height=.45cm,minimum width=4.4cm]
+\begin{ocg}{blue text}{ocblueid}{1}
+ \node[nome,blue] (p1) {\parbox[b][][t]{4.4cm}{This text is written in blue.}};
+\end{ocg}
+\begin{ocg}{red text}{ocredid}{0}
+ \node[overlay,nome,red] (p2) {\parbox[b][][t]{4.4cm}{This text is written in red.}};
+\end{ocg}
+\end{tikzpicture}
+And now the text is black again.\\
+
+\toggleocgs{ocblueid ocredid}{Click here to toggle the text!}
+
+
+
+\section{Mouseover example}
+
+Make the text visible by moving the mouse in the box around.
+
+\fbox{
+\begin{ocg}{This}{octhis}{0}
+ \toggleocgs[triggerocg=allactions]{octhis, octhis}{This}
+\end{ocg}
+\begin{ocg}{text}{octext}{0}
+ \toggleocgs[triggerocg=allactions]{octext, octext}{text}
+\end{ocg}
+\begin{ocg}{is}{ocis}{0}
+ \toggleocgs[triggerocg=allactions]{ocis,ocis}{is}
+\end{ocg}
+\begin{ocg}{not}{ocnot}{0}
+ \toggleocgs[triggerocg=allactions]{ocnot, ocnot}{not}
+\end{ocg}
+\begin{ocg}{visible}{ocvisible}{0}
+ \toggleocgs[triggerocg=allactions]{ocvisible, ocvisible}{visible.}
+\end{ocg}
+}
+
+
+
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.pdf b/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.pdf
new file mode 100644
index 0000000000..d0579f84fa
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.tex b/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.tex
new file mode 100644
index 0000000000..0fb865ecbd
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/examples/ocg-p_example_4.tex
@@ -0,0 +1,116 @@
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage[ocgtabular]{ocg-p}
+\usepackage{tikz}
+\usepackage{datatool}
+\usepackage{booktabs}
+
+%\usepackage{array}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+
+\title{\pkg{OCG-P} package, example 4}
+
+\begin{document}
+
+% generate database with data for the table
+\DTLnewdb{sdata}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{John}
+\DTLnewdbentry{sdata}{Lastname}{Doe}
+\DTLnewdbentry{sdata}{Grade}{5}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Paul}
+\DTLnewdbentry{sdata}{Lastname}{Bauer}
+\DTLnewdbentry{sdata}{Grade}{1}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Peggy}
+\DTLnewdbentry{sdata}{Lastname}{Sue}
+\DTLnewdbentry{sdata}{Grade}{3}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Ever}
+\DTLnewdbentry{sdata}{Lastname}{Last}
+\DTLnewdbentry{sdata}{Grade}{4}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Werner}
+\DTLnewdbentry{sdata}{Lastname}{Moshammer}
+\DTLnewdbentry{sdata}{Grade}{1}
+
+\maketitle
+
+\section{Without using the ocgtabular environment}
+This table can be sorted by clicking on the headers:
+
+\begin{tikzpicture}
+\begin{ocg}{First Name}{ocfirstid}{1}
+ \node[] (p1) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Firstname}{sdata}% sorted on the first name
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\begin{ocg}{First Name}{oclastid}{0}
+ \node[overlay] (p2) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Lastname}{sdata}% sorted on the last name
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\begin{ocg}{First Name}{ocgradeid}{0}
+ \node[overlay] (p3) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Grade}{sdata}% sorted on the grade
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\end{tikzpicture}
+
+\section{Using the ocgtabular environment}
+
+This table can be sorted by clicking on the headers:
+
+\begin{ocgtabular}{llc}{sdata}{}
+\toprule%
+\bfseries \setocgtabularheader{Firstname}{First name}
+& \bfseries \setocgtabularheader{Lastname}{Last name}
+& \bfseries \setocgtabularheader{Grade}{Grade}
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule%
+\end{ocgtabular}
+
+
+
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/ocg-p/ocg-p.pdf b/macros/latex/contrib/ocg-p/ocg-p.pdf
new file mode 100644
index 0000000000..5bffa9aa84
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/ocg-p.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocg-p/ocg-p.sty b/macros/latex/contrib/ocg-p/ocg-p.sty
new file mode 100644
index 0000000000..b0e0172d9e
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/ocg-p.sty
@@ -0,0 +1,478 @@
+% Copyright (C) 2012 by Werner Moshammer
+% Parts of this code are Copyright (C) 2007 by Michael Ritzert <michael.ritz...@gmail.com>
+% REPLACEMENT FOR THE OLD OCG.STY
+% FOR PDFLATEX AND XELATEX (the old ocg.sys works only with pdflatex)
+% This file may be distributed and/or modified under the LaTeX Project Public License
+
+\NeedsTeXFormat{LaTeX2e}
+\def\ocgpversion{0.4}
+\ProvidesPackage{ocg-p}[2013/01/10 v\ocgpversion\space Optional Content Group in a PDF document]
+% v0.1: 2012/11/01; v0.2: 2012/11/23; v0.3: 2012/12/01; v0.4: 2013/01/10
+\RequirePackage{eso-pic}
+\RequirePackage{ifpdf}
+\RequirePackage{ifxetex}
+\RequirePackage{xkeyval}
+
+\newif\ifocgtabular
+\DeclareOptionX[ocgp]{ocgtabular}{\ocgtabulartrue}
+\DeclareOptionX*{\PackageWarning{ocg-p}{Option unknown: \CurrentOption}}
+\ProcessOptionsX[ocgp]\relax
+
+\ifocgtabular
+ \RequirePackage{datatool}
+ \RequirePackage{tikz}
+ \RequirePackage{listings}
+\fi
+
+\newif\if@ocgp@ifps
+
+\ifpdf
+ \ifnum\pdftexversion<120
+ \PackageError{ocg-p}{%
+ pdfeTeX, version >= 1.20, required%
+ }{%
+ Install a newer version!%
+ }%
+ \fi
+\else
+ \ifxetex
+ %already ok
+ \else
+ % dvips
+ \@ocgp@ifpstrue
+ \PackageWarningNoLine{ocg-p}{%
+ Only XeLaTeX and pdfLaTeX are supported%
+ }%
+ \fi
+\fi
+
+\def\@ocgp@ocgHandle{\@auxout}
+\newif\if@ocgp@iffirstrun\@ocgp@iffirstruntrue
+
+\newif\if@ocgp@isnestedB\@ocgp@isnestedBfalse % nested OCG begin
+\newif\if@ocgp@isnestedE\@ocgp@isnestedEfalse % nested OCG end
+
+\def\@ocgp@nestedB{%
+ \xdef\@ocgp@ocgorderlist{\@ocgp@ocgorderlist\space[}
+}
+\def\@ocgp@nestedE{%
+ \xdef\@ocgp@ocgorderlist{\@ocgp@ocgorderlist\space]}
+}
+
+
+\providecommand\ocg[3]{} % if running with ocgtools
+\renewenvironment{ocg}[4][]{%
+ \if@ocgp@isnestedB% begin of nested ocg detected
+ \immediate\write\@ocgp@ocgHandle{%
+ \string\@ocgp@nestedB{}%
+ }
+ \fi
+ \global\@ocgp@isnestedBtrue % ocg begin
+ \global\@ocgp@isnestedEfalse % ocg end
+ \if@filesw%
+ \immediate\write\@ocgp@ocgHandle{%
+ \string\@ocgp@newocg{#2}{#3}{#4}{#1}%
+ }%
+ \fi
+ \gdef\@ocgp@curnum{#3}%
+ \ifpdf
+ \pdfliteral{/OC /OC\@ocgp@curnum\space BDC}%
+ \else
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ \special{ps: mark /_objdef {psocgobj\@ocgp@curnum} /type/stream /OBJ pdfmark}
+ \special{ps: mark {psocgobj\@ocgp@curnum} (/OC /OC\@ocgp@curnum\space BDC) /PUT pdfmark}
+ %\special{ps: mark /OC /OC\@ocgp@curnum\space /BDC pdfmark}%
+ \else
+ \special{pdf: content /OC /OC\@ocgp@curnum\space BDC}%
+ \fi
+ \fi
+ \message{/OC\@ocgp@curnum}%
+ \ignorespaces
+}{%
+ \ifpdf
+ \pdfliteral{EMC}%
+ \else
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ %\special{ps: mark /EMC pdfmark}%
+ \special{ps: mark {psocgobj\@ocgp@curnum} (EMC) /PUT pdfmark}
+ \else
+ \special{pdf: content EMC}%
+ \fi
+ \fi
+ \if@ocgp@isnestedE% end of nested ocg detected
+ \immediate\write\@ocgp@ocgHandle{%
+ \string\@ocgp@nestedE{}%
+ }
+ \fi
+ \global\@ocgp@isnestedEtrue % ocg end
+ \global\@ocgp@isnestedBfalse % ocg begin
+ \ignorespacesafterend
+}
+
+
+\def\@ocgp@ocglist{}
+\def\@ocgp@ocgofflist{}
+\def\@ocgp@ocgviewlist{} % to switch ocg off in layer toolbar of the viewer
+\gdef\@ocgp@ocgmaplist{}
+\def\@ocgp@ocgorderlist{} % ocgs in first-defined order + hierarchy
+
+\define@choicekey*[ocgp]{ocg}{printocg}[\@ocgp@printbin\@ocgp@printno]{always,never,ifvisible}[ifvisible]{%
+ \ifcase\@ocgp@printno\relax
+ \def\@ocgp@print{/Print<</PrintState /ON>>}%
+ \or%
+ \def\@ocgp@print{/Print<</PrintState /OFF>>}%
+ \or%
+ \def\@ocgp@print{}%
+ \fi%
+}
+\define@choicekey*[ocgp]{ocg}{exportocg}[\@ocgp@exportbin\@ocgp@exportno]{always,never,ifvisible}[ifvisible]{%
+ \ifcase\@ocgp@exportno\relax
+ \def\@ocgp@export{/Export<</ExportState /ON>>}%
+ \or%
+ \def\@ocgp@export{/Export<</ExportState /OFF>>}%
+ \or%
+ \def\@ocgp@export{}%
+ \fi%
+}
+\define@choicekey*[ocgp]{ocg}{listintoolbar}[\@ocgp@listbin\@ocgp@listno]{always,never,iffirstuse}[iffirstuse]{}
+
+\define@choicekey*[ocgp]{ocgaction}{triggerocg}[\@ocgp@actionbin\@ocgp@actionno]{onareaenter,onareaexit,onmousedown,onmouseup,allactions}[onmouseup]{%
+ \ifcase\@ocgp@actionno\relax
+ \def\@ocgp@trigger{/E}%
+ \or%
+ \def\@ocgp@trigger{/X}%
+ \or%
+ \def\@ocgp@trigger{/D}%
+ \or%
+ \def\@ocgp@trigger{/U}%
+ \or%
+ \def\@ocgp@trigger{}%
+ \fi%
+}
+
+\presetkeys[ocgp]{ocg}{printocg=ifvisible,exportocg=ifvisible,listintoolbar=iffirstuse}{}
+\presetkeys[ocgp]{ocgaction}{triggerocg=onmouseup}{}
+
+
+\newcount\@ocgp@num\@ocgp@num=0
+\newcount\@ocgp@tonum\@ocgp@tonum=0
+\newcount\@ocgp@sonum\@ocgp@sonum=0
+
+\def\@ocgp@newocg#1#2#3#4{% #1: OCG name, #2: OC id num, #3: visiblity on/off
+ \if@ocgp@iffirstrun
+ \expandafter\ifx\csname OCG#2\endcsname\relax
+ \expandafter\gdef\csname OCG#2\endcsname{#1}%
+ \global\advance\@ocgp@num by 1
+ \begingroup
+ \setkeys[ocgp]{ocg}{#4}
+ \ifpdf% PDFLATEX
+ \immediate\pdfobj{<< /Type /OCG /Name (#1) /Usage <<%
+ \@ocgp@print%
+ %/View<</ViewState /OFF>> %
+ \@ocgp@export%
+ >> >>}% new ocg
+ \xdef\@ocgp@curocg{\the\pdflastobj\space 0 R}% reference to current ocg id
+ \else
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ \xdef\@ocgp@curocg{{@ocg\the\@ocgp@num}}% reference to current ocg id
+ \special{ps: mark /_objdef \@ocgp@curocg /type/dict /OBJ pdfmark}
+ \special{ps: mark \@ocgp@curocg << /Type /OCG /Name (#1)
+ >> /PUT pdfmark}% new ocg
+ \else % XELATEX
+ \xdef\@ocgp@curocg{@ocg\the\@ocgp@num}% reference to current ocg id
+ \special{pdf:obj \@ocgp@curocg\space <</Type/OCG /Name (#1) /Usage <<
+ \@ocgp@print%
+ %/View<</ViewState /OFF>> %
+ \@ocgp@export%
+ >> >>}% new ocg
+ \fi
+ \fi
+
+ \expandafter\xdef\csname OCGpdfobj#2\endcsname{\@ocgp@curocg} % for ogcx-package
+ \xdef\@ocgp@ocglist{\@ocgp@ocglist\space\@ocgp@curocg}% list of all OCGs in "first defined" order
+ \ifnum\@ocgp@listno=1\else
+ \xdef\@ocgp@ocgorderlist{\@ocgp@ocgorderlist\space\@ocgp@curocg} % all OCGs in "first defined" order + hierarchy
+ \fi
+ \endgroup
+ \xdef\@ocgp@ocgmaplist{\@ocgp@ocgmaplist\space/OC#2\space\@ocgp@curocg\space ^^J} % name-to-id mapping
+ \ifnum#3=1 %on
+ % no list of all default-on OCGs needed, because of basestate on
+ \else%
+ \xdef\@ocgp@ocgofflist{\@ocgp@ocgofflist\space\@ocgp@curocg}% list of all default-off OCGs
+ \fi%
+ \else
+ \message{OCG#2 reopened}% layer reopened
+ \begingroup
+ \setkeys[ocgp]{ocg}{#4}
+ \ifnum\@ocgp@listno=0
+ \xdef\@ocgp@ocgobjlist{}%
+ \@ocgp@parseSpaceSeperatedList{#2}%
+ \xdef\@ocgp@ocgorderlist{\@ocgp@ocgorderlist\space\@ocgp@ocgobjlist}
+ \fi
+ \endgroup
+ \fi
+ \fi
+}
+
+
+\AtBeginDocument{% AtEndDocument{% changed because of xetex problem in beamer class
+ \@ocgp@iffirstrunfalse
+ %\message{... \@ocgp@ocgorderlist ...}
+ \ifpdf % PDFLATEX
+ \pdfcatalog{%
+ /OCProperties <<
+ /OCGs [\@ocgp@ocglist]
+ /D <</BaseState/ON /Order [\@ocgp@ocgorderlist] /OFF [\@ocgp@ocgofflist] /AS [%
+ <</Event/View /OCGs [\@ocgp@ocglist] /Category[/View]>>%
+ <</Event/Print /OCGs [\@ocgp@ocglist] /Category[/Print]>>%
+ <</Event/Export /OCGs [\@ocgp@ocglist] /Category[/Export]>>%
+ ]>>%
+ >>%
+ }
+ \else
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ \special{ps: mark {Catalog} <<
+ /OCProperties <<
+ /OCGs [\@ocgp@ocglist]
+ /D <</BaseState/ON /Order [\@ocgp@ocgorderlist] /OFF [\@ocgp@ocgofflist]>>
+ >>
+ >> /PUT pdfmark}%
+ \else % XELATEX
+ \special{pdf:put @catalog <<
+ /OCProperties <<
+ /OCGs [\@ocgp@ocglist]
+ /D <</BaseState/ON /Order [\@ocgp@ocgorderlist] /OFF [\@ocgp@ocgofflist] /AS [%
+ <</Event/View /OCGs [\@ocgp@ocglist] /Category[/View]>>%
+ <</Event/Print /OCGs [\@ocgp@ocglist] /Category[/Print]>>%
+ <</Event/Export /OCGs [\@ocgp@ocglist] /Category[/Export]>>%
+ ]>>%
+ >>%
+ >>}%
+ \fi
+ \fi
+}
+
+\AtBeginDocument{%
+ \ifpdf % PDFLATEX
+ \immediate\pdfobj{<<\@ocgp@ocgmaplist\space>>}%
+ \xdef\@ocgp@namesobj{\the\pdflastobj\space 0 R}%
+ % append to pageresources
+ \begingroup
+ \edef\x{\endgroup
+ \pdfpageresources{%
+ \the\pdfpageresources
+ /Properties \@ocgp@namesobj%
+ }%
+ }%
+ \x
+ \else
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ \AddToShipoutPicture{
+ \special{ps: mark /_objdef {Resources} /type/stream /OBJ pdfmark}
+ \special{ps: mark {Resources} << % it is something wrong here
+ % /Resources <<
+ /Properties << ^^J%
+ \@ocgp@ocgmaplist
+ %>>
+ >>
+ >> /PUT pdfmark}}%
+ \else % XELATEX
+ \AddToShipoutPicture{
+ \special{pdf: put @resources <<
+ /Properties << ^^J%
+ \@ocgp@ocgmaplist
+ >>
+ >>}}%
+ \fi
+ \fi
+}
+
+
+% parsing a space-delimited ocgid-list to a space-delimited list of ocg-objects
+\def\@ocgp@parseSpaceSeperatedList#1{\@ocgp@doparseSpaceSeperatedList#1 \relax}
+\def\@ocgp@doparseSpaceSeperatedList#1 #2{%
+ \ifcsname OCGpdfobj#1\endcsname%
+ \xdef\@ocgp@ocgobjlist{\@ocgp@ocgobjlist\space\csname OCGpdfobj#1\endcsname}%
+ \fi
+ \ifx#2\relax
+ %\@ocgp@ocgobjlist % only for debugging reasons
+ \else
+ \expandafter\@ocgp@doparseSpaceSeperatedList
+ \fi
+ #2%
+}
+
+%get the n-th element from a comma separated list
+\newcommand\@ocg@selectElementN[2]{%
+ \newcount\@ocgp@inum\@ocgp@inum=0%
+ \def\@ocgp@tempN{}%
+ \@for\@ocg@i:=#1\do{%
+ \advance\@ocgp@inum by 1\relax
+ \ifnum\@ocgp@inum=#2\relax
+ \edef\@ocgp@tempN{\@ocg@i}%
+ \fi
+ }%
+}
+
+% link to toggle layers in a document without using the layer toolbar of the viewer
+\newcommand\toggleocgs[3][]{%
+ \setocgs[#1]{#2}{}{}{#3}%
+}
+% link to show layers in a document without using the layer toolbar of the viewer
+\newcommand\showocgs[3][]{%
+ \setocgs[#1]{}{#2}{}{#3}%
+}
+% link to hide layers in a document without using the layer toolbar of the viewer
+\newcommand\hideocgs[3][]{%
+ \setocgs[#1]{}{}{#2}{#3}%
+}
+% link to set layers in a document without using the layer toolbar of the viewer
+\newcommand\setocgs[5][]{%
+ \begingroup
+ \setkeys[ocgp]{ocgaction}{#1}%
+ \newcount\@ocgp@aanum\@ocgp@aanum=0
+ \def\@ocgp@actionlist{}%
+ \loop\ifnum\@ocgp@aanum<4
+ \xdef\@ocgp@ocgobjlist{}%
+ \advance\@ocgp@aanum by 1\relax
+ \ifx\\#2\else%
+ \expandafter\@ocg@selectElementN\expandafter{#2}{\@ocgp@aanum}%
+ \ifx\@ocgp@tempN\@empty\else
+ \xdef\@ocgp@ocgobjlist{/Toggle }%
+ \expandafter\@ocgp@parseSpaceSeperatedList\expandafter{\@ocgp@tempN}%
+ \fi
+ \fi
+ \ifx\\#3\else%
+ \expandafter\@ocg@selectElementN\expandafter{#3}{\@ocgp@aanum}%
+ \ifx\@ocgp@tempN\@empty\else
+ \xdef\@ocgp@ocgobjlist{\@ocgp@ocgobjlist /ON }%
+ \expandafter\@ocgp@parseSpaceSeperatedList\expandafter{\@ocgp@tempN}%
+ \fi
+ \fi
+ \ifx\\#4\else%
+ \expandafter\@ocg@selectElementN\expandafter{#4}{\@ocgp@aanum}%
+ \ifx\@ocgp@tempN\@empty\else
+ \xdef\@ocgp@ocgobjlist{\@ocgp@ocgobjlist /OFF }%
+ \expandafter\@ocgp@parseSpaceSeperatedList\expandafter{\@ocgp@tempN}%
+ \fi
+ \fi
+ \ifnum\@ocgp@actionno<4\relax% only one action
+ \def\@ocgp@actionlist{\@ocgp@trigger << /S /SetOCGState /State [\@ocgp@ocgobjlist]>>}%
+ \advance\@ocgp@aanum by 10\relax
+ \else% allactions
+ \ifcase\@ocgp@aanum\relax\or%
+ \def\@ocgp@trigger{/E}%
+ \or%
+ \def\@ocgp@trigger{/X}%
+ \or%
+ \def\@ocgp@trigger{/D}%
+ \or%
+ \def\@ocgp@trigger{/U}%
+ \fi
+ \ifx\@ocgp@ocgobjlist\@empty\else
+ \edef\@ocgp@actionlist{\@ocgp@actionlist\space\@ocgp@trigger << /S /SetOCGState /State [\@ocgp@ocgobjlist]>> }%
+ \fi
+ \fi
+ \repeat
+ \global\advance\@ocgp@sonum by 1\relax
+ \leavevmode%
+ \ifpdf%
+ \pdfstartlink user {%
+ %/Subtype /Link
+ /Subtype /Widget
+ /FT/Btn /Ff 65536
+ /T(setocg\the\@ocgp@sonum)
+ /H/N %Highlightning Mode: N=No;I=Invert;O=Outline;P=Push
+ %/A <</S/SetOCGState /State [\@ocgp@ocgobjlist]>>
+ /AA <<
+ \@ocgp@actionlist
+ >>
+ %/Border [0 0 0]% no border
+ }%
+ #5\pdfendlink%
+ \else%
+ \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT
+ \special{ps: bann
+ << /Type /Annot
+ %/Subtype /Link
+ /Subtype /Widget
+ /FT/Btn/Ff 65536
+ /T(setocg\the\@ocgp@sonum)
+ /H/N
+ %/Border [0 0 0]% no border
+ %/A <</S/SetOCGState /State [\@ocgp@ocgobjlist]>>%
+ /AA <<
+ \@ocgp@actionlist
+ >>
+ >>}#5%
+ \special{ps:eann}%
+ \else% XELATEX
+ \special{pdf: bann
+ << /Type /Annot
+ %/Subtype /Link
+ /Subtype /Widget
+ /FT/Btn/Ff 65536
+ /T(setocg\the\@ocgp@sonum)
+ /H/N
+ %/Border [0 0 0]% no border
+ %/A <</S/SetOCGState /State [\@ocgp@ocgobjlist] >>%
+ /AA <<
+ \@ocgp@actionlist
+ >>
+ >>}#5%
+ \special{pdf:eann}%
+ \fi%
+ \fi%
+ \endgroup
+}
+
+
+
+% environment for a table which can be sorted by clicking on the header
+% IMPLEMENTATION NOT FINISHED (last argument for options)
+\ifocgtabular
+ \lst@RequireAspects{writefile}
+ \lstnewenvironment{ocgtabular}[4][]{
+ \lstset{aboveskip=0pt,belowskip=0pt}
+ \global\advance\@ocgp@tonum by 1\relax
+ \newcommand\setocgtabularheader[2]{%
+ \newcount\@ocgp@thnum\@ocgp@thnum=0%
+ \xdef\@ocgp@ocgobjtlist{}%
+ %\newcount\@ocgp@colindex%
+ \DTLgetcolumnindex{\@ocgp@colindex}{#3}{##1}%
+ \loop\ifnum\@ocgp@thnum<\DTLcolumncount{#3}%
+ \advance\@ocgp@thnum by 1\relax
+ \ifnum\@ocgp@thnum=\@ocgp@colindex\relax\else%
+ \edef\@ocgp@ocgobjtlist{\@ocgp@ocgobjtlist\space ocgtabular\the\@ocgp@tonum o\the\@ocgp@thnum}%
+ \fi%
+ \repeat%
+ \setocgs{}{ocgtabular\the\@ocgp@tonum o\@ocgp@colindex}{\@ocgp@ocgobjtlist}{##2}%
+ }
+ \newcount\@ocgp@tcnum\@ocgp@tcnum=0%
+ \setbox\@tempboxa\hbox\bgroup
+ \lst@BeginWriteFile{\jobname.oct}%
+ }{
+ \lst@EndWriteFile% closes output file
+ \egroup
+ %\vspace{-\baselineskip}%remove line from write-op
+ \begin{tikzpicture}
+ \loop\ifnum\@ocgp@tcnum<\DTLcolumncount{#3}
+ \advance\@ocgp@tcnum by 1\relax
+ \DTLgetkeyforcolumn{\@ocgp@theader}{#3}{\the\@ocgp@tcnum}
+ \message{+++ocgtabular\the\@ocgp@tonum o\the\@ocgp@tcnum +++}
+ \begin{ocg}[listintoolbar=never]{ocgtabular\the\@ocgp@tcnum}{ocgtabular\the\@ocgp@tonum o\the\@ocgp@tcnum}{\ifnum\@ocgp@tcnum=1 1\else 0\fi}
+ \node[] (ocgnode\the\@ocgp@tcnum) {
+ \DTLsort*{\@ocgp@theader}{#3}%
+ \begin{tabular}[#1]{#2}
+ \@@input\jobname.oct%
+ %\input{\jobname.oct}%problems with some commands
+ \end{tabular}
+ };
+ \end{ocg}
+ \repeat
+ \end{tikzpicture}
+ }
+\fi
+
+
+
diff --git a/macros/latex/contrib/ocg-p/ocg-p.tex b/macros/latex/contrib/ocg-p/ocg-p.tex
new file mode 100644
index 0000000000..7e482205ea
--- /dev/null
+++ b/macros/latex/contrib/ocg-p/ocg-p.tex
@@ -0,0 +1,630 @@
+% Copyright (C) 2012 by Werner Moshammer
+% This file may be distributed and/or modified under the LaTeX Project Public License
+
+%\documentclass[11pt]{article}
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage{tikz}
+\usetikzlibrary{arrows,automata}
+
+\usepackage{hyperref}
+\hypersetup
+{
+ pdfauthor={Di Werner Moshammer},
+ pdfsubject={The ocg-p package},
+ pdftitle={The ocg-p package},
+ pdfkeywords={LaTeX,OCG, Layers}
+}
+
+
+\usepackage{fancyvrb}
+%\usepackage{ocg-p}
+\usepackage{framed}
+
+\usepackage{datatool}
+\usepackage{booktabs}
+
+
+
+
+\usepackage{listings}
+%\usepackage{xcolor}
+
+\lstset{
+ language=[LaTeX]TeX,
+ basicstyle=\footnotesize\ttfamily,
+ upquote=true,
+ frame=single,
+ keywordstyle=\color{blue}\bfseries,
+ emphstyle=\color{blue}\bfseries,
+ backgroundcolor=\color{black!05},
+ fontadjust=true,
+ flexiblecolumns=true,
+ breaklines=true,
+ emph={ocg}
+}
+
+\newcommand{\TikZ}{Ti\emph{k}Z}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+
+\ifpdf
+\pdfinfo{
+/Author (DI Werner Moshammer)
+/Title (The ocg-p package)
+}
+\fi
+
+\title{The \pkg{ocg-p} package\thanks{This manual correspondends to \pkg{ocg-p} v0.4, dated 2013/01/10}}
+\author{DI Werner Moshammer\thanks{Contact me when you find mistakes in the manual: \mail{sendmail.werner@gmail.com}}}
+\date{2013/01/10}
+
+\begin{document}
+
+\maketitle
+
+\tableofcontents
+
+
+
+\begin{abstract}
+The \pkg{ocg-p} package provides the environment that allows to insert OCG (Optional Content Group) into PDF documents without JavaScript. These OCGs can be simply described as layers from the user's point of view.
+
+The \pkg{ocg-p} package is intended as a full replacement for the file |ocg.sty| which is part of the \pkg{asymptote} package. While |ocg.sty| is limited to be used with |pdfLaTeX|, the \pkg{ocg-p} package can also be used with |XeLaTeX|. Additionally nested OCGs (layers inside of another layer) are handled as such.
+
+\end{abstract}
+\newpage
+
+\section{Introduction}
+The \pkg{ocg-p} package provides the environment that allows to insert OCG (Optional Content Group) into PDF documents without JavaScript. These OCGs can be simply described as layers from the user's point of view.
+
+OCGs are part of the PDF specification since version 1.5 and are described in the \href{http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference15_v5.pdf}{PDF Reference} as:
+
+\begin{quote}
+Optional content (PDF 1.5) refers to sections of content in a PDF document that
+can be selectively viewed or hidden by document authors or consumers. This capability
+is useful in items such as CAD drawings, layered artwork, maps, and
+multi-language documents.
+\end{quote}
+
+OCGs are not part of the ISO standard 19005 |PDF/A-1|, but part of the newer |PDF/A-2| standard.
+
+The \pkg{ocg-p} package is intended as a full replacement for the file |ocg.sty| which is part of the \pkg{asymptote} package. While |ocg.sty| is limited to be used with |pdfLaTeX|, the \pkg{ocg-p} package can also be used with |XeLaTeX|. Additionally nested OCGs (layers inside of another layer) are handled as such.
+
+\section{Usage}
+Here is a quick summary of the usage of \pkg{ocg-p}. The package consists of one main environment to create layers and a few commands for buttons to change the visibility of the layers in some way.
+Based on the ocg main environment there is an additionally environment available to create tables, which can be sorted by clicking on the headers.
+
+\subsection{Download}
+This package is available on CTAN\footnote{The Comprehensive \TeX{} Archive Network \url{http://www.ctan.org/}}:
+\begin{description}
+\item[\href{ftp://ftp.ctan.org/tex-archive/macros/latex/contrib/ocg-p/ocg-p.sty}{\texttt{CTAN: macros/latex/contrib/ocg-p/ocg-p.sty}}] The source file.
+\item[\href{ftp://ftp.ctan.org/tex-archive/macros/latex/contrib/ocg-p/ocg-p.pdf}{\texttt{CTAN: macros/latex/contrib/ocg-p/ocg-p.pdf}}] Documentation.
+\end{description}
+
+\subsection{Package}
+Just load the package placing
+\begin{quote}
+ |\usepackage{ocg-p}|
+ \end{quote}
+in the preamble of your \LaTeX{} source file. %There are no options available at the moment.
+There is only one option available for the package, which can be used to offer an additional environment to create tables which can be sorted by clicking on the headers. In this case load the package with the following line:
+\begin{quote}
+ |\usepackage[ocgtabular]{ocg-p}|
+ \end{quote}
+
+Important: If packages are used, which use the original \pkg{ocg} package then \pkg{ocg-p} should be loaded after these packages. The |ocg| environment from the \pkg{ocg} package is replaced in this case.
+
+The \pkg{ocg} package is using the auxiliary file, so it is maybe necessary to compile your document 2 - 3 times until all layers are shown properly.
+
+%\subsection{Commands and Environments}
+\subsection{The ocg environment}
+%At the moment the \pkg{ocg-p} package has only one usable environment.
+This is the main environment of the \pkg{ocg-p} package.
+To create a OCG layer you have to use the |ocg| environment with three required arguments. Because it is intended as a replacement for the file |ocg.sty| this command can be used in the same way as it is used in |ocg.sty|.
+\begin{verbatim}
+\begin{ocg}{layer name}{layer id}{initial visibility}
+content ...
+\end{ocg}
+ \end{verbatim}
+The arguments are:
+ \begin{itemize}
+ \item \textit{layer name}:
+This name is shown in in the layer toolbar of the (PDF) viewer, where the visiblity of the layers can be changed.
+ \item \textit{layer id}:
+A unique id which is internally used by the OCG environment to reference the layer. Only letters and numbers are allowed
+ \item \textit{initial visibility}:
+Sets the initial visibility when the document is opend. Only 0 and 1 are allowed (0 for invisible, 1 for visible)
+ \item \textit{content}:
+The content of the layer itself.
+ \end{itemize}
+
+Beginning with \pkg{ocg-p} version 0.4 there are some optional options available to control the behaviour of the specified layer. Using this options the |ocg| environment is used the following way:
+\begin{verbatim}
+\begin{ocg}[opt1=val1, opt2=val2, ...]{layer name}{layer id}{initial visibility}
+content ...
+\end{ocg}
+ \end{verbatim}
+The options are given in a comma separated list of optionname value pairs.
+The usable options are:
+
+\begin{center}\begin{tabular}{lp{9cm}}\hline
+|printocg| & This option can be set to the values |always|, |never| and |ifvisible|. The default value is |ifvisible|. It specifies the visibility state of the content in this layer when the document is printed. |ifvisible| means that the layer is printed only if it is visible in the document. |always| means that it is printed always, independent from the current visiblity state in the document, and |never| means that is never printed.\\
+|exportocg| & This option can be set to the values |always|, |never| and |ifvisible|. The default value is |ifvisible|. It specifies the state for the content in this layer when the document is exported or saved to a format that does not support layers. |ifvisible| means that the layer is exported only if it is visible in the document. |always| means that it is exported always independent from the current visiblity state in the document, and |never| means that is never exported.\\
+|listintoolbar| & This option can be set to the values |always|, |never| and |iffirstuse|. The default value is |iffirstuse|. |iffirstuse| means that the layer is only displayed in the toolbar when it is first inserted. |always| means that it is displayed every time this layer is inserted again, and |never| means that the layer is never displayed in the toolbar. \\
+\hline
+\end{tabular}\end{center}
+
+These options can be combined. So if you want for example that a layer can never be displayed in the document but is visible on a printing then you choose |listintoolbar=never|, |printocg=always| and a initial visible of |0| (invisible).
+
+Important: Nested layers do not work with layers which are not visible in the layer toolbar of the browser.
+
+\subsection{The commands of the package}
+Beginning with \pkg{ocg-p} version 0.4 there are a few additional commands available. These commands can be used to add link actions (buttons) to the document, so that the visibility of some layers can be changed in some way.
+In all commands the |ocg|/|layer ids| should be given in a space separated list, and the last argument is for the link object itself.
+By default the link object is used by clicking with the mouse on it (mouseup event). But this behaviour can be changed by the optional options.
+
+The command |toggleocg| can be used to toggle the visible of the given layers i the document.
+\begin{verbatim}
+\toggleocgs[optional options]{tlayerid1 tlayerid2 ...}{display}
+ \end{verbatim}
+
+The command |showocgs| can be used to make the given layers visible in the document.
+\begin{verbatim}
+\showocgs[optional options]{slayerid1 slayerid2 ...}{display}
+ \end{verbatim}
+
+The command |hideocgs| can be used to make the given layers invisible in the document.
+\begin{verbatim}
+\hideocgs[optional options]{hlayerid1 hlayerid2 ...}{display}
+ \end{verbatim}
+
+The command |setocgs| is a combination of the former commands. With |setocgs| it is possible to toggle some layers given as first argument list, to make some layers visible which are given in the second argument list and to make some layers invisible given in the third argument list.
+
+\begin{verbatim}
+\setocgs[optional options]{tlayerid1 tlayerid2 ...}
+ {slayerid1 slayerid2 ...}{hlayerid1 hlayerid2 ...}{display}
+ \end{verbatim}
+
+There is one optional option availabe for all these commands, called |triggerocg|. These option can be set to the following values:
+\begin{center}\begin{tabular}{lp{9cm}}\hline
+|onareaenter| & Using this value the action is performed by entering the link area with the cursor (a mousover effect).\\
+|onareaexit| & Using this value the action is performed when the cursor exits the link area (a mouseout effect).\\
+|onmousedown| & Using this value the action is performed when the mouse button is pressed inside the link area (a mousedown effect).\\
+|onmouseup| & Using this value the action is performed when the mouse button isreleased inside the link area (a mouseup effect). |onmouseup| is the default value.\\
+|allactions| & When this option is used all four trigger events can be used with different ocgs at the same time. To do this four lists of layer ids have to be given in the arguments of the commands. While one ocg layer id list is given as a space separated list, these lists should be comma separated.\\
+& For example:\\
+& \verb+\toggleocgs[triggerocg=allactions]+\\ & \verb+ {aenid1 aenid2,aexid1,mdid1,muid1}[display}+ \\
+& The first list is for mouseover, the second for mouseout the third for mousedown and the last list for mouseup actions.\\
+& Another example where only mouseenter and mousedown actions are used:\\
+& \verb+\toggleocgs[triggerocg=allactions]+\\ & \verb+ {aenid1 aenid2,,mdid1 mdid2}+\\
+\hline
+\end{tabular}\end{center}
+
+Important: It is not possible to make an action area inside of another action layer.
+
+%The |ocg|/|layer ids| in all commands should be given in a space separated list. With |setocgs| it is possible to toggle some layers given as first argument list, to make some layers visible which are given in the second argument list and to make some layers invisible given in the third argument list. The last argument is for the link object itself. The commands |toggleocgs|, |showocgs| and |hideocgs| can be used in the same way, but they are used only for one of the actions.
+\newpage
+\subsection{The ocgtabular environment}
+The purpose of the |ocgtabular| environment is to create tables which can be sorted by clicking on the headers. This environment should also show how the main |ocg| environment can be used to create another environment which can be useful.
+
+To use the |ocgtabular| environmet the package option |ocgtabular| has to be used. In this way additional packages are imported which are necessary for this environment. The |ocgtabular| uses the original |tabular| package to create tables, where the data of the tables must be given in a database which is provided by the |datatool| package.
+
+\begin{verbatim}
+\begin{ocgtabular}[original tabular options]{original tabular argument}{ocgtabular options}
+{datatool database name}
+... original tabular/datatool code ...
+\end{ocgtabular}
+ \end{verbatim}
+
+So the only difference to the |tabular| environment are the last two arguments where in the first the name of the database is given. This database is used to sort the data. The last argument is for additional options, but there are no options available at the moment.
+
+For the header there is an addtional command available, but only inside of this environment.
+
+\begin{verbatim}
+\setocgtabularheader{columnname}{displayed header}
+ \end{verbatim}
+
+The |columnname| is the name of the column in the datatool database and |displayed header| is the text which is shown.
+
+ An example of this environment and its command is given in the following examples sections.
+
+\newpage
+\section{Examples}
+A few examples follow, showing the usage of this package.
+
+\subsection{Example 1: Three simple text layers}
+Here is a simple example with three layers with text content, where the second layer is set invisible when the document is opened. These commands are:
+
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{ocg-p}
+\begin{document}
+
+\begin{ocg}{First layer}{oc1}{1}
+ The first Layer is visible at start.
+\end{ocg}
+
+\begin{ocg}{Second layer}{oc2}{0}
+ The second layer is not visible at start.
+\end{ocg}
+
+\begin{ocg}{Third layer}{oc3}{1}
+ The third layer is visible at start.
+\end{ocg}
+
+This text is not inside of a layer and always visible.
+
+\end{document}
+\end{lstlisting}
+
+This will produce the following output, where the text in the second layer is invisible when the document is opend:
+\begin{framed}
+
+ The first Layer is visible at start.
+
+\makebox[1pt][l]{ }
+
+The third layer is visible at start.
+
+This text is not inside of a layer and always visible.
+
+\end{framed}
+
+The visiblity of the three layers can be changed with the layer toolbar of the viewer. If all layers are made invisible it looks like that:
+
+\begin{framed}
+
+\makebox[1pt][l]{ }
+
+\makebox[1pt][l]{ }
+
+\makebox[1pt][l]{ }
+
+\makebox[1pt][l]{ }
+
+This text is not inside of a layer and always visible.
+
+\end{framed}
+
+\newpage
+\subsection{Example 2: OGC and the \TikZ{} package}
+Using the \pkg{ocg-p} package with the \pkg{Ti\emph{k}Z} package is very valuable, because it is possible to show or hide some parts of the picture with the layer toolbar of the viewer. Here a first code example:
+
+\begin{lstlisting}
+\begin{tikzpicture}[node distance=3cm,every state/.style={fill=green!20},auto]
+\begin{ocg}{grid}{ocgridid}{1}
+ \draw[black!20] (-1,-1) grid (4,2);
+\end{ocg}
+
+\begin{ocg}{states}{ocstatesid}{1}
+ \node[state] (q_a) {$q_a$};
+ \node[state] (q_b) [right of=q_a] {$q_b$};
+\end{ocg}
+
+\begin{ocg}{edges}{ocedgesid}{1}
+ \path[->]
+ (q_a) edge node {0} (q_b)
+ edge [loop above] node {0} ()
+ (q_b) edge [loop above] node {1} ();
+\end{ocg}
+\end{tikzpicture}
+\end{lstlisting}
+
+When the document is opend the following is shown:
+
+\begin{framed}
+\begin{tikzpicture}[node distance=3cm,every state/.style={fill=green!20},auto]
+ \draw[black!20] (-1,-1) grid (4,2);
+ \node[state] (q_a) {$q_a$};
+ \node[state] (q_b) [right of=q_a] {$q_b$};
+ \path[->]
+ (q_a) edge node {0} (q_b)
+ edge [loop above] node {0} ()
+ (q_b) edge [loop above] node {1} ();
+\end{tikzpicture}
+\end{framed}
+
+But, for example, the edges could be made invisible with the layer toolbar:
+\begin{framed}
+\begin{tikzpicture}[node distance=3cm,every state/.style={fill=green!20},auto]
+ \draw[black!20] (-1,-1) grid (4,2);
+ \node[state] (q_a) {$q_a$};
+ \node[state] (q_b) [right of=q_a] {$q_b$};
+\end{tikzpicture}
+\end{framed}
+
+Or the grid could be made invisible:
+\begin{framed}
+\begin{tikzpicture}[node distance=3cm,every state/.style={fill=green!20},auto]
+ \draw[white!0] (-1,-1) grid (4,2);
+ \node[state] (q_a) {$q_a$};
+ \node[state] (q_b) [right of=q_a] {$q_b$};
+ \path[->]
+ (q_a) edge node {0} (q_b)
+ edge [loop above] node {0} ()
+ (q_b) edge [loop above] node {1} ();
+\end{tikzpicture}
+\end{framed}
+
+
+\subsection{Example 3: OGC and the \TikZ{} package again}
+These example should show how the layers can be used within text.
+\begin{lstlisting}
+The following text can be toggled:
+\begin{tikzpicture}[baseline=0]
+\tikzstyle{nome}=[anchor=base,outer sep=0,inner sep=0,minimum height=.45cm,minimum width=4.4cm]
+\begin{ocg}{blue text}{ocblueid}{1}
+ \node[nome,blue] (p1) {\parbox[b][][t]{4.4cm}{This text is written in blue.}};
+\end{ocg}
+\begin{ocg}{red text}{ocredid}{0}
+ \node[overlay,nome,red] (p2) {\parbox[b][][t]{4.4cm}{This text is written in red.}};
+\end{ocg}
+\end{tikzpicture}
+And now the text is black again.
+\end{lstlisting}
+
+With the layer toolbar of the viewer it is possible to activate or deactivate the two layers, so there are three possibilities how it can be seen:
+\begin{framed}
+\noindent The following text can be toggled: \parbox[b][][t]{4.4cm}{\textcolor{blue}{This text is written in blue.}} And now the text is black again.
+\end{framed}
+
+\begin{framed}
+\noindent The following text can be toggled: \parbox[b][][t]{4.4cm}{\textcolor{red}{This text is written in red.}} And now the text is black again.
+\end{framed}
+
+
+
+
+\begin{framed}
+\noindent The following text can be toggled:
+\begin{tikzpicture}[baseline=0]
+\tikzstyle{nome}=[anchor=base,outer sep=0,inner sep=0,minimum height=.45cm,minimum width=4.4cm]
+ \node[nome,blue] (p1) {\parbox[b][][t]{4.4cm}{This text is written in blue.}};
+ \node[overlay,nome,red] (p2) {\parbox[b][][t]{4.4cm}{This text is written in red.}};
+\end{tikzpicture}
+And now the text is black again.
+\end{framed}
+
+\newpage
+\subsection{Example 4: OGC and link actions (buttons)}
+Combining the \pkg{Ti\emph{k}Z} package with buttons to show, hide, toggle or set the layers adds much possibilities how this package can be used. Here is a way to show, how a table can be made, which can be sorted by clicking on the headers.
+
+\begin{lstlisting}
+\usepackage{ocg-p}
+\usepackage{tikz} % will be needed for this example
+\usepackage{datatool} % will be needed for this example
+\usepackage{booktabs} % will be needed for this example
+
+.
+.
+.
+
+% generate database with data for the table
+\DTLnewdb{sdata}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{John}
+\DTLnewdbentry{sdata}{Lastname}{Doe}
+\DTLnewdbentry{sdata}{Grade}{5}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Paul}
+\DTLnewdbentry{sdata}{Lastname}{Bauer}
+\DTLnewdbentry{sdata}{Grade}{1}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Peggy}
+\DTLnewdbentry{sdata}{Lastname}{Sue}
+\DTLnewdbentry{sdata}{Grade}{3}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Ever}
+\DTLnewdbentry{sdata}{Lastname}{Last}
+\DTLnewdbentry{sdata}{Grade}{4}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Werner}
+\DTLnewdbentry{sdata}{Lastname}{Moshammer}
+\DTLnewdbentry{sdata}{Grade}{1}
+
+This table can be sorted by clicking on the headers:
+
+\begin{tikzpicture}
+\begin{ocg}{First Name}{ocfirstid}{0}
+ \node[] (p1) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Firstname}{sdata}% sorted on the first name
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\begin{ocg}{First Name}{oclastid}{1}
+ \node[overlay] (p2) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Lastname}{sdata}% sorted on the last name
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\begin{ocg}{First Name}{ocgradeid}{0}
+ \node[overlay] (p3) {
+\begin{tabular}{llc}
+\toprule
+\bfseries \setocgs{}{ocfirstid}{oclastid ocgradeid}{First name}
+& \bfseries \setocgs{}{oclastid}{ocfirstid ocgradeid}{Last name}
+& \bfseries \setocgs{}{ocgradeid}{ocfirstid oclastid}{Grade}
+\DTLsort*{Grade}{sdata}% sorted on the grade
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+};
+\end{ocg}
+
+\end{tikzpicture}
+\end{lstlisting}
+
+\DTLnewdb{sdata}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{John}
+\DTLnewdbentry{sdata}{Lastname}{Doe}
+\DTLnewdbentry{sdata}{Grade}{5}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Paul}
+\DTLnewdbentry{sdata}{Lastname}{Bauer}
+\DTLnewdbentry{sdata}{Grade}{1}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Peggy}
+\DTLnewdbentry{sdata}{Lastname}{Sue}
+\DTLnewdbentry{sdata}{Grade}{3}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Ever}
+\DTLnewdbentry{sdata}{Lastname}{Last}
+\DTLnewdbentry{sdata}{Grade}{4}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Werner}
+\DTLnewdbentry{sdata}{Lastname}{Moshammer}
+\DTLnewdbentry{sdata}{Grade}{1}
+
+The output is the following table:
+
+\begin{framed}
+This table can be sorted by clicking on the headers:
+
+\begin{tabular}{llc}
+\toprule
+\bfseries First name & \bfseries Last name& \bfseries Grade
+\DTLsort*{Lastname}{sdata}% sorted on the Last name
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+\end{framed}
+
+By clicking on |Grade| in the header the table changes the sorting and looks then as follows:
+
+\begin{framed}
+This table can be sorted by clicking on the headers:
+
+\begin{tabular}{llc}
+\toprule
+\bfseries First name & \bfseries Last name& \bfseries Grade
+\DTLsort*{Grade}{sdata}% sorted on the grade
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule
+\end{tabular}
+\end{framed}
+
+\subsection{Example 5: The ocgtabular environment}
+This example does the same as the last but now by using the ocgtabular environment.
+
+\begin{lstlisting}
+\usepackage[ocgtabular]{ocg-p}
+\usepackage{datatool} % will be needed for this example
+\usepackage{booktabs} % will be needed for this example
+
+.
+.
+.
+
+% generate database with data for the table
+\DTLnewdb{sdata}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{John}
+\DTLnewdbentry{sdata}{Lastname}{Doe}
+\DTLnewdbentry{sdata}{Grade}{5}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Paul}
+\DTLnewdbentry{sdata}{Lastname}{Bauer}
+\DTLnewdbentry{sdata}{Grade}{1}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Peggy}
+\DTLnewdbentry{sdata}{Lastname}{Sue}
+\DTLnewdbentry{sdata}{Grade}{3}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Ever}
+\DTLnewdbentry{sdata}{Lastname}{Last}
+\DTLnewdbentry{sdata}{Grade}{4}
+\DTLnewrow{sdata}
+\DTLnewdbentry{sdata}{Firstname}{Werner}
+\DTLnewdbentry{sdata}{Lastname}{Moshammer}
+\DTLnewdbentry{sdata}{Grade}{1}
+
+This table can be sorted by clicking on the headers:
+
+\begin{ocgtabular}{llc}{sdata}{}
+\toprule%
+\bfseries \setocgtabularheader{Firstname}{First name}
+& \bfseries \setocgtabularheader{Lastname}{Last name}
+& \bfseries \setocgtabularheader{Grade}{Grade}
+\DTLforeach{sdata}{\first=Firstname, \last=Lastname,\grade=Grade}{%
+\DTLiffirstrow{\\ \midrule}{\\}
+\first & \last & \grade
+}
+\\ \bottomrule%
+\end{ocgtabular}
+
+\end{lstlisting}
+
+\section{Possible future developement}
+
+These ideas may appear in new versions of the \pkg{ocg-p} package:
+
+\begin{itemize}
+\item The package should work with dvips. There is still something wrong at the moment.
+%\item The |ocg| environment should accept options like |notprintable|, |alwaysprinted|, |notinlayertoolbar| (means that the visiblity is not changeable), |%notexportable|, |alwaysexported|.
+%So it is for example possible that a layer is not visible but is printed.
+%\item Commands for buttons which make all layers visible or invisible.
+\item The package should use |.dtx| instead of |.sty|.
+\item Radio Button Groups (/RBGroups) %/RBGroups [[ 11 0 R 13 0 R]] /ON[ 11 0 R] /OFF [13 0 R]
+\end{itemize}
+
+
+\section{Implementation}
+The implementation is rather standard. At first main switches are defined to distinguish between the possible drivers |pdfLaTeX|, |XeLaTeX| and |dvips| (not fully implemented yet). Then the environment is defined.
+
+
+\lstinputlisting[firstline=1, lastline=500]{ocg-p.sty}
+
+%\VerbatimInput[fontsize=\footnotesize,firstline=1,lastline=320]{ocg-p.sty}
+
+
+\section{Change history}
+
+ \begin{description}
+\item[0.1] Initial version, only usable with |XeLaTeX|, not based on the \pkg{ocg} package and therefore the arguments were a little bit different.
+
+\item[0.2] The \pkg{ocg-p} package was made compatible with the \pkg{ocg} package using the same environment name and arguments and using the |aux| file in the same way. Support for |pdfLaTeX| was added. First public version.
+
+\item[0.3] Fixed bug in |ocg| environment (missing \verb+\fi+). Fixed a bug if |XeLaTeX| is used. Nestes OCGs (layers inside another layer) are now handled as such.
+
+\item[0.4] Removed unnecessary \verb+\makeatletter+ and \verb+\makeatother+ commands, fixed an issue with the |beamer| class under |XeLaTeX| and other minor bugfixes. New options in the |ocg| environment. New commands for actions. New |ocgtabular| environment.
+
+\item[0.5] Planned: Not in a |.sty| file anymore, now using |.dtx|.
+
+\end{description}
+
+
+\end{document} \ No newline at end of file