summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ocgtools/examples/ocgtools-test.tex
blob: b750e5ca25fb70f7608faae1a9253840f610437d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
\usepackage[metapost]{mfpic}
\opengraphsfile{mfpic-picture}
\usepackage{amsmath}
\usepackage{helvet}
\let\rmdefault\sfdefault

\usepackage{wrapfig}
\definecolor{darkgreen}{rgb}{0,0.5,0}
% new page which works in beamer class only
\def\beamernewpage{\ifx \usetheme \undefined \relax \else \newpage\fi}

% background for web.sty package
\ifx \ifweb@navibar \undefined \relax \else
\definecolor{lightgray}{rgb}{0.9,0.9,0.9}
\newbox\backgroundbox
\newbox\backgroundboxa
\setbox\backgroundboxa=\hbox{\rotatebox{20}{{\color{lightgray}\Large ocgtools\color{black}}}}
\newbox\backgroundboxb
\setbox\backgroundboxb=\hbox to \paperwidth{\xleaders\copy\backgroundboxa\hfill}
\newbox\backgroundboxc
\setbox\backgroundboxc=\vbox to \paperheight{\xleaders\copy\backgroundboxb\vfill}
\makeatletter
 \def\ocgtools@shipoutstart@hook{\hbox to 0 pt{%
    \kern -1in \vbox to 0 pt{\vss\copy\backgroundboxc}
    \hss}}
\makeatother
\fi

\begin{document}

\sloppy
\fboxsep=4pt

