summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-12-04 00:09:42 +0000
committerKarl Berry <karl@freefriends.org>2012-12-04 00:09:42 +0000
commit0067f7a621d852e3dd89d9364753704c41f649d3 (patch)
tree829ba836083152e23df5ae44b08f6ec667622233
parent58281f233aa382e37f0e840e29a978aa95cc3f85 (diff)
new latex package ocg-p (3dec12)
git-svn-id: svn://tug.org/texlive/trunk@28437 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/README28
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdfbin0 -> 44859 bytes
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.tex27
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdfbin0 -> 60489 bytes
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.tex36
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdfbin0 -> 44984 bytes
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.tex27
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdfbin0 -> 363104 bytes
-rw-r--r--Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex301
-rw-r--r--Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty270
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/ocg-p.tlpsrc0
13 files changed, 691 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/ocg-p/README b/Master/texmf-dist/doc/latex/ocg-p/README
new file mode 100644
index 00000000000..38c8ab57e59
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/README
@@ -0,0 +1,28 @@
+% ocg-p
+% %%%%%
+%
+% LaTeX package to use OCG (Optional Content Groups) within a PDF document.
+% 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
+%
+% license
+% %%%%%%%
+% Copyright (C) 2012 by Werner Moshammer
+%
+% This file may be distributed and/or modified under the LaTeX Project Public License.
+
diff --git a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdf b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdf
new file mode 100644
index 00000000000..bcbdb726c60
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.tex b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.tex
new file mode 100644
index 00000000000..ce361e0180d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdf b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdf
new file mode 100644
index 00000000000..fedb5b92efb
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.tex b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.tex
new file mode 100644
index 00000000000..b72835cdd2c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdf b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdf
new file mode 100644
index 00000000000..981bf453abc
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.tex b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.tex
new file mode 100644
index 00000000000..cab102fce2f
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.tex
@@ -0,0 +1,27 @@
+\documentclass[a4paper]{ltxdoc}
+
+\usepackage{ocg-p}
+\usepackage{tikz}
+\usetikzlibrary{arrows,automata}
+
+\newcommand*{\pkg}[1]{\textsf{#1}}
+
+\title{\pkg{OCG-P} package, example 3}
+
+\begin{document}
+
+\maketitle
+
+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{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf
new file mode 100644
index 00000000000..e5f42f5f9ab
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex
new file mode 100644
index 00000000000..c2fa9a9cdf8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex
@@ -0,0 +1,301 @@
+% 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}
+\usepackage{fancyvrb}
+%\usepackage{ocg-p}
+\usepackage{framed}
+
+
+
+
+\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}}}
+
+\title{The \pkg{ocg-p} package\thanks{This manual correspondends to \pkg{ocg-p} v0.3, dated 2012/12/01}}
+\author{DI Werner Moshammer\thanks{Contact me when you find mistakes in the manual: \mail{sendmail.werner@gmail.com}}}
+\date{2012/12/01}
+
+\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}
+
+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}.
+
+\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.
+
+Important: If packages are used, which use the original \pkg{ocg} package then the \pkg{ocg-p} should be loaded after these packages. The |ocg| environment from the \pkg{ocg} package is replaced in this case.
+
+\subsection{Commands and Environments}
+At the moment the \pkg{package} has only one usable environment. 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}
+
+
+
+\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.
+
+\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}
+
+
+\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}
+
+
+
+
+\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.
+\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.
+\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=320]{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 xetex, 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] Planned: Not in a |.sty| file anymore, now using |.dtx|.
+
+\end{description}
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty b/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty
new file mode 100644
index 00000000000..9354753ab0c
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty
@@ -0,0 +1,270 @@
+% 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.3}
+\ProvidesPackage{ocg-p}[2012/12/01 v\ocgpversion\space Optional Content Group in a PDF document]
+
+\RequirePackage{eso-pic}
+\RequirePackage{ifpdf}
+\RequirePackage{ifxetex}
+
+\DeclareOption*{}\ProcessOptions*\relax %allow anything as option for the moment
+
+
+\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@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 /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}%
+ \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
+
+% FUTURE PARAMETERS
+% notprintable -> PrintState=OFF
+% alwaysprinted -> Printstate=ON
+% notinlayertoolbar (visiblity not changeable) -> not listed in /Order
+% notexportable -> ExportState=OFF
+% alwaysexported -> Exportstate=ON
+% visible (same as bool-argument visible) -> ViewState=ON
+% not visible (same as bool-argument visible) -> ViewState=ON
+
+% ->
+% not visible AND alwaysprinted -> only on print
+
+\newcount\@ocgp@num\@ocgp@num=0
+
+\def\@ocgp@newocg#1#2#3#4{% #1: OCG name, #2: OC id num, #3: visiblity on/off
+ \expandafter\ifx\csname OCG#2\endcsname\relax
+ \expandafter\gdef\csname OCG#2\endcsname{#1}%
+ \global\advance\@ocgp@num by 1
+ \ifpdf% PDFLATEX
+ \immediate\pdfobj{<< /Type /OCG /Name (#1) /Usage <<%
+ %/Print<</PrintState /ON>> %
+ %/View<</ViewState /OFF>> %
+ % /Export<</ExportState /OFF>>%
+ >> >>}% 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 <<
+ %/Print<</PrintState /ON>> %
+ %/View<</ViewState /OFF>> %
+ %/Export<</ExportState /OFF>>%
+ >> >>}% 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
+ \xdef\@ocgp@ocgorderlist{\@ocgp@ocgorderlist\space\@ocgp@curocg} % all OCGs in "first defined" order + hierarchy
+ \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
+ % layer reopened
+ \fi
+}
+
+
+ \AtEndDocument{%
+ %\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 {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
+\makeatletter
+\def\@ocgp@parseSpaceSeperatedList#1{ \@ocgp@doparseSpaceSeperatedList#1 \@empty }
+\def\@ocgp@doparseSpaceSeperatedList#1 #2{%
+ \ifcsname OCGpdfobj#1\endcsname
+ \xdef\@ocgp@ocgobjlist{\@ocgp@ocgobjlist\space\csname OCGpdfobj#1\endcsname}
+ \fi
+ \ifx #2\@empty
+ %\@ocgp@ocgobjlist % only for debugging reasons
+ \else
+ \expandafter\@ocgp@doparseSpaceSeperatedList
+ \fi
+ #2%
+}
+\makeatother
+
+% link to toggle a layer in a document without using the layer toolbar of the viewer
+\makeatletter
+\long\def\toggleocg#1#2{%
+ \xdef\@ocgp@ocgobjlist{}%
+ \@ocgp@parseSpaceSeperatedList{#1}
+ \leavevmode%
+ \ifpdf
+ \pdfstartlink user {%
+ /Subtype /Link
+ /A << /S/SetOCGState /State [/Toggle \@ocgp@ocgobjlist] >>
+ %/A << /Type /Action /S /GoTo /D [1 0 R] >>
+ /Border [0 0 0]% no border
+ }%
+ #2\pdfendlink%
+ \else
+ \special{pdf: bann
+ << /Type /Annot
+ /Subtype /Link
+ /Border [0 0 0]% no border
+ /A <</S/SetOCGState /State [/Toggle \@ocgp@ocgobjlist] >>%
+ >>}#2%
+ \special{pdf:eann}%
+ \fi
+}
+\makeatother
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index f900a075e7e..f84eeeeae2a 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -301,7 +301,7 @@ my @TLP_working = qw(
nomencl nomentbl nonfloat nonumonpart nopageno nostarch notes
notes2bib notoccite nowidow
nrc ntgclass ntheorem ntheorem-vn nuc numericplots numname numprint
- oberdiek objectz ocgx ocherokee ocr-b ocr-b-outline ocr-latex octavo
+ oberdiek objectz ocg-p ocgx ocherokee ocr-b ocr-b-outline ocr-latex octavo
odsfile ofs
ogham oldlatin oldstandard oldstyle
onlyamsmath onrannual opcit opensans opteng optional
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index 6746e3348b9..702bf8d55f2 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -539,6 +539,7 @@ depend nowidow
depend ntheorem
depend numname
depend numprint
+depend ocg-p
depend ocgx
depend ocr-latex
depend octavo
diff --git a/Master/tlpkg/tlpsrc/ocg-p.tlpsrc b/Master/tlpkg/tlpsrc/ocg-p.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/ocg-p.tlpsrc