Many times, when I'm coding a tikz-picture, I don't remember the command syntax or the name of one option, and I have to look in pgf-manual is not very short. Does anybody has a summary of Tikz commands fit to one or two pages?
-
3Google search for tikz cheat sheet is not of much help. – mythealias Nov 29 '12 at 07:55
-
10The problem is that it would not be an A4 paper page, more likely an A-1 paper size... That is not so helpful. However, it would be fun to see! – nickpapior Nov 29 '12 at 07:55
-
2I've seen a shortlist in Texmaker (You know in those listings on the left hand side, where you can also pick commonly used symbols and stuff like that) – long tom Dec 04 '12 at 21:16
3 Answers
Command Templates
Basic path:
\drawing-command [options] path-specification;Path specification:
(coordinate) path-component (coordinate);Path Reusage
postaction={<basic drawing commands> or <decorate>}When this option is given to any basic drawing commands below, the path is not immediately discarded and reused after the initial drawing command is finished.preaction={<basic drawing commands> or <decorate>}When this option is given to any basic drawing commands below, the path is used once before the initial drawing command is executed.
Basic Drawing Commands:
\path: constructs a path
All following commands are in fact short forms for \path with one option or two:
\draw: constructs and draws ("strokes") a path\fill: constructs and fills a path\filldraw: constructs, fills, and draws a path (in that order)\shade: constructs and shades a path\shadedraw: constructs, shades, and draws a path (in that order)\coordinate: label a coordinate\node[<options>] at (<coordinate>) (<name>) {<text>}: constructs a node\path (nodeName1) edge [options->] (nodeName2);: an edge
Coordinate Specifications:
(<x>,<y>): specifies the coordinate as a multiple of the current x- and y-vector (default: 1cm right and 1cm upwards)(<θ>:<r>)specifies a coordinate in polar form withrbeing the vector length andθbeing the angle in degrees+<coordinate specification>: specifies a coordinate relative to the previous position but does not save the current position++<coordinate specification>: specifies a coordinate relative to the previous position
Notes
Lengths can be with or without unit. If with a unit they are taken literally, if without they are multiples of the current
xoryvector (as appropriate).Relative coordinates are with respect to the last saved position. Unless specified otherwise, the above all save their resultant position as the last saved position.
When a relative coordinate is used in a bezier curve specification the behaviour is slightly different. The second control point is taken relative to the final position of the curve, and the final point is taken relative to the initial one (or last saved position).
Path Specifications:
(coordinate) (coordinate): moves the "current point" from the first coordinate to the second(coordinate) -- (coordinate): draws a line from the first coordinate to the second(coordinate) .. controls (control) and (control) .. (coordinate): draws a cubic bezier from the first coordinate to the second with the specified control points(coordinate) to[options] (coordinate): draws ato pathfrom the first coordinate to the second;to paths can be extremely complicated(coordinate) rectangle (coordinate): draws a rectangle with the coordinates as opposite corners(coordinate) circle[options]: draws a circle centred at the coordinate(coordinate) arc[options]: draws an arc starting at the coordinate(coordinate) node[options] {text}: adds a node at the coordinate(coordinate) coordinate: adds a coordinate label at the given coordinate
Basic Options
draw[=<colour specification>]1: draw the current path (with the given colour)fill[=<colour specification>]1: fill the current path (with the given colour)<colour specification>: set the colour for draw, fill, text (without explicitly enforcing those actions)line width=<dimen>: sets the line widththin,thick,ultra thicketc: presets for the line width
1 The brackets indicate an optional part and must not be type in the code. I.e. use draw=red and not draw[=red].
- 157,807
- 153,724
- 43
- 389
- 751
-
21I've run out of steam for the moment. This is CW because I think it is one of those things where if lots of people contribute a little bit then it'll be a doable project but if one person tries to do it all then they'll never finish it. – Andrew Stacey Nov 29 '12 at 09:05
-
1The comments area here should be used for temporary discussion of what should or should not go into this answer. All comments are liable to be deleted once they are resolved as the eventual aim of a CW answer like this is that all useful information be folded into it. – Andrew Stacey Nov 29 '12 at 10:24
-
I added a small section about coordinate specifications. Hope this is within the spirit of the answer. – Alexander Nov 29 '12 at 12:31
-
@Alexander I was pondering your edits as you edited again. The distinction between dimensioned and dimensionless coordinates is a "meta distinction" as it holds for just about anywhere a number is used in TikZ so I think that should be a note at the start of the coordinate section. I was also pondering the distinction between the "most recent coordinate on a path" and the "last saved coordinate" (as used for relative positioning). The aim of this is to be a cheat-sheet so I wouldn't go for a lengthy explanation, but I think that "previous position" is ambiguous as it could mean either. – Andrew Stacey Nov 29 '12 at 12:32
-
@Alexander Oh, and just to say: yes that is completely within the spirit of the answer. Thank you for contributing. – Andrew Stacey Nov 29 '12 at 12:33
-
-
@Seamus Good point. What I meant was that
colourstands for an explicit colour specification, not forcolor=colour. That should be made clearer. – Andrew Stacey Nov 29 '12 at 12:55 -
I'm not a TikZ expert, but I know that there exists
(cycle)coordinate specification that is very useful, and should be added. – yo' Nov 29 '12 at 22:53 -
3How deep should this go? Or: The OP says “I don't remember the command syntax or the name of one option“. Oftentimes I feel the same: I know that there exist (too) many options, but which are they and what do they do? For example: I know of
arcbut maybe notstart angle,end angleanddelta angle. There are 21 styles for thecurve toto path. We could fill an answer solely with nodes, another one with shapes, some libraries (decorations!) are big enough for an answer alone … – Qrrbrbirlbel Nov 30 '12 at 01:53 -
@Qrrbrbirlbel That's an extremely important point. At some stage one has to say "Read the manual for more" (so linking stuff here to the manual would be an extremely useful task). My gut feeling is that the
angleoptions forarcwould be useful, but listing all the decorations, all the available shapes not so. – Andrew Stacey Nov 30 '12 at 09:55 -
I've started a TikZ cheat sheet. We could try to make one document with the most important commands with latex: https://github.com/MartinThoma/LaTeX-examples/tree/master/cheat-sheets/Tikz – Martin Thoma Dec 05 '12 at 21:15
-
@moose Great! One big question is what to put in it. You could take the list I generated below and go through that to identify the more important commands/styles. – Andrew Stacey Dec 05 '12 at 21:29
-
-
-
I started a meta about it, @percusse, http://meta.tex.stackexchange.com/questions/6366/what-is-summary-of-tikz-commands-about. – Fernando César Oct 20 '15 at 11:33
The lazy mathematician in me decided to come up with another approach. I ran the following script on the documentation:
(for f in pgfmanual-en-tikz-{design,scopes,coordinates,paths,actions,shapes,graphs,matrices,trees,plots,transparency,decorations,transformations}.tex; do
cat $f
done) | perl -ne '
if (/(\\(begin|end)\{(coordinatesystem|keylist|package|predefinednode|command|key|stylekey|pathoperation)\})|\\(sub)*section|\\catcode/) {
print;
$c = ($_ =~ tr/{/{/);
$c -= ($_ =~ tr/}/}/);
} else {
if ($c > 0) {
print;
$c += ($_ =~ tr/{/{/);
$c -= ($_ =~ tr/}/}/);
};
};
' | xclip
Then pasted the result into the following template:
\documentclass[a4paper]{ltxdoc}
\usepackage[scale=.9]{geometry}
\usepackage{tikz}
% The location of this will depend on where you put the sources of the pgfmanual
\input{../../../local/share/pgf/doc/generic/pgf/macros/pgfmanual-en-macros}
\begin{document}
%%%% <--- pasted text goes here
\end{document}
Then removed some stuff that had been included by accident (search for codeexample and remove all such environments - they get included due to the \catcode switches.), and added a missing closing brace.
When I originally ran this in 2012, it produced a 21-page document listing all (as far as I can tell) of the commands and keys in the TikZ segment of the manual. I've re-run the process in 2022 and it is now a 27-page document.
- 2012 version: https://docs.mathforge.org/tikzcheatsheet-2012.pdf
- 2022 version, PGF version 3.1.8: https://docs.mathforge.org/tikzcheatsheet-2022.pdf
- 153,724
- 43
- 389
- 751
-
6+1 for laziness. Also, a lovely example on why plain-text documentation is awesome; I would never have thought of simply extracting all of the
tikzcommands. Bravo! (I know this is a six month old post, but come on --- this is awesome.) – Sean Allred Jun 16 '13 at 02:24 -
Thank you for this awesome answer! The best thing is, that this can be adapted to future versions of the documentation and will be always complete. I started a bounty to rewards your amazing effort. – Henri Menke Oct 06 '13 at 12:33
-
Is there the simplest example of TikZ application in which all TikZ macros and its key-values are used? :-) – kiss my armpit Oct 06 '13 at 14:32
-
1@HenriMenke Thanks for the bounty - always nice when an answer is appreciated widely. PGFTricks No idea! Why don't you try to write one? – Andrew Stacey Oct 08 '13 at 08:28
-
I just used this method on the new 3.0.0 manual and found out, that in the TeX file one has to do an additional
\let\pgfmanualpdflabel=\@gobbleand remove all text containing\pgfmanualpdflabelin the script output. – Henri Menke Aug 05 '14 at 10:34 -
1@LoopSpace Can you update the link to the summary PDF please? (if the file still available) – Cfun Jul 03 '16 at 16:28
-
23
-
-
@Atcold I will have to dig around in my archive, but will see what I can find. – Andrew Stacey Jul 18 '22 at 19:47
-
Sweet, thanks for getting back to me on Twitter and here. Looking forward to reading your cheat sheet! – Atcold Jul 20 '22 at 04:57
-
1@Atcold I've posted an updated link to the original document, I'm re-running the script now to see if it works with the latest documentation. – Andrew Stacey Jul 27 '22 at 20:01
-
1@Atcold Seemed to work okay on the most recent version so I've added that as well. – Andrew Stacey Jul 27 '22 at 20:14
VisualTikZ was recently uploaded to CTAN. It consists in more than 150 pages full of examples for TikZ commands and options. For every command or option a little figure is shown. Just as example, here you have some pages:
- 136,588
-
Just to note, there is (now) an English version of this document as well as a French one. – N. Virgo May 19 '20 at 12:39
-


