%!TEX root = tzplot-doc.tex %\begin{document} %%%================================== \part{Getting Started} %%%================================== \label{p:gettingstarted} %%================================== \chapter{An Intuitive Introduction I: Basics} \label{ci:introI} All drawing macros provided in this package work within |tikzpicture| environment, just like any other \Tikz\ commands. %%------------------------------------------------------------ \section{Lines: Basics: \protect\cmd{\tzline(0,0)(3,1)}} \label{si:lines} To draw a line from $(0,0)$ to $(3,1)$, just do |\tzline(0,0)(3,1)|. \begin{tzcode}{.3} % \tzline \begin{tikzpicture} \tzhelplines(4,2) \tzline(0,0)(3,1) \end{tikzpicture} \end{tzcode} You can use \Tikz\ options to change the style of a line. \begin{tzcode}{.3} % \tzline: change line style \begin{tikzpicture} \tzhelplines(4,3) \tzline(0,0)(3,1) \tzline[dashed](0,1)(3,2) \tzline[->,blue,thick](0,3)(4,1) \end{tikzpicture} \end{tzcode} \begin{tztikz} \tzline[dashed](0,1)(3,2) % works like: \draw [dashed] (0,1) -- (3,2); \end{tztikz} %%------------------------------------------------------------ \section{Dots: Basics} \label{si:dots} \subsection{A circle dot: \protect\cmd{\tzcdot(0,0)}} \label{ssi:tzcdot} \icmd{\tzcdot}|(0,0)| prints a `circle dot' \tikz \tzcdot(0,0);, with the \xem{radius} |1.2pt| by default, at the point |(0,0)|. The starred version \icmd{\tzcdot*} prints a filled dot \tikz \tzcdot*(0,0);. \begin{tzcode}{.3} % \tzcdot: circle dot \begin{tikzpicture} \tzhelplines(4,3) \tzcdot(0,0) \tzcdot*(3,1) \tzcdot [red] (0,1)(3pt) % radius=3pt \tzcdot*[green](3,2)(3pt) % radius=3pt \end{tikzpicture} \end{tzcode} You can change of the size of a dot by specifying the \xem{radius} of the circle, like, for example, |\tzcdot(0,0)(3pt)|. \begin{tztikz} \tzcdot*[green](3,2)(3pt) % is an abbreviation for: \draw [fill,green] (3,2) circle (3pt); \end{tztikz} \begin{tzcode}{.3} % \tzcdot \begin{tikzpicture} \tzhelplines(4,3) \tzcdot(0,0) \tzcdot*(3,1) \tzcdot[red](0,1)(2mm) % radius=2mm \tzcdot*[green](3,2)(3pt) % radius=3pt \tzline(0,0)(3,1) \tzline(0,1)(3,2) \end{tikzpicture} \end{tzcode} \subsection{A circle node dot: \protect\cmd{\tzdot(0,0)}} \label{ssi:tzdot} \icmd{\tzdot} draws a `circle node dot' at a specified coordinate. The starred version \icmd{\tzdot*} prints a filled dot. The default size (\xem{diameter} or |minimum size|) is |2.4pt|. \begin{tzcode}{.3} % \tzdot: node dot \begin{tikzpicture} \tzhelplines(4,3) \tzdot(0,0) \tzdot*(3,1) \tzdot[red](0,1)(4mm) % minimum size=4mm \tzdot*[green](3,2)(6pt) % minimum size=6pt \tzline(0,0)(3,1) \tzline(0,1)(3,2) \end{tikzpicture} \end{tzcode} The size (\xem{diameter} or |minimum size|) of a node dot can be changed by the second (or the last) parenthesis option, like |(6pt)|. \begin{tzcode}{.3} % \tzcdot \begin{tikzpicture} \tzhelplines(4,3) \tzdot(0,0)(5pt) \tzdot*(3,1) \tzdot[red](0,1)(4mm) \tzdot*[green](3,2)(6pt) \tzline(0,0)(3,1) \tzline(0,1)(3,2) \end{tikzpicture} \end{tzcode} \begin{tztikz} \tzdot[green](0,0)(6pt) % works like: \draw [green] (0,0) node [tzdot,minimum size=6pt] {}; % tzdot style is predefined \end{tztikz} \subsection{Difference between \protect\cmd{\tzcdot} and \protect\cmd{\tzdot}} \label{ssi:difference} A `circle dot' drawn by |\tzcdot| is affected by |xscale| or |yscale| in \Tikz, but a `circle node dot' drawn by |\tzdot| is not. Note also that |\tzcdot| controls the \xem{radius} of a circle dot (following \Tikz\ practice), while |\tzdot| controls the \xem{diameter} of a circle node dot. \begin{tzcode}{.3} % \tzdot: size not changed by scaling \begin{tikzpicture}[xscale=.5,yscale=1.1] %% \tzhelplines(4,3) \tzdot(0,0) \tzdot*(3,1) \tzdot[red](0,1)(4mm) \tzdot*[green](3,2)(6pt) \tzline(0,0)(3,1) \tzline(0,1)(3,2) \end{tikzpicture} \end{tzcode} \remark The circle dots drawn by |\tzcdot| are affected by \Tikz\ |scale| factors. It gets bigger or smaller by |scale|. Let us see what happens to circle dots, especially when |xscale| and |yscale| are not symmetric. \begin{tzcode}{.3} % \tzcdot: distorted \begin{tikzpicture}[xscale=.5,yscale=1.1] %% \tzhelplines(4,3) \tzcdot(0,0) \tzcdot*(3,1) \tzcdot[red](0,1)(2mm) \tzcdot*[green](3,2)(3pt) \tzline(0,0)(3,1) \tzline(0,1)(3,2) \end{tikzpicture} \end{tzcode} %%------------------------------------------------------------ \section{Coordinates: Basics: \protect\cmd{\tzcoor(0,0)(A)}} \label{si:coordinates} To define a coordinate, use \icmd{\tzcoor} with a coordinate followed by its name in parentheses. \begin{tztikz} \tzcoor(0,0)(A) % works like: \path (0,0) coordinate (A); % or \coordinate (A) at (0,0); \end{tztikz} \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tzcoor(0,0)(A) \tzcoor(60:3cm)(B) \tzline[->](A)(B) \tzdot(A)(5pt) \tzcoor(0,1)(C) \tzcoor(4,2)(D) \tzline[dashed](C)(D) \end{tikzpicture} \end{tzcode} The starred version \icmd{\tzcoor*} prints a filled node dot at a specified coordinate. \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tzcoor(0,0)(A) \tzcoor(60:3cm)(B) \tzline[->](A)(B) \tzdot(A)(5pt) \tzcoor*(0,1)(C) \tzcoor*[fill=none](4,2)(D) \tzline[dashed](C)(D) \end{tikzpicture} \end{tzcode} %%------------------------------------------------------------ \section{Curves: Basics} \label{si:curves} \subsection{\protect\cmd{\tzto(0,0)(4,2)}} \label{ssi:tzto} \icmd{\tzto} connects two points with a line or a curve using the |to| operation of \Tikz. \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tzto(0,0)(4,2) \tzto[bend right,dashed](0,1)(3,2) \tzto[out=90,in=-90,->,blue](0,2)(4,1) \end{tikzpicture} \end{tzcode} \begin{tztikz} \tzto[bend right](0,1)(3,2) % works like: \draw [bend right] (0,1) to (3,2); \end{tztikz} \subsection{\protect\cmd{\tzbezier}} \label{ssi:tzbezier} \icmd{\tzbezier} draws a B\'{e}zier curve with \xem{one or two} control points from the first coordinate to the last coordinate. The style |tzshowcontrols| predefined in the package reveals the control point(s). \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tzbezier[blue,thick](0,0)(2,0)(4,2) \tzbezier[->,tzshowcontrols](0,2)(1,3)(3,0)(4,1) \end{tikzpicture} \end{tzcode} \begin{tztikz} \tzbezier[blue](0,0)(2,0)(4,2) % works like: \draw [blue] (0,0) .. controls (2,0) .. (4,2); \tzbezier(0,2)(1,3)(3,0)(4,1) % works like: \draw (0,2) .. controls (1,3) and (3,0) .. (4,1); \end{tztikz} \subsection{\protect\cmd{\tzparabola}} \label{ssi:tzparabola} \icmd{\tzparabola} draws a parabola controlled by several options of \Tikz's |parabola| operation. The macro \icmd{\tzparabola} accepts \xem{two or three} coordinate arguments to draw a parabola and the parabola bends at the second coordinate if it exists. \begin{tztikz} \tzparabola(0,0)(2,4) % works like: \draw (0,0) parabola (2,4); \tzparabola(2,0)(3,3)(4,1) % works like: \draw (2,0) parabola bend (3,3) (4,1); \end{tztikz} \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,4) \tzparabola(0,0)(2,4) \tzparabola[bend at end,dashed](0,0)(2,4) \tzparabola(2,0)(3,3)(4,1) \tzparabola[bend pos=.33,dashed](1,0)(4,4) \end{tikzpicture} \end{tzcode} %%------------------------------------------------------------ \section{Adding text: Nodes and placement} \label{si:addingtext} \subsection{\protect\cmd{\tznode(3,1)\{text\}[right]}} \label{ssi:tznode} With \icmd{\tznode}|(){}[]|, you can put some text at a specified position. The starred version \icmd{\tznode*} draws the node perimeter, which is a |rectangle| by default. \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tznode(0,0){A} \tznode*(1,1){text} \tzdot*(2,2) \tznode(2,2){Text}[above right,blue] \end{tikzpicture} \end{tzcode} \begin{tztikz} \tznode(0,0){A} % works like: \node at (0,0) {A}; \tznode(2,2){Text}[above right,blue] % works like: \draw (2,2) node [above right,blue] {Text}; \end{tztikz} \subsection{Review: Main nodes and label nodes in \Tikz} \label{ssi:mainnodes} In \Tikz, there are two kinds of nodes: main nodes and label nodes. When a \iisw{main node} with text in it is placed at a specific point, its \iisw{label node} with a label in it is optionally placed in the \xem{direction} of a designated \xem{angle} relative to the main node. \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) \tznode*(2,1){main node} [scale=2,label={[draw,red]90:label node}] \tznode*(3,3){A}[label={above:a},label={0:r}] \end{tikzpicture} \end{tzcode} Instead of angles, you can use the corresponding placement words. In \Tikz, for example, |above| is replaced by |90| degree, |right| by |0| degree, |below left| by |-135| degree, and the like. Note that the angle expression \xem{cannot} be used for placing main nodes. \xmedskip1 \remark \begin{itemize} \item In this package, macros related to `dots' or `coordinates' (like |\tzcdot|, |tzdot|, and |\tzcoor|) can optionally have `label nodes,' while macros related to `lines' and `curves' (like |\tzline|, |\tzto|, |\tzbezier| and |\tzparabola|) optionally have `main nodes' or `text nodes.' \item There is one exception: |\tzshoworigin|. |\tzshoworigin| can have a label, but its location is controlled by positional words such as |below left| but not by ||. (See Section \ref{s:tzshoworigin} on page \pageref{s:tzshoworigin} for more details.) \end{itemize} \subsection{Abbreviations of \Tikz\ basic placement option styles: \texttt{a}, \texttt{r}, \texttt{ar}, \texttt{bl}, etc.} \label{ssi:abbreviations} You can use \isw{abbreviations} (or aliases) |a| for |above|, |c| for |centered|, |r| for |right|, |bl| for |below left|, and so on to place \iisw{main node}\xem{s}. (Again, you \xem{cannot} use angels to place main nodes.) \begin{tzcode}{.3} \begin{tikzpicture}[font=\ttfamily,text=blue] \tzhelplines[thick](2,2) \tznode(1,1){centered}[draw] % default: centered \tznode(1,2){a} [a] \tznode(1,0){b} [b] \tznode(0,1){l} [l] \tznode(2,1){r} [r] \tznode(0,2){al}[al] \tznode(2,2){ar}[ar] \tznode(0,0){bl}[bl] \tznode(2,0){br}[br] \end{tikzpicture} \end{tzcode} %%------------------------------------------------------------ \section{Labeling dots and coordinates} \label{si:labelingdots} \subsection{\protect\cmd{\tzdot}, \protect\cmd{\tzcdot}} \label{ssi:labeling:tzdot} To add a label to a dot generated by |\tzdot| or |\tzcdot|, you should specify, \xem{right after a coordinate}, |{