[Tex/LaTex] What’s new in the latest version 3.1 of TikZ?

tikz-pgf

TikZ version 3.1 is available on CTAN since January 5, 2019.

Christian Feuersaenger published the latest version on sourceforge on the same day.

The manual of version 3.0.1a which had 1161 pages now has 1282 pages.

What's new in this version?

Best Answer

I make this answer a Wiki in order to allow those who are aware of the new features of version 3.1 to make them public.

  • A new pic type right angle

is added. (page 561)

Pic type right angle=<A>--<B>--<C>.

This pic adds a drawing of a right angle to the current path. It works in the same way as angle pic.

pic-right-angle

\tikz
  \draw (1,0,0) coordinate (A) -- (0,0,0) coordinate (B) -- (0,0,1) coordinate (C)
    (B) -- (0,1,0) coordinate (D)
    pic [fill=gray,angle radius=4mm] {right angle = A--B--C}
    pic [draw,red,thick,angle eccentricity=.5,pic text=$\cdot$]
    {right angle = A--B--D};
  • Unfortunately "The Data Visualization Backend"

which was not documented in version 3.0.1a is still not documented. (page 944)

  • The 3d library

that was available is now documented (page 557).

  • In grid

if the xstep or ystep is 0 or negative the corresponding lines are not drawn (p.157 of the documentation).

enter image description here

\begin{tikzpicture}
  \draw (0,0) grid [xstep=.5,ystep=.75] (3,2);
  \draw[thick,red] (0,0) grid [ystep=0] (3,2);
\end{tikzpicture}
  • SVG Animations;

compile with latex and dvisvgm --font-format=woff --exact --zoom=-1

\documentclass[dvisvgm]{standalone}
\usepackage{tikz}
\usetikzlibrary{animations}

\begin{document}

\tikz
\node :fill opacity = { 0s="1", 2s="0", begin on=click }
      :rotate = { 0s="0", 2s="90", begin on=click }
      [fill = blue!20, draw = blue, ultra thick, circle]
      {Click me!};

\end{document}

Static SVG and animated SVG without user interaction (e. g. activation on click) are embedded into HTML with the <img> tag, e. g.:

<img src="https://url/of/some.svg" width="200"/>

The <img> tag also works on this site (TeX.SX). Unfortunately, Imgur does not allow SVG file upload, but file URLs to third-party sites can be used.

Animated SVG with user interaction and scripted SVG (as those produced with pkg animate) must be embedded into HTML using the <object> tag:

<object type="image/svg+xml" data="https://url/of/some.svg" width="200">
  <!-- optional (increases loading time): fallback & search engine indexing -->
  <img src="https://url/of/some.svg" />
</object>

Unfortunately, Blog sites and StackExchange do not accept the <object> tag, mainly for security reasons. As a workaround, an <img> tag can be used as text of a link that redirects the browser to the file URL of the SVG on click. This was done for the example above. In Markdown syntax:

[<img src="https://url/of/some.svg" width="200"/>](https://url/of/some.svg)
  • Some basic tools for perspective drawing

with one, two, or three vanishing points have been added in the perspective library. Documentation is on page 726 (section 63) of the manual.

One of the examples from the manual can be drawn with:

\documentclass[tikz,margin=2mm]{standalone}

\usetikzlibrary{perspective}

\begin{document}
  \begin{tikzpicture}[
    isometric view,
    perspective={
      p = {(12,0,0)},
      q = {(0,12,0)},
      r = {(0,0,-12)}}]
      
    \fill[gray!80!white] (tpp cs:x=0,y=0,z=3)
      -- (tpp cs:x=0,y=3,z=3)
      -- (tpp cs:x=3,y=3,z=3)
      -- (tpp cs:x=3,y=0,z=3) -- cycle;
    \fill[gray] (tpp cs:x=0,y=0,z=0)
      -- (tpp cs:x=0,y=0,z=3)
      -- (tpp cs:x=0,y=3,z=3)
      -- (tpp cs:x=0,y=3,z=0) -- cycle;
    \fill[gray!50!white] (tpp cs:x=0,y=0,z=0)
      -- (tpp cs:x=0,y=0,z=3)
      -- (tpp cs:x=3,y=0,z=3)
      -- (tpp cs:x=3,y=0,z=0) -- cycle;
  \end{tikzpicture}
\end{document}

Results in:

enter image description here

A lot of standard Tikz keys are not (yet) supported, e.g. shift, xshift, yshift, rotate around x, rotate around y, rotate around z, all the canvas is ... plane keys from the 3d library, and there are bound to be more.

Related Question