260

Quick links:

SummaryIntersections libraryArrow tips libraryDecorations librariesCalc libraryMindmap libraryShapes libraryPaper Folding libraryChains libraryShapes libraryMiscelaneous contributions to TikZ


Very often I search a special library of TikZ. At the moment there is no package which loads every library.

Is there a list of all available libraries with a short introduction (2-3 sentences)?

Maybe we can collect them here

10
  • 38
    Part IV of the PGF manual is all the libraries; the TOC gives their names, and each section starts with a short introduction.
    – Ryan Reich
    Jan 28, 2012 at 19:56
  • 3
    @RyanReich Why don't you add that as an answer? (If Marco still wants to collect libraries here, this question should probably be CW.)
    – doncherry
    Jan 29, 2012 at 9:10
  • 5
    What about third party libraries? It would actually be more useful to list those. Jan 29, 2012 at 12:43
  • 1
    @doncherry: I don't think it would be a very good answer, and however correct, he must have known that already. Also, as an answer it would not be the first, whereas it is now the top comment :)
    – Ryan Reich
    Jan 29, 2012 at 17:23
  • I totally do not understand the purpose of this list that just mimics the very good PGF documentation. Apparently, other members consider it as very useful, given the number of favorite links, which is a mystery to me. Am I overlooking something?
    – Daniel
    May 25, 2012 at 19:07

12 Answers 12

153

Summary

