Debian Codegraph @

texmf-dist/source/latex/fancytooltips/fancytooltips.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2004-2012 by Robert Marik <[email protected]>
4 % ----------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.2
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.2 or later is part of all distributions of LaTeX
14 % version 1999/12/01 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %<*driver>
20 \ProvidesFile{fancytooltips.dtx}
21 %</driver>
22 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
23 %<package>\ProvidesPackage{fancytooltips}
24 %<*package>
25 [2012/06/12 v1.12 fancytooltips.dtx file]
26 %</package>
27 %
28 %<*driver>
29 \documentclass{ltxdoc}
30 \EnableCrossrefs
31 \CodelineIndex
32 \RecordChanges
33 \OnlyDescription
34 \usepackage{xcolor,graphicx,listings}
35 \usepackage[filename=tip,mouseover,movetips,fg]{fancytooltips}
36 \buttontipwidth=2cm
37 \buttontipheight=2cm
38 \begin{document}
39 \color{black}
40 \DocInput{fancytooltips.dtx}
41 \end{document}
42 %</driver>
43 % \fi
44 %
45 % \CheckSum{1186}
46 %
47 % \CharacterTable {Upper-case
48 % \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 Lower-case
49 % \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 Digits
50 % \0\1\2\3\4\5\6\7\8\9 Exclamation \! Double quote \" Hash (number)
51 % \# Dollar \$ Percent \% Ampersand \& Acute accent \' Left paren \(
52 % Right paren \) Asterisk \* Plus \+ Comma \, Minus \- Point \.
53 % Solidus \/ Colon \: Semicolon \; Less than \< Equals \= Greater than
54 % \> Question mark \?
55 % Commercial at \@ Left bracket \[ Backslash \\
56 % Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left
57 % brace \{ Vertical bar \| Right brace \} Tilde \~}
58 %
59 %
60 % \changes{v1.0}{2007/02/15}{Initial version}
61 %
62 % \changes{v1.1}{2007/02/20}{Clener code, better documentation, fix
63 % for bug with delayinterval macro, support for dvips and Distiller
64 % users.}
65 %
66 % \changes{v1.2}{2007/03/01}{Better support for dvips users, buttons
67 % for icons are created automatically using eso-pic package and have
68 % the name "ikona.pagenumber", new option \texttt{movetips}, tooltip
69 % appears on the current page only and, as a consequence, animations
70 % are faster.}
71 %
72 % \changes{v1.3}{2007/05/08}{Fixed bug which appears in dvips route.
73 % Improved documentation -- added a note about the required version
74 % of eforms.sty}
75 %
76 % \changes{v1.4}{2009/04/29}{Added support for presentations (like
77 % \texttt{pause} command for texpower).}
78 %
79 % \changes{v1.5}{2009/05/05}{Handling number of pages via aux file
80 % (fixes some problems issued by previous modification and page
81 % break near tooltip).}
82 %
83 % \changes{v1.6}{2010/04/10}{Added options \texttt{debug},
84 % \texttt{active} and \texttt{inactive}, added an example with
85 % automatic previews for equations and floats. Added handling of
86 % this.dirty and app.focusRect. Changed the name of the file with
87 % tooltips. Added starred version of \texttt{tooltip} command.}
88 %
89 % \changes{v1.7}{2010/05/20}{Added options \texttt{blur} and
90 % \texttt{fg}, cleaned some command names}
91 %
92 % \changes{v1.8}{2010/06/10}{Added hook do insert stuff on each page.}
93 %
94 % \changes{v1.9}{2011/12/04}{Changed expansion in the new |\ref|
95 % command provided by |FancyHook| macro (see |fancy-preview|
96 % facility).}
97 %
98 % \changes{v1.10}{2012/05/09}{New script preview-latex. New options
99 % |previewall| and |nosoap|.}
100 %
101 % \changes{v1.11}{2012/05/11}{Fixed bug related to bad position if
102 % |fg| option is used and \texttt{evensidemargin} is different from
103 % \texttt{oddsidemargin}.}
104 %
105 % \changes{v1.12}{2012/06/12}{Documentation updated. New option
106 % |tooltipmark|.}
107 %
108 % \GetFileInfo{fancytooltips.dtx}
109 %
110 % \DoNotIndex{\newcommand,\newenvironment}
111 %
112 %
113 % \title{The \textsf{fancytooltips} package, the \textsf{fancy-preview} script\thanks{This document
114 % corresponds to \textsf{fancytooltips}~\fileversion, dated
115 % \filedate.} \thanks{Supported by grants 18/2006, 99/2008 and 131/2010
116 % of Higher
117 % Education Development Fund (FRV\v S) }} \author{Robert Ma\v r\'\i k \\
118 % \texttt{[email protected]}}
119 %
120 % \maketitle
121 %
122 % \setcounter{tocdepth}{2}\tableofcontents\rightskip=0em plus 0.2em\sloppy
123 % \section{Introduction}
124 %
125 % The \LaTeX{} package |fancytooltips| allows to insert tooltips into
126 % PDF documents -- a popup windows appears if the mouse hovers or
127 % clicks particular area. You can use plain text as well as
128 % mathematics, pictures and animations in your tooltips. The PDF
129 % viewer must interpret Javascripts to make the tooltips work. This is
130 % currently true only for (free) Abobe Reader and (commercial) Adobe
131 % Acrobat. There are two ways how to produce the PDF file. The
132 % simplest way is to use |pdflatex|. Another option is |latex| +
133 % |dvips| + AdobeDistiller\footnote{not free |ps2pdf|} + Adobe
134 % Acrobat\footnote{not free Adobe Reader.}.
135 %
136 % \color{black}Here you can test two tooltips: \tooltip{Einstein's
137 % formula}{1} and simple \tooltipanim{animation}{2}{7} (numbers from 1
138 % to 6). For more examples how the presentation may look like see the
139 % |examples| subdirectory. We also provide a Perl script
140 % |fancy-preview| which allows to extract equations, theorems and
141 % related parts of text into separate PDF file and insert tooltips
142 % after each |\ref|, |\eqref| and |\cite| command automatically. For
143 % more information see Figure \ref{fig:1} and demos (scientific
144 % papers, presentations, tests) at
145 % \url{http://user.mendelu.cz/marik/fancy-preview}.
146 %
147 % Related \LaTeX{} packages are |cooltooltips|, |pdfcomment| (smaller
148 % size of the resulting PDF, but restricted to plain text), |ocgtools|
149 % (works with layers, only |pdflatex| is supported) and Acro\TeX{}
150 % (works with layers, only |latex| + |dvips| + Adobe Distiller + Adobe
151 % Acrobat are supported). All these ``similar'' packages allow to
152 % write the text for the tooltips inside the main document. In
153 % contrast to this approach, |fancytooltips| package makes use of an
154 % external file. This allow to use graphics or mathematical
155 % expressions in the tooltips.
156 %
157 % The package requires |eforms.sty| and |insdljs.sty| packages, which
158 % are part of AcroTeX bundle
159 % (\url{http://www.math.uakron.edu/~dpstory/webeq.html}).
160 %
161 % \section{Usage of \texttt{fancytooltips.sty}}
162 % \subsection{Small technical background}
163 %
164 % \begin{itemize}
165 % \item The pages from the external PDF file with tootlips are
166 % inserted as icons at hidden buttons into the resulting
167 % PDF.
168 % \item If you insert tooltip, the current page is covered by an
169 % invisible transparent button which spans across the whole page
170 % (the information about the pages with tooltips is stored in |aux|
171 % file and hence we have to run \LaTeX{} \textit{three times}). The
172 % button has an associated JavaScript action to close all tooltips
173 % (i.e. make itself and other related buttons hidden).
174 % \item Another button which reveals tooltip is created. This button
175 % is transparent, covers the text typeset by \TeX{} and allows to
176 % activate a JavaScript. This JavaScript takes the picture required,
177 % puts this picture as icon to the button which covers the
178 % corresponding page and makes this button visible.
179 % \item Each page has an associated action which closes all tooltips
180 % when the page is opened.
181 % \end{itemize}
182 %
183 % \subsection{The file with tooltips}
184 % The file with tooltips is an ordinary PDF file, one tooltip per
185 % page. Tooltips should be in the top right corner at the page, in a
186 % \textit{box with nontransparent background} and the rest of the page
187 % should be transparent. If you consider to use |movetips| option
188 % which causes the tooltip appear near the mouse cursor instead of in
189 % the top right corner (see below), then every page should have the
190 % dimensions equal to the dimensions of the colored box with
191 % tooltip\footnote{Look at the files \texttt{tooltipy.tex} and
192 % \texttt{tooltipy.pdf} from |examples| subdirectory for a simple
193 % example how to meet this condition under pdf\LaTeX. You may also use
194 % ordinary \LaTeX{} class, set \texttt{\textbackslash pagestyle\{empty\}} and crop the boundary.}. You can
195 % call the tooltips by their page numbers, but for better comfort we
196 % also provide simple cross referencing mechanism. If the pdf file is
197 % created by \LaTeX, \DescribeMacro{\keytip} you can define keywords
198 % to refer to the pages using |\keytip| command. Simply put
199 % |\usepackage[createtips]{fancytooltips}| into preamble and write
200 % \texttt{\string\keytip}\marg{foo} in document. This writes
201 % information about keyword \meta{foo} and the pagenumber into file
202 % |\jobname.tips|. See
203 % \url{http://user.mendelu.cz/marik/fancytooltips} for some tooltip
204 % templates.
205 %
206 % \subsection{The file with presentation}
207 % In the file with presentation, the user is responsible to
208 % \begin{itemize}
209 % \item input either |color| or |xcolor| package in the
210 % preamble
211 % \item \LaTeX{} the file two times (we write some macros into |aux|
212 % file) or three times (if option |fg| is used).
213 % \end{itemize}
214 % You may use the following options to set the necessary information
215 % and change the default behavior of the package.
216 %
217 % \def\iitem#1{\item[{\color{blue!50!black}\texttt{#1}}]}
218 % \begin{description}\sloppy\rightskip 0 pt plus 1 em
219 % \iitem{filename} To input the tooltips from file \meta{foo.pdf}
220 % call the package with |filename| option:
221 % |\usepackage[filename=foo]{fancytooltips}|. This option is
222 % required if compiled with |pdflatex|.
223 %
224 % \iitem{movetips} By default, tooltip appears in the
225 % top right corner of the page (use View--PageLayout-Single Page in
226 % your Adobe Reader, please). If the option |movetips| is used, then
227 % tooltip appears close to the mouse pointer. More precisely, tooltip
228 % appears with left down corner at the mouse position, if there is
229 % enough place. If not, tooltip appears with right down corner at the
230 % mouse position. Finally, the tooltip is shifted down to fit the
231 % page, if necessary\footnote{This option works in this way if every
232 % page of the file with tooltips has dimensions of the box with
233 % tooltip. See the \texttt{examples} subdirectory.}.
234 %
235 %
236 % \iitem{mouseover} If you use |mouseover| option,
237 % then tooltip appears if you move the mouse pointer to the active
238 % area (no clicking is necessary).
239 %
240 % \iitem{inactive} This option makes the package
241 % inactive.
242 %
243 % \iitem{active} This option forces the package
244 % active even if |inactive| option is loaded.
245 %
246 % \iitem{blur} The rest of the page is blurred, when showing
247 % tooltip. Use either |\usepackage[blur]{fancytooltips}| or
248 % |\usepackage[blur=number]{fancytooltips}|, where |number| is
249 % a number between 0 and 1. (Note that we use transparent package
250 % and hence this could have an influence on the colors of the
251 % document and could make your PDF less portable.) This option is
252 % allowed in pdf\LaTeX{} mode only. If this options brakes colors
253 % only on the page which include tooltips, you may want to use
254 % option |fixcolor| to fix it.
255 %
256 % \iitem{fixcolor} See |blur| option.
257 %
258 % \iitem{debug} Prints two alerts reporting success or problems when
259 % opening PDF file in Adobe Acrobat (Adobe Reader). Use this option
260 % to find possible source of problems. See also the Section
261 % \ref{sec:tr} in this manual.
262 %
263 % \iitem{noextratext} No mark is appended at the end of the link
264 % which opens tooltips (see help for |\tooltip|).
265 %
266 % \iitem{nosoap} A single space is used to occupy the space for
267 % button produced by |\tooltip*| command instead of blue soap. As a
268 % result, the button produced by |\tooltip*| works as usual, but it
269 % is invisible. This is sometimes convenient for the user, since the
270 % mark does not disturb the text. However, the author has to
271 % instruct the user, that the hidden buttons follow links from
272 % cross references.
273 %
274 % \iitem {fg} The button for displaying pictures is placed on
275 % background and the buttons which activate tooltips are placed
276 % immediately in the text by default. With |fg| option all these
277 % buttons are placed into foreground after the page is completed. We
278 % use |\pdfsavepos| command and keep track of the position for
279 % buttons in aux file and hence this option works in pdf\LaTeX\ only
280 % and the file needs more compilations. This option does not do
281 % anything in dvi mode now (despite the fact that pdf\LaTeX\
282 % provides the feature also for dvi mode), but this could be changed
283 % if someone requests this feature. Use this option for example, if
284 % you use frame around hyperlinks or buttons and form fields in your
285 % PDF (like tests produced by Acro\TeX).
286 %
287 % \iitem{preview} Redefines |\ref|, |\eqref| and |\cite| commands to
288 % work with tooltips extracted by |fancy-preview|, see Section
289 % \ref{sec:fancy-preview} and demo files in |example/fancy-preview|
290 % directory. The tooltip is inserted only if the target of the
291 % reference is on different PDF page as the tooltip. This option is
292 % suitable for presentations where the whole PDF page is
293 % visible. Replaces former |\FancyHook| command.
294 %
295 % \iitem{previewall} Like |preview| but shows tooltip also if the
296 % target is on the same page. Suitable for enhanced versions of
297 % papers written on A4 page.
298 %
299 % \def\aaa#1{#1\hbox
300 % {\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
301 % {fancytipmark#1.pdf}}}}} \iitem{tooltipmark} Allows to change the
302 % tooltipmark to some predefined styles, values are \aaa1, \aaa2,
303 % \aaa3 and \aaa4. Note that you can change the mark to whatever
304 % different by redefining |\TooltipExtratext| command. Work only in
305 % pdflatex mode.
306 %
307 % \end{description}
308 %
309 % \DescribeMacro{\tooltip} The user can put the tooltip into her or
310 % his presentation using the command
311 % \texttt{\string\tooltip}{\marg{stuff}\marg{keyword-or-pagenumber}}
312 % where \meta{stuff} is the printed text in \meta{tooltipcolor} color
313 % and \meta{keyword-or-pagenumber} is either the pagenumber of the
314 % tooltip in the external file or the keyword defined by |\keytip|
315 % command and stored in |\TooltipFilename.tips| file, where
316 % |\TooltipFilename| is set automatically from the |filename| option.
317 % \DescribeMacro{\TooltipExtratext} The printed text \meta{stuff} is
318 % followed by |\TooltipExtratext| command. The default value is small
319 % blue soap, as you have seen in the second paragraph of this
320 % documentation. There is a |noextratext| option which defines
321 % |\TooltipExtratext| to be empty. \DescribeMacro{noextratext option}
322 % If \marg{keyword-or-pagenumber} is not recognized as valid keyword
323 % for tooltips, it is supposed to be pagenumber.
324 %
325 % The text \marg{stuff} is inserted in |\hbox| by
326 % |\tooltip|. \DescribeMacro{\tooltip*}With starred version of the
327 % |\tooltip| macro the text \marg{stuff} is not inserted into the box
328 % and the active button dos not cover the text \marg{stuff}, but
329 % covers the mark produced by |\TooltipExtratext|.
330 %
331 % \DescribeMacro{\tooltipanim}\DescribeMacro{\tooltipanim*} The user
332 % can put a series (animation) of tooltips into the presentation by
333 % using \texttt{\string\tooltipanim}\marg{stuff}\marg{start}\marg{end}
334 % command, where \meta{start} and \meta{end} are keywords defined by
335 % |\keytip| command or page numbers. \DescribeMacro{\delayinterval}
336 % The delay between two frames is |\delayinterval| milliseconds. The
337 % default value is 200, you can change it by command
338 % |\def\delayinterval{100}|. There is also starred version which works
339 % similarly like |\tooltip*| command.
340 %
341 % \DescribeMacro{\TooltipRefmark} Extra text added to |\ref|, |\eqref|
342 % and |\cite| commands with previews, see Section
343 % \ref{sec:fancy-preview}. The default value is the same as for
344 % |\TooltipExtratext|.
345 %
346 % \subsubsection{Changes for dvips users}
347 % Dvips users also have to prepare tooltips into PDF file, not eps as
348 % usual. But we have to insert these tooltips in Adobe Acrobat Pro
349 % program. If you use Acrobat Pro version 8.1 and later, install the
350 % file \texttt{aeb.js} from AcroTeX eDucation bundle as described in
351 % the documentation to AcroTeX.\footnote{If you do not install
352 % \texttt{aeb.js} properly, you can still create your presentation,
353 % but you have to import the |fdf| file manually, see the section
354 % Troubleshooting and known problems.}
355 %
356 % Since \LaTeX{} is not capable to find the number of pages in
357 % external PDF file with tooltips, \DescribeMacro{dvips}dvips users have to specify option
358 % |dvips| in |fancytooltips| package. \DescribeMacro{pages} You have
359 % to use also a |pages| option with the number of pages in the PDF
360 % file with tooltips, if you use dvips route. You have to call the
361 % package by
362 % something like this:\\
363 % |\usepackage[dvips,filename=tooltipy,pages=27]{fancytooltips}|
364 %
365 % You have to |latex| (two times) and |dvips| your file first. This
366 % produces |filename.ps| and |Tooltipsdljs.fdf| files. Distill the
367 % |filename.ps| file into |filename.pdf| and open this file by Adobe
368 % Acrobat Professional -- this imports macros from |Tooltipsdljs.fdf|
369 % file. In Acrobat's JavaScript console (open by |Crtl+J|) run (using
370 % |Ctrl+Enter|) the command |ImportTooltips();| which is defined for
371 % the document. This command inserts invisible buttons on the first
372 % page, imports icons (the file with icons specified as
373 % \meta{filename} parameter when loading fancytooltips must be in
374 % working directory). You should see a message ``\texttt{importing
375 % pictures}'' and the command returns 1 when finished. Then
376 % \textbf{save the file} (you can use the same name). If the command
377 % |ImportTooltips();| fails, you either have not the PDF file with
378 % tooltips in current directory, or the PDF file does not contain
379 % JavaScripts. In the latter case insert document level JavaScripts
380 % manually as described in the Section \ref{sec:tr}.
381 %
382 % \section{Tootlips at
383 % references: \texttt{fancy-preview}} \label{sec:fancy-preview}
384 % \subsection{Basic usage}
385 % There is a Perl script |fancy-preview| which can be used to extract
386 % text from bibliography items, numbered equations, numbered theorems,
387 % lemmas, etc, put this text into separate PDF file and add this text
388 % as tooltips to the corresponding |\ref|, |\eqref| and |\cite|
389 % commands. Reading the resulting file may look like on Figure
390 % \ref{fig:1}.
391 % \begin{figure}
392 % \centering
393 %\fbox{\includegraphics[width=0.95\textwidth]{cite.png}}
394 % \caption{\texttt{fancy-preview}}
395 % \label{fig:1}
396 % \end{figure}
397 %
398 %
399 % The script |fancy-preview| has been tested with Texlive2011 on both
400 % Linux and MS Windows. To run this script you need working Perl
401 % installation (usually present on Linux workstations, on MS Windows
402 % you may need to install Perl from
403 % \url{http://www.activestate.com/activeperl}) and |Config::IniFiles|
404 % module\footnote{Package |libconfig-inifiles-perl| on Ubuntu Linux,
405 % |cpan Config::IniFiles| or |ppm install Config::Inifiles| on MS
406 % Windows. Alternatively you can run |ppm| without any parameters to
407 % invoke the GUI.})
408 %
409 % To compile your document |file.tex| do the following
410 % \begin{itemize}
411 % \item Put |\usepackage{hyperref}| into the preamble of your document
412 % (if not already loaded).
413 % \item If you write references in |thebibliography| environment, put
414 % empty line after each |\bibitem| command (including the last item
415 % in |thebibliography|).
416 % \item Run |fancy-preview file|. After several compilations you
417 % should get the PDF file |file.pdf|.
418 % \end{itemize}
419 % The default work-flow is the following. The file is compiled with
420 % |pdflatex| to get correct numbers of equations and in the first
421 % pass of |preview.sty| we extract displayed equations (but the
422 % numbers are thrown away). After this we crop the PDF file by using
423 % |pdfcrop| program (an alternate program can be specified as
424 % optional parameter). Then we extract numbered environments
425 % (theorem, Theorem, lemma, corollary, definition, figure, table)
426 % using the second pass and crop the PDF file again. After this we
427 % merge all equations, theorems etc which are marked with |\label|
428 % command. The PDF file with extracted parts of the text is the used
429 % as source of toltips in final compilations.
430 %
431 % Many things can be customized. The following options are
432 % available.
433 % \begin{description}
434 % \iitem{pdfcrop} You may specify an alternative batch file to crop
435 % boundary of PDF file. Default is |pdfcrop|. The command line for
436 % an alternative program to crop PDF file is supposed to be the
437 % following: |programname input.pdf output.pdf|. Using optimal
438 % program to PDF file may be much fasater and may produce
439 % significantly smaller files. \iitem{tooltips} You may combine
440 % the tooltips extracted by |fancy-preview| with ``ordinary hand
441 % made tooltips''. Simply call |fancytooltips| in the main document
442 % by |\usepackage[inactive]{fancytooltips}| in your document and
443 % specify the file with tooltips in the command line of the
444 % |fancy-preview| or in the |ini| file. You may also compile your
445 % file by |pdflatex| and get ``normal'' PDF output (the compilation
446 % is way faster). \iitem{fancy\underline{ }options} Options passed
447 % |fancytooltips| in final compilations. Default is
448 % |previewall,nosoap|. Options |mouseover| and |movetips| are added
449 % automaticaly.\iitem{ini\underline{ }file}Specifices the |ini| file
450 % with configuration, see the next subsection.
451 % \end{description}
452 % \subsection{Configuration from ini files}
453 % Other customization can be done via |ini| files. The script looks
454 % for customizations in the file specified by |ini_file| command line
455 % parameter. If this parameterer is not used, the script looks for
456 % customization in two default locations: |~/.fancy-preview.ini| and
457 % in |./fancy-preview.ini| (both files are used if both exist). You
458 % can use |~/.fancy-preview.ini| for customizations related to all
459 % your projects and |./fancy-preview.ini| for projects in the current
460 % directory. The options from the file
461 % |./fancy-preview.ini| override |~/.fancy-preview.ini| and the
462 % options from command line override options from
463 % |./fancy-preview.ini|. The format is described at
464 % \url{http://search.cpan.org/~shlomif/Config-IniFiles-2.75/lib/Config/IniFiles.pm}.
465 %
466 % The parameters are divided into two sections, |[main]| and |[latex]|.
467 % In section |[main]| of |ini| file you can set parameters |pdfcrop|,
468 % |tooltips| and |fancy_options|.
469 %
470 % In the section |[latex]| if the initialization file you can
471 % customize the compilation by \LaTeX. Here you can set parameters
472 % |environments| and |snarfenvironments| to set the environments which
473 % will be extracted. The default values are
474 % |environments=Theorem,theorem,lemma,corollary,definition| and
475 % |snarfenvironments=figure|.
476 %
477 % The material from |tex| file is extracted in three passes. These
478 % passes are denoted by |a|, |b| and |c|. If
479 % \texttt{\string\label}\marg{foo} appears in the text which is marked
480 % for extraction, then the corresponding
481 % \texttt{\string\newlabel}\marg{foo} command is written to the |aux|
482 % file and \meta{foo} is supposed to be the name of the keyword
483 % corresponding to the PDF page with the text.
484 %
485 % If a referenced material appears in more passes, then the priority
486 % is set in the variable |$latex{'pass_order'}| and can be customized
487 % in the ini file in |[latex]| section as |pass_order| parameter. The
488 % default value is |pass_order=acb|, i.e. |c| overrides |b| and |a|
489 % overrides |c|.
490 %
491 % As a typical example consider equation with label |\label{eq}| in
492 % numbered theorem with label |\label{th}|. The equation is extracted
493 % in pass |a| (displayed equation) and in pass |b| (the whole
494 % theorem). The corresponding |\newlabel{eq}| command appers in two
495 % |aux| files -- from passes |a| and |b|. The first one corresponds to
496 % the PDF page with equation, the latter to the PDF page with whole
497 % theorem. Since |a| overrides |b|, then |\ref{eq}| and |\eqref{eq}|
498 % commands show the number of the equation followed by the tooltip
499 % with equation only. Further |\ref{th}| shows number of the theorem
500 % followed by the tooltip with the whole theorem. If you set |pass_order=ba|, then both |\ref{eq}| and |\ref{th}| are followed by the
501 % same tooltip.
502 %
503 % The following options are available\footnote{These
504 % options are used as keywords in a hash variable \texttt{latex}, i.e. for
505 % default value of \texttt{param} parameter search the file \texttt{fancy-preview}
506 % for \texttt{\$latex\{'param'\}}.}.
507 %\begin{itemize}
508 % \iitem {a} Defines commands for the first pass. It
509 % inserts |preview.sty| command which extracts displayed
510 % mathematics. Also resets |\tagform@| and |\@eqnnum| to skip
511 % printing of equation numbers.
512 % \iitem {a\underline{ }extra} Defines material which is appended to |a|
513 %
514 % \iitem {b} Defines commands fot the second pass. In this \LaTeX{}
515 % run are (by default) floating figures and theorem-like environments
516 % extracted. Inserts |preview.sty|. At the runtime,
517 % |\PreviewEnvironment[{[]}]{env}| and
518 % |\PreviewSnarfEnvironment[{[]}]{env}| for each |env| in comma
519 % separated list from |environments| and |snafenvironments| is added,
520 % respectively.
521 % \iitem {b\underline{ }extra} Defines material which is appended to |b|
522 %
523 % \iitem{environments} See |b| option.
524 %
525 % \iitem{snarfenvironments} See |b| option. Default value is |figure|.
526 %
527 % \iitem {c} If empty (default value), then the third pass is
528 % skipped. Otherwise, you may activate |preview.sty| similarly like in
529 % |b| (for a template see the source code and the default setting of
530 % |$latex{'b'}|) and extract environments and commands according to
531 % your interest. A possible application is to extract |minipage|
532 % environments, if there are two or more figures inserted in
533 % |minipage| environments into one |figure| environment.
534 %
535 % \iitem{pass\underline{ }order} Sets priority, which pass is supposed
536 % to produce the output for a |\label| which is extracted more times
537 % than once, see the previous paragraphs for explanation and example.
538 %
539 % \iitem{preview\underline{ }bibitem} Redefines |\bibtem| command. The
540 % material between |\bibitem| and |\par| is wrapped to the width of
541 % |0.75\textwidth| and extracted.
542 %
543 % \iitem{preview\underline{ }biblatex} Similarly like
544 % |preview_bibitem| but works with |biblatex|.
545 %
546 % \iitem{ini} Inserted at the begin of each |pdflatex| run.
547 %
548 % \iitem{tooltips\underline{ }envelope\underline{ }preamble} Used in
549 % preamble. Defines command |\tooltipwraper|. This command wraps the
550 % tooltips. Default is to use |tikz| to put everything into a yellow
551 % box with rounded corners and shading.
552 %
553 % \iitem{biblatex} Creates temporary file
554 % |fancy-preview-biblatex-settings.tex|. This file contains definition
555 % which allow |biblatex| to work with citations and tooltips and we
556 % input this file in final compilations. This code comes from
557 % |tex.stackexchange.com|.
558 %\end{itemize}
559 %
560 %
561 %
562 % \subsection{Tips and tricks}
563 % \begin{itemize}
564 % \item The program |pdfcrop| from \TeX live may produces large PDF
565 % files. See the discussion at
566 % \url{http://tex.stackexchange.com}\footnote{\url{http://tex.stackexchange.com/questions/42236/pdfcrop-generates-larger-file}}. The
567 % smaller size can be obtained with the solution from the discussion
568 % below the question, which is based on |gs| and |pdftk|. The
569 % |python| script from the same discussion produces slightly larger
570 % file than |pdftk|, but still much smaller than |pdfcrop| and
571 % provides the fastest solution.
572 % \item Do not use floats in environments, which are
573 % extracted. Otherwise you get an error from \LaTeX. A workaround
574 % could be also to change temporarily definition of the floating
575 % environment (redefine |figure| environment, for example).
576 % \item If you are not interested in customization via |ini| files and
577 % do not want to install extra modules to your Perl installation,
578 % you may delete the about twenty lines from |fancy-preview|
579 % starting with |use Config::IniFiles;| up to the line
580 % |read_config("./fancy-preview.ini");|
581 % \end{itemize}
582 %
583 % \section{Troubleshooting and known problems}\label{sec:tr}
584 % The source code is in Mercurial repository at
585 % \url{http://bitbucket.org/robert.marik/fancytooltips/}. You can also
586 % report problems and issues in the forum at this site. The code on
587 % |bitbucket.org| is considered as development version and repository
588 % for older versions. The last stable version is always the version
589 % from CTAN.
590 % \begin{itemize}
591 % \item
592 % The package works with |eforms.sty| from version
593 % 2006/10/03 v1.0a. You can download this or newer version from
594 % \url{http://www.acrotex.net} site.
595 % \item If the graphics included by |\TooltipExtratext| and
596 % |\TooltipRefmark| has colors with \textbf{custom opacity}, Adobe
597 % Acrobat Pro sometimes renders the pictures bad. No problems of
598 % this type have been observed with free Adobe Reader.
599 % \item For \textbf{dvips} users: In some cases the file
600 % |Tooltipsdljs.fdf| is \textbf{not imported automatically}
601 % (probably some setting in Adobe Acrobat or new versions of
602 % |eforms.sty| and |insdljs.sty|). In this case you do not see any
603 % message when using |debug| option. You have troubles of this type
604 % if you see in the Javascript console (Ctrl+J) error messages like
605 % ``\texttt{aebTrustedFunctions is not defined 3:Page:Open
606 % CloseTooltips is not defined 1:Page:Open}''. In this case you
607 % have to import the file |Tooltipsdljs.fdf| \textbf{manually from
608 % ``Form'' menu} in Adobe Acrobat Pro. Then go to the JavaScript
609 % console and run |ImportTooltips();| command.
610 % \end{itemize}
611 %
612 % Follow the points below if you want to find the source of your
613 % problems.
614 % \begin{itemize}
615 % \item For dvips users it is a good idea to check that Acro\TeX{} is
616 % properly installed. Do the demo files from Acro\TeX{} work for you?
617 % \item Try to use |debug| option, prepare the PDF file and open it in
618 % Adobe Acrobat or Adobe Reader.
619 % \begin{itemize}
620 % \item You should see two messages when opening the file. If not,
621 % the Javascript do not work in your document (are not inserted
622 % properly).
623 % \item Both messages should report success for pdflatex users. For
624 % dvips users one of the message should report error and if you
625 % run |ImportTooltips();| command in Javascript console, you should
626 % see a message in Javascript console which confirms that the
627 % pictures from external PDF file have been imported. If you save
628 % the PDF file and open again, both messages should report
629 % success.
630 % \end{itemize}
631 % \end{itemize}
632 %
633 % \PrintChanges
634 % \StopEventually{}
635 %
636 % \section{Implementation}
637 % \begin{macrocode}
638 %<*package>
639 \RequirePackage{graphicx}
640 \RequirePackage{xkeyval}
641 \RequirePackage{atbegshi}
642
643 \newif\if@fancytooltips@createtips\@fancytooltips@createtipsfalse
644 \DeclareOptionX{createtips}{\@fancytooltips@createtipstrue}
645
646 \newif\ifTooltip@usepdftex\Tooltip@usepdftextrue
647 \DeclareOptionX{dvips}{\Tooltip@usepdftexfalse}
648
649 \newif\if@fancytooltips@extratext\@fancytooltips@extratexttrue
650 \DeclareOptionX{noextratext}{\@fancytooltips@extratextfalse}
651
652 \newif\if@fancytooltips@movetips\@fancytooltips@movetipsfalse
653 \DeclareOptionX{movetips}{\@fancytooltips@movetipstrue}
654
655 \newif\if@fancytooltips@mouseover\@fancytooltips@mouseoverfalse
656 \DeclareOptionX{mouseover}{\@fancytooltips@mouseovertrue}
657
658 \newif\if@fancytooltips@inactive\@fancytooltips@inactivefalse
659 \DeclareOptionX{inactive}{\@fancytooltips@inactivetrue}
660
661 \newif\if@fancytooltips@active\@fancytooltips@activefalse
662 \DeclareOptionX{active}{\@fancytooltips@activetrue}
663
664 \newif\if@fancytooltips@fg\@fancytooltips@fgfalse
665 \DeclareOptionX{fg}{\@fancytooltips@fgtrue}
666
667 \DeclareOptionX{filename}{\xdef\TooltipFilename{#1}}
668 \DeclareOptionX{pages}{\xdef\TooltipPages{#1}}
669
670 \newif\if@fancytooltips@blur\@fancytooltips@blurfalse
671 \DeclareOptionX{blur}[0.4]{\@fancytooltips@blurtrue
672 \xdef\fancytooltips@transparency{#1}}
673
674 \newif\if@fancytooltips@fixcolor\@fancytooltips@fixcolorfalse
675 \DeclareOptionX{fixcolor}{\@fancytooltips@fixcolortrue}
676
677 \newif\if@fancytooltips@preview\@fancytooltips@previewfalse
678 \DeclareOptionX{preview}{\@fancytooltips@previewtrue}
679
680 \newif\if@fancytooltips@previewall\@fancytooltips@previewallfalse
681 \DeclareOptionX{previewall}{\@fancytooltips@previewtrue\@fancytooltips@previewalltrue}
682
683 \newif\if@fancytooltips@nosoap\@fancytooltips@nosoapfalse
684 \DeclareOptionX{nosoap}{\@fancytooltips@nosoaptrue}
685
686 \def\@@fancytipmark{}
687 \DeclareOptionX{tooltipmark}{\xdef\@@fancytipmark{#1}}
688
689 \def\fancytooltipsdebugmsg{}
690 \DeclareOptionX{debug}{\def \fancytooltipsdebugmsg
691 {
692 if (this.getField("ikona") == null)
693 {app.alert("No buttons for placing tootlips are available. Contact the author. The file may need more compilations.");}
694 else
695 {app.alert("Buttons for placing tooltips are available. Congratulations! Hope everything will work.");}
696 if (this.getField("animtiph") == null)
697 {app.alert("No hidden buttons containing tooltips available. The interactive features will not work. \n\n If you created the file by dvips, run the command ImportTooltips() in the Javascript console (Ctrl+J, write the command followed by semicolon and Ctrl+Enter).");}
698 else
699 {app.alert("Hidden buttons containing tooltips are available. Congratulations! Hope everything will work.");}
700 }}
701
702 \ProcessOptionsX
703
704 \if@fancytooltips@blur
705 \ifTooltip@usepdftex\else
706 \@fancytooltips@blurfalse
707 \AtEndDocument{\PackageWarning{fancytooltips}
708 {Blur option is incompatible with dvips. ^^J The option blur is turned off }}
709 \fi
710 \fi
711
712 \ifTooltip@usepdftex\else
713 \@fancytooltips@fgfalse
714 \fi
715
716 \newdimen\buttontipwidth
717 \newdimen\buttontipheight
718 \newdimen\fancy@a
719 \newdimen\fancy@b
720 \newdimen\fancy@layerHshift\fancy@layerHshift=0pt
721 \newdimen\fancy@layerVshift\fancy@layerVshift=0pt
722 \newdimen\fancy@button@Vshift \fancy@button@Vshift=0pt
723 \newdimen\fancy@button@Hshift \fancy@button@Hshift=0pt
724 \newtoks\pos@fancy@toks
725
726 \if@fancytooltips@active\@fancytooltips@inactivefalse\fi
727
728 \if@fancytooltips@inactive
729 \newcommand{\tooltip}{\@ifstar\tooltip@Star\tooltip@NoStar}%
730 \newcommand{\tooltip@Star}[2]{#1}%
731 \newcommand{\tooltip@NoStar}[2]{#1}%
732
733 \newcommand{\tooltipanim}{\@ifstar\tooltipanim@Star\tooltipanim@NoStar}%
734 \newcommand{\tooltipanim@Star}[3]{#1}%
735 \newcommand{\tooltipanim@NoStar}[3]{#1}%
736 \def\keytip#1{}%
737 \def\TooltipPage#1#2{}%
738 \let\TooltipExtratext\relax
739 \let\TooltipRefmark\relax
740 \ifx\@ocg@makeknown\undefined
741 \def\@ocg@makeknown#1#2#3{}\fi
742 \def\fancy@@pushButton#1#2#3#4#5#6#7#8{}
743 \def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{}
744
745 \PackageWarning{fancytooltips}{Fancytooltips inactive}%
746 \expandafter\endinput\fi
747
748 % \end{macrocode}
749 % Each |\ref| command has associated a number and writes new label
750 % into aux file. If the target page for the ref is different from the
751 % page with this |\ref| command, the corresponding tooltip is inserted.
752 % \begin{macrocode}
753 \newcount\fancycheckcount\fancycheckcount=0
754 \def\fancy@second#1#2#3#4{#2}
755
756 \def\fancypreview@refhook{%
757 \global\let\oldref\ref
758 \gdef\ref##1{\oldref{##1}\global\advance\fancycheckcount by 1\relax
759 \edef\templabel{fancyanchorref:\the\fancycheckcount}%
760 \expandafter\label\expandafter{\templabel}%
761 \expandafter\ifx \csname FancyToolTip@##1\endcsname\relax \else\hbox to 0 pt{%
762 % \end{macrocode}
763 % Here we extract the page number for the label destination.
764 % \begin{macrocode}
765 \expandafter\ifx \csname r@##1\endcsname \relax\else
766 \expandafter\let\expandafter\fancytooltip@temp@a\csname r@##1\endcsname
767 \edef\fan@tempa{\expandafter\fancy@second\fancytooltip@temp@a}%
768 \fi
769 % \end{macrocode}
770 % Here we extract the page number of the |\ref| command via faked label |fancyanchorref:\the\fancycheckcount|.
771 % \begin{macrocode}
772 \expandafter\ifx \csname r@fancyanchorref:\the\fancycheckcount\endcsname \relax\else
773 \expandafter\let\expandafter\fan@temp@w\csname r@fancyanchorref:\the\fancycheckcount\endcsname
774 \edef\fan@temp@ww{\expandafter\fancy@second\fan@temp@w}%
775 \fi
776 % \end{macrocode}
777 % We print tooltip after |\ref| only if both |\label| and |\ref| commands are on different pages
778 % \begin{macrocode}
779 \if@fancytooltips@previewall\def\fan@tempa{not a page number}\fi
780 \ifx\fan@tempa\fan@temp@ww\else\smash{%
781 \let\TooltipExtratext\relax\tooltip{\strut\TooltipRefmark}{##1}}%
782 \fi
783 \hss}%
784 \fi}%
785 % \end{macrocode}
786 % We replace the cite command. We test if natbib is loaded, if not, we redefine the command from article.cls.
787 % \begin{macrocode}
788 \ifx\NAT@citea@mbox\undefined
789 \def\@citex[##1]##2{\leavevmode
790 \let\@citea\@empty
791 \@cite{\@for\@citeb:=##2\do
792 {\@citea\def\@citea{,\penalty\@m\ }%
793 \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
794 \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
795 \@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
796 \G@refundefinedtrue
797 \@latex@warning
798 {Citation `\@citeb' on page \thepage \space undefined}}%
799 {\ifx\csname r@fancy:cite:\@citeb\endcsname\undefined \@cite@ofmt{\csname b@\@citeb\endcsname}\else\tooltip*{\@cite@ofmt{\csname b@\@citeb\endcsname}}{fancy:cite:\@citeb}\fi
800 }}}{##1}}%
801 \else
802 \def\NAT@citea@mbox{%
803 \@citea\mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}\tooltip*{}{fancy:cite:\@citeb}}
804 \fi
805 }
806
807 \if@fancytooltips@nosoap
808 \def\TooltipRefmark{\hbox{\ }}%
809 \else
810 \ifTooltip@usepdftex
811 \def\TooltipRefmark{\hbox {\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
812 {fancytipmark\@@fancytipmark.pdf}}}}}%
813 \else
814 \def\TooltipRefmark{\hbox {\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
815 {fancytipmark.eps}}}}}%
816 \fi%\ifTooltip@usepdftex
817 \fi%\if@fancytooltips@nosoap
818
819 \if@fancytooltips@preview\AtBeginDocument{\fancypreview@refhook}\fi
820
821 \if@fancytooltips@createtips
822 % \end{macrocode}
823 % This part (three lines) is processed if the option |createtips| is
824 % used. In the opposite case we process the second part, up to the end
825 % of the package.
826 % \begin{macrocode}
827 \newwrite\tipfile
828 \immediate\openout\tipfile \jobname.tips
829 \def\keytip#1{\write\tipfile{\string\tooltipname{#1}{\arabic{page}}}}
830 \expandafter\endinput\fi
831 % \end{macrocode}
832 % This part is processed if the option |createtips| is not used. We
833 % define macros which put the hidden button with the name |ikona.n| in
834 % the background of the page |n|, if one of the commands |\tooltip| or
835 % |\tooltipanim| has been used on this page. Javascripts defined by
836 % |\tooltip| and |\tooltipanim| commands then unhide this button and
837 % show the corresponding picture.
838 % \begin{macrocode}
839
840 \ifx\TooltipFilename\undefined
841 \PackageWarning{fancytooltips}{** The filename with tooltips is not given. **}
842 \fi
843
844 \ifTooltip@usepdftex
845 \RequirePackage[pdftex]{eforms}
846 \def\TooltipExtratext{\hbox{\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
847 {fancytipmark\@@fancytipmark.pdf}}}}}
848 \else
849 \RequirePackage[dvips]{eforms}
850 \def\TooltipExtratext{\hbox{\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
851 {fancytipmark.eps}}}}}
852 \fi%\ifTooltip@usepdftex
853
854 \if@fancytooltips@nosoap
855 \def\TooltipExtratext{\hbox{\ }}%
856 \fi%\if@fancytooltips@nosoap
857
858 \if@fancytooltips@extratext\else\let\TooltipExtratext\relax\fi
859
860 \AtBeginDocument{
861 \global\buttontipwidth=\paperwidth
862 \global\buttontipheight=\paperheight
863 }
864
865 \ifTooltip@usepdftex
866 \def\frametip@{%
867 \pdfstartlink user{%
868 /Subtype /Widget
869 /F 6
870 /T (ikona.\thepage)
871 /FT /Btn
872 /Ff 65536
873 /H /N
874 /BS << /W 1 /S /S >>
875 /MK << /TP 1 /IF <</A[1.0 1.0]/SW /B>> >>
876 }%
877 \vbox to \buttontipheight {\vss\hbox to \buttontipwidth{\hss}}\pdfendlink}%
878 \else
879 % \end{macrocode}
880 % For dvips users we use the macros from eqxerquiz.sty package.
881 % \begin{macrocode}
882 \def\everyeqIcon#1{\def\every@eqIcon{#1}}
883 \def\every@eqIcon{}
884 \newcommand\eqIconFTT[4][]
885 {%
886 \push@@Button{#1}{#2}{#3}{#4}{}{\eq@setButtonProps\eq@Button@driver}%
887 {\eqIconDefaults\every@ButtonField\every@eqIcon}%
888 }
889 \def\eqIconDefaults
890 {%
891 \rawPDF{}\S{}\mkIns{/TP 1 /IF<</A[1.0 1.0]/SW/B>>}\R{0}
892 \CA{}\RC{}\AC{}\BC{}\BG{}\H{B}
893 \textColor{0 g}\Ff{\FfReadOnly}
894 }
895 \def\frametip@{\eqIconFTT[\BC{}\BG{}\F{\FHidden}]%
896 {ikona.\thepage}{\paperwidth}{\paperheight}%
897 }%
898 \fi%\ifTooltip@usepdftex
899
900 \def\fancytooltips@one{1}
901 \if@fancytooltips@blur
902 \RequirePackage{ocg}
903 \ifx\fancytooltips@one\fancytooltips@transparency
904 \def\transparent#1{}
905 \else
906 \RequirePackage{transparent}
907 \fi
908 \else
909 \ifx\@ocg@makeknown\undefined
910 \def\@ocg@makeknown#1#2#3{}\fi
911 \fi
912
913 \if@fancytooltips@fg
914 \else
915 \RequirePackage{eso-pic}
916 \def\frametip{%
917 \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax
918 \else
919 \setbox0=\hbox{\frametip@}%
920 \hbox{\raise \dp0 \box0}
921 \fi}%
922 \AddToShipoutPicture{\hbox to 0 pt{\frametip\hss}}
923 \fi
924
925 \def\fancytooltips@save@position{\pdfsavepos%
926 \write\@auxout{\string\global\string \fancy@layerVshift \the\pdflastypos sp\string\relax}%
927 \write\@auxout{\string\global\string \fancy@layerHshift \the\pdflastxpos sp\string\relax}%
928 \global\let\fancytooltips@save@position\relax%
929 }
930
931 \def\fancy@beginshipout@hook{}
932 \AtBeginShipout{%
933 \TooltipPageopencloseJS
934 \setbox\AtBeginShipoutBox=\hbox{%
935 \hbox to 0 pt{\TooltipHidden}\global\def\TooltipHidden{}%
936 \fancy@beginshipout@hook\if@fancytooltips@fixcolor\hbox to 0 pt{\resizebox{1pt}{!}{\TooltipExtratext}\hss}\fi
937 \hbox to 0 pt{\box\AtBeginShipoutBox\hss}%
938 \ifTooltip@usepdftex
939 \fancytooltips@save@position
940 \if@fancytooltips@blur
941 \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax \else
942 \lower\fancy@layerVshift\hbox to 0 pt{\kern-\fancy@layerHshift\relax
943 \begin{ocg}{fancyOCG\thepage}{fancyOCG\thepage}{0}%
944 \expandafter\transparent\expandafter{\fancytooltips@transparency}%
945 \color{black}%
946 \vbox to 0 pt{\vss\hbox{\vrule width \paperwidth height \paperheight}}%
947 \end{ocg}\hss}%
948 \fi
949 \fi%\if@fancytooltips@blur
950 \if@fancytooltips@fg
951 \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax
952 \else
953 \lower\fancy@layerVshift\vbox to 0 pt{\vss\hbox to 0 pt{\kern-\fancy@layerHshift\relax\hbox{\frametip@}\hss}}%
954 \fi%\ifx
955 \lower\fancy@layerVshift\vbox to 0 pt{\vss\hbox to 0 pt{\kern-\fancy@layerHshift\relax\hbox to 0 pt{\the\pos@fancy@toks\hss}\hss}}%
956 \fi%\if@fancytooltips@fg
957 \fi%\ifTooltip@usepdftex
958 \kern\hsize}%
959 }%
960
961 % \end{macrocode}
962 % In the macros |\tooltip| and |\tooltipanim| we print the text into
963 % box with zero dimensions and then we build a button which covers
964 % this text and has an associated JavaScript action. The important
965 % part is the |\PushButton| macro. You can adjust these macros or
966 % write similar macros which do what you need.
967 % \begin{macrocode}
968 \definecolor{tooltipcolor}{rgb}{0,0,1}
969
970 \newcount\tooltip@count
971 \newtoks\tooltip@toks
972 \newtoks\tooltip@pagetoks
973 \tooltip@pagetoks={\thepage}
974 \def\tooltippage{}
975
976 \def\TooltipPage#1#2{%
977 \expandafter\gdef\csname TooltipPage#2\endcsname{#2}%
978 \expandafter\gdef\csname Tooltipcount2page#1\endcsname{#2}%
979 }
980 % \end{macrocode}
981 % We use the hack for Adobe Acrobat suggested by DPS and Jorg at
982 % http://www.acrotex.net/forum/showthread.php?tid=78.
983 % \begin{macrocode}
984
985 \def\fancy@JS#1{\JS{var DirtyBeforeTooltip=this.dirty; #1
986 this.dirty=DirtyBeforeTooltip;}}
987
988 \newcommand{\tooltip}{\@ifstar
989 \tooltip@Star%
990 \tooltip@NoStar%
991 }
992
993 \newcommand{\tooltip@Star}[2]{{\color{tooltipcolor}#1}%
994 {\let\SaveTooltipExtratext\TooltipExtratext
995 \let\TooltipExtratext\relax
996 \hbox to 0 pt{\tooltip@NoStar{\SaveTooltipExtratext
997 \vrule height 10pt depth 0 pt width 0 pt}{#2}\hss}}}
998
999 \newcommand{\tooltip@NoStar}[2]{%
1000 \global\advance\tooltip@count by 1%
1001 \edef\act{\write\@auxout{\noexpand\string\noexpand\TooltipPage{\the\tooltip@count}{\the\tooltip@pagetoks}}}\act
1002 \expandafter\ifx\csname Tooltipcount2page\the\tooltip@count \endcsname\relax
1003 \global\edef\tooltippage{}
1004 \else
1005 \global\edef\tooltippage{\csname Tooltipcount2page\the\tooltip@count \endcsname}%
1006 \fi
1007 \checkTipNumber{#2}\edef\TipNumber{\FindTipNumber{#2}}%
1008 \leavevmode
1009 \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\copy0\fancy@a=\dp0\advance\fancy@a by \ht0\relax\hbox to 0 pt{\smash{\TooltipExtratext}\hss}\fancy@pushButton{\TipNumber}{\tooltippage}{TooltipField}{\wd0}{\fancy@a}{\dp0}}
1010
1011 \def\fancy@tooltip@options#1#2{\BC{}\BG{}
1012 \S{}\AA{\AAMouseExit{\fancy@JS{CloseTooltips();}}%
1013 \if@fancytooltips@mouseover
1014 \AAMouseEnter{\fancy@JS{this.getField("ikona."+(#2)).hidden=false;
1015 try {app.clearInterval(animace);}catch (e) {}
1016 \if@fancytooltips@movetips nastav(#1,#2);\fi
1017 \if@fancytooltips@blur
1018 try{
1019 for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1020 {
1021 if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
1022 fancytooltipsOCGs[i].state = true;
1023 else
1024 fancytooltipsOCGs[i].state = false;
1025 }} catch (e) {};
1026 \fi
1027 zobraz(#1,#2);
1028 }}
1029 \fi}
1030 \A{\fancy@JS{this.getField("ikona."+(#2)).hidden=false;
1031 try {app.clearInterval(animace);}catch (e) {}
1032 \if@fancytooltips@movetips nastav(#1,#2);\fi
1033 \if@fancytooltips@blur
1034 try {
1035 for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1036 {
1037 if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
1038 fancytooltipsOCGs[i].state = true;
1039 else
1040 fancytooltipsOCGs[i].state = false;
1041 }} catch (e) {};
1042 \fi
1043 zobraz(#1,#2);
1044 }}}
1045
1046 \newtoks\@fxtoks\@fxtoks={\the\pdflastxpos}
1047 \newtoks\@fytoks\@fytoks={\the\pdflastypos}
1048
1049 \def\fancy@pushButton#1#2#3#4#5#6{%
1050 \lower #6\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltip@options{#1}{#2}]{#3}{#4}{#5}}}
1051 \def\fancy@@pushButton#1#2#3#4#5#6#7#8{}
1052
1053 \ifTooltip@usepdftex
1054 \if@fancytooltips@fg
1055 \def\fancy@pushButton#1#2#3#4#5#6{\pdfsavepos%
1056 \edef\act{\write\@auxout{\string\fancy@@pushButton{#1}{#2}{#3}{\the#4}{\the#5}{\the\@fxtoks}{\the\@fytoks}{\the#6}}}\act%
1057 }
1058 \def\fancy@@pushButton#1#2#3#4#5#6#7#8{%
1059 \expandafter\global\expandafter\pos@fancy@toks\expandafter{\the\pos@fancy@toks\fancy@onlypage{#2}{\vbox to 0 pt{\vss\hbox to 0 pt{\kern #6 sp\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltip@options{#1}{#2}]{#3}{#4}{#5}}\hss}\kern #7sp\kern-#8}}}}
1060 \fi
1061 \fi
1062
1063
1064 \def\fancy@onlypage#1#2{\def\ft@a{#1}\edef\ft@b{\thepage}%
1065 \ifx\ft@a\ft@b#2\fi}
1066
1067
1068 \def\delayinterval{200}
1069
1070 \newcommand{\tooltipanim}{\@ifstar
1071 \tooltipanim@Star%
1072 \tooltipanim@NoStar%
1073 }
1074
1075 \newcommand{\tooltipanim@Star}[3]{{\color{tooltipcolor}#1}%
1076 {\let\SaveTooltipExtratext\TooltipExtratext
1077 \let\TooltipExtratext\relax
1078 \hbox to 0 pt{\tooltipanim@NoStar{\SaveTooltipExtratext
1079 \vrule height 10pt depth 0 pt width 0 pt}{#2}{#3}\hss}}}
1080
1081 \newcommand{\tooltipanim@NoStar}[3]{%
1082 \global\advance\tooltip@count by 1%
1083 \edef\act{\write\@auxout{\noexpand\string\noexpand\TooltipPage{\the\tooltip@count}{\the\tooltip@pagetoks}}}\act
1084 \expandafter\ifx\csname Tooltipcount2page\the\tooltip@count \endcsname\relax
1085 \global\edef\tooltippage{}
1086 \else
1087 \global\edef\tooltippage{\csname Tooltipcount2page\the\tooltip@count \endcsname}%
1088 \fi
1089 \checkTipNumber{#2}\edef\TipNumberA{\FindTipNumber{#2}}%
1090 \checkTipNumber{#3}\edef\TipNumberB{\FindTipNumber{#3}}%
1091 \leavevmode
1092 \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\copy0\fancy@a=\dp0\advance\fancy@a by \ht0\relax\hbox to 0 pt{\smash{\TooltipExtratext}\hss}\fancy@anim@pushButton{\TipNumberA}{\tooltippage}{TooltipField}{\wd0}{\fancy@a}{\dp0}{\TipNumberB}}
1093
1094
1095 \def\fancy@tooltipanim@options#1#2#3{
1096 \BC{}\BG{}\S{}\AA{\AAMouseExit{\fancy@JS{CloseTooltips();}}
1097 \if@fancytooltips@mouseover
1098 \AAMouseEnter{\fancy@JS{
1099 try {app.clearInterval(animace);}catch (e) {}
1100 var cislo=#1;
1101 \if@fancytooltips@movetips nastav(#1,#2);\fi
1102 \if@fancytooltips@blur
1103 try{
1104 for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1105 {
1106 if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
1107 fancytooltipsOCGs[i].state = true;
1108 else
1109 fancytooltipsOCGs[i].state = false;
1110 }} catch (e) {};
1111 \fi
1112 function animuj()
1113 {
1114 var DirtyBeforeTooltipanim=this.dirty;
1115 if (cislo<#3) cislo=cislo+1;
1116 this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+cislo).buttonGetIcon());
1117 this.dirty=DirtyBeforeTooltipanim;
1118 };
1119 this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+#1).buttonGetIcon());
1120 this.getField("ikona."+(#2)).hidden=false;
1121 animace=app.setInterval('animuj();', \delayinterval);
1122 }}
1123 \fi}
1124 \A{\fancy@JS{
1125 try {app.clearInterval(animace);}catch (e) {}
1126 var cislo=#1;
1127 \if@fancytooltips@movetips nastav(#1,#2);\fi
1128 \if@fancytooltips@blur
1129 try{
1130 for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1131 {
1132 if(fancytooltipsOCGs[i].name == "fancyOCG"+(#3))
1133 fancytooltipsOCGs[i].state = true;
1134 else
1135 fancytooltipsOCGs[i].state = false;
1136 }} catch (e) {};
1137 \fi
1138 function animuj()
1139 {
1140 var DirtyBeforeTooltipanim=this.dirty;
1141 if (cislo<#3) cislo=cislo+1;
1142 this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+cislo).buttonGetIcon());
1143 this.dirty=DirtyBeforeTooltipanim;
1144 };
1145 this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+#1).buttonGetIcon());
1146 this.getField("ikona."+(#2)).hidden=false;
1147 animace=app.setInterval('animuj();', \delayinterval);
1148 }}
1149 }
1150
1151
1152 \def\fancy@anim@pushButton#1#2#3#4#5#6#7{%
1153 \lower #6 \hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltipanim@options{#1}{#2}{#7}]{#3}{#4}{#5}}}
1154 \def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{}
1155
1156 \ifTooltip@usepdftex
1157 \if@fancytooltips@fg
1158 \def\fancy@anim@pushButton#1#2#3#4#5#6#7{\pdfsavepos%
1159 \edef\act{\write\@auxout{\string\fancy@@anim@pushButton{#1}{#2}{#3}{\the#4}{\the#5}{\the\@fxtoks}{\the\@fytoks}{\the#6}{#7}}}\act%
1160 }
1161 \def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{%
1162 \expandafter\global\expandafter\pos@fancy@toks\expandafter{\the\pos@fancy@toks\fancy@onlypage{#2}{\vbox to 0 pt{\vss\hbox to 0 pt{\kern #6 sp\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltipanim@options{#1}{#2}{#9}]{#3}{#4}{#5}}\hss}\kern #7sp\kern-#8}}}}
1163 \fi
1164 \fi
1165
1166
1167 % \end{macrocode}
1168 % This code closes tooltip if the page is closed.
1169 % \begin{macrocode}
1170 \edef\fancytooltips@pdfpageattrJS{%
1171 var DirtyBeforeCloseTooltip=this.dirty;
1172 \if@fancytooltips@blur
1173 try{
1174 var temp = fancytooltipsOCGs.length;
1175 for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1176 {
1177 fancytooltipsOCGs[i].state = false;
1178 }
1179 }
1180 catch (e){}
1181 \fi
1182 CloseTooltips();
1183 this.dirty=DirtyBeforeCloseTooltip;
1184 }
1185 \ifTooltip@usepdftex
1186 \edef\fancy@temp{/AA << /O << /S /JavaScript /JS (
1187 \fancytooltips@pdfpageattrJS) >> >>}
1188 \expandafter\def\expandafter\TooltipPageopencloseJS\expandafter{
1189 \expandafter\global\expandafter\pdfpageattr\expandafter{\fancy@temp}%
1190 }
1191 \pdfximage{\TooltipFilename.pdf}%
1192 \edef\TooltipPages{\the\pdflastximagepages}%
1193 \else
1194 \edef\fancy@temp{ [ {ThisPage} << /AA <<
1195 /O << /S /JavaScript /JS (var DirtyBeforeCloseTooltip=this.dirty; CloseTooltips(); this.dirty=DirtyBeforeCloseTooltip;) >>
1196 >> >> /PUT pdfmark}
1197 \expandafter\def\expandafter\TooltipPageopencloseJS\expandafter{
1198 \expandafter\literalps@out\expandafter{\fancy@temp}}
1199 \edef\fancy@@temp{/S /JavaScript /JS ( \fancytooltips@pdfpageattrJS)}
1200 \expandafter\OpenAction\expandafter{\fancy@@temp}
1201 \fi%\ifTooltip@usepdftex
1202
1203 \ifTooltip@usepdftex
1204 \def\fancytempA{}
1205 \ifx\FancytooltipsAfterClose\undefined\else\edef\fancytempA{\FancytooltipsAfterClose}\fi
1206 \def\fancytempAA{}
1207 \ifx\FancytooltipsAfterShow\undefined\else\edef\fancytempAA{\FancytooltipsAfterShow}\fi
1208
1209 \if@fancytooltips@blur
1210 \def\fancytempAAA{
1211 % \end{macrocode}
1212 % OCG's have not been initialized yet, do it now.
1213 % \begin{macrocode}
1214 var inifancytooltipsOCGs = this.getOCGs();
1215 var fancytooltipsOCGs = [];
1216 for(var i=0; inifancytooltipsOCGs && i<inifancytooltipsOCGs.length;i++)
1217 {
1218 if(inifancytooltipsOCGs[i].name.substr(0,5) == "fancy")
1219 {
1220 fancytooltipsOCGs.push(inifancytooltipsOCGs[i]);
1221 inifancytooltipsOCGs[i].state=false;
1222 }
1223 }
1224 inifancytooltipsOCGs[0].state=true;
1225 inifancytooltipsOCGs[0].state=false;
1226 }
1227 \else
1228 \def\fancytempAAA{}
1229 \fi
1230
1231 \if@fancytooltips@blur
1232 \def\fancytempB{
1233 try {for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
1234 {fancytooltipsOCGs[i].state = false;} } catch (e) {}}
1235 \else
1236 \def\fancytempB{}
1237 \fi
1238
1239
1240 \begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
1241 \fancytooltipsdebugmsg
1242
1243 var animace;
1244 var fancyTooltipsLoaded = true;
1245
1246 \fancytempAAA
1247
1248 function CloseTooltips()
1249 {
1250 try {this.getField("ikona").hidden=true;}catch (e) {}
1251 try {app.clearInterval(animace);}catch (e) {}
1252 \fancytempB
1253 \fancytempA
1254 }
1255
1256 function nastav(cislo,strana)
1257 {
1258 var f=this.getField("ikona."+(strana));
1259 var g=this.getField("animtiph."+cislo);
1260 var sourf=f.rect;
1261 var sourg=g.rect;
1262 if ((mouseX+sourg[2]-sourg[0])<sourf[2])
1263 var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
1264 else
1265 var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
1266 var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
1267 if (percX>100) percX=100;
1268 if (percY>100) percY=100;
1269 if (percX<0) percX=0;
1270 if (percY<0) percY=0;
1271 f.buttonAlignX=percX;
1272 f.buttonAlignY=percY;
1273 }
1274
1275 function zobraz(cislo,strana)
1276 {
1277 var f=this.getField("ikona."+(strana));
1278 var g=this.getField("animtiph."+cislo);
1279 f.hidden=false;
1280 f.buttonSetIcon(g.buttonGetIcon());
1281 \fancytempAA
1282 }
1283
1284 this.dirty=false;
1285 app.focusRect = false;
1286 \end{insDLJS}
1287 \else
1288 \begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
1289 var animace;
1290 var fancyTooltipsLoaded = true;
1291
1292 \fancytooltipsdebugmsg
1293
1294 function CloseTooltips()
1295 {
1296 try {this.getField("ikona").hidden=true;}catch (e) {}
1297 try {app.clearInterval(animace);}catch (e) {}
1298 }
1299
1300 function ImportTooltips()
1301 {
1302 console.println("importing pictures");
1303 for (var i=1;i<=\TooltipPages;i++)
1304 {
1305 this.insertPages(this.numPages-1,"\TooltipFilename.pdf",(i-1),(i-1));
1306 var rozm=this.getPageBox("Crop",this.numPages-1);
1307 this.deletePages(this.numPages-1);
1308 var p=this.addField("animtiph."+i,"button",0,rozm);
1309 p.buttonPosition=position.iconOnly;
1310 p.hidden=true;
1311 this.getField("animtiph."+i).buttonImportIcon("\TooltipFilename.pdf",(i-1));
1312 }
1313 console.println("Imported \TooltipPages pictures, save the PDF file.");
1314 return(1);
1315 }
1316
1317 function nastav(cislo,strana)
1318 {
1319 var f=this.getField("ikona."+(strana));
1320 var g=this.getField("animtiph."+cislo);
1321 var sourf=f.rect;
1322 var sourg=g.rect;
1323 if ((mouseX+sourg[2]-sourg[0])<sourf[2])
1324 var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
1325 else
1326 var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
1327 var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
1328 if (percX>100) percX=100;
1329 if (percY>100) percY=100;
1330 if (percX<0) percX=0;
1331 if (percY<0) percY=0;
1332 f.buttonAlignX=percX;
1333 f.buttonAlignY=percY;
1334 }
1335
1336 function zobraz(cislo,strana)
1337 {
1338 var f=this.getField("ikona."+(strana));
1339 var g=this.getField("animtiph."+cislo);
1340 f.hidden=false;
1341 f.buttonSetIcon(g.buttonGetIcon());
1342 }
1343
1344 this.dirty=false;
1345 app.focusRect = false;
1346 \end{insDLJS}
1347 \fi
1348 % \end{macrocode}
1349 % A cycle is used to create hidden buttons. Each button has associated a page
1350 % from the file with tooltips as icon. These icons are invoked by JavaScripts
1351 % defined in |\tooltip| and |\tooltipanim| macros.
1352 % \begin{macrocode}
1353 \newcount\tooltip@count
1354 \ifTooltip@usepdftex
1355 \newcommand*{\TooltipHidden}{%
1356 \count@=0
1357 \@whilenum\count@<\TooltipPages \do{%
1358 \tooltip@count=\count@
1359 \advance \tooltip@count by 1%
1360 \bgroup
1361 \immediate\pdfximage
1362 page \the\tooltip@count{\TooltipFilename.pdf}%
1363 \mbox{\leavevmode
1364 \vbox to 0 pt{\vss\hbox to 0 pt{\pdfstartlink user{%
1365 /Subtype /Widget
1366 /F 6
1367 /T (animtiph.\the\tooltip@count)
1368 /FT /Btn
1369 /Ff 65536
1370 /H /N
1371 /BS << /W 1 /S /S >>
1372 /MK <<
1373 /TP 1
1374 /I \the\pdflastximage\space 0 R
1375 /IF << /SW /A >>
1376 >>
1377 }%
1378 \phantom{\pdfrefximage \pdflastximage}%
1379 \pdfendlink\hss}}}%
1380 \egroup
1381 \advance\count@\@ne}%
1382 }
1383 \else
1384 \let\TooltipHidden\relax
1385 \fi
1386 % \end{macrocode}
1387 % The keywords for the tooltips can be stored in the file
1388 % |\TooltipFilename.tips|. The topics in this file are created by
1389 % |\keytip| macro (see the first part of the code).
1390 % \begin{macrocode}
1391 \AtBeginDocument{\IfFileExists{\TooltipFilename.tips}%
1392 {\input{\TooltipFilename.tips}
1393 \PackageInfo{fancytooltips}{Inputting \TooltipFilename.tips.}}%
1394 {\PackageWarning{fancytooltips}{No file \TooltipFilename.tips!
1395 Your keywords for tooltips will not work!}}}
1396
1397 \def\tooltipname#1#2{\expandafter\xdef\csname FancyToolTip@#1\endcsname{#2}}
1398
1399 \def\FindTipNumber#1{\expandafter\ifx \csname FancyToolTip@#1\endcsname\relax
1400 #1\else\csname FancyToolTip@#1\endcsname\fi}
1401
1402 \def\checkTipNumber#1{\expandafter\ifx
1403 \csname FancyToolTip@#1\endcsname\relax \PackageInfo{fancytooltips}{No
1404 framenumber is assigned to keyword #1. I assume that #1 is the
1405 number of the frame.}%
1406 \fi}
1407
1408 %</package>
1409 % \end{macrocode}
1410 %
1411 % \Finale
1412 \endinput
1413
1414
1415