summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ocgx
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/ocgx
Initial commit
Diffstat (limited to 'macros/latex/contrib/ocgx')
-rw-r--r--macros/latex/contrib/ocgx/README17
-rw-r--r--macros/latex/contrib/ocgx/demo-ocgx.pdfbin0 -> 693034 bytes
-rw-r--r--macros/latex/contrib/ocgx/demo-ocgx.tex460
-rw-r--r--macros/latex/contrib/ocgx/ocgx-example-1.tex9
-rw-r--r--macros/latex/contrib/ocgx/ocgx-manual-en.pdfbin0 -> 334928 bytes
-rw-r--r--macros/latex/contrib/ocgx/ocgx-manual-en.tex430
-rw-r--r--macros/latex/contrib/ocgx/ocgx.sty111
-rw-r--r--macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex121
8 files changed, 1148 insertions, 0 deletions
diff --git a/macros/latex/contrib/ocgx/README b/macros/latex/contrib/ocgx/README
new file mode 100644
index 0000000000..6930d37028
--- /dev/null
+++ b/macros/latex/contrib/ocgx/README
@@ -0,0 +1,17 @@
+ocgx
+====
+
+LaTeX package to use OCG (Optional Content Groups) within a PDF document without JavaScript.
+
+
+license
+=======
+
+Copyright (C) 2012 by Paul Gaborit
+
+This file may be distributed and/or modified
+
+ 1. under the LaTeX Project Public License and/or
+
+ 2. under the GNU Public License.
+
diff --git a/macros/latex/contrib/ocgx/demo-ocgx.pdf b/macros/latex/contrib/ocgx/demo-ocgx.pdf
new file mode 100644
index 0000000000..d435dbebb5
--- /dev/null
+++ b/macros/latex/contrib/ocgx/demo-ocgx.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocgx/demo-ocgx.tex b/macros/latex/contrib/ocgx/demo-ocgx.tex
new file mode 100644
index 0000000000..87fcf46551
--- /dev/null
+++ b/macros/latex/contrib/ocgx/demo-ocgx.tex
@@ -0,0 +1,460 @@
+% Copyright (C) 2012 by Paul Gaborit
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+
+\documentclass[11pt,hyperref={colorlinks=false,runcolor=blue}]{beamer}
+%\usetheme{Warsaw}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{tikz}
+\usetikzlibrary{backgrounds,fit,calc,shadows,chains,ocgx,shapes.geometric}
+\usepackage{microtype}
+\usepackage{url}
+\usepackage{fancyvrb}
+\usepackage{listings}
+\lstdefinestyle{TeXcode}{
+ fancyvrb=true,
+ language=[LaTeX]TeX,
+ basicstyle=\scriptsize\ttfamily,
+ keywordstyle=\color{blue}\bfseries,
+ commentstyle=\color{red!50!black}\itshape,
+ stringstyle=\ttfamily\color{green!50!black},
+ showspaces=false,
+ showstringspaces=false,
+ backgroundcolor=\color{white},
+ fontadjust=true,
+ aboveskip=1ex,
+ belowskip=1ex,
+ emphstyle=\color{blue}\bfseries,
+ keepspaces=true,
+ flexiblecolumns=true,
+ emph={switchocg,showocg,hideocg,actionsocg,usetikzlibrary}
+}
+\newcommand\TkzTileWallPaper[3]{
+ \pgfmathtruncatemacro{\nx}{\paperwidth/#1}
+ \foreach \dx in {0,...,\nx}{
+ \pgfmathtruncatemacro{\ny}{\paperheight/#2}
+ \foreach \dy in {0,...,\ny}{
+ \node[anchor=south west,inner sep=0pt]
+ at ([xshift=#1 * \dx,yshift=#2 * \dy]current page.south west)
+ {\includegraphics[width=#1,height=#2]{#3}};
+ }
+ }
+}
+
+\setbeamersize{text margin left=3mm,text margin right=3mm}
+
+\newcommand\latex{{\rmfamily\LaTeX}}
+
+\newcommand{\TikZ}{Ti\emph{k}Z}
+
+\begin{document}
+\begin{frame}[fragile]
+ \frametitle{\latex{}, OCG \& \TikZ{} (without JavaScript): \texttt{ocgx} package}
+ \framesubtitle{by Paul \textsc{Gaborit} wiht help of Paul
+ \textsc{Isambert}}
+
+ \begin{alertblock}{PDF readers}
+ To fully enjoy this demonstration, use \emph{Adobe Reader},
+ \emph{Foxit Reader} or \emph{evince}!
+ \end{alertblock}
+
+ \begin{columns}
+
+ \column{.6\linewidth}
+
+ \begin{block}{Simple example: code}
+ \begin{lstlisting}[style=TeXcode]
+\begin{ocg}{My first OCG}{refmyfirstocg}{1}
+ Some content...
+\end{ocg}
+
+\switchocg{refmyfirstocg}%
+{\textcolor{red}{Click me!}}
+\end{lstlisting}
+ \end{block}
+
+ \column{.4\linewidth}
+
+ \begin{block}{Simple example: result}
+
+ \begin{ocg}{My first OCG}{refmyfirstocg}{1}
+ Some content...
+ \end{ocg}
+
+ \switchocg{refmyfirstocg}%
+ {\textcolor{red}{Click me!}}
+
+ \end{block}
+ \end{columns}
+
+\end{frame}
+
+\begin{frame}
+ \frametitle{First example with Ti\emph{k}Z}
+
+ {\centering
+ \begin{tikzpicture}[font=\small]
+ \begin{scope}[ocg={ref=toto,status=visible,name=ok}]
+ \fill[orange] circle(10pt);
+ \node[draw,rounded corners,hide ocg=toto] at (0,-1) {Hide};
+ \node[draw,rounded corners,switch ocg=toto] at (2,-1) {Switch};
+ \end{scope}
+ \node[show ocg=toto,text=red] at (0,-2) {Show};
+ \end{tikzpicture}\par}
+
+ \begin{itemize}
+ \item \switchocg{toto}{\Large \textcolor{red}{A very long phrase to
+ show that a link can be on multiple lines\ldots}\par\textcolor{red}{And with two
+ paragraphs!}}
+ \item The ``Switch'' button is \textbf{always} useable!
+ \end{itemize}
+\end{frame}
+
+\tikzset{%
+ button on/.style={%
+ draw,circle,drop shadow,
+ line width=1pt,
+ fill=lime!50,
+ switch ocg with mark on={#1}{},
+ },
+}
+\begin{frame}
+ \frametitle{An ordered stack}
+
+ \centering
+ \begin{tikzpicture}
+ \foreach \col[count=\c] in {red,orange,yellow,lime,cyan,blue,violet}{
+ \pgfmathtruncatemacro{\num}{mod(\c+1,2)+1}
+ \pgfmathsetmacro{\rad}{8-\c}
+ \begin{scope}[xshift=-.3*\c cm,ocg={name=s\num,ref=s\num}]
+ \node[ellipse,draw,line width=1pt,
+ minimum width=1.1*\rad cm,minimum height=.9*\rad cm,
+ fill=\col!70,drop shadow={fill=black}](t){};
+ \node[left=3pt of t.east,fill=white,
+ fill opacity=.5,text opacity=1,circle,inner sep=0pt]{S\num};
+ \end{scope}
+ }
+ \end{tikzpicture}
+
+ \begin{tikzpicture}
+ \node[button on=s1](but){};
+ \node[right=0 of but]{Switch S1};
+ \node[below=3pt of but,button on=s2](but){};
+ \node[right=0 of but]{Switch S2};
+ \end{tikzpicture}
+
+\end{frame}
+
+\begin{frame}
+ \frametitle{RGB and CMY color models with \texttt{xcolor}}
+
+ \def\mylist{red/0,yellow/60,green/120,cyan/180,blue/240,magenta/300}
+ \centering\begin{tikzpicture}[line width=1pt]
+ \begin{scope}
+ \node at (90:25mm) {RGB color};
+ \foreach \col/\angle in \mylist {
+ \colorlet{rgb \col}[rgb]{\col}
+ \draw (\angle:5mm) circle [radius=10mm];
+ \begin{scope}[on background layer]
+ \begin{scope}[ocg={ref=RGB\col,name=RGB \col}]
+ \fill[fill=rgb \col,fill opacity=.5]
+ (\angle:5mm) circle [radius=10mm];
+ \end{scope}
+ \end{scope}
+
+ \node[rounded corners=1mm,draw,line width=1pt,
+ minimum size=3mm,fill=rgb \col,fill opacity=.5,
+ drop shadow,
+ inner sep=0,inner xsep=0,
+ switch ocg with mark on={RGB\col}{}]
+ at (\angle:20mm){};
+ }
+ \end{scope}
+ \begin{scope}[xshift=70mm]
+ \node at (90:25mm) {CMY color};
+ \foreach \col/\angle in \mylist {
+ \colorlet{cmy \col}[cmyk]{\col}
+ \draw (\angle:5mm) circle [radius=10mm];
+ \begin{scope}[on background layer]
+ \begin{scope}[ocg={ref=CMY\col,name=CMY \col}]
+ \fill[fill=cmy \col,fill opacity=.5]
+ (\angle:5mm) circle [radius=10mm];
+ \end{scope}
+ \end{scope}
+
+ \node[rounded corners=1mm,draw,line width=1pt,
+ minimum size=3mm,fill=cmy \col,fill opacity=.5,
+ drop shadow,inner sep=0,outer sep=0,
+ switch ocg with mark on={CMY\col}{}]
+ at (\angle:20mm){};
+ }
+ \end{scope}
+
+ \begin{scope}%
+ [xshift=35mm,start chain=going below,node distance=.5mm,font=\tiny]
+ \node[on chain] at (0,20mm) {Toogle groups};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ switch ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
+ ]
+ {red, green, blue};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ switch ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
+ ]
+ {cyan, magenta, yellow};
+
+ \node[on chain] {Show groups};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ show ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
+ ]
+ {red, green, blue};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ show ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
+ ]
+ {cyan, magenta, yellow};
+
+ \node[on chain] {Hide groups};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ hide ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
+ ]
+ {red, green, blue};
+ \node%
+ [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
+ minimum size=3mm,inner sep=1mm,
+ hide ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
+ ]
+ {cyan, magenta, yellow};
+ \end{scope}
+
+ \end{tikzpicture}\par
+
+\end{frame}
+
+\foreach \name/\link/\ltxlink/\tiles in {%
+ The Big Show/%
+ {http://designfestival.com/the-cicada-principle-and-why-it-matters-to-web-designers/}/%
+ {http://latex-community.org/know-how/433-tiled-backgrounds}/%
+ {%
+ curtain1/32.7pt/\paperheight,%
+ curtain2/90pt/\paperheight,%
+ curtain3/210.9pt/\paperheight%
+ },%
+ Mosaic/%
+ {http://designfestival.com/cicada/break-it-down/?id=95}/%
+ {http://latex-community.org/know-how/433-tiled-backgrounds}/%
+ {%
+ mosaic1/30pt/30pt,%
+ mosaic2/70pt/70pt,%
+ mosaic3/110pt/110pt,%
+ mosaic4/110pt/110pt%
+ }%
+}{
+ \begin{frame}
+ \begin{tikzpicture}[remember picture,overlay]
+ \foreach \pictname/\wid/\hei in \tiles {
+ \begin{scope}[ocg={name=\pictname,ref=\pictname}]
+ \TkzTileWallPaper{\wid}{\hei}{\pictname}
+ \end{scope}
+ }
+
+ \end{tikzpicture}
+
+ \centering\begin{tikzpicture}[start chain=going below,node distance=1em]
+ \node[fill=white,fill opacity=.75,align=center,
+ text=black,font=\tiny\bfseries,text opacity=1,
+ on chain,
+ rounded corners=2mm]
+ {{\huge\name}\\\url{\link}\\(\latex{} \url{\ltxlink})};
+
+ \foreach \pictname/\wid/\hei in \tiles {
+
+ \node[on chain,text=white,fill=black,fill opacity=.5,text opacity=1,
+ text width=3cm,align=center,font=\bfseries]
+ (a) {\hspace{5mm}\pictname};
+
+ \node[rounded corners=1mm,draw,line width=1pt,%
+ minimum size=3mm,top color=white,bottom color=black,
+ fill opacity=.5,
+ drop shadow={fill=black},
+ switch ocg with mark on={\pictname}{}]
+ at ([xshift=3mm,yshift=.5mm]a.west) {};
+
+ }
+ \end{tikzpicture}\par
+ \end{frame}
+}
+
+\begin{frame}
+ \frametitle{Microtype demo (first version without hierarchy)}
+
+ \def\sampletext{%
+ Margin kerning is the adjustments of the characters at the
+ margins of a typeset text. A simplified employment of margin
+ kerning is hanging punctuation. Margin kerning is needed for
+ optical alignment of the margins of a typeset text, because
+ mechanical justification of the margins makes them look rather
+ ragged. Some characters can make a line appear shorter to the
+ human eye than others. Shifting such characters by an
+ appropriate amount into the margins would greatly improve the
+ appearance of a typeset text.%
+ }
+
+ \tikzset{
+ checkbox/.style={
+ draw,circle,line width=.5pt,%
+ minimum size=.5em,top color=white,bottom color=cyan,
+ fill opacity=1,
+ inner sep=0,
+ drop shadow={fill=black,shadow xshift=.5mm,shadow yshift=-.5mm},
+ },
+ sampletext/.style={
+ text width=8cm,align=justify,
+ font=\small,
+ fill=yellow!20,
+ inner xsep=1.5cm,
+ inner ysep=1cm,
+ draw=gray,
+ },
+ }
+
+ {\centering
+ \begin{tikzpicture}
+ \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
+ \end{scope}
+ \begin{scope}[ocg={name=Without Protrusion,ref=no-protrusion,status=invisible}]
+ \end{scope}
+ \begin{scope}[ocg={name=With Expansion,ref=expansion}]
+ \end{scope}
+ \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
+ \end{scope}
+ \begin{scope}[ocg={name=Without Expansion,ref=no-expansion,status=invisible}]
+ \end{scope}
+ \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
+ \microtypesetup{protrusion=true}%
+ \begin{scope}[ocg={name=With Expansion,ref=expansion}]
+ \microtypesetup{expansion=true}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-expansion}]
+ \microtypesetup{expansion=false}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Protrusion,status=invisible,ref=no-protrusion}]
+ \microtypesetup{protrusion=false}%
+ \begin{scope}[ocg={name=With Expansion,ref=expansion}]
+ \microtypesetup{expansion=true}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-expansion}]
+ \microtypesetup{expansion=false}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+ \end{scope}
+ \end{tikzpicture}\par
+ }
+
+ Microtype :
+ \begin{tikzpicture}
+ \node[checkbox,switch ocg with mark on={protrusion}{no-protrusion}]{};
+ \end{tikzpicture} with protrusion
+ \begin{tikzpicture}
+ \node[checkbox,switch ocg with mark on={expansion}{no-expansion}]{};
+ \end{tikzpicture} with expansion
+
+\end{frame}
+
+\begin{frame}
+ \frametitle{Microtype demo (second version with hierarchy)}
+
+ \def\sampletext{%
+ Margin kerning is the adjustments of the characters at the
+ margins of a typeset text. A simplified employment of margin
+ kerning is hanging punctuation. Margin kerning is needed for
+ optical alignment of the margins of a typeset text, because
+ mechanical justification of the margins makes them look rather
+ ragged. Some characters can make a line appear shorter to the
+ human eye than others. Shifting such characters by an
+ appropriate amount into the margins would greatly improve the
+ appearance of a typeset text.%
+ }
+
+ \tikzset{
+ checkbox/.style={
+ draw,circle,line width=.5pt,%
+ minimum size=.5em,top color=white,bottom color=cyan,
+ fill opacity=1,
+ inner sep=0,
+ drop shadow={fill=black,shadow xshift=.5mm,shadow yshift=-.5mm},
+ },
+ sampletext/.style={
+ text width=8cm,align=justify,
+ font=\small,
+ fill=yellow!20,
+ inner xsep=1.5cm,
+ inner ysep=1cm,
+ draw=gray,
+ },
+ }
+
+ {\centering
+ \begin{tikzpicture}
+ \begin{scope}[ocg={name=With Protrusion,ref=pro}]
+ \microtypesetup{protrusion=true}%
+ \begin{scope}[ocg={name=With Expansion,status=visible,ref=pro-exp}]
+ \microtypesetup{expansion=true}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=pro-no-exp}]
+ \microtypesetup{expansion=false}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Protrusion,status=invisible,ref=no-pro}]
+ \microtypesetup{protrusion=false}%
+ \begin{scope}[ocg={name=With Expansion,status=visible,ref=no-pro-exp}]
+ \microtypesetup{expansion=true}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+
+ \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-pro-no-exp}]
+ \microtypesetup{expansion=false}%
+ \node[sampletext]{\sampletext\par};%
+ \end{scope}
+ \end{scope}
+ \end{tikzpicture}\par
+ }
+
+ Microtype :
+ \begin{tikzpicture}
+ \node[checkbox,switch ocg with mark on={pro}{no-pro}]{};
+ \end{tikzpicture} with protrusion
+ \begin{tikzpicture}
+ \node[checkbox,switch ocg with mark on={pro-exp}{pro-no-exp no-pro-exp no-pro-no-exp}]{};
+ \end{tikzpicture} with expansion
+
+\end{frame}
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/ocgx/ocgx-example-1.tex b/macros/latex/contrib/ocgx/ocgx-example-1.tex
new file mode 100644
index 0000000000..37808b7483
--- /dev/null
+++ b/macros/latex/contrib/ocgx/ocgx-example-1.tex
@@ -0,0 +1,9 @@
+\documentclass{article}
+\usepackage{ocgx}
+\begin{document}
+\begin{ocg}{OCG 1}{ocg1}{1}
+ first example.
+\end{ocg}
+
+\switchocg{ocg1}{Button.}
+\end{document}
diff --git a/macros/latex/contrib/ocgx/ocgx-manual-en.pdf b/macros/latex/contrib/ocgx/ocgx-manual-en.pdf
new file mode 100644
index 0000000000..9721097d06
--- /dev/null
+++ b/macros/latex/contrib/ocgx/ocgx-manual-en.pdf
Binary files differ
diff --git a/macros/latex/contrib/ocgx/ocgx-manual-en.tex b/macros/latex/contrib/ocgx/ocgx-manual-en.tex
new file mode 100644
index 0000000000..c790c312b3
--- /dev/null
+++ b/macros/latex/contrib/ocgx/ocgx-manual-en.tex
@@ -0,0 +1,430 @@
+% Copyright (C) 2012 by Paul Gaborit
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+
+\documentclass[a4paper]{ltxdoc}
+\usepackage[vmargin=2cm,hmargin=3.5cm,nohead]{geometry}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{xcolor}
+\usepackage{ifthen}
+\usepackage{doc}
+\usepackage{fancyvrb}
+\usepackage{newverbs}
+\usepackage{listings}
+\lstdefinestyle{TeXcode}{
+ fancyvrb=true,
+ language=[LaTeX]TeX,
+ basicstyle=\ttfamily,
+ upquote=true,
+ keywordstyle=\color{blue}\bfseries,
+ commentstyle=\color{red!50!black}\itshape,
+ stringstyle=\ttfamily\color{green!50!black},
+ showspaces=false,
+ showstringspaces=false,
+ backgroundcolor=\color{blue!10},
+ fontadjust=true,
+ aboveskip=1ex,
+ belowskip=1ex,
+ emphstyle=\color{blue}\bfseries,
+ keepspaces=true,
+ flexiblecolumns=true,
+ emph={switchocg,showocg,hideocg,actionsocg,usetikzlibrary,node}
+}
+\makeatletter
+\newenvironment{prog}[1]{\vspace{1ex}--- \texttt{\emph{#1}} ---}{}
+\newenvironment{ocgXample}[1]{% name
+ \gdef\ocgXample@filename{#1}%
+ \@tempswafalse\filec@ntents{#1}%
+}
+{\endfilecontents\aftergroup\showocgXample}
+\newcommand\showocgXample{
+ \minipage{1.0\linewidth}%
+ \prog{\ocgXample@filename}
+ \lstinputlisting[style=TeXcode,aboveskip=0ex]\ocgXample@filename%
+ \endprog
+ \endminipage
+}
+
+\newcommand{\TeXexample}[3][]{%
+ \begin{minipage}{1.0\linewidth}
+ \ifthenelse{\equal{#1}{}}{\begin{prog}{#2}}{\begin{prog}{#2 (#1)}}%
+ \lstinputlisting[style=TeXcode,aboveskip=0ex,#3]{#2}%
+ \end{prog}
+ \end{minipage}\par
+}
+\makeatother
+
+\usepackage{url}
+\usepackage[colorlinks]{hyperref}
+\usepackage[english]{babel}
+\usepackage[babel]{microtype}
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{.4\baselineskip plus .5\baselineskip minus .2\baselineskip}
+\usepackage{tikz}
+\usetikzlibrary{shadows}
+\usepackage[all]{nowidow}
+\usepackage{ocgx}
+\usepackage{filecontents}
+
+\newcounter{mynotes}
+\newenvironment{note}{%
+ \vspace{5pt}
+ \tikzpicture
+ \node[%draw=black,line width=.1pt,
+ rounded corners=1em,
+ inner xsep=1.3em, inner ysep=.8em,
+ text width=\linewidth-2.6em-\pgflinewidth,
+ align=justify,
+ draw=cyan!50!black,
+ fill=white,
+ fill=yellow!20,
+ line width=1pt,
+ drop shadow={fill=cyan!50!black},
+ ] (note) \bgroup%
+}{%
+ \egroup;
+ \node[circle,overlay,
+ %fill=white,draw=cyan!50!black,
+ draw=white,fill=cyan!50!black,text=white,
+ line width=2pt,
+ drop shadow={fill=cyan!50!black},
+ font=\small\bfseries,inner sep=4pt]
+ at (note.north west){\stepcounter{mynotes}\arabic{mynotes}};
+ \endtikzpicture\par\vspace{.1em}%
+}
+
+
+\newverbcommand\code{\color{red}}{}
+\newverbcommand\style{\hspace{-2em}\color{red}}{}
+\newcommand\defaultvalue[1]{\hfill(#1)}
+\newcommand\argument[1]{\textcolor{black}{\ttfamily #1}}
+\newcommand\TikZ{Ti\emph{k}Z}
+
+\title{The \texttt{ocgx} package (version \ocgxversion)}
+\author{%
+ Paul \textsc{Isambert}
+ \and%
+ Paul \textsc{Gaborit}\\\url{paul.gaborit@gmail.com}}
+\date{\today}
+
+\begin{document}
+\maketitle
+
+\tableofcontents
+
+\section*{Abstract}
+
+The \code+ocgx+ package extends the \code+ocg-p+ package which allows
+you to create OCGs (\emph{Optional Content Group}) in PDF documents.
+
+Every OCG includes \TeX{} material into a layer of the PDF file. Each of
+these layers can be displayed or not. Links can enable or disable the
+display of OCGs.
+
+The \code+ocgx+ package does not use Javascript embedded in the PDF
+document to enable (to show) or disable (to hide) OCGs.
+
+\begin{note}
+ OCGs are usable with several PDF readers: to date, it has been
+ successfully tested with \emph{Acrobat Reader}, \emph{Foxit Reader},
+ \emph{PDF-XChange-Viewer}, and \emph{Evince}. The management of OGCs
+ by \emph{Evince} is not yet fully debugged: it still sometimes crash!
+\end{note}
+
+\section{Usage}
+
+Here is a simple example.
+
+\begin{ocgXample}{ocgx-example-1.tex}
+\documentclass{article}
+\usepackage{ocgx}
+\begin{document}
+\begin{ocg}{OCG 1}{ocg1}{1}
+ first example.
+\end{ocg}
+
+\switchocg{ocg1}{Button.}
+\end{document}
+\end{ocgXample}
+
+This document creates an OCG called \emph{ocg1} containing the text
+``\emph{first example.}'' which is visible. You can show or hide this
+OCG by clicking the link ``\emph{Button.}''.
+
+\subsection{Create OCGs}
+
+The following code creates an OCG named \emph{OCG name} with
+\emph{refocg} as internal reference. The content of this OCG is
+``\emph{content...}''. This OCG is visible (the third argument is 1).
+
+\begin{ocgXample}{ocgx-example-2}
+\begin{ocg}{OCG name}{refocg}{1}
+ content...
+\end{ocg}
+\end{ocgXample}
+
+\DescribeEnv{ocg}%
+The \code+ocg+ environment (provided by the package \code+ocg-p+)
+creates OCGs. It requires three arguments. The first argument is the
+name of the OCG as it appears in the layer toolbar of the PDF
+viewer. The second argument is the internal name used to reference this
+OCG. The third argument sets the initial visibility of the OCG when the
+document is opened (1 for visible, 0 for invisible). The content of the
+environment (any \TeX material) is added into the OCG.
+
+\begin{note}
+ The same reference can be used with several \code+ocg+ environments (not
+ necessarily in the same page). All materials are grouped in the same
+ OCG. Only the first name provided will be used.
+\end{note}
+
+\begin{note}
+ A reference of an OCG consists of letters (A-Z, a-z), numbers (0-9).
+\end{note}
+
+\begin{note}
+ The content of the \code+ocg+ environment should not span across
+ multiple pages. Currently, nothing prevents you to try it but the
+ result will certainly not be the one you were expecting!
+\end{note}
+
+\begin{note}
+ It is possible to nest an OCG in another OCG. To display the internal
+ OCG, both the internal and external OCGs need to be in the visible
+ state.
+\end{note}
+
+\subsection{Manage the visibility of OCGs}
+
+\DescribeMacro{\switchocg}%
+The \code+\switchocg+ macro turns its second argument into a clickable
+link that toggles the visibility status of all listed OCGs (by their
+reference) in its first argument: if an OCG was visible, it becomes
+invisible, and conversely, if an OCG was invisible, it becomes visible.
+
+The following code creates the link \emph{toggle} that switches the
+visibility status of OCGs whose references are \emph{ocg1} and
+\emph{ocg2}:
+
+\begin{lstlisting}[style=TeXcode]
+\switchocg{ocg1 ocg2}{toggle}
+\end{lstlisting}
+
+\DescribeMacro{\showocg}%
+The \code+\showocg+ macro turns its second argument into a clickable
+link that make visible all OCGs whose references are listed in its first
+argument: an invisible OCG becomes visible and an OCG already visible
+remains visible.
+
+The following code creates the link \emph{show} which makes visible the
+OCGs whoses references are \emph{ocg1} and \emph{ocg2}:
+
+\begin{lstlisting}[style=TeXcode]
+\showocg{ocg1 ocg2}{show}
+\end{lstlisting}
+
+\DescribeMacro{\hideocg}%
+The \code+\hideocg+ macro turns its second argument into a clickable
+link that make invisible all OCGs whose references are listed in its
+first argument: a visible OCG becomes invisible and an OCG already
+invisible remains invisible.
+
+The following code creates the link \emph{hide} which makes invisible
+the OCGs whoses references are \emph{ocg1} and \emph{ocg2}:
+
+\begin{lstlisting}[style=TeXcode]
+\hideocg{ocg1 ocg2}{hide}
+\end{lstlisting}
+
+\DescribeMacro{\actionsocg}%
+The \code+\actionsocg+ macro transforms its fourth argument into a
+clickable link. Its three first arguments are lists of references of
+OCGs. The first list contains references of OCGs which visibility status
+is to be toggled. The second list contains references of OCGs to be set
+visible. The third list contains references of OCGs to be set invisible.
+
+The following code creates the link \emph{actions} to toggle the
+visibility status of the OCG named \emph{ocg1}, to make visible the OCG
+named \emph{ocg3}, and to make invisible OCG named \emph{ocg2}:
+
+\begin{lstlisting}[style=TeXcode]
+\actionsocg{ocg1}{ocg3}{ocg2}{actions}
+\end{lstlisting}
+
+\subsection{Usage with \TikZ{}}
+
+You can use the \code+ocgx+ package with \TikZ{}. The package provides a
+\TikZ{} library offering some specific styles to add material to OCGs,
+or to transform a path (\code+\path+ or \code+\node+) into a clickable
+link. To use it, simply add the following lines in your preamble:
+
+\begin{ocgXample}{ocgx-tikz-preamble}
+\usepackage{tikz}
+\usetikzlibrary{ocgx}
+\end{ocgXample}
+
+\subsubsection*{How to add \TikZ{} scopes into OCGs}
+
+\begin{list}{}
+\item
+
+ \noindent\style+/tikz/ocg+\argument{=\{\emph{<ocg options>}\}}
+
+ The \code+ocg+ family is used to specify the options used to add a
+ scope into an OCG.
+
+ \begin{list}{}
+ \item
+
+ \noindent\style+/tikz/ocg/ref+\argument{=\emph{<refname>}}\defaultvalue{no
+ default}
+
+ This option add the current scope to the OCG referenced by
+ \texttt{refname}. If this OCG does not exist, it is created with
+ \texttt{name} and visibility \texttt{status} specified by the
+ two options below.
+
+ \noindent\style+/tikz/ocg/name+\argument{=\emph{<name>}}\defaultvalue{no
+ default, initially empty}
+
+ It is the \texttt{\emph{name}} of the OCG as it appears in the PDF
+ viewer. If the OCG is already created, this option is useless.
+
+ \noindent\style+/tikz/ocg/status+\argument{=\emph{<visibility>}}\defaultvalue{no
+ default, initially \texttt{visible}}
+
+ Specify the initial visibility state of the OCG. Permissible values
+ are \texttt{visible}, and \texttt{invisible}. If the OCG is already
+ created, this option is useless.
+
+ \end{list}
+
+ \begin{note}
+ If you prefer, you can also use the \code+ogc+ environment in a
+ \code+tikzpicture+. The \code+pgfonlayer+ environment is special:
+ inside, you must reuse options below, or use a new \code+ocg+
+ environment.
+ \end{note}
+
+\end{list}
+
+\subsubsection*{How to transform nodes or paths into clickable links}
+
+\begin{list}{}
+\item
+
+\noindent\style+/tikz/switch ocg+\argument{=\{\emph{<OCGs list>}\}}
+
+ This style transforms the current path or the current node in a link acting as
+ if it was produced by the macro \code+\switchocg+ (the visibility
+ status of referenced OCGs is reversed).
+
+ \noindent\style+/tikz/show ocg+\argument{=\{\emph{<OCGs list>}\}}
+
+ This style transforms the current path or the current node in a link acting as
+ if it was produced by the macro \code+\showocg+ (the referenced OCGs
+ are made visible).
+
+ \noindent\style+/tikz/hide ocg+\argument{=\{\emph{<OCGs list>}\}}
+
+ This style transforms the current path or the current node in a link acting as
+ if it was produced by the macro \code+\hideocg+ (the referenced OCGs
+ are made invisible).
+
+ \noindent\style+/tikz/actions ocg+\argument{=\{\emph{<OCGs
+ list>}\}\{\emph{<OCGs list>}\}\{\emph{<OCGs list>}\}}
+
+ This style transforms the current path or the current node in a link acting as
+ if it is produced by the macro \code+\actionsocg+ (the visibility
+ status of OCGs of the first list is reversed, the OCGs in the second
+ list are made visible and those of the third list are made invisible).
+
+ \noindent\style+/tikz/switch ocg with mark on+\argument{=\{\emph{<ocg
+ reference>}\}\{\emph{<OCGs list>}\}}
+
+ \noindent\style+/tikz/switch ocg with mark off+\argument{=\{\emph{<ocg
+ reference>>}\}\{\emph{<OCGs list>}\}}
+
+ These styles transform the current path or the current node in a link acting
+ as if it is produced by the macro \code+\switchocg+ (the visibility
+ status of referenced OCGs in the list is reversed).
+
+ A mark (currently a simple cross) is drawn over the current path or
+ node in an OCG whose reference is \texttt{\emph{ocg reference}}. The
+ visibility status of this OCG will be reversed as those of the entire
+ list.
+
+ If the OCG whose reference is \texttt{\emph{ocg reference}} does not
+ exist, it is created with an empty name and its initial visibility
+ state is true with \code+on+ and false with \code+off+.
+
+\end{list}
+
+\begin{note}
+ Due to limitation of PDF, whatever the shape of the current path or
+ node is, it is its \emph{bounding box} that is used to make the link:
+ the link is always \emph{rectangular} and \emph{horizontal}!
+\end{note}
+
+\subsubsection*{Example with \TikZ{}}
+
+\begin{filecontents*}{ocgx-example-3}
+\begin{tikpicture}
+ \begin{scope}[ocg={name=TikZ example,ref=tikzex,status=visible}
+ \fill[orange] (0,0) circle (1);
+ \end{scope}
+ \node[draw,switch ocg=tikzref] at (2,0) {Switch};
+\end{tikpicture}
+\end{filecontents*}
+\TeXexample{ocgx-example-3}{}
+
+
+
+\section{Examples}
+
+The document \code+demo-ocgx.tex+ provides several examples of usage of
+package \code+ocgx+ with \TikZ{} (and \code+beamer+).
+
+\section{Limits and bugs}
+
+\begin{enumerate}
+\item Links are always horizontal rectangles!
+\item An \code+ocg+ environment spanning across multiple pages are not
+ detected and don't work correctly.
+\item The packages \code+ocg-p+ and \code+ocgx+ are not compatible with
+ Plain-\TeX{}.
+\item While \code+ocg-p+ is usable with \code+pdflatex+ and
+ \code+xelatex+, \code+ocgx+ works only with \code+pdflatex+ (and
+ \code+lualatex+).
+\end{enumerate}
+
+\section{Development and history}
+This package is still experimental. It is released on CTAN. You can
+donwload the latest version from \url{https://github.com/polgab/ocgx}. Any
+help to participate in its development is welcome: contact the
+maintainer (\url{paul.gaborit@gmail.com}).
+
+\paragraph{version 0.5} (2012-12-07) Now, the \code+ocgx+ package uses
+the new \code+ocg-p+ package instead of the \code+ocg+ package : the
+layers can be nested in the layer toolbar of the PDF viewer.
+
+\paragraph{version 0.4} (2012-11-14) Added dependancy to \texttt{calc}
+TikZ library. Fixed bug: bad lists in \code+\actionsocg+.
+
+\paragraph{version 0.3} (2012-09-30) Complete documentation for part
+\emph{Usage with TikZ} and correct TDS archive.
+
+\paragraph{version 0.2} (2012-09-27) First release on CTAN.
+\end{document}
+
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/ocgx/ocgx.sty b/macros/latex/contrib/ocgx/ocgx.sty
new file mode 100644
index 0000000000..6ac757d5e5
--- /dev/null
+++ b/macros/latex/contrib/ocgx/ocgx.sty
@@ -0,0 +1,111 @@
+% Copyright (C) 2012 by Paul Gaborit
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\def\ocgxversion{0.5}
+\ProvidesPackage{ocgx}[2012/11/14 v\ocgxversion{} manage OCG in PDF document]
+\RequirePackage{ocg-p}
+
+%%%% small patch to ocg.sty %%%%
+% 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
+% % *** PATCH ***
+% \expandafter\xdef\csname OCGpdfobj#2\endcsname{\@ocg@curocg}
+% % *** END OF PATCH ***
+% \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
+% }%
+% }
+%%%% END OF PATCH %%%%
+
+\csname ocgx@end:ENDOFOCGS\endcsname
+\def\ocgx@listOCG#1 {%
+ \unless\ifcsname ocgx@end:#1\endcsname
+ \ifcsname OCGpdfobj#1\endcsname
+ \expandafter\def\expandafter\ocgx@list\expandafter{%
+ \ocgx@list
+ \csname OCGpdfobj#1\endcsname\space}%
+ \fi%
+ \expandafter\ocgx@listOCG
+ \fi
+}
+
+\long\def\switchocg#1#2{%
+ \def\ocgx@list{}%
+ \ocgx@listOCG#1 ENDOFOCGS %
+ \leavevmode%
+ \pdfstartlink user {%
+ /Subtype /Link
+ /A << /S/SetOCGState /State [/Toggle \ocgx@list] >>
+ /Border [0 0 0]
+ }%
+ #2\pdfendlink%
+}
+
+\long\def\showocg#1#2{%
+ \def\ocgx@list{}%
+ \ocgx@listOCG#1 ENDOFOCGS %
+ \leavevmode%
+ \pdfstartlink user {%
+ /Subtype/Link
+ /A << /S/SetOCGState
+ /State [/ON \ocgx@list] >>
+ /Border [0 0 0]
+ }%
+ #2\pdfendlink%
+}
+
+\long\def\hideocg#1#2{%
+ \def\ocgx@list{}%
+ \ocgx@listOCG#1 ENDOFOCGS %
+ \leavevmode%
+ \pdfstartlink user {%
+ /Subtype/Link
+ /A << /S/SetOCGState
+ /State [/OFF \ocgx@list] >>
+ /Border [0 0 0]
+ }%
+ #2\pdfendlink%
+}
+
+\long\def\actionsocg#1#2#3#4{%
+ \def\ocgx@list{}%
+ \ocgx@listOCG#1 ENDOFOCGS %
+ \edef\ocgx@toswitch{\ocgx@list}%
+ %
+ \def\ocgx@list{}%
+ \ocgx@listOCG#2 ENDOFOCGS %
+ \edef\ocgx@toshow{\ocgx@list}%
+ %
+ \def\ocgx@list{}%
+ \ocgx@listOCG#3 ENDOFOCGS %
+ \edef\ocgx@tohide{\ocgx@list}%
+ %
+ \leavevmode%
+ \pdfstartlink user{%
+ /Subtype/Link
+ /A << /S/SetOCGState
+ /State [/Toggle \ocgx@toswitch /ON \ocgx@toshow /OFF \ocgx@tohide] >>
+ /Border [0 0 0]
+ }%
+ #4\pdfendlink%
+}
diff --git a/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex b/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
new file mode 100644
index 0000000000..d69b56d0d2
--- /dev/null
+++ b/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
@@ -0,0 +1,121 @@
+% Copyright (C) 2012 by Paul Gaborit
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+
+\RequirePackage{ocgx}
+\usetikzlibrary{calc}
+
+\makeatletter
+\tikzset{
+ ocg/.style={ocg/.cd,#1,/tikz/.cd},
+ ocg={
+ % parameters
+ name/.store in=\ocgx@name,
+ visibity/.store in=\ocgx@visibility,
+ status/.is choice,
+ status/visible/.style={visibity=1},
+ status/invisible/.style={visibity=0},
+ % default values
+ name=,
+ status=visible,
+ % ref
+ ref/.style={
+ /tikz/execute at begin scope={\ocg{\ocgx@name}{#1}{\ocgx@visibility}},
+ /tikz/execute at end scope={\endocg},
+ },
+ },
+ switch ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center,outer sep=0pt]
+ {\switchocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ }
+ },
+ },
+ switch ocg with mark on/.style 2 args={
+ postaction={
+ path picture={
+ \begin{ocg}{#1}{#1}{1}
+ \draw
+ (path picture bounding box.south west)
+ --
+ (path picture bounding box.north east)
+ (path picture bounding box.south east)
+ --
+ (path picture bounding box.north west)
+ ;
+ \end{ocg}
+ },
+ switch ocg={#1 #2},
+ }
+ },
+ switch ocg with mark off/.style 2 args={
+ postaction={
+ path picture={
+ \begin{ocg}{#1}{#1}{0}
+ \draw
+ (path picture bounding box.south west)
+ --
+ (path picture bounding box.north east)
+ (path picture bounding box.south east)
+ --
+ (path picture bounding box.north west)
+ ;
+ \end{ocg}
+ },
+ switch ocg={#1 #2},
+ }
+ },
+ show ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\showocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+ hide ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\hideocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+ actions ocg/.style n args={3}{
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\actionsocg{#1}{#2}{#3}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+}
+\makeatother