Here's the list of libraries, and a brief summary of the purpose of each (any code supplied is for LaTeX and/or Plain TeX, not ConTeXt):

  • Arrow tip library with \usetikzlibrary{arrows.meta} (\usetikzlibrary{arrows} is deprecated). See details below.
  • Automata Drawing Library, accessed by \usetikzlibrary{automata}, and is used for drawing "finite state automata and Turing Machines". To draw these graphs, each node, its name and relative position is defined, as well as the types of path between each.
  • Background Library, accessed by \usetikzlibrary{backgrounds}, and "defines background for pictures". To use this in a Tikzpicture, an option is passed, e.g. \begin{tikzpicture}[show background rectangle], with a background rectangle style defined before the picture. (e.g. \tikzset{background rectangle/.style={<define background rectangle style here>}}
  • Calc library, accessed through \usetikzlibrary{calc} to make complex coordinate calculations. See details below.
  • Calendar Library, accessed through \usetikzlibrary{calendar}. This library is used to display calendars (I guess it's a Ronseal thing). You define a calendar as \calendar[display options and date options](Name (optional)).
  • Chain library to align nodes o chains. See details below.
  • Decorations libraries to decorate paths. See details below.
  • Entity Relationship Diagram Library, accessed by \usetikzlibrary{er}, as in the automata drawing library, each node is defined, as is each edge between each node, as well as any attributes. As a note of warning, underlining should be used for attributes, but this is not used as it is both ugly and difficult to implement. Italics are used instead.
  • Intersection library, accessed through \usetikzlibrary{intersections}, to calculate intersections of paths. See details below.
  • Mind map library, accessed through \usetikzlibrary{mindmap}. See details below.
  • Matrix Library, accessed through \usetikzlibrary{matrix}. Matrices are defined in the same way as in maths mode, however, each item in the matrix as assigned a value as a node, starting from 1. Each node can then be identified and manipulated. Delimiters can also be selected in the matrix options and can be "any delimiter that is acceptable to TeX’s \left command".
  • Paper folding library \usetikzlibrary{folding}. See details below.
  • Pattern Library \usetikzlibrary{patterns}. This package "defines patterns for filling areas". In the documentation, each pattern is named and an example given.
  • Petri-Net Library. This is used to draw Petri Nets, as used for mathematical modelling. As with other similar flowchart style diagrams, each node and edge is defined, as well as their style and position. Tokens can also be embedded within nodes, by treating them as children and child nodes.
  • Plot handler Library, accessed through \usetikzlibrary{plothandlers}. TikZ loads this library automatically. Each point is defined (as a node) for the plot and the each point has a curve placed
    • Plot Mark Library, accessed through \usetikzlibrary{plotmarks} is used to define additional styles for plots as used above. Each point is defined as \pgfuseplotmark{Plot description}.
  • Shape library, used to define shapes other than rectangle, circle and co-ordinate. Accessed through either \usetikzlibrary{shapes} or \usetikzlibrary{shapes.shape type}. The following additional types are available: geometric shapes, either named shapes (star, diamond, etc.) or polygons of specified side numbers; symbol shapes, e.g. "forbidden sign" as used in No Smoking signs; "multipart" shapes, with "multiple (text) parts"; and finally, "misc" shapes which "do not fit in the previous categories", such as strike-through crosses. See details below.
  • Snake library, as accessed through \usetikzlibrary{snakes} and can be best described as curved lines, and are used either between nodes or as a border to a shape , or as independent shapes.
  • To Path library, accessed through \usetikzlibrary{topaths}. This library is used to define paths between two points, and is loaded automatically. Additionally, it can take the form of curved lines between two shapes or as a loop back to a node.
  • Tree library, accessed through \usetikzlibrary{trees}. Each point on the tree is defined as a node, with children, and each child can have its own children. The tree's direction can also be specified, as well as the angle at which children emerge, however, when left to its own devices, the results are acceptable.

Sources: Anything in inverted commas has been lifted from the tikzpgfmanual, as well as the calendar sample.

17
  • 5
    How about making a CW answer for each library including an example image. So one can easily add new librarys. I would make an example and start to port your list to separated answers if it’s ok with you.
    – Tobi
    Jan 29, 2012 at 13:04
  • 2
    @Tobi: The draw back of the cw is that jClark94 doens't earned any reputation though he provides a great answer. Jan 29, 2012 at 13:06
  • 2
    I'd rather it was useful, than I got rep for it, whatever's best for the community
    – jClark94
    Jan 29, 2012 at 13:07
  • 1
    I added a headline to this answer so it could be used as a short overview. I added links to the CW answers below.
    – Tobi
    Jan 29, 2012 at 16:20
  • 1
    You have done a really nice job with this quick reference guide to Tikz libraries. For completion you might have to add math tikzlibrary (tex.stackexchange.com/questions/222680/…) Oct 5, 2018 at 23:30
65

Arrow tips library

Accessed by \usetikzlibrary{arrows.meta}

Description: Provides various new and customizable arrow tips

Example

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
\foreach \arrowtipkind[count=\i from 0] in {
Circle,
Diamond,
Ellipse,
Kite,
Latex,
Rectangle,
Square,
Stealth,
Triangle,
Turned Square,
Arc Barb,
Bracket,
Hooks,
Tee Barb,
Parenthesis,
Implies,
Butt Cap,
Fast Round,
Fast Triangle,
Round Cap,
Triangle Cap}{\foreach \specs[count=\j from 0] in {round, open, fill=red, {round, fill=blue, length=2.5mm, slant=.5}}{\draw[-{\arrowtipkind[\specs]}, yshift=-1.5*\i cm -0.2*\j cm] (0,0) -- +(1,0)\ifnum\j=0 node[above,midway,font=\scriptsize\ttfamily]{\arrowtipkind}\fi;};};
%%% Tips with particular options:
% Arc Barb[sep, arc=<angle>, length=<dim>, line width=<dim>, width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>]
% Bracket[sep, reversed, round, slant=<num>, left, right, harpoon, reversed, <color>]
% Hooks[sep, arc=<angle>, length=<dim>, line width=<dim>, width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>]
% Tee Barb[sep, inset=<dim>, inset'=<dim> <num>, line width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>] thin thick
% Implies[<color>]
\end{tikzpicture}
\end{document}

Reference

TikZ/PGF 3.1.5b Manual section Arrows.

enter image description here

2
  • 1
    it looks like double, thin uses single lines, but this is due to the shrunk image. If you run the code given you'll see that it's really double lines. Jan 29, 2012 at 17:29
  • 1
    GREAT!!!!!!!!!!! Jan 29, 2012 at 18:13
54

Intersections library

Accessed by \usetikzlibrary{intersections}

Description
Allows automated calculation of path intersections.

Example 1

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
    % Draw to path and give a name to them
    \draw [red, name path={red line}] (0,0) -- (4,3);
    \draw [blue, name path={blue curve}] (1,-0.5) to[out=80, in=100] (3,2);
    % use the intersections on a path to giv them coordinates
    % and draw a line between them
    \draw [green, name intersections={of=red line and blue curve, 
           by={first intersect, second intersect}}]
       (first intersect) -- (second intersect);
    % one can use the coordinates furtheron
    \node [above] at (first intersect) {A};
    \node [below] at (second intersect) {B};
\end{tikzpicture}
\end{document}

result

Example 2

\documentclass{standalone}% or wathever you want

% load packages
\usepackage{tikz, xcolor}
% load libraries
\usetikzlibrary{intersections,shapes.arrows,calc}

% define light and dark gray
\definecolor{lgray}{cmyk}{0,0,0,0.2}
\definecolor{dgray}{cmyk}{0,0,0,0.7}

% make some settings
\tikzset{%
    % style for the intersecting path, which
    % are nessesary for the calculation but
    % shouldn't be drawn in the final image
    ipath/.style={
%       draw,% comment this aout after construction
        red
    },
    % style for an arrow used as object
    optical arrow/.style={%
        fill=dgray,
        inner sep=3pt,
        shape=single arrow,
        minimum width=0.5cm,
        minimum height=1.5cm,
        outer sep=0pt,
        shape border rotate=90,
    },
    % style for the virtual image
    virtual optical arrow/.style={%
        fill=lgray,
        inner sep=3pt,
        shape=single arrow,
        minimum width=0.5cm,
        minimum height=1.5cm,
        outer sep=0pt,
        shape border rotate=90,
    },
    % style for the mirror
    mirror/.style={%
        line width=2pt,
    },
    % style for the axis
    optical axis/.style={%
        thin,
    },
    % style for light rays
    ray/.style={%
        thin,
        ->,
    },
    % style for imagined rays, which ar not real
    % but help by constructin the image
    imagined ray/.style={%
        ray, dgray, -,
    },
    % alias
    virtual ray/.style={imagined ray},
    % style for (focal) points
    point/.style={%
        fill=black,
        radius=0.8pt,
        inner sep=1pt,
        shape=circle,
        minimum size=2pt,
        outer sep=2pt
    },
}

% set three layers
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
% and define shortcuts to access them
\newcommand{\bglayer}[1]{%
    \begin{pgfonlayer}{background}%
    #1%
    \end{pgfonlayer}%
}
\newcommand{\fglayer}[1]{%
    \begin{pgfonlayer}{foreground}%
    #1%
    \end{pgfonlayer}%
}

\begin{document}
\begin{tikzpicture}
    % define the bounding box is nessesarx because the ipaths
    % make it bigger than needed
    \path [use as bounding box] (-5.2,-5) rectangle (6.2,5);
    % define variables, you may vary them a little
    %% radius
    \def\radius{5}
    \def\radiusII{5.05}
    %% focal distancs = \radius/2
    \def\focal{2.5}
    %% object size
    \def\size{1.cm}
    %% object width
    \def\owidth{1.25}
    % draw mirror
    %% the extra ipath is nessesary to get nicer rays
    \path [ipath, name path=M] (\radius,0) ++(90:\radius)
          arc (90:270:\radius);
    \fglayer{%
        \draw [mirror] (\radiusII-0.05,0) ++(130:\radiusII)
              arc (130:240:\radiusII);
    }
    % draw focal point
    \node (B) at (\focal,0) [point] {};
    % draw object
    \node (O) [optical arrow,anchor=tail, minimum height=\size] %
          at (\owidth,0) {};
    %% description
    \node [above right] at (O.tip) {object};
    % rays
    %% draw axis ray
    \draw [ray] (O.tip) -- (0,0) -- ($(0,0)!3!(\owidth,-\size)$);
    %% draw parallel ray
    \path [ipath, name path=PS] (O.tip) -- ++(-3,0);
    \draw [ray, name intersections={of=M and PS, by=M-PS}]
        (O.tip) -- (M-PS) -- ($(M-PS)!2!(B)$);
    %% caculate virtual axis ray
    \path [ipath, name path=AS-V] ($(0,0)!-4!(\owidth,-\size)$) -- (0,0);
    %% calculate virtual parallel ray
    \path [ipath, name path=PS-V] ($(M-PS)!-4!(B)$) -- (M-PS);
    %% draw virtual axis ray
    \draw [imagined ray, name intersections={of=AS-V and PS-V, by=Tip-V}]
        (Tip-V) -- (0,0);
    %% draw virtual axis ray
    \draw [imagined ray] (Tip-V) -- (M-PS);
    % draw virtual object
    \bglayer{\path let \p{1}=(Tip-V) in 
        (Tip-V) node (V) [minimum height=\size,
                          scale={\y{1}/\size*0.665},
                          virtual optical arrow,anchor=tip
                         ] {};}
    %% description
    \path (V.west) node [left] {virtual image};
    % draw optical axis
    \fglayer{\draw [optical axis] (-5,0) --++(11,0);}
\end{tikzpicture}
\end{document}

width drawn ipaths

final image

Reference
pgfmanual.pdf, pp. 143 et sec.

3
  • 4
    Your great example 2 should IMHO be sent to TeXample.net.
    – Speravir
    Jan 30, 2012 at 0:11
  • May I use it with tikz-3dplot?
    – zyy
    Dec 9, 2018 at 1:02
  • 1
    @zyy I don’t know. I never used ˋtikz-3dplotˋ ...
    – Tobi
    Dec 9, 2018 at 16:42
50

Calc library

Accessed by \usetikzlibrary{calc}

Description
Allows extended coordinate calculation

Example

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
    % make some mathematical calculations
    \node (a) at (1,1) {A};
    \fill [red] ($(a) + 1/3*(1cm,0)$) circle (2pt);
    % draw a segment of a path between two points
    \coordinate (b) at (0,0);
    \coordinate (c) at (0.5,3);
    \fill (b) circle (1pt) (c) circle (1pt);
    \draw [blue!50!green, ->] (b) -- ($(b)!1.5!(c)$);
    \draw [blue, ->] (b) -- ($(b)!0.5!(c)$);
    % draw a parallel line
    \draw [green] (2,0) coordinate (d) -- (3,4) coordinate (e);
    \draw [green, dashed] (2.5,1) -- ++($(e)-(d)$);
\end{tikzpicture}
\end{document}

result

Reference
pgfmanual.pdf.

3
  • The link (pgfmanual.pdf) is not working for me. Jul 24, 2015 at 16:55
  • 1
    I think this and this are the desired pdf link. Jul 24, 2015 at 16:56
  • 1
    Thanks … the link was outdated. I made an update to may answer. Btw. your first link points to the 2.10 version whir 3.00 is the current one on CTAN. (The second doesn’t load on my computer at the moment …)
    – Tobi
    Jul 24, 2015 at 18:12
43

Shapes library

Accessed by \usetikzlibrary{shapes}

Description
Allows shapes to be placed as part of a flowchart

Example

\documentclass{standalone}

\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}


\tikzstyle{decision} = [diamond, draw, text width=4.5em, 
                        text badly centered, node distance=2cm, 
                        inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, text width=5em, 
                     text centered, rounded corners, 
                     minimum height=4em, node distance=3cm]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse, node distance=2.5cm, minimum height=2em]
\tikzstyle{blank} = [node distance=1cm]

\begin{document}
\begin{tikzpicture}[node distance = 3cm, auto]
    % Place nodes
    \node [cloud] (init) {n};    
    \node [blank, below of=init] (sup) {};
    \node [decision, below of=sup] (square) {$n^2 \le 1$};
    \node [cloud, right of=square] (end) {End};
    \node [block, left of=square] (newN) {$n = \frac{2}{n}$};

    % Draw edges
    \path [line] (init) -- (square);
    \path [line] (square) -- node [near start] {yes} (end);
    \path [line] (square) -- node [near start] {no} (newN);
    \path [line] (newN) |- (sup);
\end{tikzpicture}
\end{document}

result

Reference
http://www.texample.net/tikz/examples/simple-flow-chart/ Used as a base to get started, additional style (blank) used as a support, example from a question asked at university interview.

41

Paper Folding Library

Accessed by \usetikzlibrary{folding}

Description

It contains a single command, but it is useful for producing real calendars (as used on a desktop).

Example

\documentclass{standalone}

\usepackage{tikz, xcolor}
\usetikzlibrary{folding,calendar}
\begin{document}
\sffamily\scriptsize
\begin{tikzpicture}[transform shape]
\tikzstyle{every calendar}=
[
    %Formats calendars and sets positions
    at={(-8ex,4ex)},
    week list,
    month label above centered,
    month text=\bfseries\textcolor{red}{\%mt} \%y0,
    if={(Sunday) [black!50]}
    ]
\tikzfoldingdodecahedron
[
    %Sets size of calendar
    folding line length=2.5cm,
    %Adds calendar image to each face
    face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
    face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
    face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
    face 4={ \calendar [dates=\the\year-04-01 to \the\year-04-last];},
    face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
    face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
    face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
    face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
    face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
    face 10={\calendar [dates=\the\year-10-01 to \the\year-10-last];},
    face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
    face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];},
];
\end{tikzpicture}
\end{document}