\title{Ocgtools demo}
\author{Robert Ma\v{r}\'{i}k}

\maketitle
\def\maxwell{
\nabla \cdot D&= \rho \\
\nabla \cdot B&=0 \\
\nabla \times E&=- \frac{\partial B}{\partial t}\\
\nabla \times H&=J+ \frac{\partial D}{\partial t}}

\tableofcontents
\beamernewpage
\makeatletter\ifx\PDFSCR@Info\undefined\relax\else\newpage\fi\makeatother

\section{Introduction}

\vbox to 0 pt{\noindent\hbox{\ocgpicture[width=3cm]{book.jpg}}
  \vss}

\definecolor{mywhite}{rgb}{0.3,0.3,0.6}
\hangindent=3.5cm \hangafter -5 \noindent This is test file for
\texttt{ocgtools} package. You can (using \texttt{pdflatex}) insert
hidden \TeX{} material into PDF files and open/close by clicking
active links. The active links in this document are pictures (like the
picture in this paragraph) or blue text. There are two kinds of
behavior
\begin{itemize}
\item OCG spans over allmost whole PDF pages (with black or
  transparent boundary) and can be hidden by clicikng anywhere in the
  page --  \makeatletter
  \ocgtext[0pt,bg=red,fg=yellow]{Try it here!}{Click 
  \ifocg@hide@button anywhere \else red cross \fi to close.}   \makeatother
  
\item OCG is small and can be hidden either with the same link which
  opens this text or with red mark on the right top corner --
  \ocgminitext[4cm, bg=red]{Try it here!}{Click the same link or the red mark
    to close.}
\end{itemize}

\beamernewpage Note that the pictures may look darker in Adobe Reader
on Linux if you use package option \texttt{transparent} (means
transparent boundary of the OCG's, used for example in demos for
Beamer class and \verb|pdfscreen.sty| package). For comparison you can
look at the original picture
\href{http://math.mendelu.cz/en/analyza?lang=en}{here}) or at the
demos which use \verb|web.sty| package. \ocgtext[5cm,fg=red]{PDF viewer}{More
  preciselly, Adobe Reader. \par \bigskip It is well known program.
  You can install it on both Linux and Windows.} uses another
rendering when trasparency is called and this seems to be system
dependent. So be carefull when combining
\ocgminitext[3cm,bg=lightgray,fg=darkgreen]{\texttt{transparent}}{\rightskip 0 pt
  plus 1 fill This comment is in \texttt{vbox} with specified width
  and may contain new paragraphs. It is rather long and placed on the
  top of the page. Hence \textit{it is shifted a bit to fit the area
    on the screen}. However, if the papersize is small (like for
  Beamer test files), the bottom part remains invisible for reader.

\smallskip 2-nd paragraph.

\smallskip 3-rd paragraph. This is the last paragraph.}  option and
bitmap pictures.

\definecolor{green}{rgb}{0.5,1,0.5}
\begin{minipage}[c]{0.4\linewidth}
  \ocgtext[4cm]{\begin{align}\label{eq:maxwell}\maxwell
    \end{align}
  }{\colorbox{green}{\kern-2\fboxsep\hbox to \hsize{\hss Maxwell equations\hss}}$$\begin{aligned} \maxwell
    \end{aligned}$$}
\end{minipage}\hskip 0 pt plus 1 filll
\begin{minipage}[c]{0.2\linewidth}
\ocgpicture[width=\linewidth]{tall.jpg}
\end{minipage}\hskip 0 pt plus 1 filll
\begin{minipage}{0.3\linewidth}
  Here we test
  \ocgminitextlt[bg=black,fg=yellow]{ocg's}{{\color{red}O}ptional
    {\color{red}C}ontents {\color{red}G}roup} which are inside group
  (Maxwell's equation in minipage) and which are taller than wide
  (little golf player).
\end{minipage}

\newpage
\section{Options of the package}

{
\begin{wrapfigure}[5]{r}{4cm}
  \ocgpicture[width=4cm]{wide.jpg}
\end{wrapfigure}
\def\defaultocgpapercolor{black}\def\defaultocgfontcolor{green}
This is some \ocgtext{random text}{anmf asdfh akdfjha adfjh akjdfh }
to see that \ocgminitextlb{\texttt{wrapfig}}{Wrapfig is a package for
  \LaTeX.}  works and wide pictures are scaled properly.  Several
options are available for the package \verb|ocgtools|:
\ocgminitext[6cm]{transparent}{\texttt{beamer} and \texttt{pdfscreen}
  demo files are compiled with \texttt{transparent} option -- the
  black boundary of big layers is opaque.},
\ocgminitext[6cm]{insertvisible}{The file \texttt{ocgtools-example-web.tex}
  is compiled with \texttt{insertvisible} option. The layers are
  inserted as visible layers and are turned to invisible when the PDF
  file is opened.}, 
  \ocgminitext[8cm]{nobutton}{Normally 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 viewers (like Foxit Reader) the button is not
  100\% transparent.  This option allows not to include the big button
  to hide layers.  The layers can be closed by clicking the red cross
  below. Demo files based on \texttt{pdfscreen} are compiled with this option.
  Use this option to make the document accessible to Foxit Reader users.},
  \ocgminitext{noocg}{All OCG's are ignored}, 
  \ocgminitext{inactive}{The same as 
  \texttt{noocg}}, \ocgminitext{active}{OCG's are inserted, overrides 
  \texttt{inactive} and \texttt{noocg}},
  \ocgminitext[6cm]{noprogressmsg}{No messagae about processing OCG's at
  the first page when document is opened.}, 
  \ocgminitext[8cm]{minimouseover}{\texttt{web} and \texttt{beamer} demo
  files are compiled with \texttt{minimouseover} option. You can open
  the minilayer by mouseover action in the area which is in the form
  of invisible square 8pt$\times$8pt placed at the bottom right corner
  of the referrence text.}, 
\ocgminitext[8cm]{mouseover}{The same as
  \texttt{minimouseover}, but works also for big layers.  No demo file is
  compiled with this option.}, 
\ocgminitext[8cm]{nopageclose}{By default, layers and buttons for hiding them are 
  turned into hidden when entering a page. This option turns this behavior off. 
  Demo files based on \texttt{pdfscreen} are compiled with this option.}
(each option has an associated
minilayer with an explanation). Examples distributed with the package
are in the form of demo files based on three packages (\verb|beamer|,
\verb|web|, \verb|pdfscreen|). Each example has three variants with no
panel, with panel on the right and on the left and each example is
compiled with different options. The current document is compiled with
the following options: {\bfseries \makeatletter
  \if@ocgtools@transparent transparent, \fi \if@ocgtools@insertvisible
  insertvisible, \fi \ifocg@hide@button \relax \else nobutton, \fi
  \ifx \ocgtools@progressmsg\relax
  noprogressmsg, \fi \if@ocgtools@mouseover mouseover,\fi
  \if@ocgtools@minimouseover minimouseover,\fi \if@ocgtools@pageclose\else nopageclose,\fi \makeatother }

Note that we used \verb|\def\defaultocgpapercolor{black}| and 
\verb|\def\defaultocgfontcolor{green}| on this page.

}
\newpage 
\section{A taste of mathematics}

\def\a{\begin{mfpic}[80][40]{-0.1}{2}{-0.1}{2.8}
        \gfill[green]\btwnfcn{0,1.5,0.1}{1+(x-1.2)**2}{0}
        \axes
        \xmarks{1.5}
        \tlabelsep{4pt}
        \tlabel[tc](0,0){$a$}
        \tlabel[tc](1.5,0){$b$}
        \pen{1pt}
        \function{0,1.5,0.1}{1+(x-1.2)**2}
      \end{mfpic}} 

    \begin{figure}
      \centering
      \ocgtext{\a}{\a}
      \caption{Floating figure}
      \label{fig:figure}
    \end{figure}

    Mfpic pictures can be scaled easily (see the floating figure).
    
    \beamernewpage We can add explanation to some computations easily
    (Note the text \verb|Why?| inserted automatically by redefining
    macro \verb|\ocgtextend|).

{\def\ocgtextend{\raise0.75\baselineskip\hbox to 0 pt{\hss\tiny\color{red}Why?}\hss}
  \global\def\dx{\,\mathrm{d}x}
\begin{eqnarray}\label{eq:label}
\int\ln x\dx&\ocgminitext[4cm]={Integration by parts $$\int\ln x\dx=\int1\cdot\ln x \dx$$}&x\ln x-\int x\frac 1x\dx\\
&\ocgminitext={Formula $\int 1\dx=x$}&x\ln x - x +C
\end{eqnarray}

}

\newpage 
\section{Few more tests}
Package \verb|ocgtools.sty| redefines output routine via
\verb|atbegshi.sty| package. From this reason it may be incompatible
with some other packages dealing with output routine. However, the
package \verb|eso-pic.sty| works fine.

Test for placing OCG's:

\hbox to \hsize{\hss\begin{minipage}{0.2\linewidth}
  \ocgminitextlb{lb}{This is optional OCG.}

  \ocgminitextrb{rb}{This is optional OCG.}

  \ocgminitextlt{lt}{This is optional OCG.}

  \ocgminitextrt{rt}{This is optional OCG.}
\end{minipage}
\hss\hss\hss
\begin{minipage}{0.2\linewidth}
  \ocgminitextlb{lb}{This is optional OCG.}

  \ocgminitextrb{rb}{This is optional OCG.}

  \ocgminitextlt{lt}{This is optional OCG.}

  \ocgminitextrt{rt}{This is optional OCG.}
\end{minipage}
\hss
}

\ifx \MyPersonalMacro \undefined \else
We inserted equation \eqref{eq:label} and Figure \ref{fig:figure} in
this document.

The reference to Maxwell equations \eqref{eq:maxwell} works only if
compiled on Linux via \texttt{ocgtools-preview.sh} (called from
\texttt{ocgtools-test.sh} automatically with correct parameter). \fi

\label{page}
\newpage

\ocgminitextlb{New}{New} \ocgminitextrb{page}{page}.

Second line

\bigskip

\ocgminitext{New}{New} \ocgminitext{page}{page}.

Second line
\newpage

Plain page.
\newpage

\ocgminitextlb{Last}{Last} \ocgminitextrb{page}{page}.

Second line on last page.