diff options
author | Karl Berry <karl@freefriends.org> | 2010-05-14 18:26:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-05-14 18:26:13 +0000 |
commit | 5ab9979378ea2f59c6a36d0bbf12e47d6300fc67 (patch) | |
tree | c3a2c20f18da5e557a7dab77bcfb6b36d7c12c18 /Master/texmf-dist/source/latex | |
parent | 1d489c5acd49115955f035380e9ec36c51701827 (diff) |
ocgtools 0.8 (11may10)
git-svn-id: svn://tug.org/texlive/trunk@18248 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/ocgtools/ocgtools.dtx | 505 |
1 files changed, 339 insertions, 166 deletions
diff --git a/Master/texmf-dist/source/latex/ocgtools/ocgtools.dtx b/Master/texmf-dist/source/latex/ocgtools/ocgtools.dtx index af5abccad5b..3dd5a7a77fd 100644 --- a/Master/texmf-dist/source/latex/ocgtools/ocgtools.dtx +++ b/Master/texmf-dist/source/latex/ocgtools/ocgtools.dtx @@ -22,7 +22,7 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{ocgtools} %<*package> - [2010/04/10 v0.6 ocgtools.dtx file] + [2010/05/10 v0.8 ocgtools.dtx file] %</package> % %<*driver> @@ -40,7 +40,7 @@ %</driver> % \fi % -% \CheckSum{824} +% \CheckSum{1067} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -60,7 +60,12 @@ % % % \changes{v0.5}{2010/04/01}{First public version} -% \changes{v0.6}{2010/04/10}{Keeping document's dirty for Adobe Acrobat users} +% \changes{v0.6}{2010/04/10}{Keeping document's dirty for Adobe +% Acrobat users} +% \changes{v0.7}{2010/05/01}{Each (mini)text layer +% can get its own colors, fixed layerHshift and layerVshift macros, +% options \texttt{inactive} and \texttt{active}} +% \changes{v0.8}{2010/05/10}{Minor fix related to fancytooltips package} % % \GetFileInfo{ocgtools.dtx} % @@ -76,8 +81,8 @@ % % \section{Introduction} % -% The package |ocgtools| is designed to insert OGC (Optional Group -% Content) into PDF presentations. From the user's point of view, the +% The package |ocgtools| is designed to insert OCG (Optional Content +% Group) into PDF presentations. From the user's point of view, the % package allows to insert in an comfortable way any \TeX{} material % into separate layer in PDF document and insert links which toggle % this layer on/off. Hence parts of PDF document like formatted text, @@ -88,14 +93,15 @@ % |fancytooltips|. In contrast to |cooltooltips| and |pdfcomment|, we % can work with any \TeX{} material, not only plain text. In contrast % to |fancytooltips|, no external file is necessary and more -% minilayers (see below) can be opened simultaneously on one -% page. However, |fancytooltips| and |ocgtools| can be combined in the -% same document, even on the same page. |AcroTeX| has far more +% minilayers (see below) can be opened simultaneously on one page. +% However, |fancytooltips| and |ocgtools| can be combined in the same +% document, even on the same page\footnote{remember to load +% fancytooltips as the first package}. |AcroTeX| has far more % possibilities than |ocgtools|, but has three disadvantages: (1) % limited support for |pdftex| (no layers with |pdftex| driver) (2) -% PDF file needs postprocessing (3) for the post-processing the non-free -% Adobe Acrobat Professional is necessary. However, the user of -% |ocgtools| must have |AcroTeX| installed, since we use its +% PDF file needs post-processing (3) for the post-processing the +% non-free Adobe Acrobat Professional is necessary. However, the user +% of |ocgtools| must have |AcroTeX| installed, since we use its % capability to insert buttons and JavaScripts into document (|eforms| % and |insdljs| packages). % @@ -115,9 +121,10 @@ % cannot be hidden. % % \marginpar{\texttt{Important comment!}}\textbf{\color{red} Big -% warning:} Unfortunately, with this package you may make your PDF +% warning:} Unfortunately, with this package you may make your PDF % files \textbf{less portable} even if you use Adobe Reader! Till now, -% we observed the following problems: +% we observed the following problems (for known problems not related +% to portability se the end of this manual): % \begin{itemize} % \item jpg pictures may look darker when using \texttt{transparent} % option and \textbf{Linux} version of Adobe Reader -- Adobe Reader @@ -143,6 +150,7 @@ % % \section{Usage} % +% \subsection{Compilation} % All the packages we use are on CTAN or in \TeX live2009. The file % |ocg.sty| is a part of |asymptote| package\footnote{Do not % interchange with the |ocg.sty| provided by \"Osterreichische @@ -151,7 +159,7 @@ % |AcroTeX| is quite old on CTAN but the version on CTAN works well. % New version of |AcroTeX| is at |www.acrotex.net|, if necessary. % -% \bigskip \textbf{Prerequisities}: Only |pdflatex| is supported. The +% \bigskip \textbf{Prerequisites}: Only |pdflatex| is supported. The % route via |dvips| or |dvipdfm| is not (yet?) supported (this % restriction follows from |ocg.sty| and |transparent.sty| % packages). To work with the package load |color.sty| and @@ -169,26 +177,32 @@ % to put layers on correct position. If you change the content of text % layers or minilayers, one compilation is sufficient. % -% \bigskip +% \subsection{Package options} % Load package |ocgtools.sty| as usual: % \cs{usepackage}\oarg{options}|{ocgtools}|. Options include: % \begin{description} -% \item[\texttt{transparent}] Layers in fact do not span over the -% whole page, but the material of layer is scaled to some reasonable -% size (we keep aspect ratio). If the layer is activated, the page -% is covered by a uniform color |ocgbg| and the layer is placed on -% the top. The options |transparent| makes the color |ocgbg| -% transparent. Looks cool, but it could be slow and could change -% some colors of bitmap pictures (and this behavior seems to be -% system dependent -- looks differently on Linux and differently on -% Windows). The transparency is achieved by putting the command -% |\ocgtools@transparent| on appropriate place. The default setting -% is |\def\ocgtools@transparent{\transparent{0.4}}|. Use something -% like +% \item[\texttt{transparent}] Layers produced by |\ocgtext| and +% |\ocgpicture| in fact do not span over the whole page, but the +% material of layer is scaled to some reasonable size (we keep +% aspect ratio and the width and height are not bigger than +% \DescribeMacro{\ocgtools@maxheight}|\ocgtools@maxheight| and +% \DescribeMacro{\ocgtools@maxwidth} |\ocgtools@maxwidth|). If the +% layer is activated, the page is covered by a uniform color |ocgbg| +% and the layer is placed on the top. The options |transparent| +% makes the color |ocgbg| transparent. Looks cool, but it could be +% slow and could change some colors of bitmap pictures (and this +% behavior seems to be system dependent -- looks differently on +% Linux and differently on Windows). The transparency is achieved by +% putting the command |\ocgtools@transparent| on appropriate place. +% The default setting is +% |\def\ocgtools@transparent{\transparent{0.4}}|. Use something like % like the following three lines to override:\\ % |\makeatletter|\\ % |\def\ocgtools@transparent{\transparent{0.6}}|\\ -% |\makeeatother| +% |\makeatother| \\Default values for |\ocgtools@maxheight| and +% |\ocgtools@maxwidth| are 0.9 of |\paperheight| and |\paperwidth|. +% You can redefine them after |\begin{document}| (remember to use +% |\makeatletter| \dots |\makeatother| pair). % \item[\texttt{nobutton}] The pages with active layers have a % transparent button which can be used to hide this layer. The user % simply clicks anywhere and the layers become hidden. In some @@ -213,16 +227,21 @@ % also hides the layer or minilayer. % \item[\texttt{minimouseover}] As mouseover, but restricted to % minilayers. -% \item[\texttt{noocg}] The package and its commands are ignored. % \item[\texttt{noprogressmsg}] Opening PDF on the first page show the % message related to initial processing layers. This option turns % the message off. % \item[\texttt{nopageclose}] By default, all layers become off and % all buttons become hidden if the page is changed. The option % \texttt{nopageclose} suppresses this behavior. +% \item[\texttt{inactive}] This option makes the package inactive. +% \item[\texttt{noocg}] The same as \texttt{inactive}. +% \item[\texttt{active}] This option forces the package active even if +% |inactive| option is loaded. % \end{description} % -% The macro |\ocgtext|\oarg{width}\marg{text1}\marg{text2} +% \subsection{Text layer which extends to papersize} +% The macro |\ocgtext[width=|\meta{width}, |bg=|\meta{color1}, +% |fg=|\meta{color2}|]|\marg{text1}\marg{text2} % \DescribeMacro{\ocgtext} is used to create layer which contains any % \LaTeX{} material. \meta{text1} is a text which is written in an % ``usual'' way (in blue color which indicates that this text can be @@ -230,11 +249,25 @@ % hide/unhide layer with \meta{text2} (which could be text divided % into more than one paragraph, figure created by |mfpic| or any % \LaTeX{} material). \meta{text2} is either placed into |\hbox| (if -% \meta{width} is 0\,pt, which is default) or wrapped by |\vbox| with |\hsize| -% equal to \meta{width} (in the opposite case). -% -% +% \meta{width} is 0\,pt, which is default) or wrapped by |\vbox| with +% |\hsize| equal to \meta{width} (in the opposite case). The color +% \meta{color1} is used to set the background for this box and the +% color \meta{color2} is used as text color. The default value for +% \meta{color1} is stored in macro |\defaultocgpapercolor| and the +% default vaue for this macro is \DescribeMacro{ocgpaper} |ocgpaper|. +% The color |ocgpaper| is yellow by default, more precisely, it is +% declared with |\definecolor{ocgpaper}{rgb}{1,1,0.2}|. The default +% value for \meta{color2} is stored in macro |\defaultocgfontcolor| +% and the default vaue for this macro is +% \DescribeMacro{ocgfontcolor}|ocgfontcolor|. The color |ocgfontcolor| +% is declared as black by default. You can use also key words +% |background| instead of |bg| and |color| instead of |fg|. The +% keyword |width| can be omitted, provided \meta{width} comes as first +% argument. Thus |\ocgtext[1cm,background=black,color=white]{text}| +% puts the white text on black background in the box of width 1cm. For +% more details about color management see paragraph \ref{summary}. % +% \subsection{Layer with image which extends to papersize} % \DescribeMacro{\ocgpicture} The macro % |\ocgpicture|\oarg{params}\marg{picture} is used to insert a picture % which is used as a link to layer with bigger version of this @@ -242,15 +275,19 @@ % |\includegraphics| command to draw picture in text. The layer % contains scaled version of the picture (aspect ratio is preserved). % +% \subsection{Layer with text (or whatever) in its natural size} % \DescribeMacro{\ocgminitext} The macro -% |\ocgminitext|\oarg{width}\marg{text1}\marg{text2} is used to create +% |\ocgminitext[width=|\meta{width}, |bg=|\meta{color1}, +% |fg=|\meta{color2}|]|\marg{text1}\marg{text2} is used to create % layer containing \meta{text2} which is placed near the right top % corner of \meta{text1}. \meta{text2} is placed into |\hbox| or -% |vbox| with given |hsize| according to the value of \meta{width}, -% as has been explained at |\ocgtext| macro. Macros |\ocgminitextrb|, -% |\ocgminitextlt| and |\ocgminitextlb| can be used to place the -% minilayer to the right bottom, left to and left bottom corner. +% |\vbox| with given |\hsize| according to the value of \meta{width} +% and other optional parameters, as has been explained at |\ocgtext| +% macro. Macros |\ocgminitextrb|, |\ocgminitextlt| and +% |\ocgminitextlb| can be used to place the minilayer to the right +% bottom, left to and left bottom corner. % +% \subsection{Fine-tuning, customizing} % \DescribeMacro{\ocgtextstart}\DescribeMacro{\ocgtextend} Macros % |\ocgtextstart| and |\ocgtextend| are used to denote the start and % the end of hyperlink which is used to hide/reveal layers. Default @@ -258,72 +295,121 @@ % and hence, the links are blue and there is no mark at the end of the % link. % -% \DescribeMacro{ocgpaper}\DescribeMacro{ocgbg} The colors |ocgbg| and -% |ocgpaper| are used to set the colors which are used to hide page -% and color which is used as background for text produced by -% |\ocgtext| and |\ocgminitext| commands. The default setting is -% |\definecolor{ocgpaper}{rgb}{1,1,0.2}| and -% |\definecolor{ocgbg}{rgb}{0,0,0}|. -% -% \DescribeMacro{\layerHshift} \DescribeMacro{\layerVshift} The -% dimensions |\layerHshift| and |\layerVshift| are used to place -% layers exactly on the top of the page. If presentation packages -% |web|, |beamer| or |pdfscreen| are used, then the length is set -% automatically. -% -% \DescribeMacro{\ocgtools@shipoutstart@hook} -% \DescribeMacro{\ocgtools@shipoutend@hook} Commands -% |\ocgtools@shipoutstart@hook| and |\ocgtools@shipoutend@hook| are -% introduced to insert some material at the begin and at the end of -% the box with the page contents. Can be used for example to put -% background to the presentation. Both commands should produce boxes -% of zero dimensions, i.e. use something like \begin{verbatim} -% \makeatletter \def\ocgtools@shipoutstart@hook{\hbox to 0 pt{\kern -% -1in \Huge A\hss}} \makeatother \end{verbatim} to insert letter "A" -% into the left bottom corner. Note that you will see this letter only -% if the background of the presentation is transparent. See also the -% files |ocgtools-example-web*.tex| and |ocgtools-example-web*.pdf| -% for slightly more complicated background. -% -% \DescribeMacro{\ocgclosechar} \DescribeMacro{\ocgtools@msg} Macro -% |\ocgclosechar| is used to print mark which is used to close layers -% and minilayers and |\ocgtools@msg| contains string for users of -% viewers which do not support layers (see the first few lines of the -% code for default settings). +% \DescribeMacro{ocgbg} The color |ocgbg| is used to set the color +% which are used to hide page when using |\ocgtext| and |\ocgpicture| +% commands. The default setting is |\definecolor{ocgbg}{rgb}{0,0,0}|. +% You may want to redefine this color, but you have to do this before +% |\begin{document}|. +% +% \DescribeMacro{\layerHshift} \DescribeMacro{\layerVshift} The +% dimensions |\layerHshift| and |\layerVshift| are used to place +% layers exactly on the top of the page. Should be set automatically +% in the second pass, when reading aux file. If not (the big layers +% do not cover the PDF page and minitext layers are shifted), you +% may adjust them as required after |\begin{document}|. In this +% case, \textit{report the problem} to the author of the package, +% please. +% +% Commands |\ocgtools@shipoutstart@hook| and +% |\ocgtools@shipoutend@hook| are introduced to insert some material +% at the begin and at the end of the box with the page contents. Can +% be used for example to put background to the presentation. Both +% commands should produce boxes of zero dimensions, i.e. use something +% like +% \begin{verbatim} +% \makeatletter +% \def\ocgtools@shipoutstart@hook{\hbox to 0 pt{\kern -1in \Huge +% A\hss}} +% \makeatother +% \end{verbatim} +% to insert letter "A" into the left bottom corner. Note that you will +% see this letter only if the background of the presentation is +% transparent. See also the files |ocgtools-example-web*.tex| and +% |ocgtools-example-web*.pdf| for slightly more complicated +% background. +% +% {\sloppy \DescribeMacro{\...envelope} The arguments of commands +% |\ocgpicture|, |\ocgtext| and family of |\ocgminitext| etc. are +% wrapped by macros |\ocgtools@pict@envelope|, +% |\mocgtools@text@envelope| and |\ocgtools@minitext@envelope|, +% respectively. You can redefine these macros to suit more to your +% need. All macros are |\relax| by default. +% +% }\DescribeMacro{\ocgclosechar} The |\ocgclosechar| command is used to +% print mark which is used to close layers. This mark is a red cross. +% On the minitextlayers with red background we switch this color to +% black (see the first few lines of the code to see, how we get this +% behavior). Note that we used the macro +% |\if@ocgtools@insideminilayer| which is true on layers with minitext +% and false otherwise. +% +% \DescribeMacro{\ocgtools@msg} The |\ocgtools@msg| command contains +% string for users of viewers which do not support layers (see the +% first few lines of the code for default settings). +% +% \subsection{Summary on customizing colors in text layers}\label{summary} +% Note that all colors related to the layers are set (and hence must +% be declared before) when reading auxiliary files at +% |\begin{document}|. Declaring of redefining colors after +% |\begin{document}| has no influence. To summarize, if you want to +% change colors, use the following. +% \begin{itemize}\sloppy +% \item To change the setting in the whole paper, redeclare colors +% |ocgpaper| and |ocgfontcolor| before |\begin{document}|. Use the +% command |\definecolor| for this purpose. +% \item To change the setting from now to the end of document (or +% group) redefine macros |\defaultocgpapercolor| and +% |\defaultocgfontcolor|. Use for example +% |\renewcommand{\defaultocgpapercolor}{green}|. +% \item To change the setting for one single layer use |bg| and |fg| +% keywords in optional parameter of |\ocgtext| and |\ocgminitext| +% macros. +% \end{itemize} % % \section{Possible future development and known problems} % The source code is in Mercurial repository at % \url{http://bitbucket.org/robert.marik/ocgtools/}. You can also % report problems and issues in the forum at this site. +% \subsection{Known problems} +% \begin{enumerate} +% \item The package does not work properly if the \textbf{\color{red}PDF has one page} +% only. This is probably minor problem, since most presentations are +% longer and the problem will be traced later. +% \item There could be a \textbf{\color{red}conflict with another package which +% deals with} |\pdfpageattr|. This problem is resolved for +% fancytooltips package. To make both fancytooltips and ocgtools +% work in one document, load \textit{fancytooltips as the first one} +% and ocgtools after. Remember the only one |\pdfpageattr| is +% allowed in PDF specification for each single page. +% \item In some rare cases the layers may be not inserted properly +% when the \textbf{\color{red}\LaTeX{} file is compiled on Windows} +% -- see the option \texttt{insertvisible} which solves this +% problems in most cases. Since the author has limited access to +% \TeX{} installations on Windows and hence reporting of problems +% with a minimal example is highly appreciated. +% \item The package cannot be used to hide 3D graphics inserted by +% |movie15| package. However, you can put this graphics into +% floating window or full-screen using capabilities of Acrobat Reader +% 9. +% \end{enumerate} +% \subsection{Ideas for future developement} +% These ideas may appear in new versions of the package (and patches +% which include the solutions to this or other problems are +% welcomed). % \begin{enumerate} -% \item Test and support more packages for slides than current -% web.sty, pdfscreen.sty and beamer.sty? Which ones? % \item Using |preview| package it is possible to extract equations % and figures from the document and redefine |\ref| and |\eqref| % commands in such a way that clicking (or mouseover) opens on the % current page the layer with this equation (figure) and shift -% clicking moves the user to the page with this equation -% (figure). Or would |fancytooltips| produce better results in this -% case (smaller PDF file)? See also the paper by Ross More at +% clicking moves the user to the page with this equation (figure). +% Or would |fancytooltips| produce better results in this case +% (smaller PDF file)? See also the paper by Ross More at % \url{http://www.tug.org/TUGboat/Articles/tb29-3/tb93moore.pdf} and -% the demo |examples/fancy-preview| in fancytooltips directory. See -% the |ocgtools-preview.*| files for some initial attempts in this -% direction. +% the demo |examples/fancy-preview| in fancytooltips distribution. +% See the |ocgtools-preview.*| files for some initial attempts in +% this direction based on ocgtools. % \item Introduce draft mode, which prints all layers at the end of % document with links there and back? -% \item Improve placement of minitextlayers. Currently we have one the -% reference point for both minitextlayers aligned to top and -% bottom, which is far from optimal. -% \item In some rare cases the layers may be not inserted properly -% when the \LaTeX{} file is compiled on \textbf{Windows} -- see the -% option \texttt{insertvisible} which solves this problems in most -% cases. Since the author has limited access to \TeX{} -% installations on Windows and hence reporting of problems with a -% minimal example is highly appreciated. -% \item The package cannot be used to hide 3D graphics inserted by -% |movie15| package. However, you can put this graphics into -% floating window or full-screen using capabilities of Acrobat Reader -% 9. % \item If you open and close layer and then use "Back" % (Alt+LeftArrow), the layer opens again, but the button to hide % this layer becomes unavailable. Possible solution is to define @@ -337,7 +423,7 @@ % Initial settings % \begin{macrocode} %<*package> -\def\ocgtools@msg{If message does not disappear after a short time, the +\def\ocgtools@msg{If this message does not disappear after a short time, the author either did not compile the \LaTeX{} file three times, or your PDF viewer does not support OCG. Use Adobe Reader!} @@ -346,12 +432,20 @@ \ifx\definecolor\undefined\RequirePackage{color}\fi \ifx\href\undefined\RequirePackage[pdftex]{hyperref}\fi \definecolor{ocgpaper}{rgb}{1,1,0.2} +\definecolor{ocgfontcolor}{rgb}{0,0,0} +\def\defaultocgpapercolor{ocgpaper} +\def\defaultocgfontcolor{ocgfontcolor} \definecolor{ocgbg}{rgb}{0,0,0} \RequirePackage{graphicx} \RequirePackage{pifont} \RequirePackage{ocg} +\RequirePackage{xkeyval} + +\newif\if@ocgtools@insideminilayer +\def\ocgclosechar{{\color{red}\def\temp{red}% + \ifx\temp\ocgt@@ls@bg\if@ocgtools@insideminilayer\color{black}\fi\fi + \ding{56}}} -\def\ocgclosechar{\ding{56}} % \end{macrocode} % Make packages and options known. % \begin{macrocode} @@ -365,8 +459,6 @@ \def\ocgtools@initialvisibility{1}} \newif\ifocg@hide@button\ocg@hide@buttontrue \DeclareOption{nobutton}{\ocg@hide@buttonfalse} -\newif\ifocgtools@noocg\ocgtools@noocgfalse -\DeclareOption{noocg}{\ocgtools@noocgtrue} \def\ocgtools@progressmsg{\lower \layerVshift\hbox to 0 pt{ %space \textField[\V{OCGtools: processing OCG's ...}\BG{1} \textColor{1 0 0} \textSize{10}]% @@ -378,8 +470,32 @@ \DeclareOption{mouseover}{\@ocgtools@mouseovertrue \@ocgtools@minimouseovertrue} \newif\if@ocgtools@pageclose \@ocgtools@pageclosetrue \DeclareOption{nopageclose}{\@ocgtools@pageclosefalse} +\newif\if@ocgtools@inactive\@ocgtools@inactivefalse +\DeclareOption{inactive}{\@ocgtools@inactivetrue} +\DeclareOption{noocg}{\@ocgtools@inactivetrue} +\newif\if@ocgtools@active\@ocgtools@activefalse +\DeclareOption{active}{\@ocgtools@activetrue} + \ProcessOptions +\if@ocgtools@active\@ocgtools@inactivefalse\fi +\newdimen\layerHshift \layerHshift=-1in +\newdimen\layerVshift \layerVshift=0pt + +\if@ocgtools@inactive + \newcommand\ocgpicture[2][]{\leavevmode\includegraphics[#1]{#2}} + \newcommand\ocgtext[3][0pt]{\leavevmode #2} + \newcommand\ocgtoolsplacepicture[3]{} + \newcommand\ocgtoolsplacetext[3]{} + \newcommand\ocgtoolsplaceminitext[7]{} + \newcommand\ocgminitext[3][0pt]{\leavevmode #2}% + \let\ocgminitextlt\ocgminitext + \let\ocgminitextrt\ocgminitext + \let\ocgminitextlb\ocgminitext + \let\ocgminitextrb\ocgminitext + \PackageWarning{ocgtools}{Ocgtools inactive}% +\expandafter\endinput\fi + % \end{macrocode} % We use the hack for Adobe Acrobat suggested by DPS and Jorg at % http://www.acrotex.net/forum/showthread.php?tid=78. @@ -388,8 +504,21 @@ this.dirty=DirtyBeforeOCGtools;}} % \end{macrocode} % We insert JavaScripts which are evaluated when the file is opened at -% the first page. +% the first page. There is a clash with fancytooltips package. To make +% things work, load fancytooltips before ocgtools and add the +% |\pdfpageattr| from fancytooltips to |\pdfpageattr| inserted by +% ocgtools. % \begin{macrocode} +\@ifpackageloaded{fancytooltips}{% + \let\TooltipPageopencloseJS\relax + \ifx\fancytooltips@pdfpageattrJS\undefined + \def\@ocgtools@fancytooltips{var DirtyBeforeCloseTooltip=this.dirty; + CloseTooltips(); this.dirty=DirtyBeforeCloseTooltip;} + \else + \let\@ocgtools@fancytooltips\fancytooltips@pdfpageattrJS + \fi + }{\def\@ocgtools@fancytooltips{}} + \edef\ocgtools@pdfpageattr{ /AA << /O << /S /JavaScript /JS ( @@ -398,7 +527,7 @@ % and \texttt{ocgtoolsOCGs} is not initialized, we skip to % \texttt{catch} part and initialize. % \begin{macrocode} - try{ + if (typeof(ocgtoolsOCGs)!="undefined"){ var temp = ocgtoolsOCGs.length; \if@ocgtools@pageclose for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++) @@ -411,7 +540,7 @@ % We initialize document -- we find all layers, put into % \texttt{ocgtoolsOCGs} field and make them hidden. % \begin{macrocode} - catch (e){ + else { % \end{macrocode} % No dotted rectangle for buttons which have focus. % \begin{macrocode} @@ -444,6 +573,7 @@ this.getField("OcgtoolsBtn.HideButton.main").hidden = true; this.dirty=false; \fi + \@ocgtools@fancytooltips ) >> >> } @@ -465,27 +595,17 @@ \newdimen\ocgtools@maxheight \newdimen\ocgtools@maxwidth % \end{macrocode} -% We introduce lengths which can be used to finetune position of layers -% on the screen. These lengths are not necessary for plain pages -% (like article class with geometry package) and beamer. -% \begin{macrocode} -\newdimen\layerHshift \layerHshift=0pt -\newdimen\layerVshift \layerVshift=0pt -% \end{macrocode} -% We need small shift for web.sty. -% \begin{macrocode} -\ifx\@Rightmargin\undefined\else - \layerVshift=3pt -\fi -% \end{macrocode} -% We need another shift for pdfscreen.sty. +% We introduce lengths which can be used to fine-tune position of +% layers on the screen. These lengths should be se automatically. % \begin{macrocode} -\ifx\PDFSCR@Warning\undefined\else - \layerVshift=\@Bottommargin -\fi +\def\ocgtools@save@position{\pdfsavepos +\write\@auxout{\string\global\string\advance\string \layerVshift \the\pdflastypos sp\string\relax}% +\write\@auxout{\string\global\string\advance\string \layerHshift \the\pdflastxpos sp\string\relax}% +\global\let\ocgtools@save@position\relax +} \newtoks\ocgtools@layer@toks -\ocgtools@layer@toks{} +\ocgtools@layer@toks{\ocg@place@text{0}{1}{5cm}} \newbox\ocgtools@box@a \newbox\ocgtools@box@b \newif\ifocg@page@contains@layer @@ -497,12 +617,18 @@ \let\ocgtools@shipoutstart@hook\relax \let\ocgtools@shipoutend@hook\relax \AtBeginShipout{% +\expandafter\global\expandafter\pdfpageattr\expandafter{\ocgtools@pdfpageattr} \setbox\AtBeginShipoutBox=\hbox{% % \end{macrocode} -% Hook which can be used to place backgound. +% Hook which can be used to place background. % \begin{macrocode} \ocgtools@shipoutstart@hook % \end{macrocode} +% This command writes the info about the position on the first PDF +% page and then is set to relax on next pages. +% \begin{macrocode} +\ocgtools@save@position +% \end{macrocode} % We insert the page first. % \begin{macrocode} \hbox to 0 pt{\box\AtBeginShipoutBox\hss}\kern -1in\kern \layerHshift @@ -537,21 +663,24 @@ % buttons, we keep possibility to make them hidden, in contrast to % links). % \begin{macrocode} +\ifx\ocgtools@AfterHideBtn\undefined\def\ocgtools@AfterHideBtn{}\fi \def\ocgtools@HideBtn{\pushButton[\W{0}\BG{}\S{S}\BC{}\H{N}\F{\FHidden}\A{\ocgtools@JS{ for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++) { ocgtoolsOCGs[i].state = false; } \ifocg@hide@button this.getField("OcgtoolsBtn.HideButton").hidden = true; \fi + \ocgtools@AfterHideBtn }}]{OcgtoolsBtn.HideButton.main}{\paperwidth}{\paperheight}} % \end{macrocode} % We create buttons which are attached to the top right corner % of each minilayer and can be used to hide the corresponding minilayer. % \begin{macrocode} +\ifx\ocgtools@AfterHideMiniLayer\undefined\def\ocgtools@AfterHideMiniLayer{}\fi \newcommand\ocgtools@HideMiniLayer[1] -{\setbox\ocgtools@box@a=\hbox{{\color{red}\ocgclosechar}}% +{\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}% \hbox to \wd\ocgtools@box@a% -{\hbox{{\color{red}\ocgclosechar}}\hss% +{\hbox{{\ocgclosechar}}\hss% \hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}% \F{\FHidden}\A{\ocgtools@JS{ for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++) @@ -560,16 +689,18 @@ ocgtoolsOCGs[i].state = false; } this.getField("OcgtoolsBtn.HideButton.mini.#1").hidden = true; + \ocgtools@AfterHideMiniLayer }}]% {OcgtoolsBtn.HideButton.mini.#1}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}} % \end{macrocode} -% We create buttons which are attached tothe bottom right corner +% We create buttons which are attached to the bottom right corner % of the screen and can be used to hide all layers. % \begin{macrocode} +\ifx\ocgtools@AfterHideLayers\undefined\def\ocgtools@AfterHideLayers{}\fi \newcommand\ocgtools@HideLayers[1]{% -\setbox\ocgtools@box@a=\hbox{{\color{red}\ocgclosechar}}% +\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}% \hbox to \wd\ocgtools@box@a% -{\hbox{{\color{red}\ocgclosechar}}\hss% +{\hbox{{\ocgclosechar}}\hss% \hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}% \F{\FHidden}\A{\ocgtools@JS{ for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++) @@ -579,6 +710,7 @@ \ifocg@hide@button this.getField("OcgtoolsBtn.HideButton.main").hidden = true; \fi + \ocgtools@AfterHideLayers }}]% {OcgtoolsBtn.HideButton.corner.#1}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}} % \end{macrocode} @@ -704,18 +836,13 @@ \def\posFile{\jobname.pos} \def\posOpen{\openout\posHandle=\posFile} \def\posClose{\closeout\posHandle} -\ifocgtools@noocg -\else \AtBeginDocument{\InputIfFileExists{\posFile}{}{}% \ocgtools@maxheight=0.9\paperheight \ocgtools@maxwidth=0.9\paperwidth \expandafter\global\expandafter\def\csname ocgtools@textcontent@0\endcsname -{{\color{red}\bfseries\ocgtools@msg}} -\expandafter\ocgtools@layer@toks\expandafter{\the\ocgtools@layer@toks -\ocg@place@text{0}{1}{5cm}} +{{\color{red}\bfseries\ocgtools@msg}}% \posOpen} \AtEndDocument{\posClose} -\fi % \end{macrocode} % The following commands create links to hide/unhide layers and @@ -734,40 +861,75 @@ \the\ocgtools@layercount}{\thepage}{#2}}% } +\define@key{ocg@key}{width}[0pt]{\def\ocgt@@ls@width{#1}} +\define@key{ocg@key}{background}[ocgpaper]{\def\ocgt@@ls@bg{#1}} +\define@key{ocg@key}{bg}[ocgpaper]{\def\ocgt@@ls@bg{#1}} +\define@key{ocg@key}{color}[ocgfontcolor]{\def\ocgt@@ls@fg{#1}} +\define@key{ocg@key}{fg}[ocgfontcolor]{\def\ocgt@@ls@fg{#1}} + +\newtoks\ocg@pdflastxpos\ocg@pdflastxpos{\the\pdflastxpos} +\newtoks\ocg@pdflastypos\ocg@pdflastypos{\the\pdflastypos} +\newtoks\ocg@pagetoks\ocg@pagetoks{\thepage} + +% \end{macrocode} +% The trick with |\setkeys*| allows to write |[2cm,fg=red]| instead of +% |[width=2cm,fg=red]|. +% \begin{macrocode} +\def\ocgtools@setdefault{\def\ocgt@@ls@bg{\defaultocgpapercolor}% +\def\ocgt@@ls@fg{\defaultocgfontcolor}% +\def\ocgt@@ls@width{0pt}} + \newcommand\ocgtext[3][0pt]{% +\ocgtools@setdefault +\setkeys*{ocg@key}{#1}% +\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi \global\advance\ocgtools@layercount by 1% \ocgtools@ToggleLayer{\the\ocgtools@layercount}% {\leavevmode{\ocgtextstart #2\ocgtextend}}% -\expandafter\write\expandafter\posHandle\expandafter{% -\expandafter\string\expandafter\ocgtoolsplacetext\expandafter{% -\the\ocgtools@layercount}{\thepage}{#1}}% +\edef\ocgtools@act{\write\posHandle{\noexpand\string\noexpand\ocgtoolsplacetext{\the\ocgtools@layercount}{\the\ocg@pagetoks}{width=\ocgt@@ls@width,bg=\ocgt@@ls@bg,fg=\ocgt@@ls@fg}}}% +\ocgtools@act \expandafter\global\expandafter\def \csname ocgtools@textcontent@\the\ocgtools@layercount\endcsname{#3}% } \newcommand\ocgminitextlt[3][0pt]{% -\ocg@minitext@lefttrue\do@ocg@minitext{#1}{#2}{#3}{lt}}% +\ocg@minitext@bottomfalse\ocg@minitext@lefttrue +\do@ocg@minitext{#1}{#2}{#3}{lt}}% \newcommand\ocgminitextrt[3][0pt]{% -\ocg@minitext@leftfalse\do@ocg@minitext{#1}{#2}{#3}{rt}}% +\ocg@minitext@bottomfalse\ocg@minitext@leftfalse +\do@ocg@minitext{#1}{#2}{#3}{rt}}% \newcommand\ocgminitextlb[3][0pt]{% -\ocg@minitext@lefttrue\do@ocg@minitext{#1}{#2}{#3}{lb}}% +\ocg@minitext@bottomtrue\ocg@minitext@lefttrue +\do@ocg@minitext{#1}{#2}{#3}{lb}}% \newcommand\ocgminitextrb[3][0pt]{% -\ocg@minitext@leftfalse\do@ocg@minitext{#1}{#2}{#3}{rb}}% +\ocg@minitext@bottomtrue\ocg@minitext@leftfalse +\do@ocg@minitext{#1}{#2}{#3}{rb}}% \let\ocgminitext\ocgminitextrt \long\def\do@ocg@minitext#1#2#3#4{% +\ocgtools@setdefault +\setkeys*{ocg@key}{#1}% +\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi \global\advance\ocgtools@layercount by 1\relax% \leavevmode \ifocg@minitext@left - \vbox to 0 pt{\kern 0.5\baselineskip\hbox to 0 pt{\hss\pdfsavepos}\vss}% + \ifocg@minitext@bottom + \vbox to 0 pt{\kern 0.7\baselineskip\pdfsavepos\vss}% + \else + \vbox to 0 pt{\vss\pdfsavepos\kern 0.7\baselineskip}% + \fi \fi \ocgtools@ToggleMiniLayer{\the\ocgtools@layercount}% {{\ocgtextstart #2\ocgtextend}}% -\ifocg@minitext@left\else\pdfsavepos\fi -\expandafter\write\expandafter\posHandle\expandafter{% -\expandafter\string\expandafter\ocgtoolsplaceminitext\expandafter -{\the\ocgtools@layercount}{\thepage}{\the\pdflastxpos}% -{\the\pdflastypos}{}{#1}{#4}}% +\ifocg@minitext@left\else + \ifocg@minitext@bottom + \vbox to 0 pt{\kern 0.7\baselineskip\pdfsavepos\vss}% + \else + \vbox to 0 pt{\vss\pdfsavepos\kern 0.7\baselineskip}% + \fi +\fi +\edef\ocgtools@act{\write\posHandle{\noexpand\string\noexpand\ocgtoolsplaceminitext{\the\ocgtools@layercount}{\the\ocg@pagetoks}{\the\ocg@pdflastxpos}{\the\ocg@pdflastypos}{}{width=\ocgt@@ls@width,bg=\ocgt@@ls@bg,fg=\ocgt@@ls@fg}{#4}}}% +\ocgtools@act \expandafter\global\expandafter\def \csname ocgtools@minitextcontent@\the\ocgtools@layercount\endcsname{#3}% }% @@ -853,30 +1015,39 @@ % \end{macrocode} % This code actually gives a graphical representation of the layers. % \begin{macrocode} +\let\ocgtools@pict@envelope\relax \def\ocgtools@drawpicture#1#2{\vbox to \paperheight{\vbox to 0 pt{{% \ocgtools@transparent\color{ocgbg}% \hrule width \paperwidth height \paperheight}\vss}\vss \hbox to \paperwidth{\hss -\setbox\ocgtools@box@a=\hbox{\includegraphics[height=\ocgtools@maxheight]{#1}}% +\setbox\ocgtools@box@a=\hbox{\ocgtools@pict@envelope{% + \includegraphics[height=\ocgtools@maxheight]{#1}}}% \ifdim\wd\ocgtools@box@a>\ocgtools@maxwidth - \includegraphics[width=\ocgtools@maxwidth]{#1}\else \box\ocgtools@box@a + \ocgtools@pict@envelope{\includegraphics[width=\ocgtools@maxwidth]{#1}}% + \else \box\ocgtools@box@a \fi \hss}% \vss \hbox to \paperwidth {\hss\ocgtools@HideLayers{#2}}}} \newdimen\ocg@textdimen - -\long\def\ocgtools@drawtext#1#2#3{\vbox to \paperheight{% +\let\ocgtools@text@envelope\relax +\long\def\ocgtools@drawtext#1#2#3{% +\ocgtools@setdefault +\setkeys*{ocg@key}{#1}% +\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi +\vbox to \paperheight{% \vbox to 0 pt{{\ocgtools@transparent\color{ocgbg}% \hrule width \paperwidth height \paperheight}\vss}\vss\hbox to \paperwidth {\hss -\ocg@textdimen=#1 -\ifdim\ocg@textdimen=0pt - \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}{#2}}% +\ifdim\ocgt@@ls@width=0pt + \setbox\ocgtools@box@a=\hbox{\expandafter\colorbox\expandafter{\ocgt@@ls@bg}% + {\expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@text@envelope{#2}}}% \else - \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}% - {\vbox{\hsize=#1\relax\rightskip 0 pt plus 1 fil\relax #2}}}% + \setbox\ocgtools@box@a=\hbox{\expandafter\colorbox{\expandafter\ocgt@@ls@bg}% + {\vbox{\hsize=\ocgt@@ls@width\relax\linewidth=\ocgt@@ls@width\relax + \rightskip 0 pt plus 1 fil\relax + \expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@text@envelope{#2}}}}% \fi \setbox\ocgtools@box@b\hbox{\resizebox{!}{\ocgtools@maxheight}{\copy\ocgtools@box@a}}% \ifdim\wd\ocgtools@box@b>\ocgtools@maxwidth @@ -886,15 +1057,25 @@ \fi \hss}% \vss -\hbox to \paperwidth {\hss\ocgtools@HideLayers{#3}}}} +\hbox to \paperwidth {\hss\ocgtools@HideLayers{#3}}% +}% +} \def\ocg@empty{} -\newcommand\ocgtools@drawminitext[3]{\ocg@textdimen=#1 -\ifdim\ocg@textdimen=0pt - \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}{#2\ }}% -\else \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}% - {\vbox{\hsize=#1\relax\rightskip 0 pt plus 1 fil\relax #2}}}% +\let\ocgtools@minitext@envelope\relax +\newcommand\ocgtools@drawminitext[3]{% +\@ocgtools@insideminilayertrue +\ocgtools@setdefault +\setkeys*{ocg@key}{#1}% +\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi +\ifdim\ocgt@@ls@width=0pt + \setbox\ocgtools@box@a=\hbox{\colorbox{\ocgt@@ls@bg}{\expandafter\color + \expandafter{\ocgt@@ls@fg}\ocgtools@minitext@envelope{#2}\ }}% +\else \setbox\ocgtools@box@a=\hbox{\colorbox{\ocgt@@ls@bg}% + {\vbox{\hsize=\ocgt@@ls@width\relax\linewidth=\ocgt@@ls@width\relax + \rightskip 0 pt plus 1 fil\relax + \expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@minitext@envelope{#2}}}}% \fi \def\temp{#3}% \ifx\temp\ocg@empty @@ -904,17 +1085,9 @@ \vbox to 0 pt{\hbox to 0 pt{\hss \ocgtools@HideMiniLayer{#3}}\vss}}% \fi +\@ocgtools@insideminilayerfalse } -\ifocgtools@noocg - \renewcommand\ocgpicture[2][]{\leavevmode\includegraphics[#1]{#2}} - \renewcommand\ocgtext[3][0pt]{\leavevmode #2} - \long\def\do@ocg@minitext#1#2#3#4{\leavevmode #2}% - \renewcommand\ocgtoolsplacepicture[3]{} - \renewcommand\ocgtoolsplacetext[3]{} - \renewcommand\ocgtoolsplaceminitext[7]{} -\fi - %</package> % \end{macrocode} % |