result

Reference
pgfmanual.pdf, pp. 202 et sec.

2
  • 1
    You may make the examples work like an MWE. E.g. using the standalone class; see my answers how to use it.
    – Tobi
    Jan 29, 2012 at 15:05
  • OK, thanks, I've also updated my answer below to a (hopefully) MWE
    – jClark94
    Jan 29, 2012 at 15:10
39

Mindmap Library

Accessed by \usetikzlibrary{mindmap}

Description

The main focus point, is placed in the middle, with sub-points branching off. Each node is defined, as are its children. Nodes can also be separate from each other, and each node can also be coloured differently and interconnected. Annotations are also available.

Example

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap,backgrounds}

\begin{document}
\tikzstyle{root concept}+=[concept color=blue!20,minimum size=2cm]
\tikzstyle{level 1 concept}+=[sibling angle=45]

\begin{tikzpicture}[mindmap]
\node [concept] (n1) {Stack Exchange Sites}
    child[concept color=red,grow=45] {node[concept] (c1) {Meta}}
    child[concept color=orange,grow=0] {node[concept] (c2) {Q \& A}}
    child[concept color=green,grow=-45] {node[concept] (c3) {Chat}};
\begin{pgfonlayer}{background}
\draw [concept connection] (c1) edge (c2)
                                edge (c3)
                           (c2) edge (c3);
