Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
\documentclass[a4paper,10pt]{article}
2
\usepackage{amssymb, amsmath}
3
\DeclareMathOperator{\arcsinh}{arcsinh}
4
\DeclareMathOperator{\arccosh}{arccosh}
5
\DeclareMathOperator{\arctanh}{arctanh}
6
\usepackage[utf8]{inputenc} % this is needed for umlauts
7
\usepackage[ngerman]{babel} % this is needed for umlauts
8
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
9
%layout
10
\usepackage[margin=2.5cm]{geometry}
11
\usepackage{parskip}
12
\usepackage{xcolor}
13
\usepackage{hyperref}
14
15
\pdfinfo{
16
/Author (StackExchange and GitHub authors)
17
/Title (TikZ Cheat Sheet)
18
/CreationDate (D:20120221095400)
19
/Subject (TikZ)
20
/Keywords (TikZ)
21
}
22
23
\newcommand{\myCode}[1]{\colorbox{gray!30}{#1}}
24
25
\begin{document}
26
27
\title{TikZ cheat sheet}
28
\author{StackExchange and GitHub authors}
29
\date{\today}
30
31
\section*{Command Templates}
32
\begin{itemize}
33
\item Basic path: \myCode{\textbackslash drawing-command [options] path-specification;}
34
\item Path specification: \myCode{(coordinate) path-component (coordinate);}
35
\item Path Reusage \myCode{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. \\
36
\myCode{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.
37
\end{itemize}
38
39
\section*{Basic Drawing Commands}
40
\begin{itemize}
41
\item \myCode{\textbackslash path}: constructs a path
42
\end{itemize}
43
44
All following commands are in fact short forms for \myCode{\textbackslash path} with one option or two:
45
\begin{itemize}
46
\item \myCode{\textbackslash draw}: constructs and draws ("strokes") a path
47
\item \myCode{\textbackslash fill}: constructs and fills a path
48
\item \myCode{\textbackslash filldraw}: constructs, fills, and draws a path (in that order)
49
\item \myCode{\textbackslash shade}: constructs and shades a path
50
\item \myCode{\textbackslash shadedraw}: constructs, shades, and draws a path (in that order)
51
\item \myCode{\textbackslash coordinate}: label a coordinate
52
\item \myCode{\textbackslash node}: constructs a node
53
\end{itemize}
54
55
56
\section*{Coordinate Specifications}
57
\begin{itemize}
58
\item \myCode{(<x>,<y>)}: specifies the coordinate as a multiple of the current x- and y-vector (default: 1cm right and 1cm upwards)
59
\item \myCode{(<$\theta$>:<r>)} specifies a coordinate in polar form with \myCode{r} being the vector length and \myCode{$\theta$} being the angle in degrees
60
\item \myCode{+<coordinate specification>}: specifies a coordinate relative to the previous position but does not save the current position
61
\item \myCode{++<coordinate specification>}: specifies a coordinate relative to the previous position
62
\end{itemize}
63
64
\subsection*{Notes}
65
\begin{enumerate}
66
\item Lengths can be with or without unit. If with a unit they are taken literally, if without they are multiples of the current `x` or `y` vector (as appropriate).
67
\item 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.
68
\item 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).
69
\end{enumerate}
70
71
72
\section*{Path Specifications}
73
\begin{itemize}
74
\item \myCode{(coordinate) (coordinate)}: moves the "current point" from the first coordinate to the second
75
\item \myCode{(coordinate) -- (coordinate)}: draws a line from the first coordinate to the second
76
\item \myCode{(coordinate) .. controls (control) and (control) .. (coordinate)}: draws a cubic bezier from the first coordinate to the second with the specified control points
77
\item \myCode{(coordinate) to[options] (coordinate)}: draws a `to path` from the first coordinate to the second; \myCode{to path}s can be extremely complicated
78
\item \myCode{(coordinate) rectangle (coordinate)}: draws a rectangle with the coordinates as opposite corners
79
\item \myCode{(coordinate) circle[options]}: draws a circle centred at the coordinate
80
\item \myCode{(coordinate) arc[options]}: draws an arc starting at the coordinate
81
\item \myCode{(coordinate) node[options] \{text\}}: adds a node at the coordinate
82
\item \myCode{(coordinate) coordinate}: adds a coordinate label at the given coordinate
83
\end{itemize}
84
85
\section*{Basic Options}
86
\begin{itemize}
87
\item \myCode{draw[=<colour specification>]}<sup>1</sup>: draw the current path (with the given colour)
88
\item \myCode{fill[=<colour specification>]}<sup>1</sup>: fill the current path (with the given colour)
89
\item \myCode{<colour specification>}: set the colour for draw, fill, text (without explicitly enforcing those actions)
90
\item \myCode{line width=<dimen>}: sets the line width
91
\item \myCode{thin, thick, ultra thick} \href{http://martin-thoma.com/sizes-in-latex/}{etc}: presets for the line width
92
\end{itemize}
93
94
[1] The brackets indicate an optional part and must not be type in the code. I.e. use \myCode{draw=red} and not \myCode{draw[=red]}.
95
\end{document}
96
97