1.1 Syntax

1.1.1 The environment

A tikz image lives in the following environment. Note that a semi-colon is required to mark the end of a line of codes. Therefore, one line of codes in the tikz environment can spread over multiple physical lines as long as there is no semi-colon in between.

\begin{figure}
\begin{tikzpicture}
code line 1;
code line 2 is
spreaded through two lines;
\end{tikzpicture}
\caption{}
\end{figure}

1.1.2 Functions and constants

Below is a list of mathematical functions and constants. Use braces to enclose the combination of functions. For example, (\(x\), \(e^{-x}\sin x\)) should be typed as (\x, {e^(-\x) * sin(\x r)}).

Functions and Constants Tikz Syntax Comments
\(\pi\) pi
\(e\) e
\(\sin x\) sin(\x r) \x in radians
\(\sin x\) sin(\x) \x in degrees
\(\ln x\) ln(\x)
\(\log_2 x\) log2(\x)
\(e^x\) exp(\x) or e^\x
\(x^2\) pow(\x, 2) or \x^2
\(\sqrt x\) sqrt(\x)
\(x!\) factorial(\x)