\end{pgfonlayer}

\node [extra concept] at (0,10) (n2) {\TeX {} and \LaTeX {}Stack Exchange}
    child[concept color=red,grow=45] {node[concept] (s1) {Meta}}
    child[concept color=orange,grow=0] {node[concept] (s2) {Q \& A}}
    child[concept color=green,grow=-45] {node[concept] (s3) {Chat}};

\begin{pgfonlayer}{background}
    \draw [concept connection] (s1) edge (s2)
                                    edge (s3)
                               (s2) edge (s3)
                               (n1) edge (n2);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

result

Reference
pgfmanual.pdf, pp. 207 et sec.

31

Chains Library

Accessed by \usetikzlibrary{chains}

Description

Chains are sequences of nodes that are arranged in a row or a column and that are, typically, connected by edges. More generally, they can be used to position nodes of a branching network in a systematic manner. For the positioning of nodes in rows and columns you can also use matrices (see Section 17 of pgfmanual.pdf) but chains can also be used to describe the connections between nodes that have already been connected using, say, matrices. Thus, it often makes sense to use matrices for the positioning of elements and chains to describe the connections.

Example with Chains

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle, 
    minimum size=6mm, 
    very thick, 
    draw=red!50!black!50, 
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  node distance=5mm, every on chain/.style={join}, every join/.style={->}
]
{ [start chain]
  \node [on chain,nonterminal] {unsigned integer};
  \node [on chain,terminal] {.};
  \node [on chain,terminal] {digit};
  \node [on chain,terminal] {E};
  { [start branch=plus]
    \node (plus) [terminal,on chain=going above right] {+};
  }
  { [start branch=minus]
    \node (minus) [terminal,on chain=going below right] {-};
  }
  \node [on chain, nonterminal, join=with chain/plus-end, join=with chain/minus-end] {unsigned integer};
}
\end{tikzpicture}
\end{document}

