introduction to tikz
TRANSCRIPT
-
8/12/2019 Introduction to TikZ
1/195
-
8/12/2019 Introduction to TikZ
2/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Introduction
A Picture is Worth a Thousand Words
Pictures and figures improve papers and slides for talks.
One picture on each slide
Possible sources:
pixel graphics from the Internet
vector graphics manually created using
Inkscape
xfigTikZ
. . .
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 1 / 43
-
8/12/2019 Introduction to TikZ
3/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Introduction
TikZ
TikZ istkeinZeichenprogramm
A language to create vector graphics
Two components:
1 TikZ
easy to use high-level LATEX commands2 PGF(Portable Graphics Format)
low-level commands
Pros
Optics fit to document
Graphics can contain LATEX
Perfect integration to Beamer
Export from a lot of tools
Cons
No WYSIWYG
Slow?
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 2 / 43
-
8/12/2019 Introduction to TikZ
4/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Introduction
For Starters
How to add a TikZ picture to your document?
1 include the packagetikz.
2 include additional TikZ libraries, if necessary
3 write TikZ code
graphics are described withintikzpictureenvironment
put into a picture environment to add caption, reference etc.
inline-TikZ: use the\tikzcommand to create inline graphics
like this nice 5-wheel here.
Example
It is easy to draw a thistle .
\tikz{ \filldraw[color=Thistle] circle (0.5ex); }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 3 / 43
-
8/12/2019 Introduction to TikZ
5/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing on Paths
Generel principle
central syntactic element is apath
a sequence of coordinates and drawing commands
General syntax:
\draw[options] (coordinate) command (coordinate) ...;
like moving a pencil to some place and start drawing something.
different types of paths are started with . . .
\draw draws lines and shapes
\fill fills interior shapes\filldraw draws exterior and interior of shapes
\node places a node (containing text) somewhere
\coordinate places an invisible, named coordinate somewhere
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 4 / 43
TikZ B i Ad d TikZ E M Ad d TikZ
-
8/12/2019 Introduction to TikZ
6/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
A First Example
Draw geometric forms
\filldraw[fill=Periwinkle,thick] (1,0) rectangle +(2,1) -- (3,2);
\draw (0,0) -- (0,2) -- (1,3.25){[rounded corners] -- (2,2)-- (2,0)} -- (0,2) -- (2,2) -- (0,0) -- (2,0);
Drawing graphs
test v
0 colored
\ d ra w n od e at (0 , 0 ) { t e st } ;
\ node [ draw , c i r c l e ] at ( 2 , 0) { $ v _ 0$ } ;
\ node [ fill ] at ( 4 ,0 ) { };
\ node [ draw , color = r e d ] at ( 6 , 0) [ g r ee n ] { c o lo re d } ;
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 5 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
7/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing the 5 Wheel
We are ready to pimp our slides with the COGA-5-Wheel!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 6 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
8/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing the 5 Wheel
We are ready to pimp our slides with the COGA-5-Wheel!
\ node [ fill , circle , draw , R o y a l B l u e ] at ( 0 ,1) { };
\ node [ fill , circle , draw , R o y a l B l u e ] at ( - 0 .9 5 11 , 0. 3 09 1 ) { };
\ node [ fill , circle , draw , R o y a l B l u e ] at ( - 0. 58 78 , - 0. 80 91 ) { };
\ node [ fill , circle , draw , R o y a l B l u e ] at ( 0 . 58 7 8 , - 0. 8 09 1 ) { };
\ node [ fill , circle , draw , R o y a l B l u e ] at ( 0 . 95 1 1 , 0 . 3 09 1 ) { };\ node [ fill , circle , draw , R o y a l B l u e ] at ( 0 ,0) { };
\ draw [ r ed ] (0 , 1) to ( - 0 . 9 5 1 1 , 0 . 3 0 9 1 ) to ( - 0 . 5 8 7 8 , - 0 . 8 0 9 1 )
to ( 0 . 5 8 7 8 , - 0 . 8 0 9 1 ) to ( 0 . 9 5 1 1 , 0 . 3 0 9 1 ) to ( 0 , 1 ) ;
\ draw [ r ed ] (0 , 0) to ( 0 , 1) ( 0 ,0 ) to ( - 0 .9 5 11 , 0 .3 0 91 ) ( 0 , 0)
to ( - 0. 58 78 , - 0. 80 91 ) ( 0 , 0) to ( 0 . 58 7 8 , - 0 .8 0 91 ) ( 0 , 0)
to ( 0 . 9 5 1 1 , 0 . 3 0 9 1 ) ;
Notice, here is some serious math going on!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 6 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
9/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing the 5 Wheel
We are ready to pimp our slides with the COGA-5-Wheel!
Unfortunately we have do to a lot of computation.
Can be done by PGF!
Also, lines are drawn over the nodes.
Solve this using named nodes.
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 6 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
10/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing the 5 Wheel with Less Math
Computations using PGF
\pgfmathsetmacro{\x}{computation}
Creates a variable\xwith the result of the computation
\pgfmathparse{computation}
Stores the result in the variable \pgfmathresult
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 7 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
11/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Basic commands
Drawing the 5 Wheel with Less Math
Computations using PGF
\pgfmathsetmacro{\x}{computation}
Creates a variable\xwith the result of the computation
\pgfmathparse{computation}
Stores the result in the variable \pgfmathresult
\ p g f m a t h s e t m a c r o { \ x a } { cos (90)}
\ p g f m a t h s e t m a c r o { \ y a } { sin (90)}
\ p g f m a t h s e t m a c r o { \ x b } { cos ( 9 0 + 7 2 ) }
\ p g f m a t h s e t m a c r o { \ y b } { sin ( 9 0 + 7 2 ) }
...\ node [ fill , circle , draw , R o y a lB l ue ] ( 1) at (\ x a , \ y a ) { };
\ node [ fill , circle , draw , R o y a lB l ue ] ( 2) at (\ x b , \ y b ) { };
...
\ draw [ r ed ] ( 1) to (2) to (3) to (4) to (5) to (1);
\ draw [ r ed ] ( 0) to ( 1) ( 0) to ( 2) ( 0) to ( 3) ( 0) to ( 4) . ..
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 7 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
12/195
Basic commands
Drawing the 5 Wheel with Less Math
Computations using PGF
\pgfmathsetmacro{\x}{computation}
Creates a variable\xwith the result of the computation
\pgfmathparse{computation}
Stores the result in the variable \pgfmathresult
Still we need to know a lot about how to compute coordinates on a circle
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 7 / 43
-
8/12/2019 Introduction to TikZ
13/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
14/195
Basic commands
Polar Coordinates
Polar coordinates
all coordinates can be defined via polar coordinates
needed only an angle and the radius (distnace from the origin)
expressed as (angle:radius)
\ node [ fill , circle , draw , R o y a lB l ue ] ( 1) at ( 9 0 + 0* 7 2 :1 ) { };
\ node [ fill , circle , draw , R o y a lB l ue ] ( 2) at ( 9 0 + 1* 7 2 :1 ) { };
\ node [ fill , circle , draw , R o y a lB l ue ] ( 3) at ( 9 0 + 2* 7 2 :1 ) { };
\ node [ fill , circle , draw , R o y a lB l ue ] ( 4) at ( 9 0 + 3* 7 2 :1 ) { };
\ node [ fill , circle , draw , R o y a lB l ue ] ( 5) at ( 9 0 + 4* 7 2 :1 ) { };\ node [ fill , circle , draw , R o y a lB l ue ] ( 0) at ( 0 ,0 ) { };
\ draw [ r ed ] ( 1) to (2) to (3) to (4) to (5) to (1);
\ draw [ r ed ] ( 0) to ( 1) ( 0) to ( 2) ( 0) to ( 3) ( 0) to ( 4) . ..
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 8 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
15/195
Basic commands
Polar Coordinates
Polar coordinates
all coordinates can be defined via polar coordinates
needed only an angle and the radius (distnace from the origin)
expressed as (angle:radius)
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 8 / 43
-
8/12/2019 Introduction to TikZ
16/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
17/195
Styles
Using Styles to Clean Up Code
using a lot of parameters creates ugly code
user defined styles help keeping code clean
style needs to be changed once only
Different Types of Styles1 local styles for one tikzpictureenvironment
\ begin { t i k z p i c t u r e }
[ s t y l e n a m e / . style = { s om e c o mm a nd s } , a n o t he r / . style =... ]
...
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 9 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
18/195
Styles
Using Styles to Clean Up Code
using a lot of parameters creates ugly code
user defined styles help keeping code clean
style needs to be changed once only
Different Types of Styles1 local styles for one tikzpictureenvironment
2 global styles for a document
\ t i k z s t y l e { s o u r c e } = [ draw , circle , fill = g r e e n ]
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 9 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
19/195
Styles
Using Styles to Clean Up Code
using a lot of parameters creates ugly code
user defined styles help keeping code clean
style needs to be changed once only
Different Types of Styles1 local styles for one tikzpictureenvironment
2 global styles for a document
3 styles for element types
\ begin { t i k z p i c t u r e }
[ every node /. style ={ fill , circle , i n ne r s ep =2}]
...
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 9 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
20/195
Styles
Styles Example
Example
[ d e f a u l t / . style ={ draw , fill , circle , s h a d i n g = ball ,
b al l c o lo r = Dandelion , text = w h i t e } ,
s o u r c e / . style ={ draw , fill , circle , s h a d i n g = ball ,
b al l c o lo r = ForestGreen , text = w h i t e } ,s i n k / . style ={ draw , fill , circle , s h a d i n g = ball ,
b al l c o lo r = BrickRed , text = w h i t e } ]
s0
s1
a
b
c
t
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 10 / 43
-
8/12/2019 Introduction to TikZ
21/195
-
8/12/2019 Introduction to TikZ
22/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
23/195
Graphs
Nodes
Parameter
circle, rounded corners rectangle the shape
inner sep,minimum size defining the size
inner sep=10mm minimum size=12mm inner sep=0.7mm
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 11 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
24/195
Graphs
Nodes cont.
multiline nodes: allows to have several lines of text within one node
\node[align=center] {Line 1 \\ Another line};
Line 1
Another line
node labels: can add a label to all corners of the node
\node at (0,0) [label=below left:\tiny{$note$}] {A};
Anote
anchors: defines the corner of the node that lies at the specifies
position. Default is center\node[draw,anchor=north west] at (0,0) {NW};
\node[draw,anchor=south east] at (0,0) {SE};
NW
SE
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 12 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
25/195
Graphs
Arcs
Arc styles
\draw[-] (a) to (b);
[--] [] [>=stealth,->>] [>=latex,>>->]
[double,->] [-latex] [>=diamond,->>] [o-stealth]
Named Arcs
\draw (a) to node[sloped,above] {on top} (a)
position of arc label:
above,below,right, left
should label be aligned to slope of arc?
sloped
Bug:slope is wrong if scaling is used!
right,above
sloped,above
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 13 / 43
-
8/12/2019 Introduction to TikZ
26/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
27/195
Loops
Loops
What happens if we surprisingly should draw a 6 wheel?
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 15 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
28/195
Loops
Loops
What happens if we surprisingly should draw a 6 wheel?
Or even to a 7 wheel?
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 15 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
-
8/12/2019 Introduction to TikZ
29/195
Loops
Loops
What happens if we surprisingly should draw a 6 wheel?
Or even to a 7 wheel?
The foreach command
executes the same commands for all items of a given set
assigns the value to a variable
\foreach \var in \{ item1, item2, ..., itemN\} { }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 15 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
L
-
8/12/2019 Introduction to TikZ
30/195
Loops
Putting Things Together
\ p g f m a t h s e t m a c r o { \ n } { 5 }
\ p g f m a t h t r u n c a t e m a c r o { \ n o d e s } { \ n - 1 }
\ node [ fill , circle , draw , R o ya lB lu e ] ( c ) at ( 0 ,0 ) { };
\ f o r e a c h \ i in { 0 , .. . , \ n o de s }
\ node [ fill , circle , draw , R o ya l Bl ue ] (\ i ) at (90+\ i * 3 6 0 / \ n : 1 )
\ f o r e a c h \ i in { 0 ,. .. , \ n o de s } {
\ draw [ r ed ] ( c ) to (\ i );
\ p g f m a t h t r u n c a t e m a c r o {\ j }{mod ( round (1+\ i ) , \ n ) }
\ draw [ r ed ] (\ i ) - - ( \ j );
}
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 16 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
31/195
Loops
Putting Things Together
\ p g f m a t h s e t m a c r o { \ n } { 5 }
\ p g f m a t h t r u n c a t e m a c r o { \ n o d e s } { \ n - 1 }
\ node [ fill , circle , draw , R o ya lB lu e ] ( c ) at ( 0 ,0 ) { };
\ f o r e a c h \ i in { 0 , .. . , \ n o de s }
\ node [ fill , circle , draw , R o ya l Bl ue ] (\ i ) at (90+\ i * 3 6 0 / \ n : 1 )
\ f o r e a c h \ i in { 0 ,. .. , \ n o de s } {
\ draw [ r ed ] ( c ) to (\ i );
\ p g f m a t h t r u n c a t e m a c r o {\ j }{mod ( round (1+\ i ) , \ n ) }
\ draw [ r ed ] (\ i ) - - ( \ j );
}
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 16 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
32/195
Loops
Loops cont.
\foreach with more variables
The\foreachcommand can iterate over tuples
values are assigned to several variables
ExampleWant to highlight specific numbers on the real line.
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 17 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
33/195
Loops
Loops cont.
\foreach with more variables
The\foreachcommand can iterate over tuples
values are assigned to several variables
ExampleWant to highlight specific numbers on the real line.
Give it a first try:
\ draw [ - >] ( 0 ,0 ) to ( 8 , 0 ) ;
\ f o r e a c h \ x in {0 , 1 , 1.57 , 3.14 , 2 .71} {
\ draw ( \ x , 0 . 1 ) to ( \ x , - 0 . 1 ) ;
\ n od e a t (\ x , -0.3) {\ f o o t n o t e s i z e { \ x } } ;
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 17 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
34/195
Loops
Loops cont.
\foreach with more variables
The\foreachcommand can iterate over tuples
values are assigned to several variables
ExampleWant to highlight specific numbers on the real line.
Give it a first try:
0 1 1.57 3.142.71
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 17 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
35/195
Loops
Loops cont.
\foreach with more variables
The\foreachcommand can iterate over tuples
values are assigned to several variables
ExampleWant to highlight specific numbers on the real line.
Better:
0 1
2 e
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 17 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Loops
-
8/12/2019 Introduction to TikZ
36/195
p
Loops cont.
\foreach with more variables
The\foreachcommand can iterate over tuples
values are assigned to several variables
ExampleWant to highlight specific numbers on the real line.
\ draw [ - >] ( 0 ,0 ) to ( 4 , 0 ) ;
\ f o r e a c h \ x / \ txt in
{0 , 1 , 1.57 / $\ frac {\ pi }{2}$ , 3.14 / $\ pi $ , 2.71 / $ e $} {\ draw ( \ x , 0 . 1 ) to ( \ x , - 0 . 1 ) ;
\ n od e a t (\ x , -0.3) {\ f o o t n o t e s i z e { \ t x t } } ;
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 17 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
37/195
Calculate Coordinates
Coordinates
can be defined using coordinate
like nodes with empty text
coordinates can be computed (like vector math)
need to add the package calc (\includetikzpackage{calc})
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 18 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
38/195
An Example Using Coordinate Calculation Background
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
39/195
An Example Using Coordinate Calculation Background
A
B
F
= 12
Construction
1 start with an isosceles triangle with base of length a
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
-
8/12/2019 Introduction to TikZ
40/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
41/195
An Example Using Coordinate Calculation Background
A
B
F
G
I = 12
Construction
1 start with an isosceles triangle with base of length a
2 draw a copy ofABatF
3 draw segmentAIof lengthbwith some angle
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
42/195
An Example Using Coordinate Calculation Background
A
B
F
G
I
H
= 12
Construction
1 start with an isosceles triangle with base of length a
2 draw a copy ofABatF
3 draw segmentAIof lengthbwith some angle
4 and copy it toG
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
43/195
An Example Using Coordinate Calculation Background
A
B
F
G
I
H
= 12
Construction
1 start with an isosceles triangle with base of length a
2 draw a copy ofABatF
3 draw segmentAIof lengthbwith some angle
4 and copy it toG
5 connectHandI
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
44/195
An Example Using Coordinate Calculation Background
A
B
F
G
I
H
D
C
E
= 12
Construction
1 start with an isosceles triangle with base of length a
2 draw a copy ofABatF
3 draw segmentAIof lengthbwith some angle
4 and copy it toG
5 connectHandI
6 rotate the polygonal pathFGHIAaroundA by 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 19 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
45/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
46/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
47/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
-
8/12/2019 Introduction to TikZ
48/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
A E l U i C di C l l i TikZ li i
-
8/12/2019 Introduction to TikZ
49/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
A E l U i C di t C l l ti TikZ li ti
-
8/12/2019 Introduction to TikZ
50/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
51/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
A E m l U i g C di t C l l ti TikZ li ti
-
8/12/2019 Introduction to TikZ
52/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
53/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
54/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
55/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
56/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
57/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
58/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
59/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
60/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
61/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
62/195
An Example Using Coordinate Calculation TikZ realization
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
63/195
p g
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
64/195
p g
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
65/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
66/195
p g
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
67/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
68/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
69/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
70/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realization
-
8/12/2019 Introduction to TikZ
71/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
72/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
-
8/12/2019 Introduction to TikZ
73/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
74/195
A
B
F
G
I
H
D
C
E
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
75/195
A
B
F
G
I
H
D
C
E
= 12
a= AB = FG
b= AI = HG
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
76/195
A
B
F
G
I
H
D
C
E
= 12
a= AB = FG
b= AI = HG
Example
Define Variables to use:
\ def \ a {0.5}
\ def \ b {0.5}
\ def \ b A n g l e { - 1 0 }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
77/195
A
B
F
G
I
H
D
C
E
= 12
a= AB = FG
b= AI = HG
Example
Compute Distance of PointF fromAB:
\ p g f m a t h s e t m a c r o { \ h y p } { \ a *0.5 / cos (84)}
\ p g f m a t h s e t m a c r o { \ l e n } { sqrt (\hyp *\hyp -0.25*\ a *\ a )}
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
78/195
A
B
F
G
I
H
C
E
= 12
a= AB = FG
b= AI = HG
Example
Compute the locations of the points:
\ c o o r d i n a t e ( A ) at ( 0 , 0 ) ; % s ta rt c oo rd in a te
\ c o o r d i n a t e ( B ) at ($ ( A ) + (0 ,\ a ) $);
\ c o o r d i n a t e ( F ) at ( $ ( B ) + ( \ len , 0. 5* \ a ) $);
\ c o o r d i n a t e ( G ) at ($ ( F ) + (0 ,\ a ) $);
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
79/195
A
B
F
G
I
H
C
E
= 12
a= AB = FGb= AI = HG
Example
Compute the locations of the points:
\ c o o r d i n a t e ( H t e m p ) at ( $ ( G ) - ( \ b , 0) $ );
\ c o o r d i n a t e ( H ) at ($ ( G ) ! 1! \ b A n g le : ( H t em p ) $ );
\ c o o r d i n a t e ( I t e m p ) at ( $ ( A ) + (\ b , 0) $ );
\ c o o r d i n a t e ( I ) at ($ ( A ) ! 1! \ b A n g le : ( I t em p ) $ );
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
An Example Using Coordinate Calculation TikZ realizationD
-
8/12/2019 Introduction to TikZ
80/195
A
B
F
G
I
H
C
E
= 12
a= AB = FGb= AI = HG
Example
Compute the locations of the points:
\ c o o r d i n a t e ( E ) at ( $ ( F ) !1 ! - 12 :( G ) $ );
\ c o o r d i n a t e ( D ) at ( $ ( F ) !1 ! - 12 :( H ) $ );
\ c o o r d i n a t e ( C ) at ( $ ( F ) !1 ! - 12 :( I ) $ );
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 20 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Coordinates
The Voderberg Spiral
-
8/12/2019 Introduction to TikZ
81/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 21 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Scopes in TikZ
-
8/12/2019 Introduction to TikZ
82/195
TikZ allows scopes, just like e. g. JAVA
scopes can alter the drawing projection
that means rotating, moving or scaling etc.
Possible commands are:
xscale, yscaleand scalefor scaling
rotatefor rotation around an angle
xshift, yshiftand shiftfor movements of the origin
\ begin { scope }[ rotate = 3 0 , xscale = 0 . 5 , shift = { ( 0 : \ s ) } ]
...\ end { scope }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 22 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
83/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
-
8/12/2019 Introduction to TikZ
84/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
85/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
-
8/12/2019 Introduction to TikZ
86/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
87/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
88/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
89/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
90/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
91/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
92/195
Jan-Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43
-
8/12/2019 Introduction to TikZ
93/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
94/195
Jan Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
95/195
Jan Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
96/195
Jan Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
97/195
Jan Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
98/195
Jan Philipp Kappmeier (21 02 2013) How to TikZ? 23 / 43 TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
99/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
100/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
101/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
102/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
103/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
104/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
105/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
106/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
107/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
108/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
109/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
110/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
111/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
112/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
113/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
114/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
115/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
-
8/12/2019 Introduction to TikZ
116/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Scope
Example for Scopes
-
8/12/2019 Introduction to TikZ
117/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 23 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Two Ways to Add Animations
Beamer
-
8/12/2019 Introduction to TikZ
118/195
animations can be used once
one slide in the file per frame
Animation Package
animations can be restarted
infinite loops possible
embedded into a single slide
Need a lot of computation!Take care with integral/floating point calculations!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 24 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
119/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
120/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
121/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
122/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
123/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
124/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
125/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
126/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
127/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
128/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
129/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
130/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
131/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
132/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
-
8/12/2019 Introduction to TikZ
133/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
134/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
135/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
136/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
137/195
Animation Parameter
needs a variable: newdimen varname
animated frames defined by animate
variable contains values as inanimatedvalue
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations Using Beamer Style
Packet on an arc
-
8/12/2019 Introduction to TikZ
138/195
\ n e w d i m e n \ p o s
\animate
\ a n i m a t ev a l ue < 1 - 2 0 > { \ p o s i t i o n } { 0 c m } { 5 c m }
\ begin { t i k z p i c t u r e }
\ node ( x ) at ( \ p o s it i on , 0 .7 ) [ draw , thick , fill = C a r n a t i o n P i n
\ node ( a ) at (0 , 0) [ draw , circle , fill = RedOrange , thick ] {};
\ node ( b ) at (5 , 0) [ draw , circle , fill = YellowGreen , thick ] {}
e dg e [ < -] ( a );
\ end { t i k z p i c t u r e }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 25 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations with the Animate Package
\ begin { a n i m a t e i n l i n e } [ autoplay, loop ]{24}
\ m u l t i f r a m e { 4 8 } { r A n g l e = 0 + 1 . 5 } {
\ a n i m a t e L o g o { \ r A n g l e }
-
8/12/2019 Introduction to TikZ
139/195
\ a a t e o g o { \ g e }
}
\ end { a n i m a t e i n l i n e }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 26 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Animation
Animations with the Animate Package
\ begin { a n i m a t e i n l i n e } [ autoplay, loop ]{24}
\ m u l t i f r a m e { 4 8 } { r A n g l e = 0 + 1 . 5 } {
\ a n i m a t e L o g o { \ r A n g l e }
-
8/12/2019 Introduction to TikZ
140/195
\ g { \ g }
}
\ end { a n i m a t e i n l i n e }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 26 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
Plotting in TikZ
Something like this is possible in TikZ:
-
8/12/2019 Introduction to TikZ
141/195
Size of instance
Time(s)
23
26
29
212
215
218
221
0
1
2
3
4
5
6
RUNTIME
But:quite lengthy code, as axes and legend have to be drawn manually
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 27 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
Plotting using PGFPLOTS
The PGFPLOTS package
package specialized for drawing plots
-
8/12/2019 Introduction to TikZ
142/195
based upon PGF/TikZ
available athttp://sourceforge.net/projects/pgfplots
themanualis as good as the one of TikZ
On the following slides, there will be just three examples. For more, have
a look in the manual.
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 28 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
A Starting Example
0sin(x)
x + cos(2x) 4
http://sourceforge.net/projects/pgfplotshttp://sourceforge.net/projects/pgfplots -
8/12/2019 Introduction to TikZ
143/195
400 200 0 200 400 600 800
8
6
4
2
0 90 + cos(2x) 4
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 29 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
A Starting Example
\ begin { t i k z p i c t u r e }
\ begin { axis }[ d o m a i n = - 3 6 0 : 3 6 0 , s a m p l e s = 8 0 ,
width = 1 0 c m , h e i g h t = 7 c m , xmax =800]
-
8/12/2019 Introduction to TikZ
144/195
\ a d d p l o t [ color = r e d , m a r k = x ] c o o r d i n a t e s {
( - 2 0 0 , - 1 )
( - 1 3 3 , - 1 . 2 )
( - 6 6 , - 2 )
( 0 , - 2 . 5 )( 6 6 , - 4 )
( 1 3 3 , - 5 )
( 2 0 0 , - 7 )
};
\ a d d p l o t [ color = b lu e ] { sin ( x ) } ;
\ a d d p l o t [ color = g r e en ] { - 4+ x / 9 0+ cos ( x * 2 ) } ;\ end { axis }
\ end { t i k z p i c t u r e }
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 29 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
Plotting from Files
6
-
8/12/2019 Introduction to TikZ
145/195
0 2 4 6 8 10 12 14
0
2
4
6
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 30 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
Plotting from Files
\ begin { t i k z p i c t u r e }
\ begin { axis }
\ a d dp l ot f il e { c h a r t s / d a t a . t a b l e } ;
\ { }
-
8/12/2019 Introduction to TikZ
146/195
\ end { axis }
\ end { t i k z p i c t u r e }
File features
reads gnuplot style files with datapoints specified as x y i
withxandybeeing floating point values
also specific rows of a table can be read
for details, see the manual
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 30 / 43
-
8/12/2019 Introduction to TikZ
147/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Plots
Plots in 3D
\ begin { t i k z p i c t u r e }
\ begin { axis }
\ a d d p l o t 3[ surf , domain = 0 : 3 6 0 , s a m p l e s =50]
{ i ( ) i ( ) }
-
8/12/2019 Introduction to TikZ
148/195
{ sin ( x ) * sin ( y ) } ;
\ end { axis }
\ end { t i k z p i c t u r e }
Take care, high sample values are not possible due to memory limitations!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 31 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
If You Still Miss a Powerpoint Feature
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
149/195
Do you really miss anything?
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 32 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
If You Still Miss a Powerpoint Feature
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
150/195
Do you really miss anything?
Bam! If you really, really need, just do, its easy!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 32 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
If You Still Miss a Powerpoint Feature
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
151/195
Do you really miss anything?
Bam! If you really, really need, just do, its easy!
\node[starburst,fill=yellow,draw=red,line width=2pt] at
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 32 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
152/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
153/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
cloud calloutthe shape name
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
154/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
cloud puffsthe number of puffs of the cloud
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
155/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
cloud puff arcthe angle between two meeting puffs
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
156/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
callout pointer segmentsthe number of round bubbles
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
157/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
callout relative pointerthe angle and distance of the pointer
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
158/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
aspect ratio between width and height
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Nodes and Edges Revisited
The Cloud Code
I wouldnt mind having
these fancy clouds!
-
8/12/2019 Introduction to TikZ
159/195
Example
\ node [ align = center , draw , s h a d i n g = ball , text = w h i t e ,c l ou d c a ll o ut, c l ou d p u ff s = 1 7 , c lo ud p uf f a rc = 1 4 0 ,
c a ll o ut p o in t er s e gm e nt s =3 , a n c h o r = pointer,
c a ll o ut r e la t iv e p o in t er = { ( 2 0 0 : 2 c m ) } , a s p e c t =2.5]
at ( c u r re nt p ag e . c e n t e r )
{ I w ould n t m in d h av in g \\ t he se f an cy c lo ud s ! };
current page.center absolutecoordinate on the page
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 33 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
160/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
161/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
162/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
163/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
164/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
165/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
166/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
167/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees
-
8/12/2019 Introduction to TikZ
168/195
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 34 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Trees More Like This
Defining Trees
child{}in a node definition creates a childusenodeand childiterativeley to create a tree
-
8/12/2019 Introduction to TikZ
169/195
Example
root
here there
another
\ node {\ f o o t n o t e s i z e r o o t }child {
node {\ f o o t n o t e s i z e h e r e } }
child { node {\ f o o t n o t e s i z e t h e r e }
child {
node {\ f o o t n o t e s i z e a n o t h e r } }
child {node {}
};
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 35 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Split nodes
The Rectangle Split Shape
allows to put more than one text into nodesneed to include tikzlibrary shapes.multipart
-
8/12/2019 Introduction to TikZ
170/195
the style is rectangle split
this gives a vertically split. For horizontally splitadd
rectangle split horizontal
Example
\node[rectangle split,rectangle split parts=3,draw]
{1\nodepart{two}2\nodepart{three}3};
1
2
3
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 36 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
5 2 3 7 4 6 1 9
5 2 3 74 6 1 9
-
8/12/2019 Introduction to TikZ
171/195
5 2
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
unfortunatelychildren overlap
can be solved via sibling distance
a style for each level of the tree
-
8/12/2019 Introduction to TikZ
172/195
Example
\ begin { t i k z p i c t u r e }[l ev e l 1 /. style ={ s i bl i ng d i st a nc e = 6 0 m m } ,
l ev e l 2 /. style ={ s i bl i ng d i st a nc e = 3 0 m m } ,
l ev e l 3 /. style ={ s i bl i ng d i st a nc e = 2 0 m m } ]
\ end { t i k z p i c t u r e }
All siblings on level 1 will have a distance of 60mm
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
5 2 3 7 4 6 1 9
5 2 3 7 4 6 1 9
-
8/12/2019 Introduction to TikZ
173/195
5 2
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
5 2 3 7 4 6 1 9
5 2 3 7 4 6 1 9
-
8/12/2019 Introduction to TikZ
174/195
5 2
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
5 2 3 7 4 6 1 9
5 2 3 7 4 6 1 9
-
8/12/2019 Introduction to TikZ
175/195
2 5
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
5 2 3 7 4 6 1 9
2 3 5 7 1 4 6 9
-
8/12/2019 Introduction to TikZ
176/195
2 5
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Trees
Recursive Sorting
1 2 3 4 5 6 7 9
2 3 5 7 1 4 6 9
-
8/12/2019 Introduction to TikZ
177/195
2 5
5 2
3 7
3 7
4 6
4 6
1 9
1 9
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 37 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Intersections
Intersections
B
F
G
H
D
C
E
-
8/12/2019 Introduction to TikZ
178/195
A
F
I
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 38 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Intersections
Intersections
B
F
G
H
D
C
E
Nice detail:End point of helping line is in the
middle of the angle.
-
8/12/2019 Introduction to TikZ
179/195
A
F
I
= 12
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 38 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Intersections
Intersections
B
F
G
H
D
C
E
Nice detail:End point of helping line is in the
middle of the angle.
-
8/12/2019 Introduction to TikZ
180/195
A
F
I
= 12
The good thing:
TikZ can automatically compute these intersection points.Paths can be arbitrary, not only line segments!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 38 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Intersections
Intersections cont.
How to compute intersections
1
include the TikZ library intersections2 name paths using the option [name path=pname]
Hint: invisible paths can be drawn using\path
-
8/12/2019 Introduction to TikZ
181/195
p g \p
3 compute intersections as new path:
\path [name intersections={of=pname1 and pname2}];
new intersection points are now available at
(intersection-1), (intersection-2)etc.
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 39 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Intersections
Intersections cont.
How to compute intersections
1
include the TikZ library intersections2 name paths using the option [name path=pname]
Hint: invisible paths can be drawn using\path
-
8/12/2019 Introduction to TikZ
182/195
p g p
3 compute intersections as new path:
\path [name intersections={of=pname1 and pname2}];
new intersection points are now available at
(intersection-1), (intersection-2)etc.
\ path [ name path = h e lp Pa th ] ( h e lp Po in t ) - - ( l a be l Po in t ) ;
\ path [ name path = ai ] ( B) -- ( F);
\ path [ n am e i n t er s e ct i o ns ={ of = h e l p P a t h and a i } ] ;
\ c o o r d i n a t e ( i n t e r s ) at ( $ ( i n t e r s ec t i on - 1 ) ! 0 . 5! ( h e l p P oi n t )
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 39 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
Some Styles to Define a Graph and Algorithm Visualization
Requirements
need styles for nodes and edgesstyles should change with the algorithm state
good idea to nest styles!
-
8/12/2019 Introduction to TikZ
183/195
good dea to est sty es
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 40 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
Some Styles to Define a Graph and Algorithm Visualization
Requirements
need styles for nodes and edgesstyles should change with the algorithm state
good idea to nest styles!
-
8/12/2019 Introduction to TikZ
184/195
g y
\ t i k z s t y l e { v e r t e x } = [ draw , circle , fill = G r a y ,m i n im u m size = 2 0 p t ]\ t i k z s t y l e { s e le ct ed v er te x } = [ v er te x , fill = M a r o o n ]
\ t i k z s t y l e { edge } = [ draw , thick, -]
\ t i k z s t y l e { w ei gh t } = [ font =\ small ]
\ t i k z s t y l e { s el ec te d edge } = [ draw , l in e w i dt h = 5 p t , - , G r e e n ]
\ t i k z s t y l e { i gn or ed edge } = [ draw , l in e w i dt h = 5 p t , - , S a l m o n ]
Style selected vertex based on vertex, but changes the fill color
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 40 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
Defining a Graph in Four Lines...
Using all our so far gained knowledge, we can say:
\ f o r e a c h \ p o s / \ name i n { {( 0 , 2) / a }, { (2 , 1 )/ b } , { (4 , 1 )/ c } ,
{ (0 , 0) / d } , { (3 , 0) / e } , { (2 , - 1) / f } , { (4 , - 1) / g } }
\ node [ v e rt ex ] (\ name ) at \ p os {$ \ name $};
\ f o r e a c h \ s o ur c e / \ d es t / \ w e ig h t i n { b / a /7 , c / b / 8 , d / a /5 , d / b / 9 ,
/ / / / / / / / / / / / / / }
-
8/12/2019 Introduction to TikZ
185/195
e / b / 7 , e / c / 5 , e / d / 1 5 , f / d / 6 , f / e / 8 , g / e / 9 , g / f / 1 1 }
\ path [ e dg e ] (\ s o ur ce ) - - node [ w e i gh t ] { $\ w e ig h t $ } ( \ d es t ) ;
Using:styles,node namesandforeach with tuples
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 41 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
Defining a Graph in Four Lines...
a
7
8
-
8/12/2019 Introduction to TikZ
186/195
b c
d e
f g
85
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 41 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
\ f o r e a c h \ v er te x / \ s li de in { d /1 , a /2 , f /3 , b /4 , e /5 , c /6 , g / 7}
\ path < \ s l i d e - > node [ s e l e ct e d v e rt e x ] at ( \ v e rt e x ) { $\ v e rt e
\ f o r e a c h \ s o ur ce / \ d es t in { d /a , d /f , a /b , b /e , e /c , e / g}\ path [ s e le ct ed e dg e ] (\ s o ur ce ) - - (\ d e st ) ;
\ f o r e a c h \ s ou rc e / \ dest / \ s lide in
{ d / b / 4 , d / e / 5 , e / f / 5 , b / c / 6 , f / g / 7 }
-
8/12/2019 Introduction to TikZ
187/195
{ / / , / / , / / , / / , / g / }
\ path < \ s li de - > [ i g no r ed e dg e ] ( \ s o ur c e ) - - ( \ d es t ) ;
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
7
8
7
8
-
8/12/2019 Introduction to TikZ
188/195
b c
d e
f g
85
9
7
5
15
6
8
9
11
d
85
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
b
7
85
a
7
85
-
8/12/2019 Introduction to TikZ
189/195
b c
d e
f g
5
9
7
5
15
6
8
9
11
d
5
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
b c
7
85
a
7
85
-
8/12/2019 Introduction to TikZ
190/195
b c
d e
f g
5
9
7
5
15
6
8
9
11
d
f
5
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
b c
7
85
a
b
7
85
-
8/12/2019 Introduction to TikZ
191/195
b c
d e
f g
5
9
7
5
15
6
8
9
11
d
f
b5
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
b c
7
85
a
b
7
85
-
8/12/2019 Introduction to TikZ
192/195
b c
d e
f g
5
9
7
5
15
6
8
9
11
d
f
b
e
5
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
-
8/12/2019 Introduction to TikZ
193/195
TikZ Basics Advanced TikZ Even More Advanced TikZ
Visualization of Graph Algorithms
... and an Algorithm in Another Six
a
b c
7
85
a
b c
7
85
-
8/12/2019 Introduction to TikZ
194/195
b c
d e
f g
5
9
7
5
15
6
8
9
11
d
f
b
e
c
g
5
9
7
5
15
6
8
9
11
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 42 / 43
TikZ Basics Advanced TikZ Even More Advanced TikZ
Overview
Outlook
TikZ really can do a lot of stuff
much more can be done using some of the many packages
for example object oriented programming
worth reading a bit in the manual
-
8/12/2019 Introduction to TikZ
195/195
Thank you!
Jan-Philipp Kappmeier (21. 02. 2013) How to TikZ? 43 / 43