an overview of ti k z
play

An Overview of Ti k Z A Language for Creating Graphics the T EX Way - PowerPoint PPT Presentation

An Overview of Ti k Z A Language for Creating Graphics the T EX Way T ill Tantau Institute for Theoretical Computer Science University Lbeck gtem Midterm Meeting 2008 Outline Goal-Oriented Overview Creating a Figure How Do I Use Ti k Z?


  1. An Overview of Ti k Z A Language for Creating Graphics the T EX Way T ill Tantau Institute for Theoretical Computer Science University Lübeck gtem Midterm Meeting 2008

  2. Outline Goal-Oriented Overview – Creating a Figure How Do I Use Ti k Z? Recreating a Figure From a Biochemistry Textbook Design-Oriented Overview – Design Principles Paths and Actions Special Syntax for Coordinates Special Syntax for Paths Special Syntax for Nodes Special Syntax for Trees Style Sheets Implementation-Oriented Overview – System Structure Top Layer: Ti k Z Middle Layer: pgf Basic Layer Bottom Layer: pgf System Layer Gallery of Libraries

  3. What Is Ti k Z? ◮ “T i k Z ist kein Zeichenprogramm.” (Ti k Z is not a drawing program.) ◮ Ti k Z is a T EX macro package. ◮ Just as T EX provides a special notation for formulas, Ti k Z provides a special notation for graphics.

  4. Formulas In T EX – Graphics in Ti k Z In T EX you write In Ti k Z you write See \tikz \draw[->] Let $\int_0^1 (0,0)--(2ex,1ex); \sqrt{x}\, dx$ here \dots be the integral, \dots and get and get � 1 See here . . . √ x dx be the integral, Let 0 . . .

  5. Installation and Usage of the Package. 1. U npack pgf-2.00.tar.gz in texmf/tex/generic and call texhash . (Typically already preinstalled.) 2. Add to your documents: \ usepackage {tikz} % For LaTeX \usetikzlibrary{arrows,petri,...} \ input tikz.tex % For plain TeX \usetikzlibrary{arrows,petri,...} \usemodule[tikz] % For ConTeXt \usetikzlibrary[arrows,petri,...] 3. Process the file using one of the following: ◮ pdf(la)tex ◮ (la)tex and dvips ◮ (la)tex and dvipdfm ◮ xe(la)tex and xdvipdfmx ◮ vtex ◮ textures ◮ tex4ht

  6. History and Getting Help ◮ The pgf system underlying Ti k Z was created for the graphics in my PhD thesis. ◮ The first lines of code were written around 2000. ◮ The are currently three core developers. ◮ The manual that comes with the package is around 650 pages and very detailed. ◮ There is a mailing list where people also other than myself can help you.

  7. Our Goal: Recreating This Figure. 5’ OH P P P 3’ G (oder A) Our aim is to create this figure using Ti k Z. UTP RNA- The figure is a redrawing of the figure on Polymerase H 2 O page 128 of the text book PP i 2P i Chirsten Jaussi Pyro- Biochemie phosphatase Springer-Verlag, 2005 5’ OH P P P P G U

  8. Drawing a Simple Line. 5’ OH P P P 3’ \ begin {tikzpicture} \ draw (5mm,59mm) -- (5mm,41mm); G (oder A) \ draw (5mm,49mm) -- (10mm,54mm); UTP \ draw (5mm,37mm) -- (5mm,11mm); RNA- ... Polymerase \ end {tikzpicture} H 2 O PP i 2P i ◮ Ti k Z-commands have to be given in a Pyro- {tikzpicture} environment. phosphatase ◮ The picture size is calculated 5’ automatically. OH P P P P ◮ First command: \ draw . G U

  9. A Path Consisting of Straight Lines. 5’ OH P P P 3’ \ begin {tikzpicture} \ draw (0mm,54mm) -- (5mm,59mm) G (oder A) -- (5mm,41mm); UTP RNA- ... \ end {tikzpicture} Polymerase H 2 O PP i 2P i ◮ The \ draw command ist followed by a Pyro- path. phosphatase ◮ The path starts with a coordinate. 5’ ◮ The path can be continued in straight OH lines using -- . P P P P G U

  10. A Path Containing Curves. 5’ OH P P P 3’ \ begin {tikzpicture} \ draw (10mm,34mm) arc (90:270:5mm) -- ++(3mm,0mm); G (oder A) ... UTP \ end {tikzpicture} RNA- Polymerase H 2 O ◮ An arc can be added to a path using PP i 2P i arc . Pyro- ◮ The parameters of arc are phosphatase 1. start angle, 5’ 2. end angle and 3. radius. OH P P P P ◮ A coordinate prefixed by ++ is relative. G U

  11. A Path Containg Circles. 5’ OH P P P 3’ \ begin {tikzpicture} G (oder A) \ draw ( 0mm,54mm) circle (2.5mm); \ draw (-7mm,54mm) circle (2.5mm); UTP RNA- ... Polymerase \ end {tikzpicture} H 2 O PP i 2P i ◮ A circle can be added to a path using Pyro- circle . phosphatase ◮ The radius is given in parentheses, the 5’ center is given by the previous OH coordinate. P P P P G U

  12. A Path With Two Rectangles. 5’ OH P P P 3’ \ begin {tikzpicture} \ draw (-19mm,25mm) -- (-19mm,35mm) G (oder A) -- (3mm,35mm) -- (3mm,25mm) UTP -- cycle RNA- (11mm,21mm) rectangle (34mm,11mm); Polymerase ... H 2 O PP i 2P i \ end {tikzpicture} Pyro- ◮ A path may consist of several parts. phosphatase ◮ A part can be closed using --cycle . 5’ ◮ A rectangle can be created using OH P P P P rectangle . G U

  13. Paths Can be Filled. 5’ OH P P P 3’ G (oder A) \ begin {tikzpicture} UTP \ fill RNA- (-19mm,25mm)rectangle (3mm,35mm) Polymerase (11mm,21mm) rectangle (34mm,11mm); H 2 O PP i 2P i ... \ end {tikzpicture} Pyro- phosphatase ◮ The \ fill command fills a path. 5’ ◮ It is possible to fill and draw a path. OH P P P P G U

  14. Colors Are Specified Using Options. 5’ OH P P P 3’ \ fill [lightgray] G (oder A) (-19mm,25mm) rectangle ++(22mm,10mm) (11mm,21mm) rectangle ++(23mm,-10mm); UTP RNA- \ draw [red] Polymerase H 2 O (10mm,2mm) circle (2.5mm); PP i 2P i Pyro- ... \ end {tikzpicture} phosphatase 5’ ◮ Colors are specified using options given OH in square brackets. P P P P G U

  15. Arrow Tips Are Specified Using Options. 5’ \ begin {tikzpicture} OH P P P \ draw [->] 3’ (10mm,34mm) arc (90:270:5mm) -- (11mm,24mm); \ draw [-triangle 45] G (oder A) (17mm,24mm) -- (27mm,24mm); UTP ... RNA- \ end {tikzpicture} Polymerase H 2 O PP i 2P i ◮ Arrow tips are set using an option with Pyro- a hyphen in the middle. phosphatase ◮ Whatever is left of the hyphen specifies 5’ the start arrow tip. OH ◮ Whatever is right of the hyphen P P P P specifies the end arrow tip. ◮ There are numerous predefined arrow tips. G U

  16. Labels Are Added Using Nodes. 5’ 5’ OH P P P 3’ \ begin {tikzpicture} \ draw (2mm,56mm) -- (5mm,59mm) node [above] {5’} G G (oder A) -- (5mm,41mm) node [below] {G}; UTP ... RNA- \ end {tikzpicture} Polymerase H 2 O PP i 2P i ◮ Nodes are used for adding text. Pyro- ◮ The preceding coordinate and options phosphatase specify the exact placement. 5’ ◮ The node text is given in curly braces. OH ◮ Nodes are added after the path has been P P P P drawn and filled. G U

  17. Edge Labels Are Also Added Using Nodes. 5’ OH OH P P P 3’ 3’ \ begin {tikzpicture} \ draw (5mm,49mm) -- (10mm,54mm) G (oder A) node [above right] {OH} UTP node [midway,below right] {3’}; RNA- ... Polymerase \ end {tikzpicture} H 2 O PP i 2P i ◮ It is possible to add multiple nodes at Pyro- the same place. phosphatase ◮ The midway option will place a node at 5’ the middle of the previous path OH P P P P segment. G U

  18. Nodes Can Have Special Shapes. 5’ OH \ begin {tikzpicture} P P P P P P \ draw 3’ (-14mm,54mm) node [draw] {P}; \ draw G (oder A) (-7mm,54mm) node [circle,draw]{P}; UTP RNA- \ node at (0mm,54mm)[circle,draw]{P}; ... Polymerase H 2 O \ end {tikzpicture} PP i 2P i Pyro- ◮ The first path does not contain any phosphatase lines. Nothing is drawn. 5’ ◮ The draw option specifies that the node’s shape should be drawn. OH P P P P ◮ The circle specifies a circular shape. ◮ The \ node command is just an abbreviation. G U

  19. Nodes Can Be Filled. 5’ OH P P P 3’ \ begin {tikzpicture} \ node at (3mm,35mm) G (oder A) [below left, UTP fill=lightgray, RNA- RNA- text width=2cm] Polymerase Polymerase H 2 O {RNA-\\Polymerase}; PP i 2P i ... \ end {tikzpicture} Pyro- phosphatase ◮ Use text width to specify a node’s 5’ (text) width. OH ◮ Use fill= to specify a color for filling. P P P P G U

  20. Nodes Can Be Named. 5’ OH P P P P P P 3’ \ begin {tikzpicture} \ node at (-14mm,54mm) [circle,draw,name=p1] {P}; G (oder A) \ node at (-7mm,54mm) [circle,draw,name=p2] {P}; UTP RNA- \ node at (0mm,54mm) Polymerase [circle,draw,name=p3] {P}; H 2 O PP i 2P i \ draw (p1) -- (p2) -- (p3); Pyro- \ end {tikzpicture} phosphatase ◮ You can assign a name to a node using 5’ name= . OH P P P P ◮ Later, a named node can be used “like a coordinate.” G U

  21. The Complete Picture. 5’ OH P P P 3’ G (oder A) UTP RNA- Polymerase H 2 O The whole picture can be created using the PP i 2P i just-described methods. Pyro- phosphatase 5’ OH P P P P G U

  22. Basic Design Principles Underlying Ti k Z. 1. Pictures consist of path, to which actions are applied. 2. Special syntax for coordinates. 3. Special syntax for paths. 4. Special syntax for nodes. 5. Special syntax for trees. 6. Style sheets configure the way things look.

  23. Design Principle: Paths and Actions The Concept Design Principle All Ti k Z graphics consist of paths to which one or more actions are applied. Actions are specified using options: ◮ draw will draw (stroke) a path. ◮ fill will fill a path. ◮ shade will shade the path. ◮ pattern will fill the path using a pattern. ◮ clip will clip the rest of the figure against the path. The command \ draw is an abbreviation for \ path [draw] .

  24. Design Principle: Paths and Actions Examples \ begin {tikzpicture} \ path [draw,clip] (0,0) circle (2cm); \ path [draw=red,fill=blue!20] (-1,-1) rectangle (3,1); \ end {tikzpicture}

  25. Design Principle: Syntax for Coordinates The Concept Design Principle Coordinates are given in parentheses. Different coordinate systems are possible. Supported coordinate systems: ◮ Cartesian ◮ affine ◮ polar 2D ◮ isometric 3D ◮ barycentric ◮ user defined

Recommend


More recommend