chains

Example with Matrix and Chains

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle, 
    minimum size=6mm, 
    very thick, 
    draw=red!50!black!50, 
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  every on chain/.style={join}, every join/.style={->}
]

\matrix[column sep=4mm] {
  % First row:
  & & & & \node (plus) [terminal] {+};&\\
  % Second row:
  \node (ui1)   [nonterminal] {unsigned integer};&
  \node (dot)   [terminal]    {.};               &
  \node (digit) [terminal]    {digit};           &
  \node (e)     [terminal]    {E};               &
  & % space in between
  \node (ui2) [nonterminal] {unsigned integer};\\
  % Third row:
  & & & & \node (minus)[terminal] {-};&\\
  };

{ [start chain]
  \chainin (ui1);
  \chainin (dot);
  \chainin (digit);
  \chainin (e);
  { [start branch=plus]
    \chainin (plus);
  }
  { [start branch=minus]
    \chainin (minus);
  }
  \chainin (ui2) [join=with chain/plus-end, join=with chain/minus-end];
}
\end{tikzpicture}
\end{document}

matrix

Chains with Labels

Some times one needs to add labes to the edges created by the chains library (it happened to me before). Although it is not supported natively by the library, you can do it by tweaking the library.

An example is:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\makeatletter
\def\tikz@lib@parse@join#1{%
  \def\tikz@temp{#1}%
  \ifx\tikz@temp\pgfutil@empty%
    \tikz@lib@parse@join@by by \pgf@stop%
  \else%
    \pgfutil@in@{with }{#1}% 
    \ifpgfutil@in@% 'with [by] [label]'
      \pgfutil@in@{by }{#1}%
      \ifpgfutil@in@% 'with by [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'with by label'
          \tikz@lib@parse@join@with@by@label#1\pgf@stop%
        \else% 'with by'
          \tikz@lib@parse@join@with@by#1\pgf@stop%
        \fi%
      \else% 'with [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'with label'
          \tikz@lib@parse@join@with@label#1\pgf@stop%
        \else% with
          \tikz@lib@parse@join@with@by#1 by \pgf@stop%
        \fi%
      \fi%
    \else% '[by] [label]'
      \pgfutil@in@{by }{#1}%
      \ifpgfutil@in@% 'by [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'by label'
          \tikz@lib@parse@join@by@label#1\pgf@stop%
        \else% 'by'
          \tikz@lib@parse@join@by#1\pgf@stop%
        \fi%
      \else% '[label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'label'
          \tikz@lib@parse@join@label#1\pgf@stop%
        \else%
          \tikz@lib@parse@join@by#1 by \pgf@stop%
        \fi%
      \fi%
    \fi%
  \fi%
}
\def\tikz@lib@parse@join@with@by@label with #1 by #2 label #3\pgf@stop{%
  \tikzset{after node path={(#1)edge[every join,#2]#3(\tikzchaincurrent)}}%
}
\def\tikz@lib@parse@join@with@label with #1 label #2\pgf@stop{%
  \tikzset{after node path={(#1)edge[every join]#2(\tikzchaincurrent)}}%
}
\def\tikz@lib@parse@join@by@label by #1 label #2\pgf@stop{%
  \tikzset{after node path={\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)edge[every join,#1]#2(\tikzchaincurrent)\fi}}%
}
\def\tikz@lib@parse@join@label label #1\pgf@stop{%
  \tikzset{after node path={\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)edge[every join]#1(\tikzchaincurrent)\fi}}%
}
\makeatother

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle, 
    minimum size=6mm, 
    very thick, 
    draw=red!50!black!50, 
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  every on chain/.style={join}, every join/.style={->}
]

\matrix[column sep=4mm] {
  % First row:
  & & & & \node (plus) [terminal] {+};&\\
  % Second row:
  \node (ui1)   [nonterminal] {unsigned integer};&
  \node (dot)   [terminal]    {.};               &
  \node (digit) [terminal]    {digit};           &
  \node (e)     [terminal]    {E};               &
  & % space in between
  \node (ui2) [nonterminal] {unsigned integer};\\
  % Third row:
  & & & & \node (minus)[terminal] {-};&\\
  };

{ [start chain]
  \chainin (ui1);
  \chainin (dot);
  \chainin (digit);
  \chainin (e);
  { [start branch=plus]
    \chainin (plus) [join=label {node[above left]{a label}}];
  }
  { [start branch=minus]
    \chainin (minus);
  }
  \chainin (ui2) [join=with chain/plus-end label {node[above right] {plus label}}, join=with chain/minus-end by dashed label {node [below right]{minus label}}];
}
\end{tikzpicture}
\end{document}

with edges

Reference

pgfmanual.pdf, pp. 284 et sec. The examples are a simplified version of the Tutorial: Putting a Diagram in Chains, of pp. 60

28

I created a PDF with all the libraries and a short definition from the pfdmanual.

enter image description here

You can find the PDF here table-library

It's a first version and I have not reread or corrected and I think the order is not fine. The last libraries about graphs need luatex.

6
  • 5
    Your pdf link is dead. Could you update it, please. Thank you.
    – Hotschke
    May 27, 2014 at 8:09
  • I added the PDF to the my site. With pgf 3.0 I need to update now the document. May 31, 2014 at 9:32
  • 1
    Thank you very much. Highly appreciated, the pgf/tikz documentation is very large but unhandy.
    – Hotschke
    May 31, 2014 at 17:38
  • 3
    @AlainMatthes I have looked for the .pdf all throughout your page and didn't find it. Could you give a direct [living ;)] link to the list of tikz-libraries? Thanks! Dec 17, 2015 at 11:03
  • 1
    It has been three years since the last comment and the link is still dead.
    – evaristegd
    Oct 14, 2018 at 1:07
27

Shapes library

Accessed by \usetikzlibrary{shapes, shapes.geometric, shapes.symbols, shapes.arrows, shapes.multipart, shapes.callouts, shapes.misc}

Description
Provide several shapes besides the standard ones

Example

\documentclass[parskip]{scrartcl}
\usepackage[margin=5mm,a3paper]{geometry}
\usepackage{kerkis}
\usepackage{tikz}
\usetikzlibrary{
    shapes,
    shapes.geometric,
    shapes.symbols,
    shapes.arrows,
    shapes.multipart,
    shapes.callouts,
    shapes.misc}

\begin{document}

\tikzset{every node/.style={draw=red!20!black,fill=orange!50!red!50!white,text=black,inner sep=2pt}}

{\LARGE \textbf{Standard shapes}}\\
\foreach \shape in {circle,rectangle}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Geometric shapes}}\\
\foreach \shape in {diamond,ellipse,trapezium,semicircle,regular polygon,star,isosceles triangle,kite,dart,circular sector,cylinder}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Symbol shapes}}\\
\foreach \shape in {forbidden sign,magnifying glass,cloud,starburst,signal,tape}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Arrow shapes}}\\
\foreach \shape in {single arrow,double arrow,arrow box}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Multipart shapes}}\\
\foreach \shape in {circle split,circle solidus,ellipse split,rectangle split}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Callout shapes}}\\
\foreach \shape in {ellipse callout,rectangle callout,cloud callout}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Miscellaneous shapes}}\\
\foreach \shape in {cross out,strike out,rounded rectangle,chamfered rectangle}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}

