Debian Codegraph @

texmf-dist/source/latex/ocgx/demo-ocgx.tex

raw
1 % Copyright (C) 2012 by Paul Gaborit
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7
8 \documentclass[11pt,hyperref={colorlinks=false,runcolor=blue}]{beamer}
9 %\usetheme{Warsaw}
10 \usepackage[T1]{fontenc}
11 \usepackage{lmodern}
12 \usepackage{tikz}
13 \usetikzlibrary{backgrounds,fit,calc,shadows,chains,ocgx,shapes.geometric}
14 \usepackage{microtype}
15 \usepackage{url}
16 \usepackage{fancyvrb}
17 \usepackage{listings}
18 \lstdefinestyle{TeXcode}{
19 fancyvrb=true,
20 language=[LaTeX]TeX,
21 basicstyle=\scriptsize\ttfamily,
22 keywordstyle=\color{blue}\bfseries,
23 commentstyle=\color{red!50!black}\itshape,
24 stringstyle=\ttfamily\color{green!50!black},
25 showspaces=false,
26 showstringspaces=false,
27 backgroundcolor=\color{white},
28 fontadjust=true,
29 aboveskip=1ex,
30 belowskip=1ex,
31 emphstyle=\color{blue}\bfseries,
32 keepspaces=true,
33 flexiblecolumns=true,
34 emph={switchocg,showocg,hideocg,actionsocg,usetikzlibrary}
35 }
36 \newcommand\TkzTileWallPaper[3]{
37 \pgfmathtruncatemacro{\nx}{\paperwidth/#1}
38 \foreach \dx in {0,...,\nx}{
39 \pgfmathtruncatemacro{\ny}{\paperheight/#2}
40 \foreach \dy in {0,...,\ny}{
41 \node[anchor=south west,inner sep=0pt]
42 at ([xshift=#1 * \dx,yshift=#2 * \dy]current page.south west)
43 {\includegraphics[width=#1,height=#2]{#3}};
44 }
45 }
46 }
47
48 \setbeamersize{text margin left=3mm,text margin right=3mm}
49
50 \newcommand\latex{{\rmfamily\LaTeX}}
51
52 \newcommand{\TikZ}{Ti\emph{k}Z}
53
54 \begin{document}
55 \begin{frame}[fragile]
56 \frametitle{\latex{}, OCG \& \TikZ{} (without JavaScript): \texttt{ocgx} package}
57 \framesubtitle{by Paul \textsc{Gaborit} wiht help of Paul
58 \textsc{Isambert}}
59
60 \begin{alertblock}{PDF readers}
61 To fully enjoy this demonstration, use \emph{Adobe Reader},
62 \emph{Foxit Reader} or \emph{evince}!
63 \end{alertblock}
64
65 \begin{columns}
66
67 \column{.6\linewidth}
68
69 \begin{block}{Simple example: code}
70 \begin{lstlisting}[style=TeXcode]
71 \begin{ocg}{My first OCG}{refmyfirstocg}{1}
72 Some content...
73 \end{ocg}
74
75 \switchocg{refmyfirstocg}%
76 {\textcolor{red}{Click me!}}
77 \end{lstlisting}
78 \end{block}
79
80 \column{.4\linewidth}
81
82 \begin{block}{Simple example: result}
83
84 \begin{ocg}{My first OCG}{refmyfirstocg}{1}
85 Some content...
86 \end{ocg}
87
88 \switchocg{refmyfirstocg}%
89 {\textcolor{red}{Click me!}}
90
91 \end{block}
92 \end{columns}
93
94 \end{frame}
95
96 \begin{frame}
97 \frametitle{First example with Ti\emph{k}Z}
98
99 {\centering
100 \begin{tikzpicture}[font=\small]
101 \begin{scope}[ocg={ref=toto,status=visible,name=ok}]
102 \fill[orange] circle(10pt);
103 \node[draw,rounded corners,hide ocg=toto] at (0,-1) {Hide};
104 \node[draw,rounded corners,switch ocg=toto] at (2,-1) {Switch};
105 \end{scope}
106 \node[show ocg=toto,text=red] at (0,-2) {Show};
107 \end{tikzpicture}\par}
108
109 \begin{itemize}
110 \item \switchocg{toto}{\Large \textcolor{red}{A very long phrase to
111 show that a link can be on multiple lines\ldots}\par\textcolor{red}{And with two
112 paragraphs!}}
113 \item The ``Switch'' button is \textbf{always} useable!
114 \end{itemize}
115 \end{frame}
116
117 \tikzset{%
118 button on/.style={%
119 draw,circle,drop shadow,
120 line width=1pt,
121 fill=lime!50,
122 switch ocg with mark on={#1}{},
123 },
124 }
125 \begin{frame}
126 \frametitle{An ordered stack}
127
128 \centering
129 \begin{tikzpicture}
130 \foreach \col[count=\c] in {red,orange,yellow,lime,cyan,blue,violet}{
131 \pgfmathtruncatemacro{\num}{mod(\c+1,2)+1}
132 \pgfmathsetmacro{\rad}{8-\c}
133 \begin{scope}[xshift=-.3*\c cm,ocg={name=s\num,ref=s\num}]
134 \node[ellipse,draw,line width=1pt,
135 minimum width=1.1*\rad cm,minimum height=.9*\rad cm,
136 fill=\col!70,drop shadow={fill=black}](t){};
137 \node[left=3pt of t.east,fill=white,
138 fill opacity=.5,text opacity=1,circle,inner sep=0pt]{S\num};
139 \end{scope}
140 }
141 \end{tikzpicture}
142
143 \begin{tikzpicture}
144 \node[button on=s1](but){};
145 \node[right=0 of but]{Switch S1};
146 \node[below=3pt of but,button on=s2](but){};
147 \node[right=0 of but]{Switch S2};
148 \end{tikzpicture}
149
150 \end{frame}
151
152 \begin{frame}
153 \frametitle{RGB and CMY color models with \texttt{xcolor}}
154
155 \def\mylist{red/0,yellow/60,green/120,cyan/180,blue/240,magenta/300}
156 \centering\begin{tikzpicture}[line width=1pt]
157 \begin{scope}
158 \node at (90:25mm) {RGB color};
159 \foreach \col/\angle in \mylist {
160 \colorlet{rgb \col}[rgb]{\col}
161 \draw (\angle:5mm) circle [radius=10mm];
162 \begin{scope}[on background layer]
163 \begin{scope}[ocg={ref=RGB\col,name=RGB \col}]
164 \fill[fill=rgb \col,fill opacity=.5]
165 (\angle:5mm) circle [radius=10mm];
166 \end{scope}
167 \end{scope}
168
169 \node[rounded corners=1mm,draw,line width=1pt,
170 minimum size=3mm,fill=rgb \col,fill opacity=.5,
171 drop shadow,
172 inner sep=0,inner xsep=0,
173 switch ocg with mark on={RGB\col}{}]
174 at (\angle:20mm){};
175 }
176 \end{scope}
177 \begin{scope}[xshift=70mm]
178 \node at (90:25mm) {CMY color};
179 \foreach \col/\angle in \mylist {
180 \colorlet{cmy \col}[cmyk]{\col}
181 \draw (\angle:5mm) circle [radius=10mm];
182 \begin{scope}[on background layer]
183 \begin{scope}[ocg={ref=CMY\col,name=CMY \col}]
184 \fill[fill=cmy \col,fill opacity=.5]
185 (\angle:5mm) circle [radius=10mm];
186 \end{scope}
187 \end{scope}
188
189 \node[rounded corners=1mm,draw,line width=1pt,
190 minimum size=3mm,fill=cmy \col,fill opacity=.5,
191 drop shadow,inner sep=0,outer sep=0,
192 switch ocg with mark on={CMY\col}{}]
193 at (\angle:20mm){};
194 }
195 \end{scope}
196
197 \begin{scope}%
198 [xshift=35mm,start chain=going below,node distance=.5mm,font=\tiny]
199 \node[on chain] at (0,20mm) {Toogle groups};
200 \node%
201 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
202 minimum size=3mm,inner sep=1mm,
203 switch ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
204 ]
205 {red, green, blue};
206 \node%
207 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
208 minimum size=3mm,inner sep=1mm,
209 switch ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
210 ]
211 {cyan, magenta, yellow};
212
213 \node[on chain] {Show groups};
214 \node%
215 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
216 minimum size=3mm,inner sep=1mm,
217 show ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
218 ]
219 {red, green, blue};
220 \node%
221 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
222 minimum size=3mm,inner sep=1mm,
223 show ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
224 ]
225 {cyan, magenta, yellow};
226
227 \node[on chain] {Hide groups};
228 \node%
229 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
230 minimum size=3mm,inner sep=1mm,
231 hide ocg={RGBred RGBblue RGBgreen CMYred CMYblue CMYgreen},
232 ]
233 {red, green, blue};
234 \node%
235 [on chain,draw,rounded corners=1mm,fill=white,drop shadow,
236 minimum size=3mm,inner sep=1mm,
237 hide ocg={RGByellow RGBcyan RGBmagenta CMYyellow CMYcyan CMYmagenta},
238 ]
239 {cyan, magenta, yellow};
240 \end{scope}
241
242 \end{tikzpicture}\par
243
244 \end{frame}
245
246 \foreach \name/\link/\ltxlink/\tiles in {%
247 The Big Show/%
248 {http://designfestival.com/the-cicada-principle-and-why-it-matters-to-web-designers/}/%
249 {http://latex-community.org/know-how/433-tiled-backgrounds}/%
250 {%
251 curtain1/32.7pt/\paperheight,%
252 curtain2/90pt/\paperheight,%
253 curtain3/210.9pt/\paperheight%
254 },%
255 Mosaic/%
256 {http://designfestival.com/cicada/break-it-down/?id=95}/%
257 {http://latex-community.org/know-how/433-tiled-backgrounds}/%
258 {%
259 mosaic1/30pt/30pt,%
260 mosaic2/70pt/70pt,%
261 mosaic3/110pt/110pt,%
262 mosaic4/110pt/110pt%
263 }%
264 }{
265 \begin{frame}
266 \begin{tikzpicture}[remember picture,overlay]
267 \foreach \pictname/\wid/\hei in \tiles {
268 \begin{scope}[ocg={name=\pictname,ref=\pictname}]
269 \TkzTileWallPaper{\wid}{\hei}{\pictname}
270 \end{scope}
271 }
272
273 \end{tikzpicture}
274
275 \centering\begin{tikzpicture}[start chain=going below,node distance=1em]
276 \node[fill=white,fill opacity=.75,align=center,
277 text=black,font=\tiny\bfseries,text opacity=1,
278 on chain,
279 rounded corners=2mm]
280 {{\huge\name}\\\url{\link}\\(\latex{} \url{\ltxlink})};
281
282 \foreach \pictname/\wid/\hei in \tiles {
283
284 \node[on chain,text=white,fill=black,fill opacity=.5,text opacity=1,
285 text width=3cm,align=center,font=\bfseries]
286 (a) {\hspace{5mm}\pictname};
287
288 \node[rounded corners=1mm,draw,line width=1pt,%
289 minimum size=3mm,top color=white,bottom color=black,
290 fill opacity=.5,
291 drop shadow={fill=black},
292 switch ocg with mark on={\pictname}{}]
293 at ([xshift=3mm,yshift=.5mm]a.west) {};
294
295 }
296 \end{tikzpicture}\par
297 \end{frame}
298 }
299
300 \begin{frame}
301 \frametitle{Microtype demo (first version without hierarchy)}
302
303 \def\sampletext{%
304 Margin kerning is the adjustments of the characters at the
305 margins of a typeset text. A simplified employment of margin
306 kerning is hanging punctuation. Margin kerning is needed for
307 optical alignment of the margins of a typeset text, because
308 mechanical justification of the margins makes them look rather
309 ragged. Some characters can make a line appear shorter to the
310 human eye than others. Shifting such characters by an
311 appropriate amount into the margins would greatly improve the
312 appearance of a typeset text.%
313 }
314
315 \tikzset{
316 checkbox/.style={
317 draw,circle,line width=.5pt,%
318 minimum size=.5em,top color=white,bottom color=cyan,
319 fill opacity=1,
320 inner sep=0,
321 drop shadow={fill=black,shadow xshift=.5mm,shadow yshift=-.5mm},
322 },
323 sampletext/.style={
324 text width=8cm,align=justify,
325 font=\small,
326 fill=yellow!20,
327 inner xsep=1.5cm,
328 inner ysep=1cm,
329 draw=gray,
330 },
331 }
332
333 {\centering
334 \begin{tikzpicture}
335 \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
336 \end{scope}
337 \begin{scope}[ocg={name=Without Protrusion,ref=no-protrusion,status=invisible}]
338 \end{scope}
339 \begin{scope}[ocg={name=With Expansion,ref=expansion}]
340 \end{scope}
341 \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
342 \end{scope}
343 \begin{scope}[ocg={name=Without Expansion,ref=no-expansion,status=invisible}]
344 \end{scope}
345 \begin{scope}[ocg={name=With Protrusion,ref=protrusion}]
346 \microtypesetup{protrusion=true}%
347 \begin{scope}[ocg={name=With Expansion,ref=expansion}]
348 \microtypesetup{expansion=true}%
349 \node[sampletext]{\sampletext\par};%
350 \end{scope}
351
352 \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-expansion}]
353 \microtypesetup{expansion=false}%
354 \node[sampletext]{\sampletext\par};%
355 \end{scope}
356 \end{scope}
357
358 \begin{scope}[ocg={name=Without Protrusion,status=invisible,ref=no-protrusion}]
359 \microtypesetup{protrusion=false}%
360 \begin{scope}[ocg={name=With Expansion,ref=expansion}]
361 \microtypesetup{expansion=true}%
362 \node[sampletext]{\sampletext\par};%
363 \end{scope}
364
365 \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-expansion}]
366 \microtypesetup{expansion=false}%
367 \node[sampletext]{\sampletext\par};%
368 \end{scope}
369 \end{scope}
370 \end{tikzpicture}\par
371 }
372
373 Microtype :
374 \begin{tikzpicture}
375 \node[checkbox,switch ocg with mark on={protrusion}{no-protrusion}]{};
376 \end{tikzpicture} with protrusion
377 \begin{tikzpicture}
378 \node[checkbox,switch ocg with mark on={expansion}{no-expansion}]{};
379 \end{tikzpicture} with expansion
380
381 \end{frame}
382
383 \begin{frame}
384 \frametitle{Microtype demo (second version with hierarchy)}
385
386 \def\sampletext{%
387 Margin kerning is the adjustments of the characters at the
388 margins of a typeset text. A simplified employment of margin
389 kerning is hanging punctuation. Margin kerning is needed for
390 optical alignment of the margins of a typeset text, because
391 mechanical justification of the margins makes them look rather
392 ragged. Some characters can make a line appear shorter to the
393 human eye than others. Shifting such characters by an
394 appropriate amount into the margins would greatly improve the
395 appearance of a typeset text.%
396 }
397
398 \tikzset{
399 checkbox/.style={
400 draw,circle,line width=.5pt,%
401 minimum size=.5em,top color=white,bottom color=cyan,
402 fill opacity=1,
403 inner sep=0,
404 drop shadow={fill=black,shadow xshift=.5mm,shadow yshift=-.5mm},
405 },
406 sampletext/.style={
407 text width=8cm,align=justify,
408 font=\small,
409 fill=yellow!20,
410 inner xsep=1.5cm,
411 inner ysep=1cm,
412 draw=gray,
413 },
414 }
415
416 {\centering
417 \begin{tikzpicture}
418 \begin{scope}[ocg={name=With Protrusion,ref=pro}]
419 \microtypesetup{protrusion=true}%
420 \begin{scope}[ocg={name=With Expansion,status=visible,ref=pro-exp}]
421 \microtypesetup{expansion=true}%
422 \node[sampletext]{\sampletext\par};%
423 \end{scope}
424
425 \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=pro-no-exp}]
426 \microtypesetup{expansion=false}%
427 \node[sampletext]{\sampletext\par};%
428 \end{scope}
429 \end{scope}
430
431 \begin{scope}[ocg={name=Without Protrusion,status=invisible,ref=no-pro}]
432 \microtypesetup{protrusion=false}%
433 \begin{scope}[ocg={name=With Expansion,status=visible,ref=no-pro-exp}]
434 \microtypesetup{expansion=true}%
435 \node[sampletext]{\sampletext\par};%
436 \end{scope}
437
438 \begin{scope}[ocg={name=Without Expansion,status=invisible,ref=no-pro-no-exp}]
439 \microtypesetup{expansion=false}%
440 \node[sampletext]{\sampletext\par};%
441 \end{scope}
442 \end{scope}
443 \end{tikzpicture}\par
444 }
445
446 Microtype :
447 \begin{tikzpicture}
448 \node[checkbox,switch ocg with mark on={pro}{no-pro}]{};
449 \end{tikzpicture} with protrusion
450 \begin{tikzpicture}
451 \node[checkbox,switch ocg with mark on={pro-exp}{pro-no-exp no-pro-exp no-pro-no-exp}]{};
452 \end{tikzpicture} with expansion
453
454 \end{frame}
455 \end{document}
456
457 %%% Local Variables:
458 %%% mode: latex
459 %%% TeX-master: t
460 %%% End: