summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/aobs-tikz/aobs-tikz.dtx
blob: dfdc624b37eaed61f1c8e4376766f875bd8a9a8e (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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
aobs-tikz - TikZ auxiliary styles for Beamer overlays

E-mail: claudio dot fiandrino at gmail dot com

Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The package defines auxiliary TikZ styles useful for
overlaying pictures' elements in Beamer.

The TikZ styles are grouped in a library, overlay-beamer-styles
which is automatically called by the aobs-tikz package. Users 
can either load only aobs-tikz or the library; the latter method 
necessitates TikZ manual load.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
aobs-tikz - TikZ auxiliary styles for Beamer overlays

E-mail: claudio dot fiandrino at gmail dot com

Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The package defines auxiliary TikZ styles useful for
overlaying pictures' elements in Beamer.

The TikZ styles are grouped in a library, overlay-beamer-styles
which is automatically called by the aobs-tikz package. Users 
can either load only aobs-tikz or the library; the latter method 
necessitates TikZ manual load.
\endpreamble
\postamble

Copyright (C) 2014 by Claudio Fiandrino <claudio.fiandrino@gmail.com>

This file may be distributed and/or modified under the conditions
of the LaTeX Project Public License, either version 1.3 of this
license or (at your option) any later version.
The latest version of this license is in:

   http://www.latex-project.org/lppl.txt

and version 1.3 or later is part of all distributions of LaTeX
version 2005/12/01 or later.

This work is "maintained" (as per LPPL maintenance status) by
Claudio Fiandrino.

This work consists of the files  aobs-tikz.dtx
and the derived files  aobs-tikz.ins
                                 aobs-tikz.sty
                                 tikzlibrarybeamer-overlay-styles.code.tex
                                 aobs-tikz.pdf
                                 example.tex 
                                 example.pdf
                                 README.txt

\endpostamble
\generate{\file{tikzlibraryoverlay-beamer-styles.code.tex} {\from{\jobname.dtx}{tikzlibrary}}}
\generate{\file{example.tex} {\from{\jobname.dtx}{example}}}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\generate{
   \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aobs-tikz}[2014/01/12 v1.0 Auxiliary TikZ styles for picture overlay in Beamer]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{charter,pxfonts}
\RequirePackage[dvipsnames]{xcolor}%
\definecolor{Eored}{rgb}{.647,.129,.149}
\definecolor{Eogreen}{rgb}{0,0.53,0}
\convertcolorspec{cmyk}{0.94,0.53,0,0}{rgb}\Eoblue
\definecolor{Eoblue}{rgb}{\Eoblue}
\usepackage{listings}
\lstset{language=[LaTeX]Tex,
    keywordstyle=\color{Eored},
    texcsstyle=*\color{Eored},
    basicstyle=\footnotesize\ttfamily,
    commentstyle=\footnotesize\color{Eogreen}\rmfamily,
    stringstyle=\footnotesize\rmfamily,
    showstringspaces=false,
    morekeywords={usetikzlibrary,node,tikzset,tikzstyle,
     path,draw,foreach,pgfmathsetmacro,tikz},
    literate=
            *{\{}{{{\color{Eoblue}{\{}}}}{1}
            {\}}{{{\color{Eoblue}{\}}}}}{1}
            {(}{{{\color{Eoblue}{(}}}}{1}
            {)}{{{\color{Eoblue}{)}}}}{1}
            {[}{{{\color{Eoblue}{[}}}}{1}
            {]}{{{\color{Eoblue}{]}}}}{1}
            {!}{{{!}}}{1},   
}

\usepackage{hypdoc}
\newcommand\aobstikz{\textsf{aobs-tikz}}
\newcommand\aobstikzversion{1.0}
\newcommand\aobstikzdate{\today}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{101}
%
% \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
%   Lower-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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.1}{2013/12/19}{Initial version}
% \changes{v0.2}{2013/12/23}{Path aspects}
%
% \GetFileInfo{aobs-tikz.sty}
%
% \title{The \aobstikz{} package\thanks{This document
% corresponds to \textsf{aobs-tikz}~v\aobstikzversion,
% dated~\aobstikzdate. It is released under and subject to the latest version of the \href{http://www.latex-project.org/lppl/}{\LaTeX\ Project Public License (LPPL)}.}}
% \author{Claudio Fiandrino \\ \footnotesize\href{mailto:claudio.fiandrino@gmail.com}{claudio.fiandrino@gmail.com}}
% \maketitle
% 
% \begin{abstract}
% The package provides auxiliary styles helpful for drawing overlayed pictures in Beamer. These styles should be intended as extension of the previous work shown by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} of \href{http://tex.stackexchange.com}{TeX.SX} in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)}. 
% \end{abstract}
% \tableofcontents
%\section{Introduction}
% The aim of \aobstikz{} is to provide users simple tools to create overlayed-aware pictures for Beamer presentations. A set of new TikZ styles, grouped within a library, has been define on purpose.
%
% The library is proposed as extension of the previous work by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} on \href{www.tex-stackexchange.com}{TeX.SX}, illustrated in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)}. The very first version of the library has been implemented for answering the question \href{http://tex.stackexchange.com/q/84513/13304}{Highlighting in Beamer using TikZ nodes}: \aobstikz{} further extends and improves the original styles. 
%
% The main advantage of using the new styles is that they automatically prevent the so called \emph{jumping-effect} which occasionally happen with Beamer. 
%
% \section{The new styles}
% The new styles can create overlays by altering the colors and the aspect of pictures' elements. 
% Usually, to create an animation, the elements have to appear or disapper, the shading, the fill or the border color should change. To achieve this goal, three features have to be specified: the normal behavior, the modified behaviour and the moments in which the modified behaviour takes place. \aobstikz{} defines TikZ styles for these three features accordingly . For example, to alter the shape filling, it is possible to exploit:
% \begin{itemize}
% \item \texttt{background default fill=<\textit{style}>}: the style used for default behaviour;
% \item \texttt{background fill=<\textit{style}>}: the style used for the modified behaviour;
% \item \texttt{fill on=<\textit{overlay specifications}>}: moments in which the modified behaviour is activated.
% \end{itemize}
% The new styles can alter the following TikZ properties:
% \begin{itemize}
% \item \emph{fill};
% \item \emph{draw};
% \item \emph{filldraw};
% \item \emph{text};
% \item path aspect, including thickness, double line and pattern (solid, dashed, dotted, etc\ldots);
% \item \emph{shade};
% \item \emph{shadedraw}.
% \end{itemize}
% \DescribeMacro{draw}^^A
% To alter the border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default draw=<\textit{style}>};
% \item \texttt{background draw=<\textit{style}>};
% \item \texttt{draw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{filldraw}^^A
% To alter the both filling and border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
% \item \texttt{background filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
% \item \texttt{filldraw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{text}^^A
% To alter the \texttt{text} color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default text=<\textit{style}>};
% \item \texttt{background text=<\textit{style}>};
% \item \texttt{text on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{path aspect}^^A
% To alter the path aspect, the following options are available:
% \begin{itemize}
% \item \texttt{background default aspect=<\textit{style}>};
% \item \texttt{background aspect=<\textit{style}>};
% \item \texttt{aspect on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{shade}^^A
% To alter the shading properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default shade=<\textit{style}>};
% \item \texttt{background shade=<\textit{style}>};
% \item \texttt{shade on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{shadedraw}^^A
% To alter both filling and border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default shadedraw=<\textit{style}>};
% \item \texttt{background shadedraw=<\textit{style}>};
% \item \texttt{shadedraw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \StopEventually{\PrintChanges}
% \section{Implementation}
% \subsection{Package}
%
% \iffalse
%<*package>
% \fi
% The package itself loads only TikZ and the library \texttt{overlay-beamer-styles}.
%    \begin{macrocode}
\RequirePackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
%    \end{macrocode} 
% \iffalse
%</package>
% \fi
% \iffalse
%<*tikzlibrary>
% \fi
% \subsection{TikZ Library}
% The core of the package is the TikZ library \texttt{overlay-beamer-styles}. The first style defined is \texttt{visible on} based on prior work by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} of \href{http://tex.stackexchange.com}{TeX.SX} in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)}. The original style has been enforced to make it working also in presence of opaque text.
%    \begin{macrocode}
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

\tikzset{
  background text/.style={text=#1},
  background text/.default={black},
  background default text/.style={
    background text/.default={#1},
  },
  text on/.style={alt=#1{}{background text}},
}

\tikzset{
  background fill/.style={fill=#1},
  background fill/.default={white},
  background default fill/.style={
    background fill/.default={#1},
  },
  fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
  background draw/.style={draw=#1},
  background draw/.default={white},
  background default draw/.style={
    background draw/.default={#1},
  },
  draw on/.style={alt=#1{}{background draw}}
}

\tikzset{
  background filldraw/.style args={#1 filled by #2}{draw=#1, fill=#2},
  background filldraw/.default=white filled by white,
  background default filldraw/.style={
    background filldraw/.default={#1},
  },
  filldraw on/.style={alt=#1{}{background filldraw}},
}

\tikzset{
  background aspect/.style={#1},
  background aspect/.default={white},
  background default aspect/.style={
    background aspect/.default={#1},
  },
  aspect on/.style={alt=#1{}{background aspect}},
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={top color=white, bottom color=white},
  background default shade/.style={
    background shade/.default={#1},
  },
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background shadedraw/.style 2 args={draw=#1, #2},
  background shadedraw/.default={white}{top color=white, bottom color=white},
  background default shadedraw/.style={
    background shadedraw/.default={#1},
  },
  shadedraw on/.style={alt=#1{}{background shadedraw}},
}
%    \end{macrocode}
% At this point, some comments are needed on the subsequent option \texttt{double disabled}. For the best of my knowledge, this is option is not implemented in PGF 2.10 either in PGF 3.0.0, but it is absolutely relevant to the scope of this library. Suppose you wish to alter a double path by removing in some moments its double property: without the following option, it would not be possible (at least without redrawing the path).
%    \begin{macrocode}
% option for disabling double when not needed in 
% subsequent overlays
\tikzoption{double disabled}[0pt]{%
  \pgfmathsetlength{\pgf@x}{#1}%
  \edef\tikz@double@setup{%
    \pgf@x=\the\pgf@x%
    \pgflinewidth=\pgf@x%
    \noexpand\pgfsetlinewidth{\pgflinewidth}%
    \noexpand\pgfsetinnerlinewidth{\the\pgf@x}%
  }%
\tikzset{double}}
%    \end{macrocode}
%
% \iffalse
%</tikzlibrary>
% \fi
% 
% \section{Example}
% It follows a complete example which exploits all the defined styles. The first frame mainly reports showcases of border, filling and shading properties modifications. The second frame shows examples of modifications for the remaining properties, including text color and path aspect.
%
% \iffalse
%<*example>
% \fi
%    \begin{macrocode}
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,
  shapes.geometric,
  shadows
}
% loading new library
\usetikzlibrary{overlay-beamer-styles}

\definecolor{processblue}{cmyk}{0.96,0,0,0}

\begin{document}
\begin{frame}{Styles for draw, fill and shading modifications}
\begin{columns}[T]
\begin{column}{0.2\textwidth}
\centering
Fill draw\\[2ex]
\tikz[baseline=(A.base)]{%
\node[background fill=red!50,%
      fill on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {ABCD};
}

\tikz[baseline=(A.base)]{%
\node[background fill=blue!50,%
      fill on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {EFGH};
}

\tikz[baseline=(A.base)]{%
\node[background draw=red,%
      draw on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {IJKL};
}

\tikz[baseline=(A.base)]{%
\node[background draw=blue,%
      draw on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {MNOP};
}

\tikz[baseline=(A.base)]{%
\node[background filldraw=red filled by blue!10,%
      filldraw on=<2>,anchor=base,%
      rounded corners,%
      ] (A) {QRST};
}
\end{column}
\begin{column}{0.2\textwidth}
\centering
Shadings\\[2ex]
\tikz[baseline=(A.base)]{%
\node[background shade={top color=red!50, bottom color=white},%
      shade on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {ABCD};
}

\tikz[baseline=(A.base)]{%
\node[background shade={inner color=red!50, outer color=white},%
      shade on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {EFGH};
}

\tikz[baseline=(A.base)]{
\node[background shade={left color=orange!50, right color=white},%
      shade on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {IJKL};
}

\tikz[baseline=(A.base)]{
\node[background shadedraw={blue}{top color=white, bottom color=cyan!30},%
      shadedraw on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {MNOP};
}

\tikz[baseline=(A.base)]{
\node[background shadedraw={green!50!black}{inner color=white,%
      outer color=green!30},%
      shadedraw on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {QRST};
}
\end{column}
\begin{column}{0.55\textwidth}
\centering
Node application\\[2ex]
\begin{tikzpicture}[node distance=0.5cm]
%    \end{macrocode}
% Of course, it is always possible to group in high-level styles the styles provided by \aobstikz.
%    \begin{macrocode}
\tikzset{visibility 1/.style={
      background draw=red, draw on=<{1,4}>,
      background shade={top color=white,
      bottom color=red!30},
      shade on=<{2,3}>,
      }
}
\tikzset{visibility 2/.style={
      background shadedraw={green!50!black}{inner color=white,
      outer color=green!30},
      shadedraw on=<{2,3}>,
      }
}
\tikzset{visibility 3/.style={
      background draw=orange,
      draw on=<1->,
      background fill={orange!30},
      fill on=<{2,3}>,
    }
}
%    \end{macrocode}
% The following high-level style shows that the new styles can be combined to obtained more fine results. Specifically, rather than using a \textit{shadedraw} modification, the \texttt{visibility 4} style exploits separately \textit{shade} and \textit{draw} modifications to having them visible in different overlays.
%    \begin{macrocode}
\tikzset{visibility 4/.style={
      background draw=purple,
      draw on=<2->,
      background shade={left color=purple!30,
      right color=cyan!30},
      shade on=<{3,4}>,
    }
}
\node[trapezium,
      visibility 1] (A) {Text};
\node[trapezium,
      visibility 2,
      below= of A] (B) {Text};
\node[trapezium,
      visibility 3,
      below= of B] (C) {Text};
\node[trapezium,
      visibility 4,
      below= of C] (D) {Text};
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Styles for path aspect and text color modifications}
\centering
\begin{tikzpicture}[node distance=3cm and 2cm,
      semithick ,
      state/.style={circle,
            top color=white,
            bottom color=processblue!20,
            draw, processblue,
            text=blue,
            minimum width=1cm},
      background default shade={top color=white,
            bottom color=processblue!20},
      background default draw={processblue,
            semithick}]
%    \end{macrocode}
% Shadows can be managed with the help of the style \texttt{visible on}: it follows an example with a \textit{circular drop shadow}.
%    \begin{macrocode}
\node[state,
      background draw={blue!80,
            line width=1mm},
      draw on=<2>,
      circular drop shadow={visible on=<2>},
      visible on=<{1,2}>% NOT visible in 3 
     ] (C) {$1$};
\node[state,
      background draw={orange},
      draw on=<{1,3}>,
      background default aspect={semithick,
            double disabled},
      background aspect={double},
      aspect on=<{1,3}>,
      background shade={top color=white,
            bottom color=orange!30},
      shade on=<{1,3}>,
      above left= of  C] (A) {$0$};

\node[state,
      background text=violet,
      background default text=red,
      text on=<2>,
      above right= of C] (B) {$2$};

\draw (A)-- (B) (C)-- (A);

\draw[background default aspect={solid,semithick},
      background aspect={dashdotted,
            very thick},
      aspect on=<{2,3}>,
      background default draw={black},
      background draw={red},
      draw on=<3>](B)-- (C);
\end{tikzpicture}
\end{frame}
\end{document}
%    \end{macrocode}
% \iffalse
%</example>
% \fi
%
% 
%\Finale