\end{document}

enter image description here

Reference
pgfmanual.pdf, pages 419 to 461

1
21

Miscelaneous contributions to TikZ (total of 70)

Maybe this is not the proper place to put this answer but I think it may help someone.

Here is a link that contains several contributions made to TikZ, some of them have to be loaded as packages and some can be loaded commonly as libraries through \usetikzlibrary but are not documented at the TikZ/PGF manual, instead they have their own documentation like packages.

I'll list some of the packages/libraries and a very short description of what it does

  • knots (tikz library): provide environment to draw knots easily computing intersection and automatically Splitting the path into several paths one over another.
  • hobby (tikz library): an implementation of John Hobby's algorithm to produce a smooth curve through a given set of points, it allows further customization of the curve than the normal plot operator and its result without any customization is significantly better than plot.
  • forest: offers highly improved tree drawing mechanism that than of just TikZ, should definetely be considered before drawing a tree with TikZ.
  • tikz-cd: provides support through predefined macros and default settings for drawing commutative diagrams.
  • prooftree: provides support for drawing prooftrees, the package is focused on math prooftrees used to teach math.
  • pgf-spectra: uses easy syntax to draw the spectrum of elements (currently 99 available)
  • bloques: provides set of macros to ease the drawing of block diagrams used in control theory (engineering).
  • circuitikz: used to draw electronic circuits.
  • tikzscale: provides some interface between tikzpictures and \includegraphics offering scaling methods for tikzpictures.

I have counted 65 contributions in the former link, the above cited are not the best nor special in any way, It's just the ones I've came across with.


Isolated contributions:

I've also found in user's @Qrrbrbirlbel (how do you say that?) 5 neet libraries (yep they're loaded with \usetikzlibrary), unfortunately without manuals and not available through CTAN (hopefully they'll get there) but can be downloaded in Qrrbrbirlbel's GitHub account, the below is a near copy paste of his "About me" profile text:

