From 84897d5d7dcc5750e11a40c7a1f4d2d2f6154bc7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 12 Jan 2013 00:01:08 +0000 Subject: ocg-p (11jan13) git-svn-id: svn://tug.org/texlive/trunk@28803 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/ocg-p/README | 3 + .../doc/latex/ocg-p/examples/ocg-p_example_1.pdf | Bin 44859 -> 44653 bytes .../doc/latex/ocg-p/examples/ocg-p_example_2.pdf | Bin 60489 -> 60271 bytes .../doc/latex/ocg-p/examples/ocg-p_example_3.pdf | Bin 44984 -> 61522 bytes .../doc/latex/ocg-p/examples/ocg-p_example_3.tex | 32 +- .../doc/latex/ocg-p/examples/ocg-p_example_4.pdf | Bin 0 -> 74902 bytes .../doc/latex/ocg-p/examples/ocg-p_example_4.tex | 116 +++++ Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf | Bin 363104 -> 463136 bytes Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex | 371 +++++++++++++++- Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty | 468 +++++++++++++++------ 10 files changed, 838 insertions(+), 152 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.pdf create mode 100644 Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.tex (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/ocg-p/README b/Master/texmf-dist/doc/latex/ocg-p/README index 38c8ab57e59..39d135507a3 100644 --- a/Master/texmf-dist/doc/latex/ocg-p/README +++ b/Master/texmf-dist/doc/latex/ocg-p/README @@ -2,6 +2,7 @@ % %%%%% % % 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. @@ -19,6 +20,8 @@ % 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 % %%%%%%% 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 index bcbdb726c60..29360735d23 100644 Binary files a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdf and b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_1.pdf differ 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 index fedb5b92efb..e2cfa0f5716 100644 Binary files a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdf and b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_2.pdf differ 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 index 981bf453abc..53bc6f8adc2 100644 Binary files a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdf and b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_3.pdf 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 index cab102fce2f..fdc8c8c7e21 100644 --- 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 @@ -3,6 +3,7 @@ \usepackage{ocg-p} \usepackage{tikz} \usetikzlibrary{arrows,automata} +\usepackage{color} \newcommand*{\pkg}[1]{\textsf{#1}} @@ -12,6 +13,7 @@ \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] @@ -22,6 +24,34 @@ The following text can be toggled: \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. +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/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.pdf b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.pdf new file mode 100644 index 00000000000..d0579f84fa6 Binary files /dev/null and b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.pdf differ diff --git a/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.tex b/Master/texmf-dist/doc/latex/ocg-p/examples/ocg-p_example_4.tex new file mode 100644 index 00000000000..0fb865ecbd3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf index e5f42f5f9ab..5bffa9aa847 100644 Binary files a/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf and b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.pdf 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 index c2fa9a9cdf8..7e482205ea1 100644 --- a/Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex +++ b/Master/texmf-dist/doc/latex/ocg-p/ocg-p.tex @@ -8,10 +8,22 @@ \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} + @@ -37,9 +49,16 @@ \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}} +\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{2012/12/01} +\date{2013/01/10} \begin{document} @@ -52,7 +71,7 @@ \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. +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 @@ -69,22 +88,41 @@ 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. +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}. +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. +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 the \pkg{ocg-p} should be loaded after these packages. The |ocg| environment from the \pkg{ocg} package is replaced in this case. +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. -\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|. +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 ... @@ -102,13 +140,102 @@ Sets the initial visibility when the document is opend. Only 0 and 1 are allowed 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. +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} @@ -161,7 +288,7 @@ 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: @@ -260,26 +387,226 @@ With the layer toolbar of the viewer it is possible to activate or deactivate th 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. -\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 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. +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} +\lstinputlisting[firstline=1, lastline=500]{ocg-p.sty} %\VerbatimInput[fontsize=\footnotesize,firstline=1,lastline=320]{ocg-p.sty} @@ -287,13 +614,15 @@ The implementation is rather standard. At first main switches are defined to dis \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.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.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.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.4] Planned: Not in a |.sty| file anymore, now using |.dtx|. +\item[0.5] Planned: Not in a |.sty| file anymore, now using |.dtx|. \end{description} diff --git a/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty b/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty index 9354753ab0c..b0e0172d9e6 100644 --- a/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty +++ b/Master/texmf-dist/tex/latex/ocg-p/ocg-p.sty @@ -5,15 +5,24 @@ % 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] - +\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} -\DeclareOption*{}\ProcessOptions*\relax %allow anything as option for the moment +\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 @@ -32,12 +41,13 @@ % dvips \@ocgp@ifpstrue \PackageWarningNoLine{ocg-p}{% - Only xelatex and pdflatex are supported% + 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 @@ -53,24 +63,25 @@ \providecommand\ocg[3]{} % if running with ocgtools \renewenvironment{ocg}[4][]{% \if@ocgp@isnestedB% begin of nested ocg detected - \immediate\write\@ocgp@ocgHandle{% + \immediate\write\@ocgp@ocgHandle{% \string\@ocgp@nestedB{}% } - \fi - \global\@ocgp@isnestedBtrue % ocg begin - \global\@ocgp@isnestedEfalse % ocg end - + \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}% + \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 @@ -82,12 +93,13 @@ \pdfliteral{EMC}% \else \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT - \special{ps: mark /EMC pdfmark}% + %\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 + \if@ocgp@isnestedE% end of nested ocg detected \immediate\write\@ocgp@ocgHandle{% \string\@ocgp@nestedE{}% } @@ -104,96 +116,141 @@ \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 +\define@choicekey*[ocgp]{ocg}{printocg}[\@ocgp@printbin\@ocgp@printno]{always,never,ifvisible}[ifvisible]{% + \ifcase\@ocgp@printno\relax + \def\@ocgp@print{/Print<>}% + \or% + \def\@ocgp@print{/Print<>}% + \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<>}% + \or% + \def\@ocgp@export{/Export<>}% + \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}{} -% -> -% not visible AND alwaysprinted -> only on print \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 - \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<> % - %/View<> % - % /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 <> % +\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<> % - %/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 - \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 + \@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 <> % + \@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 } - \AtEndDocument{% - %\message{... \@ocgp@ocgorderlist ...} - \ifpdf % PDFLATEX - \pdfcatalog{% - /OCProperties << - /OCGs [\@ocgp@ocglist] - /D <>% - <>% - <>% - ]>>% - >>% - } - \else - \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT - %\special{ps: mark {Catalog} << - % /OCProperties << - % /OCGs [\@ocgp@ocglist] - % /D <> - % >> - %>> /PUT pdfmark}% - \else % XELATEX - \special{pdf:put @catalog << - /OCProperties << - /OCGs [\@ocgp@ocglist] - /D <>% - <>% - <>% - ]>>% - >>% - >>}% - \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 <>% + <>% + <>% + ]>>% + >>% + } + \else + \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT + \special{ps: mark {Catalog} << + /OCProperties << + /OCGs [\@ocgp@ocglist] + /D <> + >> + >> /PUT pdfmark}% + \else % XELATEX + \special{pdf:put @catalog << + /OCProperties << + /OCGs [\@ocgp@ocglist] + /D <>% + <>% + <>% + ]>>% + >>% + >>}% + \fi + \fi +} \AtBeginDocument{% \ifpdf % PDFLATEX @@ -210,12 +267,15 @@ \x \else \if@ocgp@ifps % soon (not implemented yet) POSTSCRIPT - %\AddToShipoutPicture{ - %\special{ps: mark {Resources} << - % /Properties << ^^J% - % \@ocgp@ocgmaplist + \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}}% + >> + >> /PUT pdfmark}}% \else % XELATEX \AddToShipoutPicture{ \special{pdf: put @resources << @@ -227,44 +287,192 @@ \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@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} + \ifcsname OCGpdfobj#1\endcsname% + \xdef\@ocgp@ocgobjlist{\@ocgp@ocgobjlist\space\csname OCGpdfobj#1\endcsname}% \fi - \ifx #2\@empty + \ifx#2\relax %\@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 <>% - >>}#2% - \special{pdf:eann}% - \fi +%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 <> + /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 <>% + /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 <>% + /AA << + \@ocgp@actionlist + >> + >>}#5% + \special{pdf:eann}% + \fi% + \fi% + \endgroup } -\makeatother + + + +% 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 + + + -- cgit v1.2.3