Debian Codegraph @

texmf-dist/source/latex/aobs-tikz/aobs-tikz.dtx

raw
1 % \iffalse meta-comment
2 %<*internal>
3 \iffalse
4 %</internal>
5 %<*readme>
6 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7 aobs-tikz - TikZ auxiliary styles for Beamer overlays
8
9 E-mail: claudio dot fiandrino at gmail dot com
10
11 Released under the LaTeX Project Public License v1.3c or later
12 See http://www.latex-project.org/lppl.txt
13 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
14
15 The package defines auxiliary TikZ styles useful for
16 overlaying pictures' elements in Beamer.
17
18 The TikZ styles are grouped in a library, overlay-beamer-styles
19 which is automatically called by the aobs-tikz package. Users
20 can either load only aobs-tikz or the library; the latter method
21 necessitates TikZ manual load.
22 %</readme>
23 %<*internal>
24 \fi
25 \def\nameofplainTeX{plain}
26 \ifx\fmtname\nameofplainTeX\else
27 \expandafter\begingroup
28 \fi
29 %</internal>
30 %<*install>
31 \input docstrip.tex
32 \keepsilent
33 \askforoverwritefalse
34 \preamble
35 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
36 aobs-tikz - TikZ auxiliary styles for Beamer overlays
37
38 E-mail: claudio dot fiandrino at gmail dot com
39
40 Released under the LaTeX Project Public License v1.3c or later
41 See http://www.latex-project.org/lppl.txt
42 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43
44 The package defines auxiliary TikZ styles useful for
45 overlaying pictures' elements in Beamer.
46
47 The TikZ styles are grouped in a library, overlay-beamer-styles
48 which is automatically called by the aobs-tikz package. Users
49 can either load only aobs-tikz or the library; the latter method
50 necessitates TikZ manual load.
51 \endpreamble
52 \postamble
53
54 Copyright (C) 2024 by Claudio Fiandrino <[email protected]>
55
56 This file may be distributed and/or modified under the conditions
57 of the LaTeX Project Public License, either version 1.3 of this
58 license or (at your option) any later version.
59 The latest version of this license is in:
60
61 http://www.latex-project.org/lppl.txt
62
63 and version 1.3 or later is part of all distributions of LaTeX
64 version 2005/12/01 or later.
65
66 This work is "maintained" (as per LPPL maintenance status) by
67 Claudio Fiandrino.
68
69 This work consists of the files aobs-tikz.dtx
70 and the derived files aobs-tikz.ins
71 aobs-tikz.sty
72 tikzlibrarybeamer-overlay-styles.code.tex
73 aobs-tikz.pdf
74 example.tex
75 example.pdf
76 README.txt
77
78 \endpostamble
79 \generate{\file{tikzlibraryoverlay-beamer-styles.code.tex} {\from{\jobname.dtx}{tikzlibrary}}}
80 \generate{\file{example.tex} {\from{\jobname.dtx}{example}}}
81 %</install>
82 %<install>\endbatchfile
83 %<*internal>
84 \generate{
85 \file{\jobname.sty}{\from{\jobname.dtx}{package}}
86 }
87 \generate{
88 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
89 }
90 \nopreamble\nopostamble
91 \generate{
92 \file{README.txt}{\from{\jobname.dtx}{readme}}
93 }
94 \ifx\fmtname\nameofplainTeX
95 \expandafter\endbatchfile
96 \else
97 \expandafter\endgroup
98 \fi
99 %</internal>
100 %<*package>
101 \NeedsTeXFormat{LaTeX2e}
102 \ProvidesPackage{aobs-tikz}[2024/04/15 v1.01 Auxiliary TikZ styles for picture overlay in Beamer]
103 %</package>
104 %<*driver>
105 \documentclass{ltxdoc}
106 \usepackage[T1]{fontenc}
107 \usepackage{csquotes}
108 \usepackage{charter,pxfonts}
109 \RequirePackage[dvipsnames]{xcolor}%
110 \definecolor{Eored}{rgb}{.647,.129,.149}
111 \definecolor{Eogreen}{rgb}{0,0.53,0}
112 \convertcolorspec{cmyk}{0.94,0.53,0,0}{rgb}\Eoblue
113 \definecolor{Eoblue}{rgb}{\Eoblue}
114 \usepackage{listings}
115 \lstset{language=[LaTeX]Tex,
116 keywordstyle=\color{Eored},
117 texcsstyle=*\color{Eored},
118 basicstyle=\footnotesize\ttfamily,
119 commentstyle=\footnotesize\color{Eogreen}\rmfamily,
120 stringstyle=\footnotesize\rmfamily,
121 showstringspaces=false,
122 morekeywords={usetikzlibrary,node,tikzset,tikzstyle,
123 path,draw,foreach,pgfmathsetmacro,tikz},
124 literate=
125 *{\{}{{{\color{Eoblue}{\{}}}}{1}
126 {\}}{{{\color{Eoblue}{\}}}}}{1}
127 {(}{{{\color{Eoblue}{(}}}}{1}
128 {)}{{{\color{Eoblue}{)}}}}{1}
129 {[}{{{\color{Eoblue}{[}}}}{1}
130 {]}{{{\color{Eoblue}{]}}}}{1}
131 {!}{{{!}}}{1},
132 }
133
134 \usepackage{hypdoc}
135 \newcommand\aobstikz{\textsf{aobs-tikz}}
136 \newcommand\aobstikzversion{1.01}
137 \newcommand\aobstikzdate{\today}
138 \EnableCrossrefs
139 \CodelineIndex
140 \RecordChanges
141 \begin{document}
142 \DocInput{\jobname.dtx}
143 \end{document}
144 %</driver>
145 % \fi
146 %
147 % \CheckSum{101}
148 %
149 % \CharacterTable
150 % {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
151 % 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
152 % Digits \0\1\2\3\4\5\6\7\8\9
153 % Exclamation \! Double quote \" Hash (number) \#
154 % Dollar \$ Percent \% Ampersand \&
155 % Acute accent \' Left paren \( Right paren \)
156 % Asterisk \* Plus \+ Comma \,
157 % Minus \- Point \. Solidus \/
158 % Colon \: Semicolon \; Less than \<
159 % Equals \= Greater than \> Question mark \?
160 % Commercial at \@ Left bracket \[ Backslash \\
161 % Right bracket \] Circumflex \^ Underscore \_
162 % Grave accent \` Left brace \{ Vertical bar \|
163 % Right brace \} Tilde \~}
164 %
165 %
166 % \changes{v0.1}{2013/12/19}{Initial version}
167 % \changes{v0.2}{2013/12/23}{Path aspects}
168 % \changes{v0.2}{2024/04/15}{Thanking Matthew}
169 %
170 % \GetFileInfo{aobs-tikz.sty}
171 %
172 % \title{The \aobstikz{} package\thanks{This document
173 % corresponds to \textsf{aobs-tikz}~v\aobstikzversion,
174 % 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)}.}}
175 % \author{Claudio Fiandrino \\ \footnotesize\href{mailto:[email protected]}{[email protected]}}
176 % \maketitle
177 %
178 % \begin{abstract}
179 % 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)} which, in turn, is based on the work of \href{https://tex.stackexchange.com/users/1402/matthew-leingang}{Matthew Leingang} in \href{https://tex.stackexchange.com/a/6155/13304}{How to make beamer overlays with Tikz node}.
180 % \end{abstract}
181 % \tableofcontents
182 %\section{Introduction}
183 % 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.
184 %
185 % 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)} which, in turn, is based on the work of \href{https://tex.stackexchange.com/users/1402/matthew-leingang}{Matthew Leingang} in \href{https://tex.stackexchange.com/a/6155/13304}{How to make beamer overlays with Tikz node}. 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.
186 %
187 % The main advantage of using the new styles is that they automatically prevent the so called \emph{jumping-effect} which occasionally happen with Beamer.
188 %
189 % \section{The new styles}
190 % The new styles can create overlays by altering the colors and the aspect of pictures' elements.
191 % 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:
192 % \begin{itemize}
193 % \item \texttt{background default fill=<\textit{style}>}: the style used for default behaviour;
194 % \item \texttt{background fill=<\textit{style}>}: the style used for the modified behaviour;
195 % \item \texttt{fill on=<\textit{overlay specifications}>}: moments in which the modified behaviour is activated.
196 % \end{itemize}
197 % The new styles can alter the following TikZ properties:
198 % \begin{itemize}
199 % \item \emph{fill};
200 % \item \emph{draw};
201 % \item \emph{filldraw};
202 % \item \emph{text};
203 % \item path aspect, including thickness, double line and pattern (solid, dashed, dotted, etc\ldots);
204 % \item \emph{shade};
205 % \item \emph{shadedraw}.
206 % \end{itemize}
207 % \DescribeMacro{draw}^^A
208 % To alter the border color properties, the following options are available:
209 % \begin{itemize}
210 % \item \texttt{background default draw=<\textit{style}>};
211 % \item \texttt{background draw=<\textit{style}>};
212 % \item \texttt{draw on=<\textit{overlay specifications}>}.
213 % \end{itemize}
214 % \DescribeMacro{filldraw}^^A
215 % To alter the both filling and border color properties, the following options are available:
216 % \begin{itemize}
217 % \item \texttt{background default filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
218 % \item \texttt{background filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
219 % \item \texttt{filldraw on=<\textit{overlay specifications}>}.
220 % \end{itemize}
221 % \DescribeMacro{text}^^A
222 % To alter the \texttt{text} color properties, the following options are available:
223 % \begin{itemize}
224 % \item \texttt{background default text=<\textit{style}>};
225 % \item \texttt{background text=<\textit{style}>};
226 % \item \texttt{text on=<\textit{overlay specifications}>}.
227 % \end{itemize}
228 % \DescribeMacro{path aspect}^^A
229 % To alter the path aspect, the following options are available:
230 % \begin{itemize}
231 % \item \texttt{background default aspect=<\textit{style}>};
232 % \item \texttt{background aspect=<\textit{style}>};
233 % \item \texttt{aspect on=<\textit{overlay specifications}>}.
234 % \end{itemize}
235 % \DescribeMacro{shade}^^A
236 % To alter the shading properties, the following options are available:
237 % \begin{itemize}
238 % \item \texttt{background default shade=<\textit{style}>};
239 % \item \texttt{background shade=<\textit{style}>};
240 % \item \texttt{shade on=<\textit{overlay specifications}>}.
241 % \end{itemize}
242 % \DescribeMacro{shadedraw}^^A
243 % To alter both filling and border color properties, the following options are available:
244 % \begin{itemize}
245 % \item \texttt{background default shadedraw=<\textit{style}>};
246 % \item \texttt{background shadedraw=<\textit{style}>};
247 % \item \texttt{shadedraw on=<\textit{overlay specifications}>}.
248 % \end{itemize}
249 % \StopEventually{\PrintChanges}
250 % \section{Implementation}
251 % \subsection{Package}
252 %
253 % \iffalse
254 %<*package>
255 % \fi
256 % The package itself loads only TikZ and the library \texttt{overlay-beamer-styles}.
257 % \begin{macrocode}
258 \RequirePackage{tikz}
259 \usetikzlibrary{overlay-beamer-styles}
260 % \end{macrocode}
261 % \iffalse
262 %</package>
263 % \fi
264 % \iffalse
265 %<*tikzlibrary>
266 % \fi
267 % \subsection{TikZ Library}
268 % 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.
269 % \begin{macrocode}
270 \tikzset{
271 invisible/.style={opacity=0,text opacity=0},
272 visible on/.style={alt=#1{}{invisible}},
273 alt/.code args={<#1>#2#3}{%
274 \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
275 },
276 }
277
278 \tikzset{
279 background text/.style={text=#1},
280 background text/.default={black},
281 background default text/.style={
282 background text/.default={#1},
283 },
284 text on/.style={alt=#1{}{background text}},
285 }
286
287 \tikzset{
288 background fill/.style={fill=#1},
289 background fill/.default={white},
290 background default fill/.style={
291 background fill/.default={#1},
292 },
293 fill on/.style={alt=#1{}{background fill}},
294 }
295
296 \tikzset{
297 background draw/.style={draw=#1},
298 background draw/.default={white},
299 background default draw/.style={
300 background draw/.default={#1},
301 },
302 draw on/.style={alt=#1{}{background draw}}
303 }
304
305 \tikzset{
306 background filldraw/.style args={#1 filled by #2}{draw=#1, fill=#2},
307 background filldraw/.default=white filled by white,
308 background default filldraw/.style={
309 background filldraw/.default={#1},
310 },
311 filldraw on/.style={alt=#1{}{background filldraw}},
312 }
313
314 \tikzset{
315 background aspect/.style={#1},
316 background aspect/.default={white},
317 background default aspect/.style={
318 background aspect/.default={#1},
319 },
320 aspect on/.style={alt=#1{}{background aspect}},
321 }
322
323 \tikzset{
324 background shade/.style={#1},
325 background shade/.default={top color=white, bottom color=white},
326 background default shade/.style={
327 background shade/.default={#1},
328 },
329 shade on/.style={alt=#1{}{background shade}},
330 }
331
332 \tikzset{
333 background shadedraw/.style 2 args={draw=#1, #2},
334 background shadedraw/.default={white}{top color=white, bottom color=white},
335 background default shadedraw/.style={
336 background shadedraw/.default={#1},
337 },
338 shadedraw on/.style={alt=#1{}{background shadedraw}},
339 }
340 % \end{macrocode}
341 % 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).
342 % \begin{macrocode}
343 % option for disabling double when not needed in
344 % subsequent overlays
345 \tikzoption{double disabled}[0pt]{%
346 \pgfmathsetlength{\pgf@x}{#1}%
347 \edef\tikz@double@setup{%
348 \pgf@x=\the\pgf@x%
349 \pgflinewidth=\pgf@x%
350 \noexpand\pgfsetlinewidth{\pgflinewidth}%
351 \noexpand\pgfsetinnerlinewidth{\the\pgf@x}%
352 }%
353 \tikzset{double}}
354 % \end{macrocode}
355 %
356 % \iffalse
357 %</tikzlibrary>
358 % \fi
359 %
360 % \section{Example}
361 % 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.
362 %
363 % \iffalse
364 %<*example>
365 % \fi
366 % \begin{macrocode}
367 \documentclass{beamer}
368 \usepackage{lmodern}
369 \usepackage{tikz}
370 \usetikzlibrary{positioning,
371 shapes.geometric,
372 shadows
373 }
374 % loading new library
375 \usetikzlibrary{overlay-beamer-styles}
376
377 \definecolor{processblue}{cmyk}{0.96,0,0,0}
378
379 \begin{document}
380 \begin{frame}{Styles for draw, fill and shading modifications}
381 \begin{columns}[T]
382 \begin{column}{0.2\textwidth}
383 \centering
384 Fill draw\\[2ex]
385 \tikz[baseline=(A.base)]{%
386 \node[background fill=red!50,%
387 fill on=<2>,%
388 anchor=base,%
389 rounded corners,%
390 ] (A) {ABCD};
391 }
392
393 \tikz[baseline=(A.base)]{%
394 \node[background fill=blue!50,%
395 fill on=<{1,3}>,%
396 anchor=base,%
397 rounded corners,%
398 ] (A) {EFGH};
399 }
400
401 \tikz[baseline=(A.base)]{%
402 \node[background draw=red,%
403 draw on=<2>,%
404 anchor=base,%
405 rounded corners,%
406 ] (A) {IJKL};
407 }
408
409 \tikz[baseline=(A.base)]{%
410 \node[background draw=blue,%
411 draw on=<{1,3}>,%
412 anchor=base,%
413 rounded corners,%
414 ] (A) {MNOP};
415 }
416
417 \tikz[baseline=(A.base)]{%
418 \node[background filldraw=red filled by blue!10,%
419 filldraw on=<2>,anchor=base,%
420 rounded corners,%
421 ] (A) {QRST};
422 }
423 \end{column}
424 \begin{column}{0.2\textwidth}
425 \centering
426 Shadings\\[2ex]
427 \tikz[baseline=(A.base)]{%
428 \node[background shade={top color=red!50, bottom color=white},%
429 shade on=<2>,%
430 anchor=base,%
431 rounded corners,%
432 ] (A) {ABCD};
433 }
434
435 \tikz[baseline=(A.base)]{%
436 \node[background shade={inner color=red!50, outer color=white},%
437 shade on=<{1,3}>,%
438 anchor=base,%
439 rounded corners,%
440 ] (A) {EFGH};
441 }
442
443 \tikz[baseline=(A.base)]{
444 \node[background shade={left color=orange!50, right color=white},%
445 shade on=<2>,%
446 anchor=base,%
447 rounded corners,%
448 ] (A) {IJKL};
449 }
450
451 \tikz[baseline=(A.base)]{
452 \node[background shadedraw={blue}{top color=white, bottom color=cyan!30},%
453 shadedraw on=<{1,3}>,%
454 anchor=base,%
455 rounded corners,%
456 ] (A) {MNOP};
457 }
458
459 \tikz[baseline=(A.base)]{
460 \node[background shadedraw={green!50!black}{inner color=white,%
461 outer color=green!30},%
462 shadedraw on=<2>,%
463 anchor=base,%
464 rounded corners,%
465 ] (A) {QRST};
466 }
467 \end{column}
468 \begin{column}{0.55\textwidth}
469 \centering
470 Node application\\[2ex]
471 \begin{tikzpicture}[node distance=0.5cm]
472 % \end{macrocode}
473 % Of course, it is always possible to group in high-level styles the styles provided by \aobstikz.
474 % \begin{macrocode}
475 \tikzset{visibility 1/.style={
476 background draw=red, draw on=<{1,4}>,
477 background shade={top color=white,
478 bottom color=red!30},
479 shade on=<{2,3}>,
480 }
481 }
482 \tikzset{visibility 2/.style={
483 background shadedraw={green!50!black}{inner color=white,
484 outer color=green!30},
485 shadedraw on=<{2,3}>,
486 }
487 }
488 \tikzset{visibility 3/.style={
489 background draw=orange,
490 draw on=<1->,
491 background fill={orange!30},
492 fill on=<{2,3}>,
493 }
494 }
495 % \end{macrocode}
496 % 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.
497 % \begin{macrocode}
498 \tikzset{visibility 4/.style={
499 background draw=purple,
500 draw on=<2->,
501 background shade={left color=purple!30,
502 right color=cyan!30},
503 shade on=<{3,4}>,
504 }
505 }
506 \node[trapezium,
507 visibility 1] (A) {Text};
508 \node[trapezium,
509 visibility 2,
510 below= of A] (B) {Text};
511 \node[trapezium,
512 visibility 3,
513 below= of B] (C) {Text};
514 \node[trapezium,
515 visibility 4,
516 below= of C] (D) {Text};
517 \end{tikzpicture}
518 \end{column}
519 \end{columns}
520 \end{frame}
521
522 \begin{frame}{Styles for path aspect and text color modifications}
523 \centering
524 \begin{tikzpicture}[node distance=3cm and 2cm,
525 semithick ,
526 state/.style={circle,
527 top color=white,
528 bottom color=processblue!20,
529 draw, processblue,
530 text=blue,
531 minimum width=1cm},
532 background default shade={top color=white,
533 bottom color=processblue!20},
534 background default draw={processblue,
535 semithick}]
536 % \end{macrocode}
537 % Shadows can be managed with the help of the style \texttt{visible on}: it follows an example with a \textit{circular drop shadow}.
538 % \begin{macrocode}
539 \node[state,
540 background draw={blue!80,
541 line width=1mm},
542 draw on=<2>,
543 circular drop shadow={visible on=<2>},
544 visible on=<{1,2}>% NOT visible in 3
545 ] (C) {$1$};
546 \node[state,
547 background draw={orange},
548 draw on=<{1,3}>,
549 background default aspect={semithick,
550 double disabled},
551 background aspect={double},
552 aspect on=<{1,3}>,
553 background shade={top color=white,
554 bottom color=orange!30},
555 shade on=<{1,3}>,
556 above left= of C] (A) {$0$};
557
558 \node[state,
559 background text=violet,
560 background default text=red,
561 text on=<2>,
562 above right= of C] (B) {$2$};
563
564 \draw (A)-- (B) (C)-- (A);
565
566 \draw[background default aspect={solid,semithick},
567 background aspect={dashdotted,
568 very thick},
569 aspect on=<{2,3}>,
570 background default draw={black},
571 background draw={red},
572 draw on=<3>](B)-- (C);
573 \end{tikzpicture}
574 \end{frame}
575 \end{document}
576 % \end{macrocode}
577 % \iffalse
578 %</example>
579 % \fi
580 %
581 %
582 %\Finale