The node-families library has been developed in response to “Dependent node size” where the OP asks for automatic re-sizing of related nodes so that they have the same minimum size. Use the following keys to assign a node to a specific family of nodes that shall have the same dimensions. This works on a per-picture basis and uses the .aux file so you will need at least two compilations.

 - `Minimum Width=<family>`;
 - `Minimum Height=<family>`;
 - `Text Height=<family>`;
 - `Text Width=<family>`.

This library introduces path operators like the horizontal-vertical ones TikZ naturally has (|- and -|) but more advanced, like |-| and -|-. This answer and this one too contain more info on the library.

The paths.rectangle library provides two similar timers (the functions that place nodes along paths) for the rectangle path operator. Usually when doing \draw (0,0) rectangle node[pos=x]{A} (1,1) the node A will be placed in a position along the line connecting the two coordinates, with paths.rectangle, x can assume values greater than 1 (up to 2) which represent the actual rectangle path, not the line between the coordinates, as better explained in this answer.

This library allows shapes to be filled with image patterns, much useful to create images with textures. It's explained in this answer.

This one offers a way of positioning one node in respect with several others, providing also capability of making the node as large as the set of nodes it spans. Aside from that it has more positioning options than that of the original positioning library, since there is no manual the information has to be gathered from TeX.SX search engine (this link auto searches with the proper filters)

2
  • The link with all the contributions above is dead. Any idea where I would find the full list now? Nov 11, 2020 at 13:59
  • 1
    @ThorbjørnE.K.Christensen, it appears that I linked not a source, but a CTAN link hosted at ShareLaTeX, which merged into Overleaf, eventually killing my link. At the time I thought that was the file source, but now I see the actual source is CTAN: ctan.org/tex-archive/graphics/pgf/contrib Nov 12, 2020 at 12:39
9

Decoration libraries

Accessed by \usetikzlibrary{decorations.<name of decoration library>}

Description
As the name says, these libraries decorate a path. Sometimes the path is even substituted with a different path.

Every decoration library is stated below. Use Ctrl + F (Windows) to get to the library you need.


Path morphing decorations

Accessed by \usetikzlibrary{decorations.pathmorphing}

Description [from the TikZ manual]
A path morphing decoration "morphs" or "deforms" the to-be-decorated path. This means that what used to be a straight line might afterwards be a snaking curve and have bumps.

