Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Since the December 20, 2013, we have new major release of the wonderful TikZ/pgf package: version 3.0.0! 1

Unfortunately, I was not able to find a nice human readable list of changes, that goes to some depth and maybe even provides some examples. This page probably comes closest to it: 2

Therefore, I would like to ask you to point out some of the new features and give examples of their usage! A bounty might be awarded ;-).


1. http://sourceforge.net/projects/pgf/
2. http://sourceforge.net/projects/pgf/files/pgf/version%203.0.0/

share|improve this question
1  
Is this an official release? It hasn't made it to CTAN, yet, and thus is not part of either major TeX distribution. –  cgnieder Jan 10 at 20:30
    
it is not a major release but a release candidate. –  percusse Jan 14 at 8:11
6  
@cgnieder: It is and CTAN is working on releasing it. Once it's on CTAN it will in the distros. –  Martin Schröder Jan 15 at 11:29
3  
@MartinSchröder It is a month and a half and still not on CTAN. Any time prognosis when this is going to be released? –  Pygmalion Feb 7 at 17:14
7  

3 Answers 3

up vote 55 down vote accepted
+300

Some of the new features have already been shown on the site.

I report some examples (in alphabetical order):

angles

arrows.meta

babel

datavisualization

graphdrawing

pics

quotes

share|improve this answer
2  
Oh, I'm looking forward to pics! –  quinmars Jan 10 at 21:14
2  
The graph drawing library is amazing. Making things so much easier! When will 3.0 reach TeXLive? –  Ingo Jan 11 at 12:08
3  
What? No faded drop shadow? :( –  recluze Jan 15 at 1:43
    
texdoc tikz brings up the old documentation (v2.1 rather than 3.0), why? –  stalking is prohibited Jan 16 at 13:23
    
@CodeMocker: make sure to copy the doc directory in your personal tree. I did that way and texdoc is opening correctly the new documentation. –  Claudio Fiandrino Jan 16 at 13:28

With TikZ 3.0, you can use blend modes.

A blend mode specifies how colors mix when you paint on a canvas. Normally, if you paint a red box on a green circle, the red color will completely replace the green circle. However, in some situations you might also wish the red color to somehow "mix" or "blend" with the green circle. We already saw that, using transparency, we can draw something without completely obscuring the background. Blending is a similar operation, only here we mix colors in more complicated ways.

Note: Blending is a rather "advanced" feature of PDF. Most renderers, let alone printers, will have trouble rendering blending correctly.

Below is an example of screen blend mode (there are 16 modes: normal, multiply, screen, overlay, darken, lighten, color dodge, color burn, hard light, soft light, difference, exclusion, hue, saturation, color, luminosity).

enter image description here

\documentclass[tikz]{standalone}
\begin{document}
\tikz [blend group=screen] {
  \fill[red!90!black]   ( 90:.6) circle (1);
  \fill[green!80!black] (210:.6) circle (1);
  \fill[blue!90!black] (330:.6) circle (1);
}
\end{document}
share|improve this answer

With TikZ 3.0 arrives math library.

This library defines a simple mathematical language to define simple functions and perform sequences of basic mathematical operations.

Here is a code from the manual (p.629), slightly modified to include function use.

\documentclass[varwidth,border=50]{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath{
  function step(\n){ return 45/\n; };
  function first(\n){ return step(\n)/2; };
  function next(\n){ return first(\n)+2*step(\n); };
  function testcircle(\a){
    real \s; \s = step(\a);
    for \k in {first(\a),next(\a),...,360}{
      % set the color
      if \k>270 then { let \c = orange; } else {
        if \k>180 then { let \c = blue; } else {
          if \k>90 then { let \c = red; } else {
            let \c = green;
          };
        };
      };
      { % "print" the path command
        \path[fill=\c!50, draw=\c] (\k:0.5cm) -- (\k:1cm) --
          (\k+\s:1cm) -- (\k+\s:0.5cm) -- cycle;
      };
    }; % end for loop
  }; % end test circle
}

\begin{document}
  \begin{tikzpicture}
    \tikzmath{testcircle(4);}
    \begin{scope}[scale=-2.1]
      \tikzmath{testcircle(13);}
    \end{scope}
  \end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
wow, that code looks almost like one sees in normal looking languages. A normal looking function definition and even a normal looking "if then else". May be I should switch to Latex programming from now on. This is very good news. Can one call these functions from Latex outside \begin{tikzpicture}? Or these functions can only be used inside tikzpicture? –  Nasser 2 hours ago
    
@Nasser yes we can. If you look at the manual you can see examples outside tikzpicture. But don't be so happy : not everything is possible. It is really "math" library. You can't manipulate "strings" easily (you can still hook to standard (La)TeX for doing this). For example I was not able to create function that returns a color (like green!50) and use it after in the path. But may be somebody will tell us how to do it ;) –  Kpym 2 hours ago
    
@Kpym You may use return "..." to return a string. Then you may define a new .math expr handler to use math expressions for any pgf/tikz key. –  Paul Gaborit 1 hour ago
    
@PaulGaborit I tried to return string, it works well if I use it in a node text, but I was not able to use it in a style. I'll check with .math exp (I was not aware of the existence of this handler). Thanks for the suggestion ! –  Kpym 1 hour ago
    
@Kpym You must write your own .math expr handler like \pgfkeysdef{/handlers/.math expr}{\pgfmathparse{#1}\pgfkeysalso{\pgfkeyscurrentpath/.expand once=\pgfmathresult}} –  Paul Gaborit 1 hour ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.