Example

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\def\y{0}
\newcommand\decorated[1]{
    \tikzset{decoration=#1}
    \draw[thin,red] (0,\y) to[bend left] (1,\y);
    \filldraw[decorate,fill=yellow!60,very thick] (0,\y) to[bend left] (1,\y)
        node[right,font=\ttfamily] {#1};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{lineto}
\decorated{straight zigzag}
\decorated{random steps}
\decorated{saw}
\decorated{zigzag}
% We are not able to use our command here :(
\tikzset{decoration=bent}
\draw[thin,red] (0,\y) -- (1,\y);
\filldraw[decorate,fill=yellow!60,very thick] (0,\y) -- (1,\y)
    node[right,font=\ttfamily] {bent};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
% %
\decorated{bumps}
\decorated{coil}
\decorated{curveto}
\decorated{snake}
\end{tikzpicture}
\end{document}

enter image description here


Path replacing decorations

Accessed by \usetikzlibrary{decorations.pathreplacing}

Description [from the TikZ manual]
This library defines decorations that replace the to-be-decorated path by another path. Unlike morphing decorations, the replaced path might be quite different, for instance a straight line might be replaced by a set of circles.

Example

  • Most decorations

    \documentclass[tikz,margin=1]{standalone}
    \usetikzlibrary{decorations.pathreplacing}
    \def\y{0}
    \newcommand\decorated[1]{
        \tikzset{decoration=#1}
        \draw[thin,red] (0,\y) to[bend left] (1,\y);
        \draw[decorate,very thick] (0,\y) to[bend left] (1,\y)
            node[right,font=\ttfamily] {#1};
        \let\auxy\y
        \pgfmathsetmacro\y{\auxy+1}
    }
    \begin{document}
    \begin{tikzpicture}[y=-1cm,x=3cm]
    \decorated{border}
    % We are not able to use our command here :(
    \tikzset{decoration=brace}
    \draw[thin,red] (0,\y) -- (1,\y);
    \draw[decorate,very thick] (0,\y) -- (1,\y)
        node[right,font=\ttfamily] {brace};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+3}
    % %
    \decorated{expanding waves}
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1.5}
    \decorated{ticks}
    \decorated{waves}
    \end{tikzpicture}
    \end{document}
    

    enter image description here

  • The special decoration: show path construction.

    % Source: The TikZ - PGF manual version 3.1.3, May 9 2019, page 636
    
    \documentclass[tikz,margin=1]{standalone}
    \usetikzlibrary{decorations.pathreplacing}
    \begin{document}
    \begin{tikzpicture}[
        >=stealth, 
        every node/.style={midway, sloped, font=\tiny},
        decoration={
            show path construction,
            moveto code={
                \fill [red] (\tikzinputsegmentfirst) circle (2pt)
                    node [fill=none, below] {moveto};},
            lineto code={
                \draw [blue,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
                    node [above] {lineto};},
            curveto code={
                \draw [green!75!black,->] (\tikzinputsegmentfirst) .. controls
                    (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
                    ..(\tikzinputsegmentlast) node [above] {curveto};},
            closepath code={
                \draw [orange,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
                    node [above] {closepath};}
            }]
    
    \draw [help lines] grid (3,2);
    \path [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1) -- cycle;
    \end{tikzpicture}
    \end{document}
    

    enter image description here


Arbitrary markings

Accessed by \usetikzlibrary{decorations.markings}

Description [from the TikZ manual]
A marking can be thought of a "little picture" or more precisely of "some scope contents" that is placed "on" a path at a certain position

Example

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\colorlet{darkgreen}{green!70!black}
\begin{tikzpicture}[>=stealth]
\path (0,1) node[right,inner sep=0pt,font=\ttfamily] {markings};
\draw[postaction=decorate,decoration={
        markings,
        mark=at position 0.5 with \arrow{>}
      }] (0,0) -- (3,0) node[right=1ex] {One marking only};
\draw[postaction=decorate,decoration={
        markings,
        mark=at position 1/3 with {
          \draw[red,thick] (-2pt,-2pt) -- (2pt,2pt);
          \draw[red,thick] (-2pt,2pt) -- (2pt,-2pt);
        },
        mark=at position 2/3 with {
          \draw[darkgreen,thick] (-2pt,0) -- (0,-2pt) -- (2pt,2pt);
        }
      }] (0,-1) -- (3,-1) node[right=1ex] {Two markings};
\draw[postaction=decorate,decoration={
        markings,
        mark=between positions 0 and 1 step 0.2 with {
          \filldraw[fill=yellow] 
            (-3pt,-3pt) -- (3pt,-3pt) -- (0,3pt) -- cycle;
          \draw (0,2pt) -- (0,-1pt);
          \fill (0,-2pt) circle (.5pt);
        }
      }] (0,-2) to[bend left] (3,-2) node[right=1ex] {Several markings};
\end{tikzpicture}
\end{document}

enter image description here


Foot prints markings

Accessed by \usetikzlibrary{decorations.footprints}

Description [from the TikZ manual]
The decorations of this library can be used to decorate a path with little footprints, as if someone had "walked" along the path.

Example

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.footprints}
\begin{document}
\begin{tikzpicture}[y=-1.5cm,x=3cm]
\path (0,0) node[right,inner sep=0pt,font=\ttfamily] {footprints};
\foreach \i [count=\j] in {gnome,human,bird,felis silvestris} {
    \tikzset{decoration={footprints,foot of=\i}}
    \draw[thin,red] (0,\j) to[bend left] (1,\j);
    \draw[decorate] (0,\j) to[bend left] (1,\j) node[right] {\i};
}
\end{tikzpicture}
\end{document}

enter image description here


Shape background markings

Accessed by \usetikzlibrary{decorations.shapes}

Description [from the TikZ manual]
N/A

Example

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.shapes}
\def\y{0}
\newcommand\decorated[1]{
    \tikzset{decoration=#1}
    \draw[thin,red] (0,\y) to[bend left] (1,\y);
    \draw[decorate] (0,\y) to[bend left] (1,\y)
        node[right,font=\ttfamily] {#1};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{crosses}
\decorated{triangles}
\decorated{shape backgrounds} % You can customize it. See more in the manual
\end{tikzpicture}
\end{document}

enter image description here


Text decorations

Accessed by \usetikzlibrary{decorations.text}

Description [from the TikZ manual]
The decoration in this library decorates the path with some text. This can be used to draw text that follows a curve.

Example

\documentclass[tikz,margin=2]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\draw[postaction=decorate,decoration=text along path,
      /pgf/decoration/text={Hello world}] 
    (0,0) to[bend left] (1,0) node[right=1ex,font=\ttfamily] {text along path};
% Source: The TikZ - PGF manual, version 3.1.3, 9 May 2019, page 652
\tikzset{
    decoration={
        text effects along path,
        text={Hello world}, 
        text align=center,
        text effects/.cd,
            character count=\i,
            characters={xslant=0.5, text along path, name=c-\i}
    }
}
\draw[postaction=decorate] (0,1) -- (1,3.5) 
    node[right=1ex,font=\ttfamily] {text effects along path};
\end{tikzpicture}
\end{document}

enter image description here


Fractal decorations

Accessed by \usetikzlibrary{decorations.fractals}

Description [from the TikZ manual]

The decorations of this library can be used to create fractal lines.

Example

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.fractals}
\def\y{0}
\newcommand\decorated[3][]{
    \tikzset{decoration=#2}
    \draw[ultra thin,red] (0,\y) -- (1,\y);
    \draw[#1] decorate {
                decorate { 
                  decorate { 
                    (0,\y) -- (1,\y)
                  }
                }
              };
    \path (1,\y) node[right=1ex,font=\ttfamily] {#2};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+#3}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{Koch curve type 1}{1.5}
\decorated{Koch curve type 2}{2}
\decorated{Koch snowflake}{1}
\decorated[ultra thick]{Cantor set}{0}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .