diff options
Diffstat (limited to 'graphics/pgf/contrib')
-rw-r--r-- | graphics/pgf/contrib/tzplot/README.txt | 26 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc-A-v1.0.tex | 128 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc-B-v1.0.tex | 1943 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc-C-v1.0.tex | 3981 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc-D-v1.0.tex | 1792 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc.pdf | bin | 0 -> 808794 bytes | |||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-doc.tex | 375 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot-oblivoirpartstyle.tex | 38 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot.ist | 16 | ||||
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot.sty | 4590 |
10 files changed, 12889 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/tzplot/README.txt b/graphics/pgf/contrib/tzplot/README.txt new file mode 100644 index 0000000000..61f9ca77dc --- /dev/null +++ b/graphics/pgf/contrib/tzplot/README.txt @@ -0,0 +1,26 @@ +tzplot.sty: Plot Graphs with TikZ Abbreviations +=============================================== + +Author: In-Sung Cho + +Introduction: + +This is a LaTeX package that provides TikZ based macros to make it easy to draw graphs. +The macros provided in the tzplot package are just abbreviations for TikZ codes, which can be complicated, but using the package, hopefully, makes drawing easier, especially when drawing repeatedly. The macros were chosen and developed with an emphasis on drawing graphs in economics. + +Dependencies: + +The package tzplot depends on the packages tikz, xparse, and expl3. + +License: + +This work may be distributed and/or modified +under the conditions of the LaTeX Project Public License, +either version 1.3c of this license or any later version. +The latest version of this license is in +http://www.latex-project.org/lppl.txt. + +Contacts: + +Please report any errors or suggestions to the author, +In-Sung Cho at <ischo at ktug.org>.
\ No newline at end of file diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc-A-v1.0.tex b/graphics/pgf/contrib/tzplot/tzplot-doc-A-v1.0.tex new file mode 100644 index 0000000000..67d2e2e2aa --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc-A-v1.0.tex @@ -0,0 +1,128 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%================= +\part{Getting Ready} +%%%================= +\label{p:intro} + +%%================================== +\chapter{Introduction} + +\section{About \texttt{tzplot.sty}} + +The |tzplot| package is just a collection of macros based on \TikZ\ to save you time in typing \Tikz\ code. + +In |pstricks|, a line connecting two points |(A)| and |(B)| is drawn by |\psline(A)(B)|. +With the package |tzplot|, you can do it by |\tzline(A)(B)|. + +\begin{tztikz}{} +\tzline[blue](A)(B){my line}[right] % is an abbreviation of: + \draw [blue] (A) -- (B) node [right] {my line}; +\end{tztikz} + +Some macros in this package represent one or a few lines of code, but some represent dozens of lines of \Tikz\ code. + +All of the drawing macros of |tzplot| are prefixed by |\tz|. Of course, it means \Tikz. +The syntax of the |tzplot| macros comes from |tikz| and |pstricks|. +However, the input mode is more like |pstricks|. + +To use the |tzplot| package you have to load the package in the preamble of your document as follows. + +\begin{verbatim} + \usepackage{tzplot} +\end{verbatim} + +The package depends on the packages |tikz|, |xpars|, and |expl3|. +And it uses the following \Tikz\ libraries. +\begin{verbatim} + calc,backgrounds,positioning,intersections,arrows,shapes,patterns,plotmarks, + decorations.pathreplacing,calligraphy + +\end{verbatim} + +This package sets the basic arrow style to |stealth|. +If you don't like this, as an alternative, you can set the style like |\tikzset{>=to}| after the |tzplot| package is loaded. + +This package was originally motivated by drawing graphs in economics. +Therefore, the macros in this package have been selected and developed for drawing graphs efficiently in economics. However, this package will do a good job of drawing basic graphics in any fields. + +Finally, note that this is far from a \Tikz\ tutorial. +To make good use of this package, you need to familiarize yourself with \Tikz. + +\section{Preoccupied style names} +\label{s:abbreviations} + +This package does not provide any environment. +Since all the drawing macros, prefixed |\tz|, are just abbreviations of \Tikz\ code, +you can use the macros in the |tikzpicture| environment together with any \Tikz\ commands. + +However, there are some preoccupied style names that you should not overwrite. +Those are as follows: + +\begin{verbatim} + tzdot tzmark tzdotted + tzdashed tzhelplines tznode + tzshorten tzextend tzshowcontrols +\end{verbatim} + +This package also predefined aliases of \Tikz's basic placement options as follows: + +\begin{tzsty}{} +% preoccupied (alias) styles +\tikzset{% + a/.style={above=#1}, + b/.style={below=#1}, + c/.style={centered=#1}, + l/.style={left=#1}, + r/.style={right=#1}, + al/.style={above left=#1}, + ar/.style={above right=#1}, + bl/.style={below left=#1}, + br/.style={below right=#1}, +} +\end{tzsty} + +The |tzplot| package also defines layers as follows: + +\begin{tzsty}{} +\pgfdeclarelayer{background} +\pgfdeclarelayer{behind} +\pgfdeclarelayer{above} +\pgfdeclarelayer{foreground} + +\pgfsetlayers{background,behind,main,above,foreground} +\end{tzsty} + +Therefore, you can select the graphic layers in sequence: |background|, |behind|, |main|, |above|, and |foreground|. +For example, you can change the layer of a tangent line from |behind| (default) to |main| as follows: + +\begin{tzcode}[listing only]{1} +\begin{tikzpicture} +\tzaxes(10,10) + <tzplot macros> + <tikz macros> +\begin{pgfonlayer}{main} +\tztangentat{curve}{5}[1:8] +\end{pgfonlayer} +\end{tikzpicture} +\end{tzcode} + +\section{How to read this document} + +In drawing graphs, too many factors are involved: line style, color, fill, label, positioning, shift, and so on. +Almost all macros of this package have many arguments that control these factors. +Some are mandatory and some are optional. +Optional arguments are hidden when not used. + +The document has three essential parts: Part II, Part III, and Part IV. +Part II introduces essential macros with only frequently used options. +There are many options hidden in the macros introduces in Part II. +Some macros are not introduced in Part II. +Part III and IV describe all the features of all macros. + +You must get started with Part II. +Part II is sufficient for drawing needs in most cases. + +Unless you are an experienced user of \Tikz, it is recommended to move on to Part III and Part IV once you become familiar with Part II. In the meantime, use Part III and Part IV for reference only. Use the list of contents and the index efficiently to find macros you need. + diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc-B-v1.0.tex b/graphics/pgf/contrib/tzplot/tzplot-doc-B-v1.0.tex new file mode 100644 index 0000000000..f3253e5799 --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc-B-v1.0.tex @@ -0,0 +1,1943 @@ +%!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\ command. + +%%------------------------------------------------------------ +\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] (0,0) 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 node circle dot: \protect\cmd{\tzdot(0,0)}} +\label{ssi:tzdot} + +\icmd{\tzdot} draws a `node circle 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 `node circle 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 node circle 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|. 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. + +\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 bezier curve with one or two control points. +The style |tzshowcontrols|, which is 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. + +\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} + +\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} + + + + + +%%------------------------------------------------------------ +\section{Adding text: Nodes and placement} +\label{si:addingtext} + +\subsection{\protect\cmd{\tznode(3,1)\{text\}[right]}} +\label{ssi:tznode} + +With \icmd{\tznode}|{<text>}[<node opt>]| 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} + +The angles for label nodes can be replaced by the corresponding placement words. For example, the angle |90| degree for a label node can be replaced by |above|, |0| by |right|, |-135| by |below left|, and the like. The angle expression \xem{cannot} be used for placing a main node. + +\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 |<angle>|. +(See Section \ref{s:tzshoworigin} on page \pageref{s:tzshoworigin} for more details.) +\end{itemize} + +\subsection{Abbreviations of \Tikz\ basic placement options: \texttt{a}, \texttt{b}, \texttt{l}, \texttt{r}, \texttt{ar}, \texttt{bl}, etc.} +\label{ssi:abbreviations} + +You can use \isw{abbreviations} |a| for |above|, |r| for |right|, |bl| for |below left|, and so on to place \iisw{main node}\xem{s}. + +\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} + +\warning The abbreviations of \Tikz\ basic placement options \xem{cannot} be used to place \xem{labels}. +To place labels, use \xem{angles} or the unabridged placement options of \Tikz such as |above| and |below left|. + +%%------------------------------------------------------------ +\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}, |{<label>}| followed by |[<angle>]| (|90| degree or |above| by default in \Tikz). + +\textsc{Remember} that the order of the arguments is |(<coor>){<label>}[<angle>]|. +To change the size of a dot, you need to specify |(<dimension>)| after all the other arguments. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdot*(1,1){A} % default: 90 or above +\tzdot(2,1){B}[0](4pt) +\tzcdot*(1,2){C}[180](2pt) +\tzcdot(3,2){D}[45] +\tzdot*(4,0){E}[[red,draw]180](4pt) +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzcdot*(1,2){C}[180](2pt) % works like: + \draw[fill] (1,1) circle (2pt) node [label={180:C}] {}; +\end{tztikz} + +\subsection{\protect\cmd{\tzcoor}} +\label{ssi:tzcoor} + +\icmd{\tzcoor} can add a label to a coordinate. Just append the optional arguments |{<label>}| and |[<angle>]| after the two mandatory parenthesis arguments. + +\remark +\begin{itemize} +\item \textsc{Remember} the order of arguments is |(<coor>)(<name>){<label>}[<angle>]|. +\item It cannot be emphasized that |{<label>}| is placed by |[<angle>]| (by default |90| or |above|) and you \xem{cannot} use the abbreviations such as |a|, |l|, |ar|, and so forth to place labels for coordinates and dots. +\end{itemize} + +\begin{tzdef}{} +% syntax: simplified +\tzcoor(<coor>)(<coor name>){<label>}[[<label opt>]<angle>] +% defaults + (<m>)(<m>){}[] + % <m> means `mandatory' +\end{tzdef} + +You can see the full syntax of |\tzcoor| in Section \ref{s:tzcoor} on page \pageref{s:tzcoor}. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,2) +\tzcoor(1,1)(A){A} % default: 90 or above +\tzcoor(2,1)(B){B}[[red]0] +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzcoor(1,1)(B){B}[0] % works like: + \draw (1,1) coordinate (B) node [label={0:B}] {}; +\tzcoor(1,1)(B){B}[[red]0] % works like: + \draw (1,1) coordinate (B) node [label={[red]0:B}] {}; +\end{tztikz} + +\subsection{\protect\cmd{\tzcoor*}} +\label{ssi:tzcoor*} + +\icmd{\tzcoor*} designates a coordinate and prints a node dot with a label around the designated point like |\tzdot*| does. + +\begin{tzdef}{} +% syntax: simflified +\tzcoor*[<dot opt>](<coor>)(<coor name>){<label>}[[<label opt>]<angle>](<dot size>) +\end{tzdef} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor(1,1)(A){A} % default: 90 or above +\tzcoor(2,1)(B){B}[0] +\tzcoor*(1,2)(C){C}[180](4pt) +\tzcoor*[fill=none](3,2)(D){D}[45] +\tzcoor*(4,0)(E){E}[[red,draw]180](4pt) +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzcoor*(1,2)(C){C}[180](4pt) % works as follows: + \tzcoor(1,2)(C) + \tzdot*(C){C}[180](4pt) +\end{tztikz} + +%%------------------------------------------------------------ +\section{Adding text next to lines or curves} +\label{si:texttolines} + +\subsection{\protect\cmd{\tzline}} +\label{ssi:texttotzline} + +\icmd{\tzline} accepts two mandatory coordinates. +To add text to a line segment, just specify the optional arguments |{<text>}| and |[<node opt>]| \xem{inbetween} the two coordinates. The |[<node opt>]| is |[above,midway]|, by default. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline(0,0){route A}(3,0) +\tzline[dashed](1,1){route B}(4,1) +\tzline[blue] + (0,3) {plan C} [below,near end] (3,3) +\end{tikzpicture} +\end{tzcode} + +The optional argument |{<text>}| \xem{following the second coordinate} can also be used as a name of the graph. By default, it is placed at the second coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline(0,3)(4,0){demand} +\tzline(0,0)(3,3){supply}[r] +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzto}} +\label{ssi:texttotzto} + +To add text to a line or a curve drawn by \icmd{\tzto}, just specify the optional arguments |{<text>}| and |[<node opt>]| \xem{in bewteen} the two coordinates. By default, the |[<node opt>]| is |[above,midway]|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto(0,0){route A}(3,0) +\tzto[dashed,bend left](1,1){route B}(4,1) +\tzto[blue,bend right] + (0,3) {plan C} [below,near end] (3,3) +\end{tikzpicture} +\end{tzcode} + +The optional argument |{<text>}| \xem{following the second coordinate} can also be used as a name of the graph. By default, it is placed at the second coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[bend right=15](0,3)(4,0){demand} +\tzto[bend right=10](0,0)(3,3){supply}[r] +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzbezier}} +\label{ssi:texttotzbezier} + +\icmd{\tzbezier} accepts three or four coordinates as arguments. +You can add text to the curve drawn by |\tzbezier| using the optional arguments |{<text>}| and |[<pos>]| after the last coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzbezier(0,2)(1,3)(3,0)(4,1){curve}[r] +\tzbezier[red,yshift=-5mm] + (0,2)(1,3)(3,0)(4,1){curve}[midway] +\tzbezier[green,text=blue,yshift=-10mm] + (0,2)(1,3)(3,0)(4,1){curve}[b,near end] +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzparabola}} +\label{ssi:texttotzparabola} + +\icmd{\tzparabola} accepts two or three coordinate arguments. +You can add text to a parabola drawn by |\tzparabola| using the optional arguments |{<text>}| and |[<node opt>]| \xem{followed by the last coordinate}. +The text is placed at (by default) or around the last coordinate according to |[<node opt>]|. + + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola(0,2)(1,.5)(3,2){$AC$}[r] +\tzparabola[bend at end,blue](0,0)(4,3){$u(x)$}[r,red] +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{An Intuitive Introduction II: Repetition of Coordinates} +\label{ci:introII} + +%%------------------------------------------------------------ +\section{Linking many coordinates: Semicolon versions} +\label{si:manycoordinates} + +\subsection{\protect\cmd{\tzlines}: Connected line segments} +\label{ssi:tzlines} + +\icmd{\tzlines} connects with line segments an arbitrary number of coordinates. The coordinate iteration must end with semicolon |;|. +Here, the \xem{semicolon} |;| indicates \xem{the end of repetition} of coordinates. +Let us call this kind of macro a \iisw{semicolon version}. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines(0,0)(1,2)(3,0)(4,1)(2,2)(3,3)(0,3)(0,1)(4,2); +\end{tikzpicture} +\end{tzcode} + +With the optional argument |{<text>}| followed by |[<node opt>]| \xem{inbetween two coordinates}, you can print |{<text>}| at or around the middle point of the corresponding line segment in accordance with |[<node opt>]| (by default |[midway]|). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[dashed,->](0,0){up}[l] + (1,2){down}[r] + (3,0){up}[r] + (4,1); +\end{tikzpicture} +\end{tzcode} + +The optional argument |{<text>}| \xem{following the last coordinate} can be used as a name of the whole connected line segments. The |{<text>}| is placed at (by default) or around the last coordinate according to |[<node opt>]|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[sloped,auto] +\tzhelplines(4,3) +\tzlines[dashed,->](0,0){up} + (1,2){down} + (3,0){up} + (4,1){Weight}[r,blue] ; +\end{tikzpicture} +\end{tzcode} + +\textsc{Remember} the repeated pattern is the triple |(<coor>){<text>}[<node opt>]| in that order. +DO NOT FORGET to indicate when the repetition ends by typing the semicolon. So it will look like |(){}[]..repeated..(){}[];| + +\subsection{\protect\cmd{\tzpolygon}, \protect\cmd{\tzpolygon*}: Closed paths} +\label{ssi:tzpolygon} + +\icmd{\tzpolygon} draws closed line segments. |\tzpolygon| is also one of semicolon versions, meaning that it has to end with a semicolon |;|. +In fact, |\tzpolygon| is a closed version of |\tzlines|. + +The starred version |\tzpolygon*| does the same thing as |\tzpolgon| except for one thing. +|\tzplygon*|, by default, fills the interior of the polygon with |black!50| with |fill=opacity=.3|. (Changing the fill opacity is not an issue in this introduction. See Section \ref{s:tzpolygon} on path \pageref{s:tzpolygon} for more details.) + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon(1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\end{tikzpicture} +\end{tzcode} + +The optional arguments |{<text>}| and |[node opt]| inbetween two coordinates prints |<text>| according to |[node opt]| (by default |[midway]|) around the middle point of the corresponding line segment. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon*[green,thick](1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\tzpolygon[dashed] + (0,0){up}[l] (1,2){down}[r] (3,0){up}[r] (4,1); +\end{tikzpicture} +\end{tzcode} + +The options |{<text>}| and |[node opt]| following the last coordinate can be used as a name of the connected line segments. + +Here, the entire repeated pattern is |(coor){text}[pos] .. repeated .. (){}[];|. +DO NOT FORGET to indicate when the repetition ends by typing a semicolon. + +\begin{tzcode}{.3} +\begin{tikzpicture}[sloped,auto] +\tzhelplines(4,3) +\tzpolygon[dashed] + (0,0){up} (1,2){down} (3,0){up} (4,1) {Weight}[r] ; +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tzpath*}: Filling area} +\label{ssi:tzpath} + +\icmd{\tzpath} accepts an arbitrary number of coordinates to form a path, like |\tzlines| does, but the path is invisible. This is a \xem{semicolon version} macro, so the coordinate iteration must be ended by a semicolon |;|. +With |[draw]| option you can visualize the invisible path. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpath[draw](1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\end{tikzpicture} +\end{tzcode} + +You can fill the interior of a path formed by |\tzpath| (after being closed) with color or pattern, in usual \Tikz\ way. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue](0,3)(4,0) +\tzpath[pattern=crosshatch] + (1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\tzpath[pattern=bricks,preaction={fill=brown}] + (0,0) (1,2) (3,0) (4,1); +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue](0,3)(4,0) +\tzpath[fill,green](1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\tzpath[fill](0,0) (1,2) (3,0) (4,1); +\end{tikzpicture} +\end{tzcode} + + + +The starred version \icmd{\tzpath*} takes the default options |fill=black!50| and |fill opacity=.3| to fill the area. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue](0,3)(4,0) +\tzpath*[green](1,3)(0,2)(2,0)(3,1)(4,2)(2,3); +\tzpath*(0,0) (1,2) (3,0) (4,1); +\end{tikzpicture} +\end{tzcode} + +How to change the |fill opacity| with |\tzpath*| is not discussed in this introduction, but one example is given below. (See Section \ref{s:tzpath*} on page \pageref{s:tzpath*} for more details.) + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue](0,3)(4,0) +\tzpath*[green](1,3)(0,2)(2,0)(3,1)(4,2)(2,3);{1} %% +\tzpath*(0,0) (1,2) (3,0) (4,1);{.7} %% +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{Many dots: Semicolon versions} +\label{si:manydots} + +\subsection{\protect\cmd{\tzcdots}, \protect\cmd{\tzcdots*}} +\label{ssi:tzcdots} + +\icmd{\tzcdots} accepts an arbitrary number of coordinates to print circle dots, but the coordinate repetition must be ended by |;| (semicolon version). +\icmd{\tzcdots*} prints filled circle dots. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdots(0,0)(1,1)(2,1)(3,2)(4,3); +\tzcdots*[fill=red](0,3)(1,3)(2,3)(3,3)(4,2); +\end{tikzpicture} +\end{tzcode} + +Each coordinate can be labeled by specifying the optional argument |{<label>}| followed by |[<angle>]|. You can also change the size (\xem{radius}) of the dots by specifying the parenthesis argument |(<dot radius>)| \xem{after} the semicolon. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdots(0,0)(1,1){B}(2,1)(3,2){D}[-90](4,3);(5pt) +\tzcdots*[fill=red](0,3){A} + (1,3){B} + (2,3){C}[-90] + (3,3) + (4,2){E}[[blue]0];(3pt) % radius +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzdots}, \protect\cmd{\tzdots*}} +\label{ssi:tzdots} + +\icmd{\tzdots} accepts an arbitrary number of coordinates to print circle node dots, but the repetition must be ended by |;| (semicolon version). +\icmd{\tzdots*} prints filled circle node dots. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots(0,0)(1,1)(2,1)(3,2)(4,3); +\tzdots*[fill=red](0,3)(1,3)(2,3)(3,3)(4,2); +\end{tikzpicture} +\end{tzcode} + +Each coordinate can be labeled by specifying the optional argument |{<label>}| followed by |[<angle>]|. You can also change the size of the dots by specifying the parenthesis argument |(<size>)| \xem{after} the semicolon. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots(0,0)(1,1){B}(2,1)(3,2){D}[-90](4,3);(10pt) +\tzdots*[fill=red](0,3){A} + (1,3){B} + (2,3){C}[-90] + (3,3) + (4,2){E}[[blue]0];(6pt) % diameter +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Many coordinates: Semicolon versions} +\label{si:manycoordinates} + +\subsection{\protect\cmd{\tzcoors}, \protect\cmd{\tzcoors*}} +\label{ssi:tzcoors} + +|\tzcoor| accepts \xem{a pair} of mandatory arguments in parentheses: |(<coor>)(<name>)|. +\icmd{\tzcoors} accepts \xem{an arbitrary number of the pairs} to define multiple coordinates. It is a semicolon version, meaning that a semicolon is necessary to indicate when the repetition ends. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors(0,0)(A) + (1,1)(B) + (2,1)(C) + (3,3)(D) + (4,2)(E); +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + +The optional arguments |{<label>}| and |[<angle>]| following each pair of |(<coor>)| and |(<name>)| allow you to add |<label>| in the direction |<angle>| around the coordinate. +Here, the repeated pattern is |(<coor>)(<name>){<label>}[<angle>]|, in that order. The first two parenthesis arguments are mandatory and others are optional. The pattern is repeated until |\tzcoors| meets a semicolon |;|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors(0,0)(A){A} + (1,1)(B) + (2,1)(C){C}[0] + (3,3)(D){D}[180] + (4,2)(E){E}[-90]; +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + +The starred version \icmd{\tzcoors*} does one more thing: prints node dots. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(0,0)(A){A} + (1,1)(B) + (2,1)(C){C}[0] + (3,3)(D){D}[180] + (4,2)(E){E}[-90]; +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzcoorsquick}} +\label{ssi:tzcoorsquick} + +\icmd{\tzcoorsquick} is just to see the array of many coordinates at a glance. +|\tzcoorsquick| works like |\tzcoors|, but it automatically prints the name of each coordinate as its label, right at the point, by default. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick(0,0)(A) + (1,1)(Best) + (2,1)(Case) + (3,3)(Done) + (4,2)(End); +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tzcoorsquick*}} +\label{ssi:tzcoorsquick*} + +\icmd{\tzcoorsquick*} prints node dots and automatically puts the labels |above| (in the direction of |90| degree from) them, by default. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick*(0,0)(A) + (1,1)(Best) + (2,1)(Case) + (3,3)(Done) + (4,2)(End){END!}[[blue]0]; +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\texttt{plot coordinates}: Semicolon versions} +\label{si:plotcoordinates} + +\subsection{\protect\cmd{\tzplot*}: Mark dots with \texttt{[mark=*]}} +\label{ssi:tzplot*} + +\icmd{\tzplot*} accepts an arbitrary number of coordinates to print bullets with the \xem{radius} (|mark size| in \Tikz) of |2pt|, which is the initial value in \Tikz. The repetition of coordinates must be ended by |;| (semicolon version). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot*(0,0) + (1,1) + (2,1) + (3,3) + (4,2); +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzplot*(0,0)(1,1)(2,1); % works like: + \draw [mark=*] plot coordiates {(0,0)(1,1)(2,1)}; +\end{tztikz} + +Each coordinate can be labeled by specifying the optional argument |{<text>}| followed by |[<angle>]|. With the option |mark=o| you can print hollow dots. You can also change the \xem{radius} of the marks by specifying the parenthesis argument |(<mark size>)| \xem{after} the semicolon. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot*[mark=o](0,0){A} + (1,1){Best} + (2,1){Case} + (3,3){Done} + (4,2){END!}[[blue]0];(1.2pt) +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzplot}: Lines with \texttt{[tension=0]}} +\label{ssi:tzplot:lines} + +\icmd{\tzplot} accepts an arbitrary number of coordinates and draws line segments connecting them. The repetition of coordinates must be ended by |;| (semicolon version). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot(0,0) + (1,1) + (2,1) + (3,3){Done} + (4,2){END!}[[blue]0]; +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzplot(0,0)(1,1)(2,1); % works like: + \draw plot coordiates {(0,0)(1,1)(2,1)}; +\end{tztikz} + + +\subsection{\protect\cmd{\tzplot*[draw]}: Lines with dots} +\label{ssi:tzplot*} + +\icmd{\tzplot*}|[draw]| prints bullets and draws line segments connecting specified coordinates. The repetition of coordinates must be ended by |;| (semicolon version). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot*[draw](0,0) + (1,1) + (2,1) + (3,3) + (4,2){END!}[[blue]0]; +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzplotcurve}: Curves with \texttt{[smooth,tension=1]}} +\label{ssi:tzplotcurve} + +\icmd{\tzplotcurve} plots coordinates with the option |[smooth,tension=1]|, resulting in a curve connecting specified coordinates. +The repetition of coordinates must be ended by |;| (semicolon version). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve(0,0) + (1,1) + (2,1) + (3,3) + (4,2){END!}[[blue]0]; +\end{tikzpicture} +\end{tzcode} + +\begin{tzdef}{} +% syntax: simplified +\tzplotcurve[<opt>]{<tension>}"<path name>" + (<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>]; +% defaults + [smooth,tension=1]{1}""(<m>){}[]..repeated..(){}[]; +% <m> means mandatory +\end{tzdef} + +\begin{tztikz}{} +\tzplotcurve(0,0)(1,1)(2,1); % works like: + \draw [smooth,tension=1] plot coordiates {(0,0)(1,1)(2,1)}; +\end{tztikz} + +You can change the tension value by specifying the optional argument |{<tension>}|, before the first coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor(.5,.5)(A) +\tzplotcurve[blue]{2}(1,3)(A)(4,0); +\tzplotcurve[thick](1,3)(A)(4,0); % default: tension=1 +\tzplotcurve[red]{.5}(1,3)(A)(4,0); +\tzplotcurve[dashed]{0}(1,3)(A)(4,0); +\end{tikzpicture} +\end{tzcode} + + + + +%%================================== +\chapter{An Intuitive Introduction III: Plotting Functions} +\label{ci:introIII} + + +%%------------------------------------------------------------ +\section{Axes} +\label{si:axes} + +\subsection{\protect\cmd{\tzaxes}} +\label{ssi:tzaxes} + +\begin{tzdef}{} +% syntax: simplified +\tzaxes[<opt>]<x-shift,y-shift>(<x1,y1>)(<x2,y2>) + {<x-text>}[<x-opt>]{<y-text>}[<y-opt>] +% defaults + [->,>=stealth]<0,0>(0,0)(<m>){}[right]{}[above] +% <m> means mandatory +\end{tzdef} + +\icmd{\tzaxes} draws the x-axis from |<x1>| to |<x2>| and the y-axis from |<y1>| to |<y2>|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzaxes(-1,-1)(8,5) % basics +\end{tikzpicture} +\end{tzcode} + +If |(<x1,y1>)| is omitted, it is regarded as |(0,0)|. +And optionally the names of x-axis and y-axis can be printed at a specified place (by default, |[right]| for x-axis and |[above]| for y-axis). + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzaxes[draw=blue](8,5){$x$}{$y$} % +\end{tikzpicture} +\end{tzcode} + +With the optional argument |<x-shift,y-shift>|, the axes are shifted accordingly. Two axes intersect at |(<x-shift,y-shift>)|, by default |(0,0)|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzaxes(-1,-1)(8,5){$Q$}[b]{$P$}[l] +\tzaxes[dashed,-]<2,1>(-1,-1)(8,5) % shift +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tzaxes*}} +\label{ssi:tzaxes*} + +The starred version \icmd{\tzaxes*} is just to set the current state to a \iisw{bounding box} when |\tzaxes| is executed. Use |\tzaxes*| before any larger graphics. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzaxes*(8,5){$x$}{$f(x)$} % bounding box +\tzhelplines(-2,-1)(10,8) +\tzto[out=90,in=-135,dashed](-2,8)(12,-2) +\tzbezier[blue](-1,-1)(3,-2)(7,12)(10,10) +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzshoworigin}, \protect\cmd{\tzshoworigin*}} +\label{ssi:tzshoworigin} + +\icmd{\tzshoworigin} prints `$0$' (roughly) at the bottom left of the origin. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzshoworigin +\tzaxes(-1,-1)(8,5) +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzshoworigin*} prints a node dot with the size of |2.4pt| (by default) at the origin. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzshoworigin* +\tzaxes(-1,-1)(8,5) +\end{tikzpicture} +\end{tzcode} + +|\tzshoworigin*(<coor>){<text>}[<node opt>]| prints a node dot and text around |(<coor>)|, by default |(0,0)|. (Notice that the place where the |<text>| is printed at is not by |<angle>|. So you can use the abbreviations of \Tikz\ basic placement options such as |a|, |l|, |br|, ect. See Section \ref{s:abbreviations}.) + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzshoworigin*{$O_1$} +\tzaxes(-1,-1)(8,5) +\tzaxes[blue]<7,4>(8,5)(-1,-1) +\tzshoworigin*(7,4){$O_2$}[ar] +\end{tikzpicture} +\end{tzcode} + +Notice that, in the above example, the two axes intersect at |(7,4)| by the shift option |<7,4>|. + +\subsection{\protect\cmd{\tzaxisx}, \protect\cmd{\tzaxisy}} +\label{ssi:tzaxesx} + +\icmd{\tzaxisx} and \icmd{\tzaxisy} draw the x-axis and the y-axis, respectively. + +\begin{tzdef}{} +% syntax: simplified +\tzaxisx[<opt>]<y-shift>{<x1>}{<x2>}{<text>}[<node opt>] +% defaults + [->,>=stealth]<0>{<m>}{<m>}{}[right] +\end{tzdef} + +|\tzaxisy| works similarly for the y-axis. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzaxisx{-1}{8}{$x$} +\tzaxisy[draw=blue,thick]{-1}{5}{$y$} +\tzaxisx[dashed,-]<2>{-1}{8} +\tzaxisy[thick,<->]<1>{-1}{5} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Ticks} +\label{si:tikzs} + +\subsection{\protect\cmd{\tzticks}} +\label{ssi:tzticks} + +\icmd{\tzticks}|{<x-tick places>}{y-tick places>}| prints tick labels for x- and y-axis at specified places, which are comma separated. +By default, tick labels are the numbers specified. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(8,5) +\tzshoworigin +\tzaxes(-1,-1)(8,5) +\tzticks{1,2,...,8}{1,2,...,5} +\end{tikzpicture} +\end{tzcode} + +You can change the numbered label, for example |{2,4,7}|, to any other form, by doing like, for example, |{2/mylabel,4,7}|. (Internally, |\tzticks| uses |foreach| operation of \Tikz.) + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(8,5) +\tzshoworigin +\tzaxes(-1,-1)(8,5) +\tzticks{2/x,4/y,5.5/$z_1$,7}{1,2.5/$\frac25$,4} +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tzticks*}} +\label{ssi:tzticks*} + +\icmd{\tzticks*} prints tick labels from |0pt| to |3pt| by default, without printing tick labels. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(8,5) +\tzshoworigin +\tzaxes(-1,-1)(8,5) +\tzticks*{1,2,...,7}{1,2,...,4} +\end{tikzpicture} +\end{tzcode} + +You can change the length of tick marks, for example, like |(-2pt:3pt)| and |(-5pt:10pt)| as shown in the following example. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(8,5) +\tzaxes(-1,-1)(8,5) +\tzticks*(-2pt:3pt){1,2,...,7}(-5pt:10pt){1,2,...,4} +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzticksx(*)}, \protect\cmd{\tzticksy(*)}} +\label{ssi:tztikcsx} + +\icmd{\tzticksx} and \icmd{\tzticksy} prints x-tick labels and y-tick labels, respectively. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(8,5) +\tzaxes(-1,-1)(8,5) +\tzticksx{1/x,3/y,5/z,7} +\tzticksy(-5pt:10pt){1,2,4/k} +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzticksx*} and \icmd{\tzticksy*} suppress tick labels for their corresponding axes, like |\tzticks*|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(8,5) +\tzaxes(-1,-1)(8,5) +\tzticksx*{1/x,3/y,5/z,7} +\tzticksy*(-5pt:10pt){1,2,4/k} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Projections on the axes} +\label{si:projections} + + +\subsection{\protect\cmd{\tzprojx(*)}, \protect\cmd{\tzprojy(*)}} +\label{ssi:tzprojx} + +\icmd{\tzprojx} draws a dotted (by default) line from a coordinate to its projection on the x-axis and prints text around (|[below]| by default) the projection point. + +|\tzprojy| works similarly but for the projection point on the y-axis. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzaxes(4,3) +\tzdot*(3,2){$(x_1,x_2)$}[45] +\tzprojx(3,2){$x_1$} +\tzprojy[solid,->,draw=blue](3,2){$x_2$}[bl] +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzprojx*} does one more thing. It prints a node dot at a specified coordinate. |\tzprojy*| works similarly but for the projection point on the y-axis. + + +\begin{tzcode}{.3} +\begin{tikzpicture} +%\tzhelplines(4,3) +\tzaxes(4,3) +\tznode(3,2){$(x_1,x_2)$}[ar] +\tzprojx*(3,2){$x_1$}[xshift=-3pt] +\tzprojy[->,dashed,draw=red](3,2){$x_2$} +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzproj(*)}} +\label{ssi:tzproj} + +\icmd{\tzproj} combines |\tzprojx| and |\tzprojy|. +And \icmd{\tzproj*} combines |\tzprojx*| and |\tzprojy*|, so it suppresses tick labels. + + +\begin{tzcode}{.3} +\begin{tikzpicture} +%\tzhelplines(4,3) +\tzaxes(4,3) +\tznode(3,2){$(x_1,x_2)$}[ar] +\tzproj[<->,solid,draw=red](3,2){$x_1$}{$x_1$} +\tzproj*(1.5,2.5){$a$}[xshift=3pt,text=blue]{$b$} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Plot functions} +\label{si:plotfunctions} + +\subsection{\protect\cmd{\tzfn}} +\label{ssi:tzfn} + +\icmd{\tzfn}|{<fn of \x>}[<a:b>]| plots a function of $x$ over the specified domain $[a:b]$, which means that $a\leq x \leq b$. +Optionally, you can add |{<text>}| at |[<node opt>]| as shown in the following example. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines(5,5) +\tzaxes(5,5) +\tzfn{(\x-1)^2}[0:3] % y=(x-1)^2 +\def\Gx{(\x-2)^2+1} +\tzfn[dashed]{\Gx}[1:4]{$g(x)$}[r] % g(x)=(x-2)^2+1 +\tzfn[red]{sin(\x r)+3}[0:2*pi] % y=sin x +\end{tikzpicture} +\end{tzcode} + +You can name a path formed by |\tzfn| by specifying the optional argument |"<path name>"| right before the mandatory curly brace argument |{<fn of \x>}|. The name of a path is used to find intersection points. + +\begin{tzdef}{} +% syntax: simplified +\tzfn[<opt>]"<path name>"{<fn of \x>}[<a:b>]{<text>}[<node dot>] +% defaults + []""{<m>}[<m>]{}[] +% <m>: mandatory +\end{tzdef} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7,font=\footnotesize] +\tzhelplines(5,5) +\tzaxes(5,5){$x$}{$y$} +\def\bgt{4-\x} +\def\IC{3/\x} +\def\ICa{4/\x} +\tzfn"bgt"{\bgt}[0:4] % name path = bgt +\tzfn[blue]"IC"{\IC}[.75:4] % name path = IC +\tzfn[red]{\ICa}[1:4] % name path = ICa (automatically) +\end{tikzpicture} +\end{tzcode} + +\remark +If the curly brace mandatory argument consists of \xem{only a macro name} like |{\Foo}|, the macro name |Foo| (without the backslash) is automatically assigned to the \xem{name of the path}. + +\subsection{\protect\cmd{\tzhfnat}, \protect\cmd{\tzhfn}: Horizontal lines} +\label{ssi:tzhfn} + +\icmd{\tzhfnat} draws a horizontal line (the graph of a constant function) at $y$, by default, from bottom to top of the \ixxw{current bounding box}. + +\begin{tzdef}{} +% syntax +\tzhfnat[<opt>]"<path name>"{<y-val>}[<from:to>]{<text>}[<pos>] +% defaults + []""{<m>}[south:north of current bounding box]{}[] +\end{tzdef} + +\icmd{\tzhfn}|(<coor>)| accepts a coordinate, instead of the value of $y$ to draw a vertical line at the value of $y$ coordinate of |(<coor>)|, ignoring the value of $x$ coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzhfnat{0} +\tzhfnat[dashed]{1}[1:4]{Two}[l,at start] +\tzcoors(0,2)(A)(0,3)(B); +\tzhfn[blue](A)[0:3]{Three}[b,near end] +\tzhfn[->](B)[0:3]{Four}[r] +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzvfnat}, \protect\cmd{\tzvfn}: Vertical lines} +\label{ssi:tzvfn} + +\icmd{\tzvfn} draws a vertical line at $x$ from left to right of the |current bounding box| by default. + +\begin{tzdef}{} +% syntax: simplified +\tzvfnat[<opt>]"<path name>"{<x-vale>}[<from:to>]{<text>}[<pos>] +% defaults + []""{<m>}[west:east of current bounding box]{}[] +\end{tzdef} + +\icmd{\tzvfn}|(<coor>)| accepts a coordinate, instead of the value of $x$. It draws a vertical line at the value of $x$ coordinate of |(<coor>)|, ignoring the value of $y$ coordinate. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzvfnat{0} +\tzvfnat[dashed]{1}[1:3]{Two}[b,at start] +\tzvfn[blue](2,0)[0:3]{Three}[a,near end,sloped] +\tzvfn[->](3,0)[0:3]{Four}[r] +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzLFn}: Linear functions} +\label{ssi:tzLFn} + +\icmd{\tzLFn}|(<coor1>)(<coor2>)...| draws a \xem{linear function} passing through two points: |(<coor1)| and |(<coor2>)|. +|\tzLFn(<coor1>){<slope>}...| draws a linear function passing through |(<coor1>)| with the slope of |<slope>|. If both of the two coordinates are specified the |<slope>| is ignored. The domain in the form of |[a:b]| is also required. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7,font=\footnotesize] +\tzhelplines(5,5) +\tzaxes(-1,-1)(5,5) +\tzdots*(1,1)(3,2); +\tzLFn(1,1)(3,2)[0:4]{two points}[r] +\tzLFn(1,1){1.5}[0:3]{one point and a slope}[r] +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{Intersection points} +\label{si:intersections} + +\subsection{Naming paths} +\label{ssi:namingpaths} + +In \Tikz, you can find \xem{intersection} points when two \xem{named paths} intersect. The name of a path is usually given by the option |[name path=<path name>]| in \Tikz. + +In this package, of course, you can use the option |[name path=<path name>]| in usual \Tikz\ way. With the package \pkg{tzplot}, you can also name a path by specifying an optional argument within quotation marks such as |"<path name>"|. + +All macros (with a few exceptions) related to lines and curves accept this quotation optional argument to name paths as follows: + +\begin{verbatim} + \tzline[<opt>]"<path name>"(<coor>)... + \tzlines..."<path name>"(<coor>)... + \tzpolygon..."<path name">(<coor>)... + \tzpath..."<path name">(<coor>)... + \tzto..."<path name">(<coor>)... + \tzparabola..."<path name">(<coor>)... + \tzbezier..."<path name">(<coor>)... + \tzfn..."<path name">{<fn of \x>}... + \tzLFn..."<path name">(<coor>)... + and more... +\end{verbatim} + +\begin{tztikz}{} +\tzline[dashed]"foo"(1,1)(3,3) % works like + \draw [dashed,name path=foo](1,1) -- (3,3); +\end{tztikz} + +In most cases, the quotation optional arguments for naming paths are placed immediately before the first mandatory argument or essential argument (when no mandatory argument exists) of the |tzplot| macros. + +\subsection{\protect\cmd{\tzXpoint(*)}: Intersection points of two paths} +\label{ssi:tzXpoint} + +For example, \icmd{\tzXpoint}|{path1}{path2}(A)| finds intersection points of |path1| and |path2| and names the first intersection point |(A)|. This intersection can be referred to as |(A)| or |(A-1)|. If there are two or more intersection points found, they are called |(A)=(A-1)|, |(A-2)|, |(A-3)|, and so on. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline"AA"(0,0)(3,2) +\tzline"BB"(0,3)(3,0) +\tzXpoint{AA}{BB}(X) +\tzdot*(X){E} +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzXpoint*} prints a node dot at the first intersection point. +You can label the point by specifying |{<text>}| and |[<angle>]| after the specified intersection name. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7,font=\footnotesize] +\tzhelplines(5,5) +\tzaxes(5,5){$x$}{$y$} +\def\bgt{4-\x} +\def\IC{3/\x} +\tzfn"bgt"{\bgt}[0:4] % name path = bgt +\tzfn[blue]"IC"{\IC}[.75:4] % name path = IC +\tzXpoint*{bgt}{IC}(E){$A$}[45] % first intersection +\tzdot(E-2){$B$}[45](5pt) % second intersection +\end{tikzpicture} +\end{tzcode} + +\remark +You have to expect \Tikz\ to take a few seconds (or less) to find the intersection points. + +\subsection{\protect\cmd{\tzvXpointat(*)}, \protect\cmd{\tzvXpoint(*)}: Vertical intersection points} +\label{ssi:tzvXpoint} + +To find vertical intersection points at $x$ to a curve, you should specify a path name and either the value of $x$ or the coordinate $(x,y)$. Here the $y$ coordinate is ignored. + +\icmd{\tzvXpointat}|{<path>}{<x>}(A)| finds vertical intersection points with |<path>| at $x=\texttt{<x>}$ and names it |(A)|. +The starred version \icmd{\tzvXpointat*} additionally prints a node dot at the (first) intersection point. + +For example, \icmd{\tzvXpoint}|{<path>}(<coor>)(A)| gives the same result as |\tzvXpoint{<path>}{<x-coor>}(A)|. Here the $y$ coordinate of |(<coor>)| is not important. |\tzvXpoint| is useful when you do not know the exact value of $x$ coordinate of |(<coor>)|. +The starred version \icmd{\tzvXpoint*} additionally prints a node dot at the (first) intersection point. + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7,font=\scriptsize] +\tzhelplines(5,5) +\tzaxes(5,5) +\def\Fx{(\x-1)^2} +\tzfn\Fx[0:3] % name path = Fx (automatically) +\tzvXpointat{Fx}{2.5}(A) +\tzvXpoint{Fx}(2.8,1)(B) % y=1 is ignored +\tzproj*[->](A){$2.5$}{$f(2.5)$} +\tzdot(B){$B$}[0] +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzhXpointat}, \protect\cmd{\tzhXpoint}: Horizontal intersection points} +\label{ssi:tzhXpoint} + +\icmd{\tzhXpointat}|{<path>}{<y>}(A)| works like |\tzvXpointat{<path>}{<x>}(A)|, but it uses the value of $y$ instead of $x$. +The starred version \icmd{\tzhXpointat*} additionally prints a node dot at the (first) intersection point. + +\icmd{\tzhXpoint}|{<path>}(<coor>)(A)| works like |\tzvXpoint{<path>}(<coor>)(A)|, but it uses only the $y$ coordinate of |(<coor>)|, ignoring the value of $x$ coordinate. +The starred version \icmd{\tzhXpoint*} prints a node dot at the (first) intersection point. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7,font=\scriptsize] +\tzhelplines(5,5) +\tzaxes(5,5) +\def\Fx{(\x-1)^2} +\tzfn\Fx[0:3] % name path = Fx (automatically) +\tzhXpointat{Fx}{2.5}(A) +\tzhXpoint{Fx}(1,2.8)(B) % x=1 is ignored +\tzproj*[<-](A){$f^{-1}(2.5)$}{$y=2.5$} +\tzdot(B){$B$}[0] +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{Tangent lines} +\label{si:tangentlines} + +\subsection{\protect\cmd{\tztangentat}} +\label{ssi:tztangentat} + +\icmd{\tztangentat}|{<path>}{<x>}| draws a tangent line to |<path>| at $x=\texttt{<x>}$. The line is drawn on the |behind| layer, by default. + +\remark +The slope of a tangent line drawn by |\tztangentat| is just approximate. + +\begin{tzdef}{} +% syntax +\tztangentat{<path>}{<x>}[<domain>]{<text>}[<pos>] +% defaults + []{<m>}{<m>}[<m>]{}[] +% <m> means mandatory +\end{tzdef} + +The domain is a mandatory argument and should be of the form |[<from:to>]|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines[use as bounding box](5,5) +\tzparabola[thick,blue]"curve"(0,1)(2,3)(4,2) +\tzvXpointat*{curve}{1} +\tzvXpointat*{curve}{3} +\tztangentat{curve}{1}[0:3] +\tztangentat[red]{curve}{3}[1:5] +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tztangent}} +\label{ssi:tztangent} + +\icmd{\tztangent} works like |\tztangentat|, but it accepts a coordinate instead of the value of $x$. + +|\tztangent{<path>}(<coor>)| draws a tangent line to |<path>| at $x$ coordinate of |(<coor>)|. Here, the $y$ coordinate of |(<coor>)| is ignored. The line is drawn on the |behind| layer, by default. + + +\begin{tzdef}{} +% syntax +\tztangentat{<path>}(<coor>)[<from:to>]{<text>}[<pos>] +% defaults + []{<m>}(<m>)[<m>]{}[] +\end{tzdef} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines[draw=none,use as bounding box](5,5) +\tzparabola[thick,blue]"curve"(0,1)(2,3)(4,2) +\tzvXpoint*{curve}(1,0)(A){A}[135] +\tzvXpoint*{curve}(3,0)(B){B}[45] +\tztangent{curve}(A)[0:3] +\tztangent[red]{curve}(B)[1:5] +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzsecantat}, \protect\cmd{\tzsecant}} +\label{ssi:tzsecant} + +\icmd{\tzsecantat}|{<path>}{<x1>}{<x2>}| draws a secant line segment of |<path>| from $x_1=\texttt{<x1>}$ to $x_2=\texttt{<x2>}$ on the |behind| layer, by default. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines[use as bounding box](5,5) +\tzaxes(5,5) +\tzparabola"curve"(0,1)(2,3)(5,1) +\tzsecantat{curve}{1}{2} +\tzsecantat[red]{curve}{1}{3} +\tzsecantat[blue]{curve}{1}{4} +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzsecant} works like |\tzsecantat|, but it accepts two coordinates instead of two values of $x$. + +|\tzsecant{<path>}(<coor1>)(<coor2>)| draws a secant line segment of |<path>| from the $x$ coordinate of |(<coor1>)| to the $x$ coordinate of |(<coor2>)|, ignoring $y$ values of the coordinates, on the |behind| layer by default. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines[use as bounding box](5,5) +\tzaxes(5,5) +\tzparabola"curve"(0,1)(2,3)(5,1) +\tzsecant{curve}(1,0)(2,0) +\tzsecant[red]{curve}(1,0)(3,0) +\tzsecant[blue,dashed]{curve}(1,0)(4,0) +\end{tikzpicture} +\end{tzcode} + + +You can extend or shorten a secant line by specifying the domain |[<from:to>]|, which is an optional argument. +If you specify the domain, |\tzsecant| draws a secant line over the domain. +You can also add some text next to the line by specifying the optional arguments |{<text>}| and |[<node opt>]|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.7] +\tzhelplines[use as bounding box](5,5) +\tzaxes(5,5) +\tzparabola"curve"(0,1)(2,3)(5,1) +\tzsecant{curve}(1,0)(2,0) +\tzsecant[red]{curve}(1,0)(3,0)[0:5]{secant}[r] +\tzsecantat[blue,dashed]{curve}{1}{4}[0:5]{blue}[r] +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Examples: Economics} +\label{ci:examples} + +%%------------------------------------------------------------ +\section{Markets} +\label{si:markets} + +\subsection{Market equilibrium: step by step} +\label{ssi:mkteqm} + +\paragraph{Step 1} Determine the size of the graph. + +\begin{tzcode}{.3} +\begin{tikzpicture}[x=0.05cm,y=0.05cm,scale=.7] +% to avoid `dimension too large' error: x/y=0.05cm +\tzhelplines[step=.5cm](110,110) +\tzaxes(110,110){$Q$}{$P$} +%\tzto[bend right=15]"dem"(0,100)(100,0){$D$}[a] +%\tzto[bend right=15]"supp"(0,10)(100,90){$S$}[ar] +%\tzXpoint*{dem}{supp}(eqm){$E$} +%\tzproj(eqm){$Q^*$}{$P^*$} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Step 2} Draw the demand and supply curves. +Here, we are using |\tzto|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[x=0.05cm,y=0.05cm,scale=.7] +% to avoid `dimension too large' error: x/y=0.05cm +\tzhelplines[step=.5cm](110,110) +\tzaxes(110,110){$Q$}{$P$} +\tzto[bend right=15]"dem"(0,100)(100,0){$D$}[a] +\tzto[bend right=15]"supp"(0,10)(100,90){$S$}[ar] +%\tzXpoint*{dem}{supp}(eqm){$E$} +%\tzproj(eqm){$Q^*$}{$P^*$} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Step 3} Find an equilibrium point and name it. Use the starred version |\tzXpoint*| to print a dot and then label the point. + +\begin{tzcode}{.3} +\begin{tikzpicture}[x=0.05cm,y=0.05cm,scale=.7] +% to avoid `dimension too large' error: x/y=0.05cm +\tzhelplines[step=.5cm](110,110) +\tzaxes(110,110){$Q$}{$P$} +\tzto[bend right=15]"dem"(0,100)(100,0){$D$}[a] +\tzto[bend right=15]"supp"(0,10)(100,90){$S$}[ar] +\tzXpoint*{dem}{supp}(eqm){$E$} +%\tzproj(eqm){$Q^*$}{$P^*$} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Step 4} If necessary, use |\tzproj| to draw projection lines with text at the projection points. + +\begin{tzcode}{.3} +\begin{tikzpicture}[x=0.05cm,y=0.05cm,scale=.7] +% to avoid `dimension too large' error: x/y=0.05cm +%\tzhelplines[step=.5cm](110,110) +\tzaxes(110,110){$Q$}{$P$} +\tzto[bend right=15]"dem"(0,100)(100,0){$D$}[a] +\tzto[bend right=15]"supp"(0,10)(100,90){$S$}[ar] +\tzXpoint*{dem}{supp}(eqm){$E$} +\tzproj(eqm){$Q^*$}{$P^*$} +\end{tikzpicture} +\end{tzcode} + +\subsection{Tax incidence: step by step} +\label{ssi:taxincidence} + +\begin{enumerate}[{Step} 1{:}] +\item Determine the size of the graph. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.035,font=\scriptsize] +\tzhelplines[step=10cm](120,120) +\tzaxes(120,120){$Q$}{$P$} +\end{tikzpicture} +\end{tzcode} + +\item Define functions and plot them. And then, find an intersection point. +\item Draw the shifted supply curve and find new equilibrium point. And then, project the point on each axis. +\item To illustrate the social welfare loss (SWL), find a vertical intersection point of the original supply curve using new equilibrium point. +\item Project the old equilibrium point and the vertical intersection point onto the $y$ axis and add text. +\item Fill the area of the social welfare loss with color. +\item Add text `SWL' at the appropriate place. +\end{enumerate} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.035,font=\scriptsize] +%\tzhelplines[step=10cm](120,120) +\tzaxes(120,120){$Q$}{$P$} +% step 2 +\def\demA{100-\x} +\def\suppA{10+\x} +\tzfn\demA[0:100]{$D$}[ar] % name path = \demA +\tzfn\suppA[0:90]{$S$}[r] % name path = \suppA +\tzXpoint*{demA}{suppA}(E) +% step 3 +\tzfn[dashed]"suppB"{\suppA+20}[0:80]{$S'$}[ar] +\tzXpoint*{demA}{suppB}(newE){$E'$} +\tzproj(newE){$Q$}{$P_d$} +% step 4 +\tzvXpoint{suppA}(newE)(vX) +% step 5 +\tzprojy(vX){$P_s$} +\tzprojy(E){$P^c$} +% step 6 +\tzpath*[red](E)(newE)(vX); +% step 7 +\tznode($(E)!10cm!(E-|0,0)$){}[pin={-70:SWL}] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Firms} +\label{si:firms} + +\subsection{Cost curves} +\label{ssi:costcurves} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzaxes(10,10){$q$}{$AC$\\$AVC$\\$MC$}[align=center] +\tzparabola"MC"(.5,4)(2,2)(6,9){$MC$}[a] +\tzhXpointat{MC}{5}(A) +\tzhXpointat{MC}{3}(B) % (B-2) will be used! +\tzdots*(A)(B-2); +\tzparabola(2,7)(A)(8,9){$AC$}[r] +\tzparabola(1,4.5)(B-2)(8,8){$AVC$}[r] +\end{tikzpicture} +\end{tzcode} + +\subsection{Equilibrium of a competitive firm} +\label{ssi:competitive} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.4,font=\scriptsize] +%\tzhelplines(10,10) +\tzaxes(10,10){$q$}{$P$\\$AC$\\$MC$}[align=center] +\tzparabola"MC"(2,2)(6,9){$MC$}[a] +\tzhXpointat{MC}{4}(A) % point (A) on MC at q=4 +\tzparabola"AC"(2,7)(A)(8,9){$AC$}[r] % (A): minAC +\tzhfnat[blue]"price"{6}[0:9]{$P$}[l,at start] +\tzXpoint*{price}{MC}(E) +\tzprojx(E){$q^*$} +\tzvXpoint{AC}(E)(ACeqm) % point on AC in eqmuilibrium +\tzprojy(ACeqm){$AC(q^*)$} +\tzpath*[red](E-|0,0)(E)(ACeqm)(ACeqm-|0,0); +\tznode(2,5){$\pi^*$} +\end{tikzpicture} +\end{tzcode} + + +\subsection{Monopoly equilibrium} +\label{ssi:monopoly} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(10,10) +\tzaxes(10,10){$Q$}{$P$} +\def\DD{8-\x} +\def\MR{8-2*\x} +\def\MC{\x} +\tzfn\DD[0:8]{$D$}[ar] +\tzfn\MR[0:4.5]{$MR$}[r] +\tzfn\MC[0:7]{$MC$}[r] +\tzXpoint*{MR}{MC}(E) +\tzvXpoint*{DD}(E)(EE) +\tzproj(EE){$Q^M$}{$P^M$} +\tzXpoint{DD}{MC}(C) +\tzpath*(EE)(C)(E); +\tznode(C){\tiny SWL}[l] +\tzpath*[blue](0,8)(EE)(EE-|0,0); +\tznode(1,6){C.S.} +\tzpath[pattern=horizontal lines](0,0)(E)(E-|0,0); +\tznode(1,2){P.S.} +\end{tikzpicture} +\end{tzcode} + +%%------------------------------------------------------------ +\section{Consumers: Budget lines and indifference curves} +\label{si:consumers} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.3,font=\scriptsize] +%\tzhelplines(15,12) +\tzaxes(15,12){$x$}{$y$} +\def\bgt{-3/4*\x+9} % 3x+4y=36 +\tzfn\bgt[0:12] +\tzvXpoint*{bgt}(6,0)(A){A}[45] +\tzplotcurve"ICC"(3,9)(A)(12,3); % trial and error +\tzproj(A){$x^*$}{$y^*$} +\tzticks{12}{9} +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.15,font=\scriptsize] +%\tzhelplines(35,25) +\tzaxes(35,25){$x$}{$y$} +\def\bgt{-2/3*\x+20} % 2x+3y=60 +\def\IC{150/\x} % u(x,y)=xy +\tzfn\bgt[0:30] +\tzfn\IC[7:30] +\tzcoor*(15,10)(E){$E$}[45] +\tzproj(E) +\tzticks{15,30}{10,20} +\tzvXpointat*[red]{IC}{12}(A) +\tztangent[blue,densely dashed]{IC}(A)[5:20] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Production Possibility Curves} +\label{si:PPC} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(9,8) +\tzaxes(9,8){$X$}{$Y$} +\tzto[out=-10,in=105]"PPC"(0,7)(6,0){PPC}[ar] +\tzvXpointat*{PPC}{2}(E) +\tztangent[blue]"tan"{PPC}(E)[0:8] +\tzvXpointat*{tan}{4}(F) +\tzplotcurve[densely dashed,red](2,7)(F)(8,4); +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{Edgeworth box} +\label{si:edgeworth} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(9,7) +\tzaxes(9,7){$x_1$}{$y_1$} +\tzaxes<8,6>(8,6)(-1,-1){$x_2$}[l]{$y_2$}[b] +\tzshoworigin{$O_1$} +\tzshoworigin(8,6){$O_2$}[ar] +\tzto[bend right](2,5)(7,2){$u_1$}[r] +\tzto[bend left](1,4)(6,1){$u_2$}[b] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Growth} +\label{si:growth} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(10,8) +\tzshoworigin +\tzaxes*(10,8){$k$}{$y$} % bounding box +\def\Fk{3*(\x)^(1/3)} +\def\sFk{2*(\x)^(1/3)} +\def\ndk{7/9*\x} +\tzfn\Fk[0:9]{$y=f(k)$}[r] % path name=Fk +\tzfn\sFk[0:9]{$sf(k)$}[r] % path name=sFk +\tzfn\ndk[0:9]{$(n+\delta)k$}[r] % path name=ndk +\tzXpoint*{sFk}{ndk}(E)[2]{$E$}[135] % 2nd X point +\tzvXpoint*{Fk}(E-2)(YE) % 2nd X point +\tzproj(YE){$k^*$}{$y^*$} +\tzvXpointat*{Fk}{2}(A) +\tzvXpointat*{sFk}{2}(B) +\tzvXpointat*{ndk}{2}(C) +\tzproj(A){$k_0$}{$y_0$} +\tzprojy(B){$sf(k_0)$} +\tzprojy(C){$(n+\delta)k_0$} +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{Liquidity trap} +\label{si:trap} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(10,8) +\tzshoworigin +\tzaxes(10,8){$Y$}{$r$} +\tzline"LM"(1,2)(5,2) +\tzto[out=0,in=-95](5,2)(8,6){$LM$}[a] +\tzto[dashed,out=0,in=-95](5,2)(9.5,6){$LM'$}[a] +\tzLFn"IS"(4,2){-1}[5:1]{$IS$}[a] +\tzLFn[dashed]<1,0>"ISa"(4,2){-1}[5:1]{$IS'$}[a] % shift +\tzXpoint{IS}{LM}(E) +\tzXpoint{ISa}{LM}(E1) +\tzproj(E){$Y^*$}{$r_0$} +\tzprojx(E1){$Y'$} +\end{tikzpicture} +\end{tzcode} + +$LM$ curves are drawn with two paths. +To shift the $IS$ curve, |<shift coor>| is used. See Section \ref{s:tzLFn} on page \pageref{s:tzLFn} for more details. + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +%\tzhelplines(10,8) +\tzshoworigin +\tzaxes(10,8){$m$}{$r$} +\tzto[out=-88,in=180](1,7)(5,2) + <--(9,2) node [r] {$m^d$}> % code.append +\tzvfnat{5}[0:6]{$m^s_0$}[a] +\tzvfnat{6.5}[0:6]{$m^s_1$}[a] +\tzvfnat{8}[0:6]{$m^s_2$}[a] +\tzprojy(5,2){$r_0$} +\tzticksx{5/{$m_0$},6.5/{$m_1$},8/{$m_2$}} +\end{tikzpicture} +\end{tzcode} + +The money demand ($m_d$) curve is drawn with one path. +To do this, |<code.append>| is used. +See Section \ref{s:tzto} on page \pageref{s:tzto} for more details. + + +%%------------------------------------------------------------ +\section{Miscellany} +\label{si:misc} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[font=\scriptsize] +\def\z{1} +\tzcoors + (0,0)(A) + ($(A) + (45:\z)$)(B) + ($(B) + (45:\z)$)(C) + ($(A) + (-45:\z)$)(D) + ($(D) + (45:\z)$)(E) + ($(E) + (45:\z)$)(F) + ($(D) + (-45:\z)$)(G) + ($(G) + (45:\z)$)(H) + ($(H) + (45:\z)$)(I); + +\foreach \a in {A,...,I} + { \tzdot*(\a){\a} + } + +\tzlines(D)(A)(B)(C)(F)(E)(D)(G)(H)(I)(F); +\tzlines[red](B)(E)(H); +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=1,font=\scriptsize] +\tzaxes(4,4){alternatives}{preferences} +\tzticksx{1/$a$,2/$b$,3/$c$} +\tzplot[mark=ball](1,3)(2,2)(3,1){A}[0]; +\tzplot[mark=*,mark color=red](1,2)(2,1)(3,3){B}[0]; +\tzplot[mark=+](1,1)(2,3)(3,2){C}[0]; +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=1,font=\scriptsize] +\tzaxes(4,4){alternatives}{preferences} +\tzticksx{1/$a$,2/$b$,3/$c$} +\foreach \x in {1,2,3} + {\foreach \y in {1,2,3} + {\tzdot*(\x,\y)} + } +\tzlines(1,3)(2,2)(3,1){A}[r]; +\tzlines(1,2)(2,1)(3,3){B}[r]; +\tzlines(1,1)(2,3)(3,2){C}[r]; +\end{tikzpicture} +\end{tzcode} + + diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc-C-v1.0.tex b/graphics/pgf/contrib/tzplot/tzplot-doc-C-v1.0.tex new file mode 100644 index 0000000000..36320a2bfd --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc-C-v1.0.tex @@ -0,0 +1,3981 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%========================== +\part{Points, Lines, and Curves} +%%%========================== +\label{p:linesandcurves} + + +%%================================== +\chapter{Getting Ready} +\label{c:gettingready} + +%%------------------------------------------------------------ +\section{Styles: \texttt{tzdotted}, \texttt{tzdashed}, \texttt{tzhelplines}} +\label{s:styles:tzhelplines} + +The styles \ixttw{tzdotted}, \ixttw{tzdashed}, and \ixttw{tzhelplines} are defined as follows: + +\begin{tzsty}{} +% styles: tzdotted, tzdashed, tzhelplines +\tikzset{% + tzdotted/.style={line cap=round,dash pattern=on 0pt off 1cm/(#1)}, + tzdotted/.default=10 +} +\tikzset{% + tzdashed/.style={dashed=none,dash pattern=on 5mm/(#1) off 5mm/(#1)}, + tzdashed/.default=10 +} +\tikzset{% + tzhelplines/.style={help lines,-,tzdotted} +} +\end{tzsty} + +The style |tzdotted| and |tzdashed| prints 10 dots and 10 dashes per 1cm, respectively, by default. +The style |tzhelplines| uses |tzdotted| by default. + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzhelplines}, \protect\cmd{\tzhelplines*}} +\label{s:tzhelplines} + +\icmd{\tzhelplines} draws |grid| from the first coordinate to the second coordinate. +If only one coordinate is specified, then the first coordinate is regarded as |(0,0)|. + +The starred version \icmd{\tzhelplines*} uses the grid as a \iisw{bounding box}. + +\begin{tzdef}{} +% syntax: minimum +\tzhelplines(<coor>) +% syntax: full +\tzhelplines[<opt>](<coor1>)(<coor2>) +% defaults + [help lines,tzdotted=10](<m>)() +% (<m>): mandatory argument +\end{tzdef} + +Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument. + +\begin{tztikz}{} +\tzhelplines(4,3) % works similarly to: + \draw [help lines] (0,0) grid (4,3); + +\tzhelplines(1,1)(4,3) % works similarly to: + \draw [help lines] (1,1) grid (4,3); +\end{tztikz} + + +By default, |\tzhelplines| prints |grid| with |10| dots per |1cm|. +|\tzhelplines| with the option value |[tzdotted=<n>]| prints |<n>| dots per |1cm|. +(That is, the default value is |tzdotted=10|.) + +\begin{tzcode}{.3} +% \tzhelplines +\begin{tikzpicture} +\tzhelplines(2,2) +\draw [help lines] (3,0) grid (5,2); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% tzdotted: (default: 10 dots per 1cm) +\begin{tikzpicture} +\tzhelplines[thick](1,2) % 10 dots +\tzhelplines[thick,tzdotted=20](2,0)(3,2) % 20 dots +\tzhelplines[thick,tzdotted=5](4,0)(5,2) % 5 dots +\end{tikzpicture} +\end{tzcode} + +With the option value, |[tzdotted=<n>/<d>]|, |\tzhelplines| prints |<n>| dots per |<d>cm|. + +Similarly for |tzdashed|. + +\begin{tzcode}{.3} +% tzdotted, tzdashed +\begin{tikzpicture} +\tzhelplines[thick,tzdashed](4,2) +\tzhelplines[thick,step=.5](4,2) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% scaled: 7 dots per .7cm (10 dots per hard 1cm) +\begin{tikzpicture}[scale=.7] +\tzhelplines[tzdashed](4,3) +\tzhelplines[step=.5](4,3) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% scaled: 10/.7 means 10 dots per .7cm +\begin{tikzpicture}[scale=.7] +\tzhelplines[tzdashed=10/.7](4,3) %% +\tzhelplines[step=.5,tzdotted=10/.7](4,3) %% +\end{tikzpicture} +\end{tzcode} + + + +%%================================== +\chapter{Dots} +\label{c:dots} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcdot(*)}: A small circle} +\label{s:tzcdot} + +A dot is usually expressed by a small circle. +\icmd{\tzcdot} prints a circle dot \tikz \tzcdot(0,0);. + +The starred version \icmd{\tzcdot*} prints a filled circle dot \tikz \tzcdot*(0,0);. +The \xem{radius} of the circle is |1.2pt|, by default. + +\begin{tzdef}{} +% syntax: minimum +\tzcdot(<coor>) +% syntax: medium +\tzcdot*(<coor>){<label>}[<angle>](<radius>) +% syntax: full +\tzcdot*[<opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<radius>) +% defaults + *[ solid,thin,tzcdot=1.2pt ]<>(<m>){}[](1.2pt) +% tzcdot is a predefined key (in this package). +% (<m>): mandatory +\end{tzdef} + +Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument. All others are optional arguments. + +\paragraph{How to change the size} +There are three ways to change the \xem{radius} of a circle dot drawn by |\tzcdot|. + +\begin{enumerate} +\item The simplest way is to use the last parenthesis option, like |\tzcdot(0,0)(3pt)|. + +\begin{tztikz}{} +\tzcdot(0,0) or \tzcdot(0,0)(1.2pt) % is an abbreviation of: + \draw (0,0) circle (1.2pt); % default radius=1.2pt +\end{tztikz} + +\begin{tztikz}{} +\tzcdot*(0,0)(3pt) % is an abbreviation of: + \draw [fill] (0,0) circle (3pt); +\end{tztikz} + +\item +You can use the key-value option |[tzcdot=<dim>]|, like |\tzcdot[tzcdot=3pt](0,0)|, to change the \xem{radius} of a circle dot. The |tzcdot| key is defined in the package. +If both the |tzcdot| key-value and the last parenthesis option are used, the former wins. + +\begin{tztikz}{} +\tzcdot\tzcddot[tzcdot=1.2pt](1,1) or \tzcdot(1,1) % works like: + \draw (1,1) circle [radius=1.2pt]; % default radius=1.2pt +\end{tztikz} + +\begin{tztikz}{} +\tzcdot*[tzcdot=3pt] % works like: + \draw [fill] (0,0) circle [radius=3pt]; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzcdot(*) +\begin{tikzpicture} +\tzhelplines(4,2) +\tzcdot(0,0) \tzcdot[tzcdot=4pt](1,1) +\tzcdot*(2,1)(2pt) \tzcdot*(3,0)(3pt) +\end{tikzpicture} +\end{tzcode} + +\item +Another way to change the radius is to use a macro, like |\settzcdotradius{3pt}|, +It is effective within the |tizpicture| environment unless changed by \icmd{\settzcdotradius} again. + +\begin{tzcode}{.3} +% \settzcdotradius +\begin{tikzpicture} +\tzhelplines(4,2) +\settzcdotradius{4pt} +\tzcdot(0,0) \tzcdot(1,1) +\tzcdot*(2,1)(2pt) \tzcdot*(3,0) +\end{tikzpicture} +\end{tzcode} + +\end{enumerate} + + +\paragraph{How to label} +You can add a label to a specified coordinate by adding the optional argument |{<label>}| immediately after |(<coor>)|. You can also change the |<label>| position by the option |[<angle]|. +(Note that you \xem{cannot} use the abbreviations such as |a|, |r|, |bl|, etc. to place label nodes.) + +\begin{tztikz}{} +\tzcdot(0,0){A} % is an abbreviation of: + \draw (0,0) circle (1.2pt) node [label={:A}] {}; + +\tzcdot(0,0)(2pt){A}[[blue]0] % is an abbreviation of: + \draw (0,0) circle (2pt) node [label={[blue]0:A}] {}; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzcdot: labels +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdot(0,0){A} % default position: 90 or above +\tzcdot[tzcdot=4pt](1,1){B}[0] +\tzcdot*(2,1){C}[45](2pt) +\tzcdot*(3,0){D}[-90](3pt) +\tzcdot(4,3){E}[-90](6pt) +\end{tikzpicture} +\end{tzcode} + +The position does not depend on the size of dot circles. + +\paragraph{How to change colors} +With the first optional argument |[<opt>]| you can change the color of a dot. +You can also change the color of a label, as shown in the following example. + +\begin{tzcode}{.3} +% \tzcdot(*) +\begin{tikzpicture} +\draw [help lines] (0,0) grid (4,3); +\tzcdot(0,0){A} +\tzcdot*[red](1,0){\textbf{B}}[45] +\tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt) +\tzcdot[tzcdot=2*7pt](3,2){big}[center] +\tzcdot*[fill=red,text=blue](4,3){D}(2*3pt) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} +Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed. + +\begin{tzcode}{.3} +% \tzcdot: shift +\begin{tikzpicture} +\draw [help lines] (0,0) grid (4,3); +\tzcdot(0,0){A} +\tzcdot*[red]<0,2>(1,0){\textbf{B}}[45] % shift +\tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt) +\tzcdot[tzcdot=2*7pt]<1,-1>(3,2){big}[center] % shift +\tzcdot*[fill=red,text=blue](4,3){D}(2*3pt) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzcdot: repeated +\begin{tikzpicture} +\tzhelplines(4,2) +\foreach \x in {0,...,4} + { \foreach \A in {2,4,6,8} + { \tzcdot[blue] (\x,0)(\A pt) } } +\foreach \x in {0,...,4} + { \foreach \A in {2,4,6,8} + { \tzcdot[red]<1,1>(\x,0)(\A pt) } } % shift +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcdots(*)}: Multiple circle dots} +\label{s:tzcdots} + +The macro \icmd{\tzcdots} takes an arbitrary number of coordinates as arguments to print multiple circle dots with the radius |1.2pt|, by default. +You need to indicate when the iteration of an arbitrary number of coordinates ends, by typing a \xem{semicolon} |;|. +Let us call this kind of macro a \iisw{semicolon version}. + +\remark +\begin{itemize} +\item DO NOT FORGET to enter `|;|' at the end of iteration. + \begin{itemize} + \item Tokens such as `|!|' and `|#|' other than the open parenthesis `|(|' works like the semicolon `|;|' to indicate the end of iteration. + But it is highly recommended to use `|;|' for consistency. + \end{itemize} +\item Without |;|, the macro does nothing or a compile error occurs. +\end{itemize} + + +The starred version |\tzcdots*| prints multiple filled dots. + +\begin{tzdef}{} +% syntax: minimum +\tzcdots*(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: full +\tzcdots*[<opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>] + ..repeated.. (){}[] ; (<dot radius>) +% defaults + *[tzcdot=1.2pt]<>(<m>){}[]..repeated..(){}[] ; (1.2pt) +\end{tzdef} + +\begin{tzcode}{.3} +% \tzcdots(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdots(0,0)(1,1)(2,1)(3,2)(4,0); +\tzcdots*(0,3)(1,2)(2,2)(3,3)(4,3); +\end{tikzpicture} +\end{tzcode} + +\paragraph{How to label} + +Each coordinate can be followed by the optional arguments |{<label>}| and |[<angle>]| to label dots. So the repeating pattern is the triple |(<coor>){<label>}[<angle>]|. + +\begin{tzcode}{.3} +% \tzcdots: label +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdots(0,0){A} + (1,1) + (2,1){C}[0] + (3,2){D}[-90] + (4,0){E}; +\tzcdots*(0,3)(1,2){B}(2,2){C}[45](3,3)(4,3); +\end{tikzpicture} +\end{tzcode} + +\paragraph{How to change the size of dots} + +There are three ways of changing the \xem{radius} of dots. +\begin{enumerate} +\item The simplest way is to use the \xem{last} parenthesis optional argument, \xem{after the semicolon}. +\item Another way is to use the \ixxw{tzcdot} key, like |\tzcdots[tzcdot=3pt]...|. +If both options are used the key-value option wins. +\item You can also use the macro \icmd{\settzcdotradius}. +The effect remains within the |tikzpicture| environment unless it is changed again. +\end{enumerate} + +\begin{tzcode}{.3} +% \tzcdots: size (radius) +\begin{tikzpicture} +\tzhelplines(4,3) +\settzcdotradius{3pt} +\tzcdots(0,0)(1,0){3pt}; +\tzcdots*(1,1)(2,1){1pt};(1pt) % simplest +\tzcdots[tzcdot=5pt](2,2)(3,2){5pt}; +\tzcdots*(3,3)(4,3){3pt}; +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{How to change colors} + +With the first optional argument |[<opt>]|, you can change the color of dots. +You can also change the color of all labels together using the first optional argument, +like |\tzcdots[text=red]...| as shown in the following example. + +\begin{tzcode}{.3} +% \tzcdots: color +\begin{tikzpicture} +\tzhelplines(4,3) +\settzcdotradius{3pt} +\tzcdots*[red] + (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0); +\tzcdots*[thick,blue,fill=green,text=red] + (1,2){A}(2,2){Ben}[[blue]-90](3,2){C}(4,2){D};(4pt) +\tzcdots*[blue] + (1,3){A}(2,3){B}(3,3){C}(4,3){D}; +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzcdots: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E}; +\tzcdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E}; +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzdot(*)}: A single node dot} +\label{s:tzdot} + +The macro \icmd{\tzdot} prints a small circle node \tikz \tzdot(0,0);, as a dot, with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default. + +The starred version \icmd{\tzdot*} prints a filled dot \tikz \tzdot*(0,0);. + +\begin{tzdef}{} +% syntax: minimum +\tzdot(coor) +% syntax: medium +\tzdot*(<coor>){<label>}[<angle>](<dot size>) +% syntax: full +\tzdot*[<node opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<dot size>) +% defaults + *[ tzdot=2.4pt ]<>(<m>){}[](2.4pt) +% the style tzdot is predefined +% (<m>): mandatory +\end{tzdef} + +|\tzdot(*)| accepts one mandatory argument, denoted by |(|\ixxw{<m>}|)|. All others are optional. + +The style \ixxw{tzdot} is defined as follows: + +\begin{tzsty}{} +% style: tzdot +\tikzset{ + tzdot/.style={draw,circle,solid,thin,inner sep=0pt,minimum size=#1}, + tzdot/.default=2.4pt +} +\end{tzsty} + + +\subsection{{\normalfont\scshape Three Ways} to change the size of node dots} +\label{ss:threeways} + +There are \iscw{Three Ways} to change the \xem{diameter} (or |minimum size|) of a node dot drawn by |\tzdot(*)|. + +\begin{enumerate} +\item Use the predefined style |tzdot| in the first optional agrument, like |\tzdot[tzdot=5pt](0,0)|, which gives the same result as |\tzdot[minimum size=5pt](0,0)|. + +\begin{tztikz}{} +\tzdot(0,0) % works like: + \path (0,0) node [tzdot=2.4pt] {}; % default size +% or equivalently + \node [tzdot,minimum size=2.4pt] at (0,0) {}; +\end{tztikz} + +\item The simplest way is to use the last parenthesis optional argument, like |\tzdot(0,0)(5pt)|, which yields the same result as in |\tzdot[tzdot=5pt](0,0)|. +If both options are used, the |tzdot| (or |minimum size|) option overwrites the last parenthesis option. + +\begin{tzcode}{.3} +% \tzdot(*) +\begin{tikzpicture} +\tzhelplines(4,2) +\tzdot(0,0) \tzdot[tzdot=8pt](1,1) +\tzdot*(2,1)(4pt) \tzdot*(3,0)(6pt) +\end{tikzpicture} +\end{tzcode} + +\item To change the size of all node dots draw by |\tzdot*|, you can use the macro |\settzdotsize|. Its effect remains until the end of |tikzpicture| environment unless changed again. + +\begin{tzcode}{.3} +% \settzdotsize +\begin{tikzpicture} +\tzhelplines(4,2) +\settzdotsize{8pt} +\tzdot(0,0) \tzdot(1,1) +\tzdot*(2,1)(4pt) \tzdot*(3,0) +\end{tikzpicture} +\end{tzcode} + +\end{enumerate} + +\subsection{How to label} +\label{ss:tzdot:label} + +You can add a label to a specified coordinate by specifying the optional argument |{<label>}| immediately after the coordinate |(<coor>)|. + +You can also change the label position by the option |[<angle>]| following |{<label>}|. + +\begin{tztikz}{} +\tzdot(0,0){A}(3pt) % works like: + \path (0,0) node [tzdot=3pt,label={:A}] {}; + +\tzdot*(0,0){A}[[red]0](3pt) % works like: + \path (0,0) node [fill,tzdot=3pt,label={[red]0:A}] {}; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzdot: labels +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdot(0,0){A} +\tzdot(1,1){B}[0](8pt) +\tzdot*(2,1){C}[45](4pt) +\tzdot*(3,0){D}[-90](6pt) +\tzdot(4,3){E}[-90](12pt) +\end{tikzpicture} +\end{tzcode} + +Unlike |\tzcdot|, the |\tzdot|'s label position depends on the size of a circle node. In \Tikz\ jargon, |{<label>}| is a \iisw{label node} for a \iisw{main node} that is a circle node with no text in it. + + +\subsection{How to change colors and shapes} +\label{ss:tzdot:color} + +With the first optional argument |[<node opt>]| you can change of the color or shape of dots. +You can also change the label color using |[<label opt>]| as shown in the example below. + +\remark +\begin{itemize} +\item |[<node opt>]| is for options of \xem{main nodes}, |[<label opt>]| is for options of \xem{label nodes}. +\item |[<label opt>]| is used in the form of |[[<label opt>]angle>]|. +\end{itemize} + +\begin{tzcode}{.3} +% \tzdot: color +\begin{tikzpicture} +\draw [help lines] (0,0) grid (4,3); +\tzdot(0,0){A} +\tzdot*[red](1,0){\textbf{B}}[45] +\tzdot*[red,fill=green](2,1){green}[[blue]0](2*10pt) +\tzdot[tzdot=4*7pt](3,2){big}[center] +\tzdot*[fill=red](4,3){D}(4*3pt) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzdot: shape +\begin{tikzpicture} +\draw [help lines] (0,0) grid (4,3); +\tzdot[regular polygon](0,0){A}(10pt) +\tzdot*[red](1,0){\textbf{B}}[45] +\tzdot*[red,fill=green,rectangle](2,1){green}[0](2*10pt) +\tzdot[tzdot=4*7pt](3,2){big}[center] +\tzdot*[fill=red,star](4,3){D}(4*3pt) +\end{tikzpicture} +\end{tzcode} + + + +\subsection{How to move: \texttt{shift}} +\label{ss:tzdot:shift} + +Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed. + +\begin{tzcode}{.3} +% \tzdot: shift +\begin{tikzpicture} +\draw [help lines] (0,0) grid (4,3); +\tzdot[regular polygon](0,0){A}(10pt) +\tzdot*[red]<0,2>(1,0){\textbf{B}-shifted}[45] % shift +\tzdot*[red,fill=green,rectangle](2,1){green}[0](2*10pt) +\tzdot[tzdot=4*7pt]<1,-1>(3,2){big}[center] % shift +\tzdot*[fill=red,star](4,3){D}(4*3pt) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzdot: repeated +\begin{tikzpicture} +\tzhelplines(4,2) +\foreach \x in {0,...,4} + { \foreach \A in {1,2,3,4} + { \tzdot[blue] (\x,0)(2*\A mm) } } +\foreach \x in {0,...,4} + { \foreach \A in {1,2,3,4} + { \tzdot[green]<1,1>(\x,0)(2*\A mm) } } % shift +\end{tikzpicture} +\end{tzcode} + + +\subsection{Comparison: \protect\cmd{\tzdot} and \protect\cmd{\tzcdot}} +\label{ss:tzdot:comparison} + +The most important difference between |\tzcdot| and |\tzdot| is that |\tzcdot| is affected by \Tikz's scaling factor, but |\tzdot| is not. +This is critical when |xscale| is not equal to |yscale|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[xscale=1.6,yscale=.8] +\tzhelplines(3,3) +\tzcdot(0,0)(3pt) % dostorted +\tzdot(1,0)(6pt) +\tzcdots*(1,1)(2,1)(3,1);(2pt) % distorted +\tzdots*(1,2)(2,2)(3,2);(4pt) +\end{tikzpicture} +\end{tzcode} + +The following table further shows the differences between them. +%Everything else is the same for end-users. + +\begin{tzcode}[listing only,colback=green!10!white]{.3} +% concept % single % multi % size control % [key=default size] +node [circle] \tzdot \tzdots \settzdotsize [tzdot=2.4pt] % diameter +circle \tzcdot \tzcdots \settzcdotradius [tzcdot=1.2pt] % radius +\end{tzcode} + +\remark +\begin{itemize} +\item In \Tikz, a `node' is `not' affected by `scaling' unless the \Tikz\ option |transform shape| is used together. +|\tzdot| is also useful for labelling a large dot. + \begin{itemize} + \item In |\tzdot|, |<label>| is a label in a \iisw{label node} for a node dot (as a \iisw{main node}). + So if a node dot gets larger, its label moves accordingly. + (Unlike, a label with |\tzcdot| or |\tzcdots|.) + \item The position of |<label>| in |\tzcdot| does not depend on the size of dots. + \end{itemize} +\item The package |tzplot| takes |\tzdot| as a \xem{standard dot}, not |\tzcdot|. +So, you can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of any standard dots. +\end{itemize} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzdots(*)}: Multiple node dots} +\label{s:tzdots} + +\icmd{\tzdots} takes an arbitrary number of coordinates as arguments to print multiple node circle dots with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default. + +This is a \iisw{semicolon version} macro, with the whole repeating pattern |(<coor>){<label>}[<angle>]|, which means that you need to type a \xem{semicolon} |;| at the end of the repetition. The \xem{semicolon} says, ``\xem{The repetition ends here}." + +\remark +\begin{itemize} +\item DO NOT FORGET to enter `|;|' at the end of iteration. + \begin{itemize} + \item Tokens such as `|!|' and `|#|' other than the open parenthesis `|(|' works like the semicolon `|;|' to indicate the end of iteration. + But it is highly recommended to use `|;|' for consistency. + \end{itemize} +\item Without |;|, the macro does nothing or a compile error occurs. +\end{itemize} + +The starred version \icmd{\tzdots*} prints multiple filled node dots. + +\begin{tzdef}{} +% syntax: minimum +\tzdots*(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: full +\tzdots*[<node opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>] + ..repeated.. (){}[] ; (<dot size>) +% defaults + *[tzdot=2.4pt]<> (<m>){}[] ..repeated.. (){}[] ; (2.4pt) +\end{tzdef} + +\begin{tzcode}{.3} +% \tzdots(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots(0,0)(1,1)(2,1)(3,2)(4,0); +\tzdots*(0,3)(1,2)(2,2)(3,3)(4,3); +\end{tikzpicture} +\end{tzcode} + +\paragraph{How to label} + +Each coordinate can be followed by the optional arguments |{<label>}| and |[<angle>]| to label dots. So the triple |(<coor>){<label>}[<angle>]| is the whole repeating pattern. + +\begin{tzcode}{.3} +% \tzdots: label +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots(0,0){A} + (1,1) + (2,1){C}[0] + (3,2){D}[-90] + (4,0){E}; +\tzdots*(0,3)(1,2){B}(2,2){C}[45](3,3)(4,3); +\end{tikzpicture} +\end{tzcode} + + +\paragraph{How change the size of dots} + +There are \threeways\ of changing the \xem{diameter} of node dots, as discussed in Section \ref{ss:threeways} on page \pageref{ss:threeways}. + +\begin{enumerate} +\item The simplest way is to use the `last' parenthesis optional argument, \xem{after the semicolon}. +\item Another way is to use the style \ixxw{tzdot}, like |\tzdots[tzdot=3pt]...|. +If both options are used the |tzdot| option style wins. +\item You can also use the macro \icmd{\settzdotsize}. +The effect remains within the |tikzpicture| environment unless it is changed again. +\end{enumerate} + +\begin{tzcode}{.3} +% \tzdots: size (diameter) +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{3mm} +\tzdots(0,0)(1,0){3mm}; +\tzdots*(1,1)(2,1){2mm};(2mm) % simplest +\tzdots[tzdot=4mm](2,2)(3,2){4mm}; +\tzdots*(3,3)(4,3){3mm}; +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{How to change colors} + +With the first optional argument |[<node opt>]| you can change of the color of node dots. +You can also change the color of each label by |[<label opt>]|. + +\begin{tzcode}{.3} +% \tzdots: color +\begin{tikzpicture}[->] +\tzhelplines(4,3) +\settzdotsize{6pt} +\tzdots*[red] + (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0); +\tzdots*[thick,blue,fill=green] + (1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt) +\tzdots*[blue] + (1,3){A}(2,3){B}(3,3){C}(4,3){D}; +\end{tikzpicture} +\end{tzcode} + +\remark +\begin{itemize} +\item |[<node opt>]| is the option of a \iisw{main node} and |[<label opt>]| is the option of a \iisw{label node}. +\item |[<label opt>]| is used in the form of |[<[<label opt>]angle>]|, like |[[red]90]|. +\item You can control all labels together using |every label/.style| as in the following example. +\end{itemize} + +\begin{tzcode}{.3} +% \tzdots: every label/.style +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{6pt} +\tzdots*[red] + (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0); +\tzdots*[thick,blue,fill=green] + (1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt) +\tikzset{every label/.style={draw,text=red}} %% +\tzdots*[blue] + (1,3){A}(2,3){B}(3,3){C}(4,3){D}[0]; +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% every label/.style +\begin{tikzpicture}[every label/.style={draw,text=red}] +\tzhelplines(4,3) +\tzdots*(0,0){Ace}[[font=\LARGE\ttfamily]-90] + (2,1){\textbf{Bob}}[[blue]135] + (3,2){$C_1$\\$N_o$}[[align=center]0]; +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzdots: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E}; +\tikzset{every label/.style={red}} +\tzdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E}; +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Coordinates} +\label{c:coordinates} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcoor} and \protect\cmd{\tzcoor*}} +\label{s:tzcoor} + +\subsection{\protect\cmd{\tzcoor}} +\label{ss:tzcoor} + +For example, \icmd{\tzcoor}|(0,0)(A)| means that the coordinate |(0,0)| is named |(A)|. + +\begin{tztikz}{} +\tzcoor(0,0)(A) % is an abbreviation of: + \path (0,0) coordinate (A); + % or + \coordinate (A) at (0,0); +\end{tztikz} + +\begin{tzdef}{} +% syntax: minimum +\tzcoor(<coor>)(<name>) +% syntax: medium +\tzcoor(<coor>)(<name>){<label>}[<angle>] +% syntax: full +\tzcoor<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>] +% defaults + <>(<m>)(<m>){}[] +\end{tzdef} + +Here, |<m>| stands for `mandatory.' |\tzcoor| takes two mandatory arguments in parenthesis. + +\paragraph{How to label} +You can put a label to a coordinate by specifying the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|. + +\begin{tztikz}{} +\tzcoor(0,0)(A){$A$}[0] % works like: + \path (0,0) coordinate [label={0:$A$}] (A); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzcoor +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor(0,0)(A){$A_1$} % Tikz default: 90 or above +\tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0] +\draw (A) -- (B); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the coordinate by specifying the optional argument |<shift coor>| before |(<coor>)|. + +\begin{tzcode}{.3} +% \tzcoor: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor<0,1>(0,0)(A){$A_1$} %% +\tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0] +\tzline(A)(B) +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzcoor*}} +\label{ss:tzcoor*} + +The starred version \icmd{\tzcoor*} works like |\tzcoor| with one exception. It prints a `node dot' of the size |2.4pt|, by default, at a specified coordinate. + +\begin{tzdef}{} +% syntax: minimum +\tzcoor*(<coor>)(<coor name>) +% syntax: medium +\tzcoor*(<coor>)(<coor name>){<label>}[<angle>] +% syntax: full +\tzcoor*[<dot opt>]<shift coor> + (<coor>)(<name>){<label>}[[<label opt>]<angle>](<dot size>) +% defaults + *[]<>(<m>)(<m>){}[](2.4pt) +\end{tzdef} + + +\begin{tztikz}{} +\tzcoor*(0,0)(A) % works like: + \path (0,0) coordinate (A); + \tzdot*(0,0) +\end{tztikz} + +\begin{tztikz}{} +\tzcoor(0,0)(A){$A$}[right] % works like: + \path (0,0) coordinate (A); + \tzdot*(0,0){$A$}[right] +\end{tztikz} + +\begin{tzcode}{.3} +% \tzcoor +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor*(0,0)(A){$A_1$} % Tikz default: 90 or above +\tzcoor*(30:3cm)(B){$B_2$}[[draw,blue]0] +\draw (A) -- (B); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Changing the color and size of a dot} + +You can change the color of a dot by specifying |[<dot opt>]|, which is, in fact, \Tikz\ node option. +To change the size of dots, you can apply the \threeways\ (see Subsection \ref{ss:threeways} on page \pageref{ss:threeways}). + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor(1,1)(A){A} +\tzcoor*(2,1)(B){B}[0] +\tzcoor*[red](1,2)(C){C}[180] +\tzcoor*[fill=none,tzdot=5pt](3,2)(D){D}[45] +\tzcoor*[blue,thick,fill=green](4,0)(E){E}[180](6pt) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} The optional argument |<shift coor>| works just like in |\tzcoor|. + +\begin{tzcode}{.3} +% \tzcoor*: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor*<0,1>(0,0)(A){$A_1$} %% +\tzcoor*(2,1)(B){$B_2$\\end point}[[align=left,red]0] +\tzline(A)(B) +\end{tikzpicture} +\end{tzcode} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcoors} and \protect\cmd{\tzcoors*}: Semicolon versions} +\label{s:tzcoors} + +\subsection{\protect\cmd{\tzcoors}} +\label{ss:tzcoors} + +The macro \icmd{\tzcoors} takes an arbitrary number of pairs of coordinates and their names as arguments. +For example, |\tzcoors(0,0)(A) (1,1)(B) (2,2)(C);| means that |(0,0)| is represented by the name |(A)|, |(1,1)| by |(B)|, and |(2,2)| by |(C)|. + +\begin{tzdef}{} +% syntax: minimum +\tzcoors(<coor>)(<name>..repeated..(<coor>)(<name>) ; +% syntax: full +\tzcoors <shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>] + ..repeated.. ()(){}[] ; +% defaults + (<m>)(<m>){}[] ..repeated.. ()(){}[] ; +\end{tzdef} + +This is a \xem{semicolon version} macro. The quadruple |(<coor>)(<name>){<label>}[<angle>]| is the whole repeating pattern. +It is required to type a \xem{semicolon} (|;|) to indicate when the repetition ends. + + +\begin{tztikz}{} +\tzcoors (0,0)(A) (1,1)(B) (2,1)(C) (3,0)(D) ; % works like: + \path (0,0) coordinate (A) + (1,1) coordinate (B) + (2,1) coordinate (C) + (3,0) coordinate (D); +\end{tztikz} + +\begin{tztikz}{} +\tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C}[0] (3,0)(D){D}[90]; % works like: + \path (0,0) coordinate (A) + (1,1) coordinate (B) + (2,1) coordinate [label={0:C}] (C) + (3,0) coordinate [label={90:D}] (D); +\end{tztikz} + +You can add a label to each specified coordinate by adding the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|. + +\begin{tzcode}{.3} +% \tzcoors +\begin{tikzpicture} +\tzcoors (0,0)(A){Ace}[[font=\LARGE\ttfamily]-90] + (2,1)(B){\textbf{Bob}}[[blue]135] + (3,2)(C){$C_1$\\$N_o$}[[align=center]0]; +\draw (A) -- (B) -- (C); +\end{tikzpicture} +\end{tzcode} + +By the option |<shift coor>|, all specified coordinates are shifted. + +\begin{tzcode}{.3} +% \tzcoors +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D); +\tzlines(A)(B)(C)(D); +% shift +\tzcoors <1,1> (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D); +\tzlines[dashed](A)(B)(C)(D); +\end{tikzpicture} +\end{tzcode} + +\subsection{\protect\cmd{\tzcoors*}} +\label{ss:tzcoors*} + +The starred version \icmd{\tzcoors*} takes an arbitrary number of coordinates as arguments to print node dots at the coordinates. Full repeating pattern is |(<coor>)(<name>){<label>}[<angle>]|. It is required to type a \xem{semicolon} |;| to indicate when the iteration of coordinates ends. + +\begin{tzdef}{} +% syntax: minimum +\tzcoors*(<coor>)(<name>)..repeated..(<coor>)(<name>) ; +% syntax: full +\tzcoors*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>] + ..repeated.. ()(){}[] ; (<dot size>) +% defaults + *[](<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt) +\end{tzdef} + +You can label each dot by specifying the optional arguments |{<label>}| and |[<angle>]| after the pair |(<coor>)(<name>)|. + +\begin{tzcode}{.3} +% \tzcoors* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(0,0)(A) + (1,1)(B){B} + (2,1)(C) + (3,3)(D){D}[0] ; +\end{tikzpicture} +\end{tzcode} + +You can change the dot color by |[<dot opt>]| and the label color by |[label opt]|. +You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the dot size. The simplest way of changing the dot size is to specify the `last' (even after the semicolon) parenthesis option |(<dot size>)|. + +\begin{tzcode}{.3} +% \tzcoors* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*[red](0,0)(A) + (1,1)(B){B} + (2,1)(C) + (3,3)(D){D}[[blue]0] ; (6pt) +\end{tikzpicture} +\end{tzcode} + +By specifying the optional argument |<shift coor>| immediately before the first coordinate, you can move all specified coordinates. + +\begin{tzcode}{.3} +% \tzcoors*: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{6pt} +\tzcoors*[red] (0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D); +\settzdotsize{4pt} +\tzcoors*[blue]<.5,0>(0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D); +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcoorsquick} and \protect\cmd{\tzcoorsquick*}} +\label{s:tzcoorsquick} + +\subsection{\protect\cmd{\tzcoorsquick}} +\label{ss:tzcoorsquick} + +You can see the coordinate array at a glance using \icmd{\tzcoorsquick}, which displays specified names as text at the |center| of the coordinates, by default. + +\begin{tzdef}{} +% syntax: minimum +\tzcoorsquick(<coor>)(<name>)..repeated..(<coor>)(<name>) ; +% syntax: full +\tzcoorsquick<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>] + ..repeated.. ()(){}[] ; +% defaults + <> (<m>)(<m>){}[center] ..repeated.. ()(){}[] ; +\end{tzdef} + +\begin{tzcode}{.3} +% \tzcoorsquick +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick(0,0)(A) + (1,1)(Ben) + (2,1)(Cate) + (3,2)(Daniel); +\end{tikzpicture} +\end{tzcode} + +A label can be suppressed by the empty braces |{}|. +You can shift the coordinate by specifying |<shift coor>| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzcoorsquick: shift, color +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick + (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel); +\tikzset{every label/.style={blue}} +\tzcoorsquick <0,1> + (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel); +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzcoorsquick*}} +\label{ss:tzcoorsquick*} + +The starred version \icmd{\tzcoorsquick*} prints node dots on the coordinates and displays the names |above| (or |90| degree from) the dots, by default. + +\begin{tzdef}{} +% syntax: minimum +\tzcoorsquick*(<coor>)(<name>)..repeated..(<coor>)(<name>) ; +% syntax: full +\tzcoorsquick*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>] + ..repeated.. ()(){}[] ; +% defaults + *[ tzdot=1.2pt ]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; +\end{tzdef} + +\begin{tzcode}{.3} +% \tzcoorsquick* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick*(0,0)(A) + (1,1)(Ben) + (2,1)(Cate) + (3,2)(Daniel); +\end{tikzpicture} +\end{tzcode} + +A label can be suppressed by the empty braces |{}|. +You can change the dot size using the \threeways\ (on page \pageref{ss:threeways}). +You can shift the coordinate by specifying |<shift coor>| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzcoorsquick*: size, color, shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoorsquick* + (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel); +\tikzset{every label/.style={blue}} +\tzcoorsquick*[blue]<0,1> + (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel); (6pt) +\end{tikzpicture} +\end{tzcode} + +\remark +The first optional argument of |\tzcoorsquick*| is for only dots. +You can use the \Tikz\ option |every label/.style={...}| to control all the labels together. +You can also control each labels using |[<label opt>]| for each coordinate. + +\begin{tzcode}{.3} +% \tzcoorsquick* +\begin{tikzpicture}[every label/.style={draw,red}] +\tzhelplines(4,3) +\tzcoorsquick*[fill=none,blue,very thick] + (0,0)(A)(1,1)(B-1)(2,1)(C)(3,3)(D)[[blue]0];(8pt) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzgetxyval}} +\label{s:tzgetxyval} + +\icmd{\tzgetxyval} extracts the values of x-coordinate and the y-coordinate \xem{in the unit of centimeter} from a coordinate and saves the values in the user-defined macros, so that you can use them later. +For example, |\tzgetxyval(3,2){\xval}{\yval}| results in |\xval=3| and |\yval=2|. + +\begin{tzdef}{} +% syntax +\tzgetxyval(<coor>){<\macroXval>}{<\macroYval>} +% default +(<m>){<m>}{<m>} +\end{tzdef} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzfn"dem"{3-(3/4)*\x}[0:4] +\tzfn"sup"{\x}[0:4] +% intersection point: (E) +\tzXpoint*{dem}{sup}(E)(5pt) +% extract x/y-coordinate from (E) +\tzgetxyval(E){\Ex}{\Ey} +\tzdots*(\Ex,\Ey){E}(\Ex+1,\Ey){F}(\Ex,\Ey+1){G}; +\tzdot(E)(10pt) +\tznodeframe(2,0){x\;=\;\Ex\,cm\\ y\;=\;\Ey\,cm} + [font=\ttfamily\scriptsize,align=left] +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Plot Coordinates: \protect\cmd{\tzplot}: Semicolon Versions} +\label{c:plotcoordinates} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplot} and \protect\cmd{\tzplot*}: Syntax} +\label{s:tzplot} + +\icmd{\tzplot} takes an arbitrary number of coordinates as arguments. +Each |(<coor>)| can be followed by the optional arguments |{<label>}| and |[<angle>]| to label the coordinate. This is a \xem{semicolon version} and the whole repeating pattern is the triple |(<coor>){<label>}[<angle>]|. It is required to type a semicolon |;| to indicate when the coordinate iteration ends. + +The macro |\tzplot| draws connected line segments that link specified coordinates. + +\begin{tzdef}{} +% syntax: minimum +\tzplot(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: medium +\tzplot(<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>] ; +% syntax:full +\tzplot[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>" + (<coor>){<label>}[<[label opt]angle>] + ..repeated.. + (){}[] ; (<mark size>) <code.append> +% defaults + [tzmark=2pt]{0}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <> +\end{tzdef} + +The style \ixxw{tzmark} is defined as follows: + +\begin{tzsty}{} +% style: tzmark +\tikzset{ + tzmark/.style= + {mark options={solid,thin},mark size=#1}, + tzmark/.default=\tzmarksize +} +\end{tzsty} + +\icmd{\tzmarksize} is the \xem{radius} of a |mark| and the default is |2pt| as in \Tikz. +The value of |\tzmarksize| can be changed by the macro \icmd{\settzmarksize}, like |\settzmarksize{3pt}|. + + +The starred version |\tzplot*| draw connected line segments and print dot marks at specified coordinates. + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplot*}: Dots and marks} +\label{s:tzplot-dots} + +|\tzplot*| prints \Tikz\ marks (|*| by default) at specified coordinates. +You can change the mark color and mark style using the first bracket optional argument. + +\begin{tztikz}{} +\tzplot*(0,0)(1,2)(2,2)(3,3); % works like: + \draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) } ; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzplot* +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot*(0,0)(1,1)(2,1)(3,3); +\tzplot*[mark=o](0,3)(1,3)(2,2)(3,1); +\tzplot*[red](0,2)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Labels, marks, and marks size} +You can also add labels to specified coordinates with the optional arguments |{<label>}| and |[<angle>]| immediately after each |(<coor>)|. + +\begin{tztikz}{} +\tzplot*(0,0){A}[90](1,2)(2,2)(3,3){D}[0]; % works like: + \draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) } + node (0,0) [label={90:D}] {} + node (3,3) [label={0:D}] {} ; +\end{tztikz} + +There are three ways to change the mark size. + +\begin{enumerate} +\item The simplest way is to use the parenthesis optional argument |(<mark size>)|, \xem{immediately after the semicolon}. +\item You can use the style |\tzmark|, like |\tzmark=3pt|. +\item You can also use the macro |\settzmarksize|, which is effective until the end of |tikzpicture| environment. +\end{enumerate} + +\begin{tzcode}{.3} +% \tzplot*: label, size +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot*(0,0){A}(1,1)(2,1)(3,3){D}[[blue]0];(1mm) +\tzplot*[mark=o,tzmark=6pt](0,3)(1,3)(2,2)(3,1); +\settzmarksize{4pt} +\tzplot*[red](0,2){A}(1,2){B}(2,0){C}[[blue]0](3,2){D}; +\end{tikzpicture} +\end{tzcode} + +With |\tzplot*|, you can draw line segments by giving the |draw| option in the first bracket optional argument, like |\tzplot*[draw]|. + +\begin{tzcode}{.3} +% \tzplot*: line, more marks, size +\begin{tikzpicture}[scale=1] +\tzhelplines(4,3) +\settzmarksize{3pt} +\tzplot*[draw,mark=x](0,0)(1,1)(2,1)(3,3); +\tzplot*[blue,mark=diamond*](0,3)(1,3)(2,2)(3,1);(10pt) +\tzplot*[draw,dashed,red,mark=heart](0,2)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + +\remark In \Tikz, the |mark| shapes are affected by |scale|, |xscale|, and |yscale|. + +\begin{tzcode}{.3} +% \tzplot*: marks: distorted +\begin{tikzpicture}[yscale=.5] +\tzhelplines(4,3) +\settzmarksize{3pt} +\tzplot*[draw,mark=x](0,0)(1,1)(2,1)(3,3); +\tzplot*[blue,mark=diamond*](0,3)(1,3)(2,2)(3,1);(10pt) +\tzplot*[draw,dashed,red,mark=heart](0,2)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move specified coordinates using the option |<shift coor>| before the first coordinate (to be precise, immediately before the option |"<path name>"| if it exists). + +\begin{tzcode}{.3} +% \tzplot*: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot*[draw] (1,3){A}(2,3)(3,3)(4,3){D}[0]; +\tzplot*[draw,red]<-1,-1>(1,3){A}(2,3)(3,3)(4,3){D}[0]; +\tzplot*[draw,blue]<0,-3>(1,3){A}(2,3)(3,3)(4,3){D}[0]; +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplot}: Lines} +\label{s:tzplot-lines} + +|\tzplot| draws connected line segments connecting specified coordinates. + +\begin{tztikz}{} +\tzplot(0,0)(1,2)(2,2)(3,3); % works like: + \draw [tension=0] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ; +\end{tztikz} + +\begin{tztikz}{} +\tzplot[blue,smooth cycle]{1}(0,0)(1,2)(2,2)(3,3); % works like: + \draw [blue,tension=1] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ; +\end{tztikz} + +\paragraph{Options: draw, mark, plot} +You can use the optional argument |[<opt>]| to change the style of lines and marks. + +\begin{tzcode}{.3} +% \tzplot: line +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot (0,0)(1,1)(2,1)(3,3); +\tzplot[dashed,mark=o](0,3)(1,3)(2,2)(3,1); +\tzplot[red,mark=ball,mark options={ball color=purple}] + (0,1)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + +To close the path of |\tzplot| you can use the option |smooth cycle| in the first bracket optional argument |[<opt>]| or in the second bracket optional argument |[<plot opt>]|. + +\begin{tzcode}{.3} +% \tzplot: smooth cycle +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot (0,0)(1,1)(2,1)(3,3); +\tzplot[dashed,mark=o,smooth cycle] + (0,3)(1,3)(2,2)(3,1); +\tzplot[red,mark=*,mark options={blue}] + [smooth cycle] %% + (0,1)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{Labels} You can label specified coordinates with the options |{<label>}| and |[<angle>]| immediately after each |(<coor>)|. + +\begin{tzcode}{.3} +% \tzplot: label +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot(0,0){A}(1,1){B}[-90](2,1)(3,3){Da}[[draw]0]; +\tzplot[mark=o](0,3)(1,3){B}(2,2)(3,1){Db}[0]; +\tzplot[red,mark=*,draw=blue] + (0,1)(1,2){B}(2,0)(3,2){Dc}[[blue]0]; +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} You can also move the line segments by specifying the option |<shift coor>| before the first coordinate (to be precise, immediately before the option |"<path name>"| if it exists). + +\begin{tzcode}{.3} +% \tzplot: shift +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot <1,0>(0,0)(1,1)(2,1)(3,3){Da}[0]; +\tzplot[mark=o] <1,0>(0,3)(1,3)(2,2)(3,1){Db}[0]; +\tzplot*[draw,red]<1,0>(0,1)(1,2)(2,0)(3,2){Dc}[0]; +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{name path} for intersections} + +To find the intersection point of two lines, you may want to name the paths first, like |[name path=<path name>]| in \Tikz. With |\tzplot|, you can do it by specifying the quotation optional argument |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzplot: "path name" +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot[name path=Da] (0,0)(1,1)(2,1)(3,3){Da}[0]; +\tzplot[mark=o] "Db"(0,3)(1,3)(2,2)(3,1){Db}[0]; +\tzplot*[draw,red]"Dc"(0,1)(1,2)(2,0)(3,2){Dc}[0]; +% intersection points +\tzXpoint*[gray]{Da}{Db} +\tzXpoint*[blue]{Da}{Dc} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending the path} +In order to \xem{extend a path}, formed by |\tzplot|, \xem{from the last coordinate}, you can write \Tikz\ code in the very last optional argument |<code.append>|, \xem{after the semicolon}. + +\begin{tzcode}{.3} +% \tzplot: "path name" +\begin{tikzpicture}[scale=.8] +\tzhelplines(6,4) +\tzplot(0,0)(1,1)(2,1)(3,3){Da}[0];< -- (6,4) > +\tzplot[mark=o](0,3)(1,3)(2,2)(3,1){Db}[0];(4pt) +\tzplot[mark=ball,red](0,1)(1,2)(2,0)(3,2){Dc}[0]; + (5pt)< to [bend left] ++(2,-2) node {ends here!} > +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplot}: Curves} +\label{s:tzplot:curves} + +You can draw a curve with |\tzplot|, by specifying the optional argument |{<tension>}| before the coordinates or between the first and second bracket options (if they exist). +The default value of |tension| is |0|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot[tension=1](0,0)(1,1)(2,1)(3,3); +\tzplot[mark=o] (0,3)(1,3)(2,2)(3,1); % tension=0 +\tzplot*[draw,red,smooth cycle]{1} + (0,1)(1,2)(2,0)(3,2); +\end{tikzpicture} +\end{tzcode} + +To plot curves, the macro |\tzplotcurve| is provided. +Basically, |\tzplotcurve| is the |tension=1| version of |\tzplot|. +(See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve}.) + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplot}: Bars and combs} +\label{s:tzplot-bars} + +With |\tzplot|, you can draw bars or combs, using the \Tikz\ options |ybar|, |xbar|, |ycomb|, and |xcomb|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot*[draw](0,0)(1,1)(2,1)(3,3); +\tzplot[ybar](0,3)(1,3)(2,2)(3,1); +\tzplot[dashed,red,mark=heart](0,1)(1,2)(2,0)(3,2);%(5pt) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot[xbar](.5,2.5)(1,3)(2,2)(3,1); +\tzplot[xbar,bar width=2mm,fill,red!50] + (1,2.5)(1.5,2)(2,0)(3,1.5);(3pt) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[yscale=1.5] +\tzhelplines(0,-1)(4,1) +\tzplot[ycomb,mark=*,very thick,blue] + (.5,.1)(1,.3)(1.5,.4)(2,.5) + (4,-.1)(3.5,-.3)(3,-.4)(2.5,-.5); +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot[xcomb,mark=*,very thick] + (1,2.5)(1.5,2)(2,0)(3,1.5); +\end{tikzpicture} +\end{tzcode} + +\remark +\begin{itemize} +\item +Do not use |<shift coor>| for plotting bars or combs to avoid getting unexpected results. It gives you wrong bars because |<shift coor>| moves coordinates but not bars. + +%\item Use the option |shift={(coor)}| to move bars. +%\begin{tzcode}{.3} +%% shift : shift={(1,1)} +%\begin{tikzpicture}[scale=1] +%\tzhelplines(4,3) +%\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3); +%\tzplot[ybar,shift={(1,1)}](0,3)(1,3)(2,2)(3,1); %% +%\tzplot[red,mark=heart]<1,1>(0,2)(1,2)(2,0)(3,2); +%\end{tikzpicture} +%\end{tzcode} + +\item +It can be a mess when using |shift={(coor)}| with the type of mixed coordinates: native and named coordinates. + +%\begin{tzcode}{.3} +%% \tzplot(*) +%% shift : mixed coor : shift={(1,1)} : chaos +%\begin{tikzpicture}[scale=1] +%\tzhelplines(4,3) +%\tzcoors(0,3)(A)(1,3)(B)(2,2)(C)(3,1)(D); +%\tzcoors(0,2)(a)(1,2)(b)(2,0)(c)(3,2)(d); +%\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3); +%\tzplot[ybar,shift={(1,1)}](A)(1,3)(C)(D); %% +%\tzplot[dashed,red,mark=heart]<1,1>(a)(1,2)(c)(d); +%\end{tikzpicture} +%\end{tzcode} + +\end{itemize} + + + +%%----------------------------------- +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplotcurve(*)}} +\label{s:tzplotcurve} + +\icmd{\tzplotcurve} draws a curve connecting specified coordinates with |tension=1|, by default. Basically, it is equivalent to |\tzplot| with |[tension=1]|. + +The starred version \icmd{\tzplotcurve*} draws a curve and displays marks |*|, by default. +Basically, this is equivalent to |\tzpolot*[draw,tension=1]|. + +\begin{tzdef}{} +% syntax: minimum +\tzplotcurve(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: full +\tzplotcurve*[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>" + (<coor>){<label>}[<[label opt]angle>] + ..repeated.. + (){}[] ; (<mark size>) <code.append> +% defaults + *[tzmark=2pt]{1}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <> +\end{tzdef} + +\begin{tztikz}{} +\tzplotcurve(0,0)(1,2)(2,2)(3,3); % works like: + \draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ; +\end{tztikz} + +\begin{tztikz}{} +\tzplotcurve[blue,smooth cycle]{2}(0,0)(1,2)(2,2)(3,3); % works like: + \draw [blue,tension=2] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ; +\end{tztikz} + +Since |\tzplotcurve| is a \xem{semicolon version}, you need to enter a semicolon to indicate when the coordinate iteration ends. +In repeating coordinates, each mandatory coordinate can have a label. +So the whole repeating pattern is the triple |(<coor>){<text>}[<pos>]|. +For example, |(A){here}[above]| is something like, in |tikz|, +|(A) node [above] {here}|. + +\paragraph{Options: lines, labels, colors, smooth cycle} Use the first bracket option. + +\begin{tztikz}{} +\tzplotcurve(0,0)(1,2)(2,2){A}[below](3,3){B}[right]; % works like: + \draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } + (2,2) node [below] {A} + (3,3) node [right] {B} ; +\end{tztikz} + +You can change the color of all labels together by adding |[text=<color>]| to the first bracket option list. + +\begin{tzcode}{.3} +% \tzplotcurve(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue] + (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0]; +\tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1); +\end{tikzpicture} +\end{tzcode} + +The simplest way to change the mark size is to specify |(<mark size>)| immediately after the semicolon |;|. + +\begin{tzcode}{.3} +% \tzplotcurve(*): smooth cycle, mark size +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue,smooth cycle] + (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %% +\tzplotcurve*[smooth cycle](1,.5)(2,3)(3,2)(2,1)(3,1); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Tension} +You can change the value tension (|1| by default) by specifying the options |{<tension>}| before the coordinates or between the two bracket options if they exist. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoor(.5,.5)(A) +\tzplotcurve[blue]{2}(1,3)(A)(4,0); +\tzplotcurve[thick](1,3)(A)(4,0); % default: tension=1 +\tzplotcurve[red]{.5}(1,3)(A)(4,0); +\tzplotcurve[dashed]{0}(1,3)(A)(4,0); +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} Use the optional argument |<shift coor>| before the first coordinate (to be precise, immediately before |"<path name>"|, if exists). + +\begin{tzcode}{.3} +% \tzplotcurve(*): shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue,smooth cycle] + <0,1>(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %% +\tzplotcurve*[smooth cycle](1,.5)(2,3)(3,2)(2,1)(3,1); +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Extending the path} In order to extend the path of |\tzplotcurve| from the last coordinate, you can write \Tikz\ code in the very last optional argument |<code.append>|, after the semicolon. + +\begin{tzcode}{.3} +% \tzplotcurve(*): <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue,thick] + (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[-45];(3pt) + < arc (-90:90:1cm) node [above] {up} > %% +\tzplotcurve[dashed](1,.5)(2,3)(3,2)(2,1)(3,1); + < -- ++(-1,-1) node [below] {down} > %% +\end{tikzpicture} +\end{tzcode} + +You can also use |<--cycle>| to close the path with a straight line from the last coordinate to the first coordinate. + +\begin{tzcode}{.3} +% \tzplotcurve(*): <--cycle> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue] + (0,0)(1,2)(2,2)(3,3)(4,1){A}[right];(3pt)<--cycle> +\tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1);<--cycle> +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{name path} for intersection points} +You can name the path of |\tzplotcurve| by specifying the option |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzplotcurve(*): name path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve[blue]"IC"(.5,3)(1.5,1.2)(4,.5){$u$}[0]; +\tzplot[draw=red]"bgt"(0,3)(4,0){budget}[-90]; +% intersection points +\tzXpoint{IC}{bgt}(K) +\tzdots*(K){$A_1$}[30](K-2){$A_2$}; +\end{tikzpicture} +\end{tzcode} + + + + + +%%================================== +\chapter{Nodes} +\label{c:nodes} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznode} and \protect\cmd{\tznode*}} +\label{s:tznode} + +The macro \icmd{\tznode} allows you to put text at specified coordinates. +You can also optionally name a node so you can refer to the coordinate name later. + +The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draws the perimeter of the specified node. The default node shape is |rectangle|. + +\begin{tzdef}{} +% syntax: minimal +\tznode(<coor>){<text>} +% syntax: full +\tznode[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>] +% defaults + []<>(<m>)(){}[] +\end{tzdef} + +\begin{tztikz}{} +\tznode(0,0){text} % works like: + \path (0,0) node {text}; + % or + \node at (0,0) {text}; +\end{tztikz} + +\begin{tztikz}{} +\tznode[draw] (0,0)(A){text}[above right] % works like: + \node [draw] (A) at (0,0) [above right] {text}; +\end{tztikz} + +|\tznode*| prints the perimeter of a node, which is |rectangular| by default. + +\begin{tzdef}{} +% syntax: minimal +\tznode*(<coor>){<text>} +% syntax: full +\tznode*[<opt>]<shift coor>(<coor>)(<name>){<text>}[<node opt>]<code.append> +% defaults + *[draw]<>(<m>)(){}[]<> +\end{tzdef} + +\begin{tztikz}{} +\tznode* (0,0)(A){text}[above right] % works like: + \node [draw] (A) at (0,0) [above right] {text}; +\end{tztikz} + +\paragraph{Putting text} You can use \Tikz\ options in the optional arguments |[<opt>]| or |[<node opt>]| to put text with different colors, fonts, and so on. + +\begin{tzcode}{.3} +% \tznode(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tznode(1,1){text} +\tznode(2,2){another\\text}[align=left] +\tznode*(3,1){\textbf{text}} +\tznode*[blue](3,0){\scshape Text}[r] % right +\tznode*(4,2){another\\text}[align=center,font=\itshape] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Abbreviations} You can use \xem{abbreviations} such as |a| for |above|, |l| for |left|, |ar| for |above right|, |bl| for |below left|, and so on to indicate where the \xem{text} of a \xem{main node} is placed. + +\begin{quote} +\warning +A \iisw{main node} is placed by the placement words, while a \iisw{label node} is placed by the placement words or the |<angle>| expression. +\begin{itemize} +\item You CANNOT use the abbreviations to place a \xem{label node} for \xem{points} or \xem{dots} or \xem{coordinates}. +\item +Instead, use |<angle>| or the original (unabridged) placement words such as |right| and |below left| to place |<label>|. +\item +Note that, on the other hand, you CANNOT use the |<angle>| option to place a \xem{main node}. +\end{itemize} +\end{quote} + + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdot*(1,1) +\tznode*(1,1){A}[ar] +\tznode*[red](1,1){B}[b] +\tznode(1,1){C}[l] +\tznode*[inner sep=0pt,text=blue,scale=2] + (3,2){Text}[label=180:Left,pin=45:Above Right] +\tznode*[inner sep=0pt,text=red,scale=2] + (3,2){Text}[b=2cm] %% below=2cm +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming nodes} +You can name a node at a specified coordinate |(<coor>)| by specifying |(<name>)| immediately after the coordinate. You can use the node name as a \iisw{node coordinate}. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tznode*(1,1)(A){A} +\tznode*[fill=blue,text=yellow](2,3)(B){B} +\tznode*[circle,text=red](4,1)(C){C} +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the coordinates by specifying the option |<shift coor>| immediately before the coordinate |(<coor>)|. + +\begin{tzcode}{.3} +% shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tznode*<-1,0>(1,1)(A){A} +\tznode*[fill=blue,text=yellow]<1,-1>(2,3)(B){B} +\tznode*[circle,text=red]<-2,-1>(4,1)(C){C} +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodedot(*)}} +\label{s:tznodedot} + +\icmd{\tznodedot} names a node and prints a circle node dot. +|\tznodedot| is the same as |\tzdot|, except for one thing. +|\tznodedot| names a node. + +The starred version \icmd{\tznodedot*} prints a filled circle node dot (of the size |2.4pt|, by default), just like |\tzdot*|. But it optionally names a node. + +\begin{tzdef}{} +% syntax: medium +\tznodedot(<coor>)(<node name>){<label>}[<angle>] +% syntax: full +\tznodedot*[<opt>]<shift coor>(<coor>)(<node name>){<label>}[<[label opt]angle>] + (<dot size>) +% defaults + *[]<>(<m>)(){}[](2.4pt) +\end{tzdef} + +Since |\tznodedot(*)| prints a dot, its |<label>| is placed by |<angle>|. + +\begin{tzcode}{.3} +% \tznodedot(*): label, color +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodedot(1,1)(A){A}[180] +\tznodedot*(2,3)(B){\textbf{B}} +\tznodedot[rectangle](4,1)(C){C}[[red]0] +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + +You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of node dots. +The simplest way is to use the last parenthesis option |(<dot size>)|. + +\begin{tzcode}{.3} +% \tznodedot(*): size +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{5pt} %% +\tznodedot(1,1)(A){A}[180] +\tznodedot*(2,3)(B){B} +\tznodedot[rectangle](4,1)(C){C}[0](10pt) %% +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + + +You can move the coordinates of dots by specifying the |<shift coor>| option immediately before the coordinate. + +\begin{tzcode}{.3} +% \tznodedot(*): shift +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{5pt} +\tznodedot(1,1)(A){A}[180] +\tznodedot*(2,3)(B){B} +\tznodedot[rectangle]<-1,-1>(4,1)(C){C}[0](10pt) %% +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodeframe} and \protect\cmd{\tznodeframe*}} +\label{s:tznodeframe} + +\icmd{\tznodeframe} draws and names a rectangle node with text in it. + +%\icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|. + +\begin{tzdef}{} +% syntax: +\tznodeframe[<opt>](<coor>)(<node name>){<text>}[<node opt>] +% defaults + []<>(<m>)(){}[text=black] +\end{tzdef} + +The starred version |\tznodeframe*| fills the rectangle with color (|black!50| by default) with |fill opacity=.3| by default. + +%\icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|. + +\begin{tzdef}{} +% syntax: +\tznodeframe*[<opt>]<shift coor> + (<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>(<m>)(){}[draw=black,text=black]{.3} +\end{tzdef} + +\remark +|\tznodeframe| works very similar to |\tznode|, but the starred versions are different. +While |\tznode*| draws the perimeter of a node, |\tznodeframe*| fills a node with color. + + +\begin{tzcode}{.3} +% \tznodeframe +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodeframe(0,0)(A) +\tznodeframe(4,2)(B)[circle] +\tzline[blue,thick](A)(B) +\tznodeframe[scale=1.5](2,1){Node frame} + [label=180:Left, pin=-45:pin] +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tznodeframe: fill (opacity=1) +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodeframe(0,3) +\tznodeframe(0,0)(A) +\tznodeframe(4,2)(B)[circle] +\tzline[blue,thick](A)(B) +\tznodeframe[fill=green,scale=1.5](2,1){Node frame} + [label=180:Left, pin=-45:pin] +\end{tikzpicture} +\end{tzcode} + +By default, |\tznodeframe*| fills a node with color with |opacity=.3|. + +\begin{tzcode}{.3} +% \tznodeframe*: opacity=.3 (by default) +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodeframe(0,0)(A) +\tznodeframe(4,2)(B)[circle] +\tzline[blue,thick](A)(B) +\tznodeframe*[green,scale=1.5](2,1){Node frame} + [label=180:Left, pin=-45:pin] +\end{tikzpicture} +\end{tzcode} + +You can change the |fill opacity| of |\tznodeframe*| by specifying the last curly brace option |{<fill opacity>}|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate. + +\begin{tzcode}{.3} +% opacity, shift +\begin{tikzpicture} +\tzhelplines[solid](4,3) +\tznodebox(0,0) +\tznodeframe*(1,2)(A){A}{.1} % opacity +\tznoderectangle[fill=yellow](2,2)(B){B} +\tznodebox*[red](3,2)(C){Cat} +\tznodeframe[fill=green]<-1,-2>(4,2)(D){Dog} % shift +\tzto[->,bend left=45](A.north)(C.90) +\tzto[->,bend right=45,dashed](B.-135)(D.west) +\end{tikzpicture} +\end{tzcode} + +\remark +In addition to using the option |{<fill opacity>}|, you can use a macro to change the default value. +\begin{itemize} +\item The default fill opacity can be changed by the macro \icmd{\settzfillopacity}. +\item +The default fill color is |black!50|. You can change the default color +with the macro \icmd{\settzfillcolor}. +\end{itemize} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodecircle} and \protect\cmd{\tznodecircle*}} +\label{s:tznodecircle} + +\icmd{\tznodecircle} works just like |\tznodeframe| but with a node circle. + +\begin{tzdef}{} +% syntax: +\tznodecircle[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>] +% defaults + []<>(<m>)(){}[text=black] +\end{tzdef} + +\icmd{\tznodecircle*} works just like |\tznodeframe*| but with a node circle. + +\begin{tzdef}{} +% syntax: +\tznodecircle*[<opt>]<shift coor> + (<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>(<m>)(){}[draw=black,text=black]{.3} +\end{tzdef} + +\begin{tzcode}{.3} +% \tznodecircle +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodecircle(0,0)(A) +\tznodecircle(4,2)(B)[circle] +\tzline[blue,thick](A)(B) +\tznodecircle[scale=1.5](2,1){Node frame} + [label=180:Left, pin=-45:pin] +\end{tikzpicture} +\end{tzcode} + +You can change the |fill opacity| of |\tznodecircle*| by specifying the last curly brace option |{<fill opacity>}| or using |\settzfillopacity|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate. + +\begin{tzcode}{.3} +% opacity, shift +\begin{tikzpicture} +\tzhelplines[solid](4,3) +\tznodecircle(0,0) +\tznodecircle*(1,2)(A){A}{.1} % opacity +\tznodecircle[fill=yellow](2,2)(B){B} +\tznodecircle*[red](3,2)(C){Cat} +\tznodecircle[fill=green]<-1,-2>(4,2)(D){Dog} % shift +\tzto[->,bend left=45](A.north)(C.90) +\tzto[->,bend right=45,dashed](B.-135)(D.west) +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodeellipse} and \protect\cmd{\tznodeellipse*}} +\label{s:tznodeellipse} + +\icmd{\tznodeellipse} works just like |\tznodeframe| but with a node circle. + +\begin{tzdef}{} +% syntax: +\tznodeellipse[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>] +% defaults + []<>(<m>)(){}[text=black] +\end{tzdef} + +\icmd{\tznodeellipse*} works just like |\tznodeframe*| but with a node circle. + +\begin{tzdef}{} +% syntax: +\tznodeellipse*[<opt>]<shift coor> + (<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>(<m>)(){}[draw=black,text=black]{.3} +\end{tzdef} + +\begin{tzcode}{.3} +% \tznodeellipse +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodeellipse(0,3) +\tznodeellipse(0,0)(A) +\tznodeellipse(4,2)(B)[circle] +\tzline[blue,thick](A)(B) +\tznodeellipse[scale=1.5](2,1){Node frame} + [label=180:Left, pin=-45:pin] +\end{tikzpicture} +\end{tzcode} + +You can change the |fill opacity| of |\tznodeellipse*| by specifying the last curly brace option |{<fill opacity>}|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate. + +\begin{tzcode}{.3} +% opacity, shift +\begin{tikzpicture} +\tzhelplines[solid](4,3) +\tznodeellipse(0,0) +\tznodeellipse*(1,2)(A){A}{.1} % opacity +\tznodeellipse[fill=yellow](2,2)(B){B} +\tznodeellipse*[red](3,2)(C){Cat} +\tznodeellipse[fill=green]<-1,-2>(4,2)(D){Dog} % shift +\tzto[->,bend left=45](A.north)(C.90) +\tzto[->,bend right=45,dashed](B.-135)(D.west) +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Lines} +\label{c:lines} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzline}: Connecting two points} +\label{s:tzline} + +\icmd{\tzline} connects two points with a straight line. + +\begin{tzdef}{} +% syntax: miminum +\tzline(<coor1>)(<coor2>) +% syntax: medium +\tzline[<opt>](<coor1>){<text1>}[<node opt1>] + (<coor2>){<text2>}[<node opt2>] +% syntax: full +\tzline[<opt>]<shift coor>"<path name>" + (<coor1>){<text1>}[<node opt1>] + (<coor2>){<text2>}[<node opt2>]<code.append> +% defaults + []<>""(<m>){}[above](<m>){}[]<> +\end{tzdef} + + +\begin{tztikz}{} +\tzline(0,0)(2,1) % works like: + \draw (1,1) -- (2,1); +\end{tztikz} + + +\subsection{Line styles} +\label{ss:tzline:linestyles} + +You can use the first optional argument |[<opt>]| to control the line styles. + +\begin{tztikz}{} +\tzline[blue](0,0)(2,1) % works like: + \draw [blue] (1,1) -- (2,1); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzline +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->](0,0)(3,3) +\tzline[*-o](0,2)(3,0) +\tzline[dashed](1,2)(4,0) +\tzdots*(1,2)(4,0); +\end{tikzpicture} +\end{tzcode} + +\subsection{Adding text} +\label{ss:tzline:addingtext} + +You can add text by specifying the optional arguments |{<text>}| and |[node opt]|. + +\paragraph{Text next to the line} +With the options |{<text1>}[<node opt1>]| inbetween two coordinates, you can add text next to the line, with the option |[above,midway]| by default. + +\begin{tztikz}{} +\tzline[blue](0,0){my line}[sloped](2,1) % works like: + \draw [blue] (1,1) -- node [above,sloped] {my line} (2,1) ; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzline: text next to line +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline(0,0){Above}(4,0) % default [above] +\tzline[blue](0,1){Near end}[b,near end](4,1) % below +\tzline[->](0,2){Sloped}[sloped](3,3) % default [above] +\end{tikzpicture} +\end{tzcode} + +You can use the \xem{abbreviations} of \Tikz\ basic placement options such as |a| for |above|, |bl| for |below left|, and so on. + + +\paragraph{Text at or around the last coordinate} + +You can also add text at or around the second coordinate by specifying |{<text2>}| and |[<node opt2>]| immediately after the second coordinate. + +\begin{tztikz}{} +\tzline[blue](0,0)(2,1){my line}[right] % works like: + \draw [blue] (1,1) -- (2,1) node [right] {my line}; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzline +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->](0,0)(3,3){\textbf{line A}}[r] +\tzline[*-o](0,2)(3,0){line B}[red,draw=blue,b=1mm] +\tzline[dashed](1,2){dashed}[sloped](4,0){line C}[ar] +\tzdots*(1,2)(4,0); +\end{tikzpicture} +\end{tzcode} + +%\subsection{Relative coordinates: \texttt{+} or \texttt{++}} +%\label{ss:tzline:relative} +% +%You can make the second coordinate relative to the first. +%You can even select `|+| relative' or `|++| relative' by specifying the option |<+>| or |<++>| immediately before the second coordinate. +% +%\begin{tztikz}{} +%\tzline+(0,0)<+>(2,1) % works like: +% \draw (1,1) -- + (2,1); +%\end{tztikz} +% +%\begin{tzcode}{.3} +%% \tzline +%\begin{tikzpicture} +%\tzhelplines(4,3) +%\tzline[blue,->](0,0) (3,3) {A}[r] +%\tzline[*-o] (0,2){b} <+>(3,-2){B}[r] +%\tzline[dashed] (1,2){c}<++>(3,-2){C}[r] +%\tzdots*(1,2)(4,0); +%\end{tikzpicture} +%\end{tzcode} +% +%Notice that, with |\tzline|, |<+>| and |<++>| make no difference. +%But with the macro |\tzlines| it is not the case. +% +%\remark +%Notice that using |<+>| and |<++>| makes no difference in |\tzline|. +%But it is not the case with the macro |\tzlines| that connects multiple coordinates. + +\subsection{Moving the line: \texttt{shift}} +\label{ss:tzline:shift} + +You can move the line drawn by |\tzline| by specifying the option |<shift coor>| before the first coordinate (to be precise, immediately before the option |"<path name>"|, which is put immediately before the first coordinate, if it exists). + +\begin{tzcode}{.3} +% \tzline: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->] (0,0)(3,3){A}[r] +\tzline[blue] <1,0>(0,0)(3,3){A}[r] +\tzline[dashed] (1,2)(4,0){C}[r] +\tzline[dashed]<-.5,-.5>(1,2)(4,0){C}[r] +\tzdots*(1,2)(4,0); +\end{tikzpicture} +\end{tzcode} + + + +\subsection{Extending the path} +\label{ss:tzline:extendingpath} + +You can extend the path generated by |\tzline| from the last coordinate, by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzline: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->](0,0)(3,3)<arc(0:-60:1cm)> +\tzline[dashed,->](1,2)(4,0) + <to[bend left] ++(-4,1) node [a] {ends here!}> +\end{tikzpicture} +\end{tzcode} + + +\subsection{Naming the path: Intersection points} +\label{ss:tzline:namepath} + +When you specify the option |"<path name>"| immediately before the first coordinate, it works like |[name path=<path name>]| in the option list |[<opt>]|. +You can use this name to find intersection points. + +\begin{tzcode}{.3} +% \tzline+: name path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->] "dem" (0,0)(3,3){demand}[r] +\tzline[dashed,->]"supp"(1,2)(4,0){supply}[ar] +% intersection point +\tzXpoint*{dem}{supp} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzline+}: Relative coordinates} +\label{s:tzline+} + +The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| relative (with |++|) to the first coordinate |(<coor1>)|. +%That is, |\tzline+(A)(B)| is equivalent to |\tzline(A)<++>(B)|. + +\xem{Everything else is the same as in} |\tzline|. + +\begin{tzdef}{} +% syntax: full +\tzline+[<opt>]<shift coor>"<path name>" + (<coor1>){<text1>}[<node opt1>] + (<coor2>){<text2>}[<node opt2>]<code.append> +% defaults + +[]<>""(<m>){}[above](<m>){}[]<> +\end{tzdef} + + +\begin{tztikz}{} +\tzline+(0,0)(2,1) % works like: + \draw (1,1) -- ++ (2,1); +\end{tztikz} + +\begin{tztikz}{} +\tzline+[dashed]"AA"(1,1){A}[red](2,1){B}[right,blue] % works like: + \draw [dashed,name path=AA] + (1,1) -- node [red] {A} ++ (2,1) node [right,blue] {B}; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzline+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline+[blue,->](0,1)(3,2) {A}[r] +\tzline+[*-o] (0,2){b}(3,-2){B}[r] +\tzline+[dashed]<1,0>(0,2){b}(3,-2){B}[r] +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzline+: name path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline+[blue,->] "dem" (0,0)(3,3){demand}[r] +\tzline+[dashed,->]"supp"(1,2)(3,-2){supply}[ar] +% intersection point +\tzXpoint*{dem}{supp} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Styles: \texttt{tzshorten} and \texttt{tzextend}} +\label{s:tzshorten} + +The style \ixxw{tzshorten} and \ixxw{tzextend} are defined as follows. + +\begin{tzsty}{} +% tzshorten +\tikzset{% + tzshorten/.style 2 args ={shorten <=#1, shorten >=#2}, + tzshoretn/.default={2pt}{2pt} +} + +% tzextend (negative tzshorten) +\tikzset{% + tzextend/.style 2 args ={shorten <=-#1, shorten >=-#2}, + tzextend/.default={2pt}{2pt} +} +\end{tzsty} + +For example, |[tzshorten={2mm}{1mm}]| is equivalent to |[shorten <=2mm,shorten >=1mm]| in \ +Tikz. Simple |[tzshorten]| means that |[tzshorten={2pt}{2pt}]| by default. + +The style |tzextend| is a negative |tzshorten|. For example, |tzextend{2mm}{1mm}| is equivalent to |tzshorten{-2mm}{-1mm}|. + + +\begin{tzcode}{.3} +% tzshorten, tzextend +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots(0,0)(3,0); \tzline(0,0)(3,0) +\tzdots(0,1)(3,1); +\tzline[->,thick,blue,tzshorten={2mm}{1mm}](0,1)(3,1); +\tzdots(1,2)(3,2); +\tzline[<->,thick,red,tzextend={1cm}{1cm}](1,2)(3,2); +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzlines}: Connecting multiple points: Semicolon version} +\label{s:tzlines} + +\icmd{\tzlines} connects two or more points with connected line segments. +Since |\tzlines| takes an arbitrary number of coordinates as arguments, it is a \xem{semicolon version}. So, you need to enter a semicolon to indicate when the coordinate iteration ends. + +\begin{tzdef}{} +% syntax: minimum +\tzlines(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: medium +\tzlines(<coor>){<text>}[<node opt>]..repeatd..(<coor>){<text>}[<node opt>] ; +% syntax: full +\tzlines[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>] + ..repeated.. (){}[] ; <code.append> +% defaults + []<>"" (<m>){}[] ..repeated.. (){}[] ; <> +\end{tzdef} + +The whole repeating pattern in |\tzlines| is the triple |(<coor>){<text>}[<node opt>]|. +%Any |<+ or ++>| after the last coordinate, if any, is ignored. + +\begin{tztikz}{} +% standard version +\tzlines(1,1)(2,2)(3,1)(4,3); % works like: + \draw (1,1) -- (2,2) -- (3,1) -- (4,3); +\end{tztikz} + +\paragraph{Line styles} +Use the first optional argument |[<opt>]| to control the style of the connected line drawn by |\tzlines|. + +\begin{tzcode}{.3} +% \tzlines +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[blue,<->](0,1)(1,2)(3,1)(4,3); +\tzlines[dashed](0,0)(1,1)(2,1)(3,0); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} + +You can add text in the |midway|, by default, of each line segment by specifying the options |{<text>}| and |[<node opt>]| immediately after each coordinate (except the last one). +The options |{<text>}| and |[<node opt>]| after the last coordinate put |<text>| at or around the last coordinate. + + +\begin{tzcode}{.3} +% \tzlines: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[red,thick,<->,text=blue] + (0,1){Up} + (1,2){Down}[a,sloped] + (3,1){Up} + (4,3){line A} ; +\tzlines[dashed](0,0)(1,1)(2,1)(3,0){line B}[r]; +\end{tikzpicture} +\end{tzcode} + +%\paragraph{Relative coordinates: \texttt{+} and \texttt{++}} +% +%You can make the coordinates (from the second coordinate) relative to the previous one by specifying the option |<+>| and |<++>| immediately before the coordinates. +%(In \Tikz, only |<++>| refreshes the \xem{current point} to new one.) +% +%\begin{tzcode}{.3} +%% \tzlines +%\begin{tikzpicture} +%\tzhelplines(4,3) +%\tzlines[red,thick,<->,text=blue] +% (0,1){Up} +% <+>(1,1){Down}[a,sloped] % current point: (0,1) +% <++>(3,0){Up} % new current point: (3,1) +% <++>(1,2){line A} ; +%\tzlines[dashed](0,0)(1,1)(2,1)<++>(1,-1){line B}[r]; +%\end{tikzpicture} +%\end{tzcode} + +\paragraph{Shift} +You can move the connected line by specifying |<shift coor>| before the first coordinate or before |"<path name>"| (if any). + +\begin{tzcode}{.3} +% \tzlines: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[red,thick,<->,text=blue] + <0,-1>(0,1) + (1,2) + (3,1) + (4,3){shifted\\line A}[align=left,ar] ; +\tzlines[dashed]<1,0>(0,0)(1,1)(2,1)(3,0){line B}[r] ; +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming paths} +You can name the path of |\tzlines| by specifying the option |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzlines: shift, intersection +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[red,thick,<->,text=blue] + <0,-1>"AA"(0,1) + (1,2)(3,1)(4,3){shifted\\line A}[align=left,ar] ; +\tzlines[dashed] + <1,0>"BB"(0,0)(1,1)(2,1)(3,0){line B}[r] ; +% intersection points +\tzXpoint*{AA}{BB}(X){X1}[-90] % [<angle>] for point +\tzdot(X-2){X2}[0] % [<angle>] for dot +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending the path} +You can extend the path of |\tzlines| by writing \Tikz\ code in the last (even \xem{after the semicolon}) optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzlines +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[red,thick,<->,text=blue] + (0,1){Up} + (1,2){Down}[a,sloped] + (3,1){Up} + (4,3) ; + <arc(0:90:1cm)> +\tzlines[dashed] + (0,0)(1,1)(2,1)(3,0) ; + <to[bend right] ++(2,2) node{Here!}> +\end{tikzpicture} +\end{tzcode} + +You can close the path by |<--cycle>|. + +\begin{tzcode}{.3} +% \tzlines: closed path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines[red,thick,<->,text=blue] + (0,1){Up} + (1,2){Down}[a,sloped] + (3,1){Up} + (4,3){line A} ; <--cycle> +\tzlines[dashed] + (0,0)(1,1)(2,1)(3,0){line B}[r] ; <--cycle> +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzlines+}: Relative coordinates: Semicolon version} +\label{s:tzlines+} + +The \iisw{plus version} \icmd{\tzlines+} connects two or more points with connected line segments, but each coordinate (except the first one) is \xem{relative} to the previous coordinate. +%For example, |\tzline+(A)(B)(C)(D);| is equivalent to |\tzline(A)<++>(B)<++>(C)<++>(D);|. + +\xem{Everything else is the same as in} |\tzlines|. +It is also required to enter a \xem{semicolon} to indicate when the coordinate iteration ends. + + +\begin{tzdef}{} +% syntax: full +\tzlines+[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>] + ..repeated.. (){}[] ; <code.append> +% defaults + []<>"" (<m>){}[] ..repeated.. (){}[] ; <> +\end{tzdef} + + +\begin{tztikz}{} +\tzlines+(1,1)(2,2)(3,1)(4,3); % works like: + \draw (1,1) -- ++(2,2) -- ++(3,1) -- ++(4,3); +\end{tztikz} + + +\begin{tztikz}{} +\tzlines+[dashed]"AA"(1,1){A}(2,2){B}(3,1){C}[below]; % works like: + \draw [dashed,name path=AA] + (1,1) -- node {A} ++(2,2) + -- node {B} ++(3,1) node [below] {C} ; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzlines+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlines+[red,thick,<->,text=blue] + (0,1){Up} + (1,1){Down}[a,sloped] + (2,-1){Up} + (1,2){line A} ; +\tzlines+[dashed,auto,text=red] + (0,0){A}(1,1){B}(1,0){C}(1,-1){line B}[blue,draw,r] ; +\end{tikzpicture} +\end{tzcode} + + + +%%================================== +\chapter{Connecting Points} +\label{c:tzto} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzto}: Two points} +\label{s:tzto} + +\icmd{\tzto} connects two points with a straight or curved line, using \Tikz\ |to| operation. +So |\tzto| is more general than |\tzline|, which connects points only with a straight line. + +\begin{tzdef}{} +% syntax: minimum +\tzto(<coor>)(<coor>) +% syntax: medium +\tzto[<opt>](<coor>){<text>}[<node opt>](<coor>){<text>}[<node opt>] +% syntax: full +\tzto[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>](<coor>){<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>){}[above](<m>){}[]<> +\end{tzdef} + + +\begin{tztikz}{} +\tzto(1,1)(3,2) % works like: + \draw (1,1) to (3,2); +\end{tztikz} + + + +\begin{tztikz}{} +\tzto[->,bend right](1,1){A}[near start](3,2) % works like: + \draw [->,bend right] (1,1) to node [near start] {A} (3,2); + +\tzto[->,bend right](1,1){A}[near start](3,2){B}[right] % works like: + \draw [->,bend right] (1,1) to node [near start] {A} + (3,2) node [right] {B}; +\end{tztikz} + +\paragraph{Line styles} +You can control line styles with the first optional argument |[<opt>]|. + +\begin{tzcode}{.3} +% \tzto +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[blue,thick,->](0,1)(3,3) +\tzto[out=0](0,0)(4,2) +\tzto[bend right,dashed](2,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} + +You can add text \xem{next to the line} (|[midway,above]|, by default) by specifying the options |{<text>}| and |[<node opt>]| \xem{inbetween} the two coordinates. + +You can also add text \xem{at or around} the last coordinate by the options |{<text>}| and |[<node opt>]| \xem{immediately after} the last coordinate. + +\begin{tzcode}{.3} +% \tzto: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[blue,thick,->](0,1){line}[sloped](3,3) +\tzto[out=0](0,0){curve}[pos=.8](4,2){line B}[r] +\tzto[bend right,dashed](2,0)(4,1){line C}[red,r] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the line by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"| (if any). + +\begin{tzcode}{.3} +% \tzto: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[blue,thick,->]<0,1>(0,1){line}[sloped](3,3) +\tzto[out=0]<1,1>(0,0){curve}[pos=.8](4,2){line B}[r] +\tzto[bend right,dashed]<-1,0>(2,0)(4,1){line C}[red,r] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming paths: Intersections} +You can name the path of |\tzto| by specifying the option |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzto: name path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[bend right=45,blue,thick,->]"curveA"(1,3)(4,0) +\tzto[out=0]"curveB"(0,0)(4,2){line B}[r] +% intersection point +\tzXpoint*{curveA}{curveB} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending the path} +You can extend the path of |\tzto| by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzto: extending path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto[bend right=45,blue,thick,->] + (1,3)(4,0)<--([turn]0:1cm) node [b] {extended}> +\tzto[out=0] + (0,0)(4,2)<--([turn]0:1cm) node [r] {extended}> +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzto+}: Relative coordinates} +\label{s:tzto+} + +The \iisw{plus version} \icmd{\tzto+} uses the second coordinate relative to the first coordinate. + +\xem{Everything else is the same as in} |\tzto|. + +\begin{tztikz}{} +\tzto+(1,1)(3,2) % works like: + \draw (1,1) to ++(3,2); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzto+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto+[blue,thick,->](0,1){line}[sloped](3,2) +\tzto+[out=0](0,0){curve}[pos=.8](4,2){line B}[r] +\tzto+[bend right,dashed](2,0)(2,1){line C}[red,r] +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzto+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzto+[bend right=45,blue,thick,->] + (1,3)(3,-3)<--([turn]0:1cm) node [b] {extended}> +\tzto+[out=0] + (0,0)(4,2)<--([turn]0:1cm) node [r] {extended}> +\end{tikzpicture} +\end{tzcode} + + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tztos}: Multiple points: Semicolon version} +\label{s:tztos} + +\icmd{\tztos} takes an arbitrary number of coordinates as arguments to connect them by \Tikz\ |to| operation. Since this is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate iteration ends. +So the quadruple |(<coor>)[<to opt>]{<text>}[<node opt>]| is +the whole repeating pattern. +Here, |[<to opt>]| is for the options of |to| operation such as |[bend right]|, |[bend left=<angle>]|, |[out=<angle>,in=<angle>]|and so on. + +\begin{tzdef}{} +% syntax +\tztos[<opt>]<shift coor>"<path name>" + (<coor1>)[<to opt>]{<text>}[<node opt>]..repeated..()[]{}[] ; <code.append> +% defaults + []<0,0>""(<m>)[]{}[]..repeated..()[]{}[]<> +\end{tzdef} + +\begin{tztikz}{} +\tztos(0,0)(1,2)(3,1); % works like: + \draw (0,0) to (1,2) to (3,1); +\end{tztikz} + +\begin{tztikz}{} +\tztos[blue] (0,0)[bend right] (1,2)[out=-60] (3,1); % works like: + \draw [blue] (0,0) to [bend right] (1,2) to [out=-60,in=45] (3,1); +\end{tztikz} + +\paragraph{How to connect coordinates} +You can use \Tikz's |to| operation option to connect the coordinates with different types of curves. + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos[blue,<->](0,1)(1,2)(3,1)(4,3); +\tztos[red,thick] + (0,0)[bend right] + (1,1) + (2,1)[out=-135,in=45] + (3,0); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} +You can add text next to lines or curves by specifying the options |{<text>}| and |[<node opt>]| inbetween coordinates or after the option |[<to opt>]|, if it exists. +You can also add text at or around the last coordinate by the last options |{<text>}| and |[<node opt>]|. + +It has its |+| verison |\tztos+|. + +\begin{tzcode}{.3} +% \tztos: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos(0,1)[bend right]{A} + (1,2){Ben}[red,sloped,a] + (3,1)[bend right]{Cate}[sloped,near end] + (4,3){Name}[draw,blue,a] ; +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the line or curve of |\tztos| +using the option |<shift coor>| before the first coordinate or immediately before |"<path name">|, if any. + +\begin{tzcode}{.3} +% \tztos: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos[blue,<->](0,1)(1,2)(3,1)(4,3); +\tztos[red,thick] + <1,1>(0,0)[bend right] + (1,1) + (2,1)[out=-135,in=45] + (3,0); +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{\texttt{name path}} +You can name the path of |\tztos| by specifying |"<path name>"| immediately before the first mandatory coordinate. + +\begin{tzcode}{.3} +% \tztos: intersection points +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos[blue,<->]"AA"(0,1)(1,2)(3,1)(4,3); +\tztos[red,thick] + <1,1>"BB"(0,0)[bend right] + (1,1) + (2,1)[out=-135,in=45] + (3,0); +% intersection points +\tzXpoint*{AA}{BB}(X) +\tzdot(X-2)(4pt) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Extending the path} +You can extend the path of |\tztos| from the last coordinate, +by writing \Tikz\ code in the last (after the semicolon) optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos[blue,<->](0,1)(1,2)(3,1)(4,3);<--cycle> +\tztos[red,thick] + (0,0)[bend right] + (1,1) + (2,1)[out=-135,in=45] + (3,0); < to ([turn]0:1.5cm) > +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tztos+}: Relative coordinates: Semicolon version} +\label{s:tztos+} + +The \iisw{plus version} \icmd{\tztos+} takes each coordinate (except the first coordinate) relative (with |++|) to the previous coordinate. + +\xem{Everything else is the same as in} |\tztos|. + +\begin{tzcode}{.3} +% \tztos+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos+[blue,<->](0,1)(1,1)(2,-1)(1,2);<--cycle> +\tztos+[red,thick] + (0,0)[bend right] + (1,1) + (1,0)[out=-135,in=45] + (1,-1); < to ([turn]0:1.5cm) > +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Filling area} +\label{c:fillingarea} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpath} and \protect\cmd{\tzpath*}: Semicolon versions} +\label{s:tzpath} + + +\icmd{\tzpath} creates a path connecting an arbitrary number of coordinates, but it does not stroke the path. You can visualize the path with |\tzpath[draw]|. +Since |\tzpath| is a \ixsw{semicolon version} macro, you need to enter a \xem{semicolon} |;| to indicate where the coordinate iteration ends. + + +The main purpose of |\tzpath| is to fill an enclosed area with color or pattern. +You can use |\tzpath[fill]| or |\tzpath[pattern=<...>]| to do it. + +The starred version \icmd{\tzpath*} fills the interior of |\tzpath| with |black!50| with |fill opacity=.3|, by default. +|\tzpath*| is equivalent to |\tzpath[fill=black!50,fill opacity=.3]|. +You can change the defaults by \icmd{\settzfillcolor} and \icmd{\settzfillopacity}. +The effect remains valid until the end of the |tikzpicture| environment, unless changed again. + +\begin{tzdef}{} +% syntax: minimal +\tzpath (<coor>)(<coor>)..repeated..(<coor>) ; +\tzpath*(<coor>)(<coor>)..repeated..(<coor>) ; {<fill opacity>} +% syntax +\tzpath*{<path style>}[<opt>]<shift coor>"<path name>" + (<coor>)[<path style>]{<text>}[<node opt>] + .. repeated .. ()[]{}[] ; {<fill opacity>}<code.append> +% defaults: \tzpath + {to}[]<>""(<m>)[]{}[]<>..repeated..()[]{}[]<>;{}<> +% defaults: \tzpath* + *{to}[fill=black!50,fill opacity=.3]<>""(<m>)[]{}[]<>..repeated..()[]{}[]<>;{.3}<> +\end{tzdef} + +\paragraph{Path construction operation} +(If you are not an experienced user of \Tikz\, just skip this part.) + +|\tzpath| is similar to |\tztos|, but it is more flexible in constructing paths. +|\tzpath| allows you to choose how to construct a path using the |[<path style>]| option \xem{inbetween} coordinates. \xem{Path extension operation} can be selected from `|--|', `|to|', `\verb+|-+', `\verb+-|+', etc. +You can use the first brace option |{<path style>}| to change all the |<path style>| inbetween coordinates. The default path style is `|to|' and can be change by \icmd{\settzpathstyle}, like |\settzpathstyle{--}|. It remains valid until the end of |tikzpicture| environment unless changed again. + + +\begin{tzcode}{.3} +% \tzpath: path construction +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3); +\tzpath[draw] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzpath: path construction +\begin{tikzpicture} +\tzhelplines(4,3) +\settzpathstyle{to[bend right]} +\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3); +\tzpath[draw] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); +\end{tikzpicture} +\end{tzcode} + +You can extend the path of |\tzpath| by writing \Tikz\ code in the last (after the semicolon) optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzpath: <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3); + < to [bend right=60] (0,1) > +\tzpath[fill] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); <--cycle> +\end{tikzpicture} +\end{tzcode} + +\paragraph{Filling the interior} + +You can optionally change the opacity of fill color using the \Tikz\ option |fill opacity|. + +\begin{tzcode}{.3} +% \tzpath: fill, fill opacity +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[red,very thick](0,3)(4,0) +\tzpath[fill](0,0)(3,1)(2,3)(0,2); % default opacity=1 +\tzpath[fill,green,fill opacity=.5] + <1,-1>(0,0)(3,1)(2,3)(0,2); +\end{tikzpicture} +\end{tzcode} + +The starred version |\tzpath*| fill the interior of |\tzpath| with the defaults |black!50| and |fill opacity=.3|. You can change the opacity by specifying the last (after the semicolon) optional argument |{<fill opacity>}|. +You can also use |\settzfillcolor| and |\settzfillopacity| to change the defaults. + +\begin{tzcode}{.3} +% \tzpath* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[red,very thick](0,3)(4,0) +\tzpath*(0,0)(3,1)(2,3)(0,2); +\tzpath*[fill=green] + <1,-1>(0,0)(3,1)(2,3)(0,2); {.5} %% +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzpath* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpath*[blue](0,1)(1,2)[-|](3,1)(4,3); + < to [bend right=60] (0,1) > +\tzpath*[red] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); <--cycle> +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpath+} and \protect\cmd{\tzpath*+}: Relative coordinates: Semicolon versions} +\label{s:tzpath+} + +The \iisw{plus version} \icmd{\tzpath+} uses each coordinate (except for the first coordinate) relative (with |++|) to the previous coordinate. + +\xem{Everything else is the same as in} |\tzpath|. + +\icmd{\tzpath*+} is simply the plus version of |\tzpath*|. + +\begin{tzcode}{.3} +% \tzpath+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[red,very thick](0,3)(4,0) +\tzpath+[pattern=bricks,preaction={fill=brown}] + (0,0)(3,1)(-1,2)(-2,-1); +\tzpath+[pattern=north east lines,opacity=.5] + <1,-1>(0,0)(3,1)(-1,2)(-2,-1); +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzpath*+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[red,very thick](0,3)(4,0) +\tzpath*+(0,0)(3,1)(-1,2)(-2,-1); +\tzpath*+[fill=green] + <1,-1>(0,0)(3,1)(-1,2)(-2,-1); {.5} %% +\end{tikzpicture} +\end{tzcode} + + +%%======================================= +%%================================== +\chapter{Curves} +\label{c:curves} + +There are many ways to draw curves. + +%%----------------------------------- +%%------------------------------------------------------------ +\section{Bezier curves} +\label{s:beziercurves} + +\icmd{\tzbezier} draws a bezier curve with one or two control points. + +\subsection{\protect\cmd{\tzbezier}} +\label{ss:tzbezier} + +\begin{tzdef}{} +% syntax: minimal +\tzbezier(<start-coor>)(cntl-coor>)(<last-coor>) +\tzbezier(<start-coor>)(cntl-coor>)(<cntl-coor>)(<last-coor>) +% syntax: full +\tzbezier[<draw opt>]<shift coor>"<name path>" + (<start-coor>)(cntl-coor>)(<cntl-coor>)(<last-coor>) + {<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>)(<m>)()(<m>){}[]<> +\end{tzdef} + +\paragraph{Control points} + +You can specify one or two control points, |(<cntl-coor>)|. +So |\tzbezier| accepts three or four coordinates. + +\begin{tztikz}{} +% three coordinates: one control point +\tzbezier(0,1)(1,0)(4,3) % works like: + \draw (0,0) ..controls (1,0).. (4,3); +\end{tztikz} + +\begin{tztikz}{} +% four coordinates: two control points +\tzbezier(0,1)(1,0)(2,4)(4,3) % works like: + \draw (0,0) ..controls (1,0) and (2,4).. (4,3); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzbezier +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[red](0,3)(1,2)(2,4)(4,3) +\tzbezier[blue](0,2)(1,.5)(4,0) +\end{tikzpicture} +\end{tzcode} + +The style \ixxw{tzshowcontrols} displays the control points by drawing dotted lines, by default. +You can also change the dotted line style, like |tzshowcontrols={dashed,green}|. + + +\begin{tzcode}{.3} +% \tzbezier: tzshowcontrols +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[blue,tzshowcontrols](0,2)(1,.5)(4,0) +\tzdots*[blue](0,2)(1,.5)(4,0); +\tzbezier[red,tzshowcontrols={green,dashed}] + (0,3)(1,2)(2,4)(4,3) +\tzdots*[red](0,3)(1,2)(2,4)(4,3); +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} +You can add text next to the curve or at the last coordinate +by specifying the options |{<text>}| and |[node opt]| immediately after the last coordinate. + + +\begin{tzcode}{.3} +% \tzbezier: adding text +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[blue](0,2)(1,.5)(4,0){curve}[draw,black,r] +\tzbezier[red](0,3)(1,2)(2,4)(4,3){bezier}[near end,a] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the curve by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if any. + +\begin{tzcode}{.3} +% \tzbezier: shift +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[blue] + (0,2)(1,.5)(4,0){curve}[draw,black,r] +\tzbezier[blue,dashed] + <1,1>(0,2)(1,.5)(4,0){curve}[r] +\tzbezier[red] + (0,3)(1,2)(2,4)(4,3){bezier}[near end,a] +\tzbezier[red,dashed] + <0,-1>(0,3)(1,2)(2,4)(4,3){bezier}[blue,near end,a] +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{name path}} +You can name the path of |\tzbezier| by specifying the option |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzbezier: name path +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[blue,dashed,thick]<1,1>"curve" + (0,2)(1,.5)(4,0){curve}[r] +\tzbezier[red,dashed,thick]<0,-1>"bezier" + (0,3)(1,2)(2,4)(4,3){bezier}[blue,near end,a] +% intersection point +\tzXpoint*{curve}{bezier}(X){X}[-90] % <angle> +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending the path} +You can extend the path of |\tzbezier| from the last coordinate, by writing \Tikz\ code +in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzbezier: extending path +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier[red](0,3)(1,2)(2,4)(4,3){bezier}[near end,a] + < to [bend right] ++(-1,-1) node [below] {A} > +\tzbezier[blue,->](0,2)(1,.5)(4,0) + < |- ++(-2,1) node [above] {B} > +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzbezier+}: Relative coordinates} +\label{ss:tzbezier+} + +For the \iisw{plus version}, |\tzbezier+(A)(B)(C)|, |(B)| and |(C)| are relative to |(A)|, as in \Tikz. + +For |\tzbezier+(A)(B)(C)(D)|, |(B)| and |(D)| are relative to |(A)|, and |(C)| is relative to |(D)|, as in \Tikz. + +\begin{tztikz}{} +% three coordinates +\tzbezier+(0,1)(1,-1)(4,3) % works like: + \draw (0,1) ..controls +(1,-1).. ($(0,1)+(4,3)$); +\end{tztikz} + +\begin{tztikz}{} +% four coordinates +\tzbezier+(0,1)(1,-1)(-2,1)(4,3) % works like: + \draw (0,1) ..controls +(1,-1) and +(-2,1).. ($(0,1)+(4,3)$); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzbezier+ +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezier+(0,3)(1,-1)(-2,1)(4,0){bezier}[near end,a] + < to [bend right] ++(-1,-1) node [below] {A} > +\tzbezier+[blue,->](0,2)(1,-1.5)(4,-2) + < |- ++(-2,1) node [above] {B} > +\end{tikzpicture} +\end{tzcode} + + +%%----------------------------------- +%%------------------------------------------------------------ +\section{Parabolas} +\label{s:parabolas} + + +\subsection{\protect\cmd{\tzparabola}} +\label{ss:tzparabola} + +\icmd{\tzparabola} draws a parabola going through specified coordinates. +It accepts two or three coordinates. +In the case of three coordinates, the parabola bends at the second coordinate. + +\begin{tztikz}{} +% two coordinates +\tzparabola(0,0)(3,2) % works like: + \draw (0,0) parabola (3,2); +\end{tztikz} + +\begin{tztikz}{} +% three coordinates +\tzparabola(0,0)(1,1)(3,2) % works like: + \draw (0,0) parabola bend (1,1) (3,2); +\end{tztikz} + +\begin{tzdef}{} +% syntax: minimal +\tzparabola(<coor>)(<coor>) +\tzparabola(<coor>)(<coor>)(<coor>) +% syntax: full +\tzparabola[<opt1>]<shift coor>"<path name>" + (<coor>)(<coor>)(<coor>){<text>}[<node opt>]<code.append> +% default + []<>""(<m>)()(<m>){}[]<> +\end{tzdef} + +\paragraph{Parabolas} +|\tzplot| draws the graph of $f(x)=ax^2+bx+c$ for appropriate values of $a$, $b$, and $c$. + +\begin{tzcode}{.3} +% \tzparabola: two coordinates +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[thick](0,0)(2,2) +\tzparabola[bend at end,dashed](0,0)(2,2) +\tzparabola[red,thick,bend pos=.5](2,0)(4,3) +\tzparabola[blue,parabola height=-2cm](2,3)(4,2) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzparabola: three coordinates +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[thick](0,2)(1,0)(2,2) +\tzparabola[blue](0,3)(2,1)(4,2) +\tzparabola[red,thick](2,0)(3,2)(4,3) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} +You can add text at or around the last coordinate by specifying the options |{<text>}| and |[<node opt>]| immediately after the last coordinate. + +\begin{tzcode}{.3} +% \tzparabola: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[thick](0,0)(2,2){parabola}[blue,draw,a] +\tzparabola[blue](0,3)(2,1)(4,2){AC}[r] +\tzparabola[red,thick,bend pos=.5](2,0)(4,3){C}[ar] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move the parabola by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if any. + +\begin{tzcode}{.3} +% \tzparabola: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[blue] (0,3)(2,1)(4,2){AC}[r] +\tzparabola[dashed]<0,-.5>(0,3)(2,1)(4,2){AC}[r] +\tzparabola[dotted]<0,-1> (0,3)(2,1)(4,2){AC}[r] +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{name path}} +You can name the path of |\tzparabola| by specifying the option |"<path name>"| immediately before the first coordinate. + +\begin{tzcode}{.3} +% \tzparabola: name path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[blue]"AC"(0,3)(2,1)(4,2){AC}[r] +\tzparabola"BB"(1,0)(2,2)(3,0) +% intersection points +\tzXpoint*{AC}{BB}(X) +\tzdot(X-2)(3pt) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending the path} +You can extend the path of |\tzparabola| from the last coordinate by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzparabola: extending path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola[blue,->]"AC"(0,3)(2,1)(4,2) + < -- ++ (-1,1) > +\tzparabola"BB"(1,0)(2,2)(3,0) + < -| ++ (1,1) node [right] {K!} > +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzparabola+}: Relative coordinates} +\label{ss:tzparabola+} + +For the \iisw{plus version} \icmd{\tzparabola+}, the second and the third coordinates are relative to the first coordinate. + +\xem{Everything else is the same as in} |\tzparabola|. + +\begin{tztikz}{} +% two coordinates +\tzparabola+(0,1)(3,2) % works like: + \draw (0,1) parabola ($(0,1)+(1,2)$); +\end{tztikz} + + +\begin{tztikz}{} +% three coordinates +\tzparabola+(0,1)(1,1)(3,-1) % works like: + \draw (0,1) parabola bend +(1,1) ($(0,1)+(3,-1)$); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzparabola+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabola+[thick](0,0)(2,2){parabola}[blue,draw,a] +\tzparabola+[blue](0,3)(2,-2)(4,-1){AC}[r] +\tzparabola+[red,thick,bend pos=.5](2,0)(2,3){C}[ar] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzplotcurve}} +\label{s:tzplot} + +See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve} for more details on |\tzplotcurve|. + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzto}, \protect\cmd{\tztos}} +\label{s:curvetzto} + +See Section \ref{s:tzto} on page \pageref{s:tzto} for more details on |\tzto|. + +See Section \ref{s:tztos} on page \pageref{s:tztos} for more details on |\tztos|. + + + + +%%================================== +\chapter{Polygons and Circles} +\label{c:polygons} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpolygon}: Semicolon verion} +\label{s:tzpolygon} + +\icmd{\tzpolygon} connects an arbitrary number of coordinates to draw a polygon, a closed figure. |\tzpolygon| is equivalent to a closed |\tzlines|. Since |\tzpolygon| is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate repetition ends. + + +\begin{tzdef}{} +% syntax: minimum +\tzpolygon(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: medium +\tzpolygon (<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt] ; +% syntax +\tzpolygon[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>] + ..repeated.. (){}[] ; <code.append> +% defaults + []<>""(<m>){}[] .. repeated.. (){}[] ; {} <> +\end{tzdef} + +\begin{tztikz}{} +\tzpolygon(1,1)(2,2)(3,1)(4,3); % works like: + \draw (1,1) -- (2,2) -- (3,1) -- (4,3) -- cycle; +\end{tztikz} + +You can add text next to lines by specifying the options |{<text>}| and |[<node opt>]| \xem{inbetween} coordinates. + +\begin{tzcode}{.3} +% \tzpolygon +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon[fill,blue,auto] + (0,1){Side A}[sloped,red] + (1,3){B} + (2,3) + (3,2){Side D}[swap,sloped] + (1,0); +\end{tikzpicture} +\end{tzcode} + +You can also move the polygon by specifying the option |<shift coor>| before the first coordinate. + +\begin{tzcode}{.3} +% \tzpolygon: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon[blue,auto] + (0,1){Side A}[sloped,red] + (1,3){B} + (2,3) + (3,2){Side D}[swap,sloped] + (1,0); +\tzpolygon[auto,dashed]<1,-.5> + (0,1)(1,3)(2,3){C}(3,2)(1,0); +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpolygon*}: Semicolon version} +\label{s:tzpolygon*} + +\icmd{\tzpolygon*} paints the interior of the polygon with |black!50| with |fill opacity=.3|, by default. + +\begin{tzdef}{} +% syntax: minimum +\tzpolygon*(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: medium +\tzpolygon*(<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt] ; +% syntax +\tzpolygon*[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>] + ..repeated.. (){}[] ; {<fill opacity>} <code.append> +% defaults + *[fill=black!50,fill opacity=.3]<>""(<m>){}[] .. repeated.. (){}[] ; {} <> +\end{tzdef} + +You can change the opacity by specifying the the last optional argument |{<fill opacity>}| immediately after the semicolon. + +\begin{tzcode}{.3} +% \tzpolygon: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon*[draw=blue,auto] + (0,1){Side A}[sloped,red] + (1,3){B} + (2,3) + (3,2){Side D}[swap,sloped] + (1,0); +\tzpolygon*[green,auto,dashed,text=black]<1,-.5> + (0,1)(1,3)(2,3){C}(3,2)(1,0); {.7} +\end{tikzpicture} +\end{tzcode} + +You can also change the defaults using |\settzfillcolor| and |\sttzfillopacity|. + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpolygon+} and \protect\cmd{\tzpolygon*+}: Relative coordinates: Semicolon verion} +\label{s:tzpolygon} + +The plus version \icmd{\tzpolygon+} uses each coordinate (except the first one) relative to the previous coordinate. + +\xem{Everything else is the same as in} |\tzpolygon|. + +\icmd{\tzpolygon*+} is just a plus version of |\tzpolygon*|. + +\begin{tztikz}{} +\tzpolygon+(1,1)(2,2)(3,1)(4,3); % works like: + \draw (1,1) -- ++(2,2) -- ++(3,1) -- ++(4,3) -- cycle; +\end{tztikz} + +\begin{tztikz}{} +\tzpolygon+[dashed]"AA"(1,1)(2,2){A}(3,1){B}[below]; + % is an abbreviation (with defaults) of: + + \draw [dashed,name path=AA] (1,1) + -- ++(2,2) + -- ++(3,1) node {A} + -- ++(4,3) node [below] {B} + -- cycle; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzpolygon: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzpolygon*+[blue,auto] + (0,1){Side A}[sloped,red] + (1,2){B} + (1,0) + (1,-1){Side D}[swap,sloped] + (-2,-2); +\tzpolygon*+[green,auto,dashed,text=black]<1,-.5> + (0,1)(1,2)(1,0){C}(1,-1)(-2,-2); {.7} +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzframe} and \protect\cmd{\tzframe*}} +\label{s:tzframe} + +\icmd{\tzframe} accepts two coordinates draws a rectangle. + +\begin{tzdef}{} +% syntax: minimum +\tzframe(<coor>)(<coor>) +% syntax: full +\tzframe[<opt>]<shift coor>"<path name>"(<coor1>)(<coor2>) +% defaults + []<>""(<m>)(<m>) +\end{tzdef} + +\begin{tztikz}{} +\tzframe(0,1)(3,2) % works like: + \draw (0,1) rectangle (3,2); +\end{tztikz} + + +The plus version \icmd{\tzframe+} uses the second coordinate as the coordinate relative (with |++|) to the first. + +\begin{tztikz}{} +\tzframe+(0,1)(3,2) % works like: + \draw (0,1) rectangle ++(3,2); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzframe, \tzframe+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzframe(0,0)(3,2) +\tzframe+[blue,rounded corners=2mm](1,3)(1,-2) +\end{tikzpicture} +\end{tzcode} + +The starred version \icmd{\tzframe*} fills the interior +with |black!50| with |fill opacity=.3|, by default. + +|\tzframe+| has also its starred version \icmd{\tzframe*+}. + +\begin{tzdef}{} +% syntax +\tzframe*[<opt>]<shift coor>"<path name>"(<coor1>)(<coor2>){<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3} +\end{tzdef} + +With the starred versions, you can change the fill opacity using the last option |{<fill opacity>}|. + +\begin{tzcode}{.3} +% \tzframe*(+) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzframe[fill](0,0)(3,2) +\tzframe*+[green,rounded corners=2mm](1,3)(1,-2){.7} %% +\end{tikzpicture} +\end{tzcode} + +You can move |\tzframe| and its friends by specifying the option |<shift coor>| immediately before the first mandatory coordinate. + +\begin{tzcode}{.3} +% \tzframe(*)(+): shift +\begin{tikzpicture} +\tzhelplines(4,4) +\tzframe(0,0)(3,2) +\tzframe[blue,dashed]<1,1>(0,0)(3,2) +\tzcoors(1,3)(A)(1,-2)(B); +\tzframe*+[blue,rounded corners=2mm](A)(B) +\tzframe*+[red,rounded corners=2mm]<-.5,-.5>(A)(B) +\tzframe*+[green,rounded corners=2mm]<1,1>(A)(B) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzcircle} and \protect\cmd{\tzcircle*}} +\label{s:tzcircle} + +\icmd{\tzcircle} draws a circle around a specified coordinate with a specified radius. + +\begin{tzdef}{} +% syntax +\tzcircle[<opt>]<shift coor>"<path name>"(<coor>)(<radius>) +% defaults + []<>""(<m>)(<m>) +\end{tzdef} + +\begin{tztikz}{} +\tzcircle(0,0)(1cm) % works like: + \draw (0,0) circle (1cm); +\end{tztikz} + +The starred version \icmd{\tzcircle*} fills the interior +with |black!50| with |fill opacity=.3|, by default. +You can change the fill opacity using the last option |{<fill opacity>}|. + +\begin{tzdef}{} +% syntax +\tzcircle*[<opt>]<shift coor>"<path name>"(<coor>)(<radius>){<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3} +\end{tzdef} + +\begin{tzcode}{.3} +% \tzcircle(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcircle(2,2)(1) +\tzcircle[fill=red](3,1)(.5cm) +\tzcircle*[blue](2,1)(1){.5} +\tzcircle*[green](3,.5)(.5cm) +\end{tikzpicture} +\end{tzcode} + +You can move the circle by specifying the option |<shift coor>| immediately before the center coordinate. + +\begin{tzcode}{.3} +% \tzcircle(*): shift +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzcircle(2,2)(1) +\tzcircle[blue,dashed]<-.5,0>(A)(1) +\tzcircle*(3,1)(.5cm) +\tzcircle*[blue]<.5,0>(B)(.5cm) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzellipse} and \protect\cmd{\tzellipse*}} +\label{s:tzellipse} + +\icmd{\tzellipse} draws an ellipse around a specified coordinate with the specified x-radius and y-radius. + +\begin{tzdef}{} +% syntax +\tzellipse[<opt>]<shift coor>"<path name>"(<coor>)(<x and y radius>) +% defaults + []<>""(<m>)(<m>) +\end{tzdef} + +\begin{tztikz}{} +\tzellipse(0,0)(1 and .5) % works like: + \draw (0,0) ellipse (1 and .5); +\end{tztikz} + +The starred version \icmd{\tzellipse*} fills the interior +with |black!50| with |fill opacity=.3|, by default. +You can change the fill opacity using the last option |{<fill opacity>}|. + +\begin{tzdef}{} +% syntax +\tzellipse*[<opt>]<shift coor>"<path name>"(<coor>)(<x and y radius>){<fill opacity>} +% defaults + *[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3} +\end{tzdef} + +\begin{tzcode}{.3} +% \tzellipse(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzellipse(2,2)(1.5 and 1) +\tzellipse[fill=red](3,1)(1cm and .5cm) +\tzellipse*[blue](2,1)(1 and 1.5){.5} +\tzellipse*[green](3,.5)(1cm and .5cm) +\end{tikzpicture} +\end{tzcode} + +You can move the ellipse by specifying the option |<shift coor>| immediately before the mandatory coordinate. + +\begin{tzcode}{.3} +% \tzellipse(*): shift +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzellipse(2,2)(1.5 and 1) +\tzellipse[blue,dashed]<-.5,0>(A)(1.5 and 1) +\tzellipse*(3,1)(1cm and .5cm) +\tzellipse*[blue]<.5,0>(B)(1cm and .5cm) +\end{tikzpicture} +\end{tzcode} + + + +%%================================== +\chapter{Arcs and Wedges} +\label{c:arcs} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzarc(')}: Centered arcs} +\label{s:tzarc} + +\subsection{Arcs} +\label{ss:tzarc} + +\icmd{\tzarc} draws an arc around a specified center. + +\begin{tzdef}{} +% syntax: minimum +\tzarc(<coor>)(<angA:angB:radius>) +% syntax: full +\tzarc[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>)(<m>){}[]<> +\end{tzdef} + + +\begin{tztikz}{} +\tzarc(1,1)(30:120:1) % works like: + \draw (1,1) ++(30:1) arc (30:120:1); +\end{tztikz} + +The \iisw{swap version} \icmd{\tzarc'} switches its drawing direction from \ixxw{counterclockwise} to \ixxw{clockwise} and vice versa. + +\begin{tztikz}{} +\tzarc'(1,1)(30:120:1) % works like: + \draw (1,1) ++(30:1) arc (30:120-360:1); +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzarc, \tzarc' +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots*(1,1)(3,2); +\tzarc [blue,->] (1,1)(-45:180:1) +\tzarc'[dashed,->] (1,1)(-45:180:1) +\draw [->](3,2) ++(-45:1) arc (-45:180:1); +\draw [dashed,->](3,2) ++(-45:1) arc (-45:180-360:1); +\end{tikzpicture} +\end{tzcode} + +You can add text along the arc by specifying the options |{<text>}| and |[<node opt>]| immediately after the two mandatory arguments. + + +\begin{tzcode}{.3} +% \tzarc('): adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzarc [blue,->] (1,1)(-45:180:1){A}[r] +\tzarc'[dashed,->](1,1)(-45:180:1) +\tzarc[->] (3,2)(-45:180:1){arc}[midway,sloped] +\tzarc'[dashed,->](3,2)(-45:180:1) +\end{tikzpicture} +\end{tzcode} + +You can move arcs by specifying the option |<shift coor>| just before the center coordinate. + +\begin{tzcode}{.3} +% \tzarc('): shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzarc [blue,->] (1,1)(-45:180:1){A}[r] +\tzarc'[dashed,->] (1,1)(-45:180:1) +\tzarc [blue,->] <2,1>(1,1)(-45:180:1){A-shifted}[r] +\tzarc'[dashed,->]<2,1>(1,1)(-45:180:1) +\end{tikzpicture} +\end{tzcode} + +You can also extend the path of |\tzarc| by specifying the last option |<code.append>| with \Tikz\ code written in it. For example, |<--cycle>| makes a closed path. + + +\begin{tzcode}{.3} +% \tzarc('): <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzarc [blue,->](1,1)(-45:180:1)<--++(1,2)> +\tzarc'[dashed,->] (1,1)(-45:180:1) +\tzarc [blue,->] <2,1>(1,1)(-45:180:1)<--cycle> +\end{tikzpicture} +\end{tzcode} + + + +\subsection{Elliptical arcs} +\label{ss:ellipticalarc} + +|\tzarc| draws an elliptical arc if you specify |x-radius| and |y-radius|. + +\begin{tzcode}{.3} +% \tzarc: elliptical +\begin{tikzpicture} +\tzhelplines(4,4) +\tzarc[->,red](1,1)(30:270:1.5 and 0.5) +\tzarc'[->,dotted](1,1)(30:270:1.5 and 0.5) +\tzdots*(1,1)(2,2); +\tzarc[->,blue,dashed](2,2)(0:-270:1 and 2) +\tzarc'[->](2,2)(0:-270:1 and 2) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzarc: elliptical +\begin{tikzpicture} +\tzhelplines(4,4) +\tzarc[->,red](1,1)(30:270:1.5 and 0.5) +\tzdots*(1,1)(2,2); +\tzarc[->,blue,dashed,fill=green,fill opacity=.3] + (2,2)(0:-270:1 and 2)<--(2,2)> % code.append +\tzarc[->,blue,dashed] + <1,0>(2,2)(0:-270:1 and 2) % shift +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzarcfrom(')}: Arcs as in \Tikz} +\label{s:tzarcfrom} + +\icmd{\tzarcfrom} draws an arc starting from a point, like \Tikz\ does. + +\begin{tzdef}{} +% syntax: minimum +\tzarcfrom(<coor>)(<angA:angB:radius>) +% syntax: full +\tzarcfrom[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>)(<m>){}[]<> +\end{tzdef} + + +\begin{tztikz}{} +\tzarcfrom(1,1)(30:120:1) % works like: + \draw (1,1) arc (30:120:1); +\end{tztikz} + +\xem{Everything else is the same as in }|\tzarc|. + +\icmd{\tzarcfrom'} is the \iisw{swap version} of |\tzarcfrom|. + + +\begin{tzcode}{.3} +% \tzarcfrom +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdots*(1,1)(3,2); +\tzarcfrom [blue,->] (1,1)(-45:180:1){A}[r] +\tzarcfrom'[dashed,->](1,1)(-45:180:1) +\tzarcfrom[->] (3,2)(-45:180:1){arc}[midway,sloped] +\tzarcfrom'[dashed,->](3,2)(-45:180:1) +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzarcsfrom}: Connected arcs: Semicolon version} +\label{s:tzarcsfrom} + +\icmd{\tzarcsfrom} accepts an arbitrary number of |(<angA:AngB:radius>)| following the start coordinate. You need to enter a \xem{semicolon} to indicate when the repetition ends. + +\begin{tzdef}{} +% syntax +\tzarcsfrom[<opt>]<shift coor>"<path name>"(<start coor>) + (<angA:angB:radius>){<text>}[<node opt>] + ..repeated..(){}[] ; <code.append> +% defaults + []""(<m>)(<m>){}[]..repeated..(){}[];<> +\end{tzdef} + + +\begin{tzcode}{.4} +% \tzarcfrom: adding text, <code.append> +\begin{tikzpicture} +\edef\x{atan(2/3)} +\tzhelplines(4,4) +\tzcoor*(3,2)(A) +\tzarcsfrom[->,auto](A) + (0:180:1){1}[midway] + (180:360:1.2){2}[midway] + (0:180:1.4){3}[midway,swap] + (180:360:1.6){4}[midway,swap]; + < node [right,blue] {End!} > +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.4} +% \tzarcfrom: shift +% flag: step 1 +\begin{tikzpicture} +\tzhelplines(-2,-2)(2,2) +\tzdot*(0,0) +\edef\x{atan(2/3)} +\tzarcsfrom[red,->](0,0) + (-\x:-\x-180:1){red 1}[midway]; +\tzarcsfrom[blue,->](0,0) + (180-\x:-\x:1){blue 1}[midway]; +\tzarcsfrom[dashed,->]<.5,.5>(0,0) + (180-\x:-\x:1){blue 1}[midway]; +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.4} +% flag: step 2 +\begin{tikzpicture} +\edef\x{atan(2/3)} +\tzarcsfrom[red](0,0) + (-\x:-\x-180:1){1}[midway] + (-\x+180:-\x:2){2}[midway]; +\tzarcsfrom[blue](0,0) + (180-\x:-\x:1){1}[midway] + (-\x:-\x-180:2){2}[midway]; +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.4} +% flag: step 3 +\definecolor{flagred}{RGB}{205,48,57} +\definecolor{flagblue}{RGB}{17,73,156} +\begin{tikzpicture}[scale=1] +\edef\x{atan(2/3)} +\tzarcsfrom[draw=none,fill=flagred](0,0) + (-\x:-\x-180:1) + (-\x+180:-\x:2); + (-\x:-\x+180:1);<-- cycle> +\tzarcsfrom[draw=none,fill=flagblue](0,0) + (180-\x:-\x:1) + (-\x:-\x-180:2) + (-\x+180:-\x+360:1);<-- cycle> +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{Wedges} +\label{s:wedges} + +\subsection{\protect\cmd{\tzwedge(')}} +\label{ss:tzwedge} + +\icmd{\tzwedge} draws a wedge around a specified center coordinate. + +|\tzwedge| works similarly to |\tzarc|, but it forms a closed path from the center coordinate. + +\begin{tzdef}{} +% syntax +\tzwedge[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<pos>] +% defaults + []<>""(<m>)(<m>){}[midway] +\end{tzdef} + +\begin{tzdef}{} +% syntax +\tzwedge*[<opt>]<shift coor>"path name"(<coor>)(<angA:angB:radius>) + {<text>}[<pos>]{<fill opacity>} +% defaults + []<>""(<m>)(<m>){}[midway]{.3} +\end{tzdef} + +\begin{tztikz}{} +\tzwedge(1,1)(30:120:1) % works like: + \draw (1,1) -- ++(30:1) arc (30:120:1) -- cycle; +\end{tztikz} + +The \iisw{swap version} \icmd{\tzwedge'} switches the drawing direction from \ixxw{counterclockwise} to \ixxw{clockwise} and vice versa. + + +\begin{tztikz}{} +\tzwedge'(1,1)(30:120:1) % works like: + \draw (1,1) -- ++(30:1) arc (30:120-360:1) -- cycle; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzwedge, \tzwedge' +\begin{tikzpicture} +\tzcoor*(2,1)(A)(3pt) +\tzhelplines(4,3) +\tzwedge[blue,very thick](A)(30:120:1.5) +\tzarc[->,green] (A)(30:120:1.3) +\tzwedge'[dashed](A)(0:135:1.5){clockwise}[sloped,red] +\tzarc'[->,green](A)(0:135:1.3) +\tzwedge'[fill](A)(-60:240:1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzwedge('): shift +\begin{tikzpicture} +\tzcoor*(2,1)(A) +\tzhelplines(4,3) +\tzwedge[blue,very thick]<.1,.1>(A)(30:120:1.5) % shift +\tzarc[->,lightgray]<.1,.1>(A)(30:120:1.3) % shift +\tzwedge'[dashed](A)(0:135:1.5){clockwise}[sloped,red] +\tzarc'[->,lightgray](A)(0:135:1.3) +\tzwedge'[fill]<2,0>(A)(-60:240:1) % shift +\end{tikzpicture} +\end{tzcode} + + + + + +\subsection{\protect\cmd{\tzwedge*(')}} +\label{ss:tzwedge*} + +\icmd{\tzwedge*} works just like |\tzwedge|, but it fills wedges with |black!50| with |fill opacity=.3|, by default. +You can change the defaults with |\settzfillcolor| and |\settzfillopacity|. + +\begin{tzdef}{} +% syntax +\tzwedge*[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<pos>] +% defaults + [fill=black!50,fill opacity=.3]<>""(<m>)(<m>){}[midway] +\end{tzdef} + +\icmd{\tzwedge*'} is the \iisw{swap version} of |\tzwedge*|. + +\begin{tzcode}{.3} +% \tzwedge*, \tzwedge*' +\begin{tikzpicture}[->,>=stealth] +\tzhelplines(3,3) +\tzwedge[very thick,blue](1,1)(30:120:1.5) +\tzwedge*[-,very thick,blue,fill=red](1,1)(30:120:1) +\tzwedge'[dashed](1,1)(30:120:1.5){clockwise}[pos=.45] +\tzwedge*'[dashed,fill=green](1,1)(-90:180:1) +\tzdot*(1,1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzwedge*('): shift +\begin{tikzpicture} +\tzdot*(1,1) +\tzhelplines(3,3) +\tzwedge[blue,very thick](1,1)(30:120:1.5) +\tzwedge[red,very thick]<.5,.5>(1,1)(30:120:1.5) +\tzwedge'[dashed](1,1)(0:135:1.5) +\tzwedge*[fill=blue](1,1)(300:240:1){B}[b] +\tzwedge*[fill=red]<2,0>(1,1)(300:240:1){B}[b] +\end{tikzpicture} +\end{tzcode} + + diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc-D-v1.0.tex b/graphics/pgf/contrib/tzplot/tzplot-doc-D-v1.0.tex new file mode 100644 index 0000000000..3f76a7cb3e --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc-D-v1.0.tex @@ -0,0 +1,1792 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%========================== +\part{Plotting Graphs} +%%%========================== +\label{p:plotting} + + +%%================================== +\chapter{Axes} +\label{c:axes} + +%%------------------------------------------------------------ +\section{Draw axes} +\label{s:tzaxes} + +\subsection{\protect\cmd{\tzaxes}} +\label{ss:tzaxes} + +Basically, \cmd{\tzaxes}|(<x1,y1>)(<x2,y2>)| draws the $x$ axis from |<x1>| to |<x2>| and the $y$ axis from |<y1>| to |<y2>|. +The coordinate |(<x1,y1>)| represents the origin and |(<x2,y2>)| represents the opposite corner of the rectangle. + +|\tzaxes| takes only one coordinate |(<x2,y2>)| as a mandatory argument, in which case |(<x1,y1>)| is considered as |(0,0)|. + +\begin{tzdef}{} +% syntax: minimal +\tzaxes(<x2,y2>){<x-axis name>}{<y-axis name>} +% syntax: full +\tzaxes[<opt>]<x-shift,y-shift>(<x1,y1>)(<x2,y2>) + {<x-axis label>}[<node opt>]{<y-axis name>}[<node opt>] +% defaults + [->]<0,0>(0,0)(<m>){}[right]{}[above] +% arguments + [#1]: line style, arrow type (for x-axis & y-axis) + <#2>: axes shift coor %% axes intersect at (#2) + (#3): (x1,y1) %% origin: if omitted, regarded as (0,0) + (#4): (x2,y2) %% opposite corner: mandatory + {#5}: x-axis name + [#6]: x-axis name option %% node option + {#7}: y-axis name + [#8]: y-axis name option %% node option +\end{tzdef} + +Here, |(|\ixxw{<m>}|)| stands for a mandatory argument. + +\begin{tzcode}{.3} +% tzaxes +\begin{tikzpicture}[scale=.7] +\tzhelplines(3,3) +\tzaxes(3,3){$x$}{$y$} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +By default, the $x$ and $y$ axes intersect at $(0,0)$. +Specifying the option |<x-shift,y-shift>| moves the axes to intersect at $(\text{\ttfamily<x-shift,y-shift>})$. + + +\begin{tzcode}{.3} +% \tzaxes: shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(7,7) +\tzshoworigin* +\tzaxes[thick,blue]<1,2>(7,7){$x$}{$y$} +\tzaxes[-,dashed](7,7){$X$}[below]{$Y$}[left] +\tzaxes<6,1>(6,1)(3,6){$a$}[left]{$b$} +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzaxes*}} +\label{ss:tzaxes*} + +The starred version \icmd{\tzaxes*} sets the current state to a \iisw{bounding box} when |\tzaxes| is executed. It is recommended for you to use |\tzaxes*| as the first graphics command in |tikzpicture| environment or before any larger graphics. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5] +\tzaxes*(8,5){$x$}{$f(x)$} % bounding box +\tzhelplines(-2,-1)(10,8) +\tzto[out=90,in=-135,dashed](-2,8)(12,-2) +\tzbezier[blue](-1,-1)(3,-2)(7,12)(10,10) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzaxisx} and \protect\cmd{\tzaxisy}} +\label{s:tzaxisx} + +\icmd{\tzaxisx} draws only the $x$ axis. + +\begin{tzdef}{} +% syntax +\tzaxisx[<opt>]<y-shift>{<from>}{<to>}{<x-axis name>}[<node opt>] +% defaults + [->]<0>{<m>}{<m>}{}[right] +% arguments: + [#1]: line style, arrow type (for x-axis) + <#2>: y-shift of x-axis + {#3}: x-axis starts from %% mandatory + {#4}: x-axis runs to %% mandatory + {#5}: x-axis name + [#6]: x-axis name option %% node option +\end{tzdef} + +\icmd{\tzaxisy} draws only the $y$ axis. + +\begin{tzdef}{} +% syntax +\tzaxisy[<opt>]<x-shift>{<from>}{<to>}{<y-axis name>}[<node opt>] +% defaults + [->]<0>{<m>}{<m>}{}[above] +% arguments: + [#1]: line style, arrow type (for y-axis) + <#2>: x-shift of y axis + {#3}: y-axis starts from %% mandatory + {#4}: y-axis runs to %% mandatory + {#5}: y-axis name + [#6]: y-axis name option %% node option +\end{tzdef} + + + +\begin{tzcode}{.3} +% \tzaxisx, \tzaxisy +\begin{tikzpicture}[scale=.5] +\tzshoworigin +\tzhelplines(5,5) +\tzaxisx[blue]{-1}{5}{$xx$} +\tzaxisy[red] {-1}{5}{$yy$}[green] +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.3} +% \tzaxisx, \tzaxisy: shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(7,7) +\tzshoworigin +\tzaxisx{-1}{7}{$xx$}[near end,below] +\tzaxisy{-1}{7}{$yy$}[midway,sloped,auto] +\tzaxisx[-,dashed,red]<2>{-1}{7}{$xx'$}[blue] +\tzaxisy[-,dashed,blue]<3>{-1}{7}{$yy'$} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Display the origin} +\label{s:tzshoworigin} + +\subsection{\protect\cmd{\tzshoworigin}} +\label{ss:tzshoworigin} + + +\icmd{\tzshoworigin} prints `0' (approximately) at the bottom left of the origin |(0,0)|, by default. + +\begin{tzdef}{} +% syntax +\tzshoworigin<shift coor>(<origin>){<text>}[<node opt>] +% default + <>(0,0)<>{0}[below left,text height=1.25ex,text depth=.25ex] +\end{tzdef} + +All arguments of |\tzshoworigin| are optional. + +\begin{tzcode}{.3} +% \tzshoworigin +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,5) +\tzshoworigin +\tzaxes(8,5) +\end{tikzpicture} +\end{tzcode} + +You can change the text by specifying the curly brace option |{<text>}|, like, for example, |\tzshoworigin{$O$}|. +You can also change the coordinate of origin by the option |(<origin>)|. +Specifying the option |<shift coor>| also moves the origin. + + +\begin{tzcode}{.3} +% \tzshoworigin +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-1)(8,6) +\tzshoworigin{$O_1$} +\tzaxes(8,6){$x$}{$y$} +\tzshoworigin<2,1>{$O_2$}[red] +\tzaxes[dashed]<2,1>(8,6) +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzshoworigin*}} +\label{ss:tzshoworigin*} + + +\icmd{\tzshoworigin*} prints a node dot at the origin with no text by default. +Internally the dot is processed by |\tzdot*|. All arguments are optional. + +\begin{tzdef}{} +% syntax +\tzshoworigin*[<dot opt>]<shift coor>(<origin>){<text>}[<node opt>](<dotsize>) +% default + *[]<>(0,0)<>{}[below left,text height=1.25ex,text depth=.25ex](2.4pt) +\end{tzdef} + +\begin{tzcode}{.3} +% \tzshoworigin* +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-1)(6,4) +\tzshoworigin* +\tzaxes(-2,-1)(6,4) +\end{tikzpicture} +\end{tzcode} + +You can add text with the option |{<text>}|. +The default size of the dot is |2.4pt|, and it can be changed it with the last option |(<dot size)|. You can change the dot style using the first optional argument |[<dot opt>]|. +You can also move the dot by specifying the option |<shift coor>|. + +\begin{tzcode}{.3} +% \tzshoworigin* +\begin{tikzpicture}[scale=.5] +\tzhelplines(-1,-1)(7,7) +\tzshoworigin*[blue]{$o_1$}[red](5pt) +\tzaxes(-1,-1)(7,7){$x$}{$y$} +\tzaxes<6,4>(6,4)(1,1){$x'$}[left]{$y'$}[below] +\tzshoworigin*[fill=none]<6,4>{$O'$}[blue,ar](3pt) +\end{tikzpicture} +\end{tzcode} + +\remark +For |\tzshoworigin*|, text for the origin and the dot are placed independently. In other words, the position of node text does not depend on the size of a node dot. +(In fact, the node text for the origin should look good with the `ticks', so it was not designed as a |label| for the node dot. This also means that the origin text cannot be positioned by an |<angle>|.) + + +\begin{tzcode}{.3} +% \tzshoworigin* (with ticks) +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,1)(6,5) +\tzshoworigin*{0}(5pt) +\tzaxes(-2,-1)(6,5){$x$}{$y$} +\tzticks{1,...,5}{1,...,4} +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzaxesL(')}: L-type axes} +\label{s:tzaxesL} + +\icmd{\tzaxesL} is similar to |\tzaxes|, but it draws only the `L' type axes with |(<x1,y1>)| as the origin and |(<x2,y2>)| as the opposite corner of the rectangle. +Those two coordinates are mandatory. + +\begin{tzdef}{} +% syntax +\tzaxesL[<opt>]<shift coor>(<x1,y1>)(<x2,y2>) + {<x-axis name>}[<node opt>]{<y-axis name>}[<node opt>] +% defaults + []<>(<m>)(<m>){}[right]{}[above] +% arguments: + [#1]: line style, arrow type + <#2>: shift coordinate + (#3): (x1,y1) %% mandatory + (#4): (x2,y2) %% mandatory + {#5}: x-axis name + [#6]: x-axis name option %% node option + {#7}: y-axis name + [#8]: y-axis name option %% node option +\end{tzdef} + +The swap version \icmd{\tzaxesL'} swaps |(x1,y1)| and |(x2,y2)| from |\tzaxesL|. +That is, |\tzaxesL'(A)(B)| is equivalent to |\tzaxesL(B)(A)|. + +\begin{tzcode}{.3} +% \tzaxesL, \tzaxesL' +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,7) +\tzshoworigin +\tzaxes(8,7){$x$}{$y$} +\tzaxesL[red,thick](2,2)(6,5){$a$}{$b$} +\tzaxesL'[blue,dashed,->](2,2)(6,5){$c$}{$d$} +\tzaxesL'[->](7,1)(4,7){m}[draw,r]{n}[draw,circle] +\end{tikzpicture} +\end{tzcode} + +The option |<shift coor>| moves the whole L-type axes. + +\begin{tzcode}{.3} +% \tzaxesL, \tzaxesL': shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,7) +\tzshoworigin +\tzaxes(8,7){$x$}{$y$} +\tzaxesL[red,thick](2,2)(6,5){$a$}{$b$} +\tzaxesL[red,thick]<.5,.5>(2,2)(6,5){$a'$}{$b'$} +\tzaxesL'[blue,dashed,->](2,2)(6,5){$c$}{$d$} +\tzaxesL'[blue,dashed,->]<-1,-1>(2,2)(6,5){$c'$}{$d'$} +\end{tikzpicture} +\end{tzcode} + + + +%%================================== +\chapter{Ticks} +\label{c:ticks} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzticks}: Tick labels} +\label{s:tzticks} + +By default, \icmd{\tzticks} prints tick labels and draw zero length tick marks, i.e. from |(0pt)| to |(0pt)|. + +\begin{tzdef}{} +% syntax: minimal +\tzticks{<x-ticks pos>}{<y-ticks pos>} +% syntax: medium +\tzticks(<x-from:x-to>){<x-ticks pos/labels>}[<node opt>] + (<y-from:y-to>){<y-ticks pos/labels>}[<node opt>] +% syntax: full +\tzticks[<opt>]<x-shift,y-shift> + (<x-from:x-to>){<x-ticks pos/labels>}[<node opt>] + (<y-from:y-to>){<y-ticks pos/labels>}[<node opt>] +% defaults + []<0,0>(0pt:0pt){<m>}[text height=1.25ex,text depth=.25ex,below](0pt:0pt){}[left] +\end{tzdef} + +\paragraph{Tick labels} +Internally, |\tzticks| uses \Tikz's |foreach| operation. +So you need to provide comma separated lists to print tick labels. +If only one comma separated is used, it is for $x$ tick labels. + +\begin{tzcode}{.3} +% \tzticks +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzaxes(-1,-1)(10,10) +\tzticks[blue]{1,...,8}{2,...,7} +\end{tikzpicture} +\end{tzcode} + +You change the numbered labels to a different format slashes and other text, as follows: |<number>/<other text>|. + +\begin{tzcode}{.3} +% \tzticks: tick labels +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzaxes(-1,-1)(10,10) +\tzticks{1/$x_1$,2,5/$x_2$,8/$x_3$}[blue] + {2/$\sqrt{x}$,3/y,4/m,5,7/$k$}[red] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Tick marks} +To prints tick marks you need to specify |(<x-from:x-to>)| for $x$ ticks and/or |(<y-from:y-to>)| for $y$ ticks. (The default is |(0pt:0pt)|.) + +\begin{tzcode}{.3} +% \tzticks: tick marks +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzticks[draw=red,thick] + (-5pt:10pt){1,...,7,8/$\alpha$} + (0pt:3cm){2,...,6,7/$\beta$} +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} +The position of tick labels does not depend on the length of the tick marks. +To change the position, use the option |<x-shift,y-shift>|, where |<x-shift>| is for |y-ticks| and |<y-shift>| is for |x-ticks|. + +\begin{tzcode}{.3} +% \tzticks: shift +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzaxes[dashed]<4,2>(-1,-1)(10,10) +\tzticks[draw=red]<4,2> + (-5pt:10pt){5,...,8} + (0pt:3cm){3,...,7} +\end{tikzpicture} +\end{tzcode} + + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzticks*}: Tick marks} +\label{s:tzticks*} + +The starred version \icmd{\tzticks*} always ignores all tick labels and draws tick marks from |0pt| to |3pt|, by default. + +\begin{tzdef}{} +% syntax: minimal +\tzticks*{<x-ticks pos>}{<y-ticks pos>} +% syntax: medium +\tzticks*(<x-from:x-to>){<x-ticks pos>}(<y-from:y-to>){<y-ticks pos>} +% syntax: full +\tzticks*[<opt>]<x-shift,y-shift> + (<x-from:x-to>){<x-ticks pos/labels>}(<y-from:y-to>){<y-ticks pos/labels>} +% defaults + []<0,0>(0pt:3pt){<m>}(0pt:3pt){} +% starred(*) version always ignores tick labels +\end{tzdef} + +\begin{tzcode}{.3} +% \tzticks* +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzticks*[draw=red,thick] + {1,...,7,8/$\alpha$} % label ignored + (0pt:3cm){2,...,6,7/$\beta$} % label ignored +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.5} +% \tzticks* +\begin{tikzpicture}[scale=.5] +\tzhelplines(10,8) +\tzaxes(-1,-1)(10,8) +\tzticks*{0,0.2,...,8} + {0,0.2,...,7} % default +\tzticks*(0pt:10pt){1,...,8} + (0pt:10pt){1,...,7} +\tzticks{1,...,8}{2,...,7} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzticksx(*)} and \protect\cmd{\tzticksy(*)}} +\label{s:tzticksx} + +You can handle $x$ ticks and $y$ ticks independently. + +\paragraph{X ticks} + +\icmd{\tzticksx} only prints x-tick labels but not tick marks, by default. +To prints tick marks you need to specify |(<x-from>:<x-to>)|. + +\begin{tzdef}{} +% syntax +\tzticksx[<opt>]<y-shift>(<from>:<to>){<x-tick pos/labels>}[<node opt>] +% defaults + []<>(0pt:0pt){<m>}[text height=1.25ex,text depth=.25ex,below] +\end{tzdef} + + +\icmd{\tzticksx*} only prints x-tick marks from |0pt| to |3pt|, by default, suppressing tick labels. + +\begin{tzdef}{} +% syntax: +\tzticksx*[<opt>]<y-shift>(<from>:<to>){<xtick pos>} +% defaults + *[]<>(0pt:3pt){<m>} +% starred(*) version always suppresses tick labels +\end{tzdef} + + +\paragraph{Y ticks} + +\icmd{\tzticksy} only prints y-tick labels but not tick marks, by default. +To prints tick marks you need to specify |(<x-from>:<x-to>)|. + +\icmd{\tzticksy*} only prints y-ticks from |0pt| to |3pt| by default, suppressing tick labels. + +\begin{tzdef}{} +% syntax: +\tzticksy[<opt>]<x-shift>(<from:to>){<y-ticks pos/labels>}[<node opt>] +% defaults + []<>(0pt:0pt){<m>}[] +\end{tzdef} + +\begin{tzdef}{} +% syntax +\tzticksy*[<opt>]<x-shift>(from:to){<yticks pos>} +% defaults + []<>(0pt:0pt){<m>} +% starred(*) version suppresses tick labels +\end{tzdef} + + +\begin{tzcode}{.3} +% \tztickx(*), \tzticky(*) +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzticksx [draw=red,thick] + (-5pt:1cm){1,...,7,8/$\alpha$} +\tzticksy*[draw=blue,thick] + (0pt:3cm){2,...,6,7/$\beta$} % labels ignored +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +The options |<y-shift>| and |<x-shift>| move x-ticks and y-ticks, respectively. + +\begin{tzcode}{.3} +% \tztickx(*), \tzticky(*): shift +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzaxes[dashed]<2,1>(-1,-1)(10,10) +\tzticksx*[draw=red,thick] + <1>(-5pt:10pt){1,...,7,8/$\alpha$} % labels ignored +\tzticksy [draw=blue,thick] + <2>(0pt:3cm){2,...,6,7/$\beta$} +\end{tikzpicture} +\end{tzcode} + + + + +%%================================== +\chapter{Projections} +\label{c:projections} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzproj(*)}} +\label{s:tzproj} + +\icmd{\tzproj} accepts a mandatory coordinate and draws perpendicular lines onto each axis from the coordinate. The lines are |dotted|, by default. + +\begin{tzdef}{} +% syntax: minimum + \tzproj(<coor>) +% syntax: medium + \tzproj*(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>] +% syntax: + \tzproj*[<opt>]<x-shift,y-shift>(<coor>) + {<x-text>}[<node opt>]{<y-text>}[<node opt>](<dot size>) +% defaults + *[]<0,0>(<m>){}[text height=1.25ex,text depth=.25ex,below]{}[left](2.4pt) +\end{tzdef} + +\icmd{\tzproj*} additionally prints a black node dot of the size |2.4pt|, by default. + +\paragraph{Dot size} +You can only control the size of by |(<dot size>)| or by the \threeways\ on page \pageref{ss:threeways}. +If you want to control |fill| or |color|, use |\tzdot*|. + +\begin{tzcode}{.3} +%\tzproj(*) +\begin{tikzpicture}[scale=.5] +\tzaxes(8,6) +\tzproj[dashed,blue](2,3) +\tzcoors(30:7)(A)(50:6)(B); +\tzproj*(A) +\tzproj*[dashed,text=blue](B)(5pt) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} +You can also add text around the projection point on each axis by the option |{<text>}|. +The position and color of the text is controlled by the option |[<node option>]|. +The default position is (approximately) |[below]| for the x axis and |[left]| for the y axis. + + +\begin{tzcode}{.3} +% \tzproj(*): adding text +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(8,6) +\tzproj[dashed,blue](2,3){$x$}{$y$} +\tzcoors(30:7)(A)(50:6)(B); +\tzproj*[text=blue](A){$a_1$}{$a_2$} +\tzproj*[dashed](B){$x^*$}[green]{$y^*$}[red] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Projection shift} +Specifying the option |<x-shift,y-shift>| moves the projection point and text on each axis. + +\begin{tzcode}{.3} +% \tzproj(*): projection shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(8,6) +\tzproj[dashed,blue](2,3){$x$}{$y$} +\tzcoors(30:7)(A)(50:6)(B); +\tzaxes[blue]<3,1>(8,6) +\tzproj*[dashed,text=blue]<3,1>(A){$a_1$}{$a_2$} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzprojx(*)} and \protect\cmd{\tzprojy(*)}} +\label{s:tzprojx} + +\icmd{\tzprojx} draw a dotted line, which is perpendicular to the x axis. + +\icmd{\tzprojx*} additionally prints a black node dot of the size |2.4pt|, by default. + + +\begin{tzdef}{} +% syntax: + \tzprojx[<opt>]<x-shift,y-shift>(<coor>){<x-text>}[<node opt>](<dot size>) +% defaults + []<0>(<m>){}[text height=1.25ex,text depth=.25ex,below](2.4pt) +\end{tzdef} + + +\icmd{\tzprojy} draws a dotted line, which is perpendicular to the y axis. + +\icmd{\tzprojy*} additionally prints a black node dot of the size |2.4pt|, by default. + +\begin{tzdef}{} +% syntax: + \tzprojy[<opt>]<x-shift,y-shift>(<coor>){<y-text>}[<node opt>](<dot size>) +% defaults + []<0>(<m>){}[left](2.4pt) +\end{tzdef} + + +You can only control the size of by |(<dot size>)|. +If you want to control |fill| or |color|, use |\tzdot*|. +You can also add text around the projection point on each axis by specifying the option |{<x-text>}| or |{<y-text>}| followed by the option |[<node option>]|. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(-1,-2)(6,6) +\tzshoworigin +\tzaxes(-1,-1)(6,6) +\tzproj*[dashed](4,5){4}{5}(3pt) +\tzprojx*[green,thick,solid](3,4){$x=3$}[blue] +\tzprojy*[thick](5,2){2}(5pt) +\end{tikzpicture} +\end{tzcode} + +Specifying the option |<x-shift,y-shift>| with |\tzprojx(*)| and |\tzprojy(*)| moves the projection point and text accordingly. + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(-1,-2)(6,6) +\tzshoworigin +\tzaxes(-1,-1)(6,6) +\tzaxes[blue]<2,1>(-1,-1)(6,6) +\tzprojx*[green,thick,solid]<2,1>(3,4){$x=3$}[blue] +\tzprojy*[thick]<2,1>(5,2){2}(5pt) +\end{tikzpicture} +\end{tzcode} + + + + +%%================================== +\chapter{Plot Functions} +\label{c:functions} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzfn}: Plot functions} +\label{s:tzfn} + +\subsection{Syntax} +\label{ss:tzfn} + +\icmd{\tzfn} plots a function of |\x|. + +\begin{tzdef}{} +% syntax: minimum +\tzfn{<fn of \x>}[<domain>] +% syntax: medium +\tzfn{<fn of \x>}[<domain>]{<text>}[<pos>] +% syntax +\tzfn[<opt>]<shift coor>"<path name>" + {<fn of \x>}[<domain>]{<text>}[<node opt>]<code.append> +% [<domain>] should be of the form [<from num:to num>] +% defaults + [samples=200]<>""{<m>}[<m>]{}[]<> +\end{tzdef} + +|\tzfn| takes two mandatory arguments: |{<fn of \x>}| and |[<domain>]|. +The domain should be of the form |[<from num:to num>]|, like |[1:5]|. + +\begin{tztikz}{} +\tzfn{2*\x+1}[1:5] % works like: + \draw [samples=200,domain=1:5] plot (\x,{2*\x+1}); +\end{tztikz} + + +\subsection{Define and name functions} + +To use |\tzfn| you need to express a function as a function of |\x|. +You can add text (as a function name) at the end of the graph, +by specifying |{<text>}| and |[<node opt>]| immediately after the domain. + +\begin{tzcode}{.3} +% \tzfn +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,8) +\tzaxes(8,8) +\def\Dx{7-2/3*\x} +\tzfn{\Dx}[0:7]{$D$}[r] +\tzfn{1+\x}[0:7]{$S$}[blue,r] +\end{tikzpicture} +\end{tzcode} + +You can also use the predefined functions of \Tikz such as |sin|, |cos|, |ln|, |log10|, |log2|, |exp|, |sqrt|, and so on. (See \Tikz\ manual.) + +\begin{tzcode}{.3} +% \tzfn +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(8,6) +\tzaxes*(-2,-2)(8,6) +\def\Fx{sin(\x r)+3} +\def\Gx{exp(\x)} +\def\Hx{ln(\x)} +\tzfn\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r] +\tzfn[blue]\Gx[-2:2]{$e^x$}[red,r] +\tzfn[dashed]\Hx[.2:7]{$\ln\,x$}[r] +\end{tikzpicture} +\end{tzcode} + +\subsection{Name paths: \texttt{name path}} + +You can name the path of |\tzfn| by specifying the option |"<path name>"| immediately before the mandatory argument |{<fn of \x>}|. You can use the path name to find intersection points. + +\begin{tztikz}{} +\tzfn"mypath"\Fx[1:5] % works like: + \draw [samples=200,,domain=1:5,name path=mypath] plot (\x,{\Fx}}; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzfn: name path: intersection point +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,8) +\tzaxes(8,8) +\def\Dx{7-2/3*\x} +\def\Sx{1+\x} +\tzfn"Dx"\Dx[0:7]{$D$}[r] +\tzfn"Sx"\Sx[0:7]{$S$}[blue,r] +\tzXpoint*{Dx}{Sx}(E){E} +\end{tikzpicture} +\end{tzcode} + +\remark +Suppose that the mandatory argument |<fn of \x>| is represented by a macro name only, say |\Fx|. Then +\begin{itemize} +\item The name |Fx| (without the backslash) of the macro can be used as |<path name>|, unless you specify another name. +\item That is, |\tzfn\Fx| is equivalent to |\tzfn"Fx"\Fx|. +(You don't need to type the same thing twice.) +\begin{tztikz}{} +\tzfn\Fx[1:5] % works like: + \draw [samples=200,domain=1:5,name path=Fx] plot (\x,{\Fx}); +\end{tztikz} +\end{itemize} + +\subsection{Move graphs: \texttt{shift}} + +You can move the graph of |\tzfn| by specifying the option |<shift coor>| before the mandatory argument |{<fn of \x>}| or immediately after the option |"<path name">|, if any. + +\begin{tzcode}{.3} +% \tzfn: shift +\begin{tikzpicture}[scale=.6] +\tzhelplines(8,8) +\def\Dx{7-2/3*\x} +\def\Sx{1+\x} +\tzfn \Dx[0:7]{$D$}[right] % name path = Dx +\tzfn"supply"\Sx[0:7]{$S$}[right] % name path = supply +\tzXpoint*{Dx}{supply}(E){$E$} +\tzfn[dashed]<1,1>"demandA"\Dx[0:7]{$D'$}[right] +\tzfn[dashed]<1,-1>"supplyA"\Sx[0:7]{$S'$}[right] +\tzXpoint*{demandA}{supplyA}(E1){$E'$} +\end{tikzpicture} +\end{tzcode} + + +\subsection{Extend paths: \texttt{<code.append>}, \protect\cmd{\tzfnAtBegin}, \protect\cmd{\tzfnAtEnd}} +\label{ss:tzfn:atbegin} + +\paragraph{\texttt{<code.append>}} +You can extend the path created by |\tzfn| from the end of the graph, by writing \Tikz\ code in the \xem{last optional argument} |<code.append>|. Internally it add the \Tikz\ code after the text node |{<text>}| and |[<node opt>]|. + +\begin{tzcode}{.3} +% \tzfn: <code.append> +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(8,6) +\tzaxes*(-2,-2)(8,6) +\def\Fx{sin(\x r)+3} +\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r] + < to [bend right] ++(2,-2) node [b] {End!} > +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{\bs tzfnAtEnd}} +You can also extend the path with \icmd{\tzfnAtEnd}. +Internally it adds \Tikz\ code immediately before the options |{<text>}| and |[<node opt>]|. But you have to use |\tzfnAtEnd| (immediately) \xem{before each} |\tzfn|. + +\begin{tzcode}{.3} +% \tzfnAtEnd +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(8,6) +\tzaxes*(-2,-2)(8,6) +\def\Fx{sin(\x r)+3} +\tzfnAtEnd{to [bend right] ++(2,-2) node [b] {End!}} +\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r] +% < to [bend right] ++(2,-2) node [b] {End!} > +\end{tikzpicture} +\end{tzcode} + + +\paragraph{\texttt{\bs tzfnAtBegin}} +You can use \icmd{\tzfnAtBegin} (immediately) \xem{before each} |\tzfn| to insert \Tikz\ code before the path of |\tzfn|. + +\begin{tzcode}{.3} +% \tzfnAtBegin +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(8,6) +\tzaxes*(-2,-2)(8,6) +\def\Fx{sin(\x r)+3} +\tzfnAtBegin{ (0,0) -- } +\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzLFn}: Plot linear functions} +\label{s:tzLFn} + + +\icmd{\tzLFn} draws a linear function: $y=ax+b$. + +\begin{itemize} +\item +When you know two coordinates on a line, +|\tzLfn(<coor1>)(<coor2>)| draws the line. +\item +When you know one coordinate and the slope of a line, +|\tzLfn(<coor1>){<slope>}| draws the line. +\item +If you specify all the three arguments |(<coor1>)(<coor2>){<slope>}|, then the slope is ignored. +\end{itemize} + +\begin{tzdef}{} +% syntax +\tzLFn[<opt>]<shift coor>"<path name>" + (<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append> +% defaults +[]<>""(<m>)(){1}[<m>]{}[]<> +\end{tzdef} + +|\tzLFn| accepts two mandatory arguments: |(<coor1>)| and |<domain>|. +\begin{itemize} +\item The domain should be of the form |[<from num:to num>]|. +\item If just one coordinate is specified without a slope, the slope is regarded as |1|, by default. +\end{itemize} + +For example, |\tzLFn(1,1)(2,3)[0:4]| draws a line passing through two points: $(1,1)$ and $(2,3)$, over $0\leq x\leq 4$. +|\tzdefLFn\Gx(1,1){.5}[0:4]| draws a line passing through a point $(1,1)$ with the slope |.5|, over $0\leq x\leq 4$. + +You can add text at the end of the line of |\tzLFn| by the options |{<text>}| and |[<node opt>]|. You can also name the path of |\tzLFn| by specifying the option |"<path name>"| immediately before the mandatory coordinate. + +\begin{tzcode}{.3} +% \tzLFn +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFn[red]"Fx"(A){.5}[0:4]{$f(x)$}[a] +\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r] +\tzXpoint*[fill=none]{Fx}{Gx}(E){$E$}(3pt) +\end{tikzpicture} +\end{tzcode} + +You can move the line by specifying the option |<shift coor>| immediately before |"<path name">|. +You can also expand the path of |\tzLFn| by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzLFn: shift, expanding path +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r] +\tzLFn[dashed,red,->]<1,1>"Gx"(B)(C)[0:4]{$g(x)$}[r] + < arc (0:140:2) node [below] {End!} > +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Horizontal lines} +\label{s:tzhfn} + +\subsection{\protect\cmd{\tzvfnat}} +\label{ss:tzhfnat} + +\icmd{\tzhfnat} draws a horizontal line at a specified value of $y$. + + +\begin{tzdef}{} +% syntax: minimal +\tzhfnat{<y-val>}[<domain>] +% syntax: full + \tzhfnat[<opt>]<shift coor>"<path name>"{<y-val>}[<domain>]{<text>}[<pos>]<code.append> +% defaults + []<>""{<m>}[left:right (of current bonding box)]{}[]<> +\end{tzdef} + +|\tzhfnat| accepts only one mandatory argument |{<y-val>}|. +The domain is optional and should be of the form |[<from num:to num>]|. +The default domain is from left to right of the \ixxw{current bounding box}. + +\remark Internally, the default domain of |\tzhfn| depends on \ixxw{current bounding box}. +\begin{itemize} +\item Each |\tzhfnat| may draw a line with a (slightly) different length. +\item If an appropriate |current bounding box| is not formed before |\tzhfnat| is executed, you will probably get an unexpected result. +\item In that case, you can fix a |bounding box| in the beginning of the |tikzpicture| environment using macros such as \icmd{\tzbbox}, \icmd{\tzhelplines*}, \icmd{\tzaxes*}, or \Tikz's \icmd{\useasboundingbox}. +\end{itemize} + + +\begin{tzcode}{.3} +% \tzhfnat +\begin{tikzpicture} +\tzhelplines(4,3) +\tzhfnat[blue,thick]{0} +\tzhfnat[red,thick]{1}[1:3]{line A}[r] +\tzhfnat[blue]{2}{line B}[r] +\tzhfnat[red]{3}[0:3]{line C}[draw=blue,red,r] +\end{tikzpicture} +\end{tzcode} + +You can name the path of |\tzhfnat| by the option |"<path name>"|. +You can move the line by the option |<shift coor>|. +You can also expand the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzhfnat: shift +\begin{tikzpicture} +\tzhelplines*(4,4) % bonding box +\tzfn"XX"{\x}[0:4] +\tzhfnat[blue,thick]{0} +\tzhfnat[red,thick]<-.5,.5>"AA"{1}[1:3]{line A'}[r] +\tzXpoint*{AA}{XX} +\tzhfnat[blue,->]{2}{line B}[r] + < arc (0:120:1.5) node [b,draw] {End!} > +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzhfn}} +\label{ss:tzhfn} + +\icmd{\tzhfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $y$ value of the coordinate. +For example, |\tzhfn(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhfnat{3}|. + +\xem{Everything else is the same as in} |\tzhfnat|. + +\begin{tzdef}{} +% syntax: minimal +\tzhfn(<coor>)[<domain>] +% syntax: full + \tzhfn[<opt>]<shift coor>"<path name>"(<coor>)[<domain>]{<text>}[<pos>]<code.append> +% defaults + []<>""{<m>}[left to right of current bonding box]{}[]<> +\end{tzdef} + +\begin{tzcode}{.3} +% \tzhfn: shift +\begin{tikzpicture} +\tzhelplines*(4,4) % bonding box +\tzcoors(0,1)(A)(0,2)(B); +\tzfn"XX"{\x}[0:4] +\tzhfn[blue,thick](5,0) % x=5 ignored +\tzhfn[red,thick]<-.5,.5>"AA"(A)[1:3]{line A'}[r] +\tzXpoint*{AA}{XX} +\tzhfn[blue,->](B){line B}[r] + < arc (0:120:1.5) node [b,draw] {End!} > +\end{tikzpicture} +\end{tzcode} + + + + + + +%%------------------------------------------------------------ +\section{Vertical lines} +\label{s:tzvfn} + +\subsection{\protect\cmd{\tzvfnat}} +\label{ss:tzvfnat} + +\icmd{\tzvfnat} draws a vertical line at a specified value of $x$. + + +\begin{tzdef}{} +% syntax: minimal +\tzvfnat{<x-val>}[<domain>] +% syntax: full + \tzvfnat[<opt>]<shift coor>"<path name>"{<x-val>}[<domain>]{<text>}[<pos>]<code.append> +% defaults + []<>""{<m>}[bottom:top (of current bonding box)]{}[]<> +\end{tzdef} + +|\tzvfnat| accepts only one mandatory argument |{<x-val>}|. +The domain is optional and should be of the form |[<from num:to num>]|. +The default domain is from bottom to top of the \ixxw{current bounding box}. + + +\begin{tzcode}{.3} +% \tzvfnat +\begin{tikzpicture} +\tzhelplines(4,4) +\tzvfnat[blue,thick]{0} +\tzvfnat[red,thick]{1}[1:3]{line A}[a] +\tzvfnat[blue]{2}{line B}[a] +\tzvfnat[red]{3}[0:3]{line C}[draw=blue,red,a] +\end{tikzpicture} +\end{tzcode} + +You can name the path of |\tzvfnat| by the option |"<path name>"|. +You can move the line by the option |<shift coor>|. +You can also expand the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzvfnat: shift +\begin{tikzpicture} +\tzhelplines*(4,4) % bonding box +\tzfn"XX"{\x}[0:4] +\tzvfnat[blue,thick]{0} +\tzvfnat[red,thick]<.5,-.5>"AA"{1}[1:3]{line A'}[a] +\tzXpoint*{AA}{XX} +\tzvfnat[blue,->]{2}{line B}[a] + < arc (90:-30:1.5) node [b,draw] {End!} > +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzvfn}} +\label{ss:tzvfn} + +\icmd{\tzvfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $x$ value of the coordinate. +For example, |\tzvfn(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvfnat{3}|. + +\xem{Everything else is the same as in} |\tzvfnat|. + +\begin{tzdef}{} +% syntax: minimal +\tzvfn(<coor>)[<domain>] +% syntax: full +\tzvfn[<opt>]<shift coor>"<path name>"(<coor>)[<domain>]{<text>}[<pos>]<code.append> +% defaults + []<>""{<m>}[bottom:top (of current bonding box)]{}[]<> +\end{tzdef} + +\begin{tzcode}{.3} +% \tzvfn: shift +\begin{tikzpicture} +\tzhelplines*(4,4) % bonding box +\tzcoors(1,0)(A)(2,0)(B); +\tzfn"XX"{\x}[0:4] +\tzvfn[blue,thick](0,5) % y=5 ignored +\tzvfn[red,thick]<.5,-.5>"AA"(A)[1:3]{line A'}[a] +\tzXpoint*{AA}{XX} +\tzvfn[blue,->](B){line B}[a] + < arc (90:-30:1.5) node [b,draw] {End!} > +\end{tikzpicture} +\end{tzcode} + + + + + +%%================================== +\chapter{Intersections} +\label{c:intersections} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzXpoint(*)}: Intersection points} +\label{s:intersections} + +\icmd{\tzXpoint} finds intersection points of two paths and save them as coordinate names for later use. + +\begin{tzdef}{} +% syntax: minimal +\tzXpoint{<path>}{<path>}(<coor name>) +% syntax: medium +\tzXpoint{<path>}{<path>}(<coor name>){<label>}[<angle>] +% syntax: full +\tzXpoint[<opt>]{<path>}{<path>}(<coor name>)[<nth>]{<label>}[<[<label opt>]angle>] +% defaults + []{<m>}{<m>}()[1]{}[] +\end{tzdef} + +For example, |\tzXpoint{path1}{path2}(A)| determines an intersection of the two paths and names the point |(A)| or |(A-1)|. (By default the name is |(intersection)| as in \Tikz.) +If there are two or more intersection points, they are named as follows: |(A)=(A-1)|, |(A-2)|, |(A-3)|, etc. + +You can determine which intersection point is named by specifying the option |[<nth>]|. If you select the second intersection point to be named |(A)| out of multiple intersections, they are named as follows: |(A-1)|, |(A)=(A-2)|, |(A-3)|, |(A4)|, etc. +You can label intersection points by specifying the option |{<label>}| and |[<angle>]|. + + +\begin{tzcode}{.3} +% \tzXpoint +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,8) +\tzaxes(8,8) +\tzto[red,bend right]"AA"(1,8)(8,1) +\tzto[blue,bend right]"BB"(0,2)(8,6) +\tzXpoint{AA}{BB}(A) +\tzdot*(A) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{\icmd{\tzXpoint*}} The starred version |\tzXpoint*| simply adds a node dot to |\tzXpoint|. +The default dot size is |2.4pt| and it can be changed by the last option |(<dot size>)| or the \threeways\ (on page \pageref{ss:threeways}). + +\begin{tzdef}{} +% syntax: minimum +\tzXpoint*{<path>}{<path>} +% syntax: medium +\tzXpoint*{<path>}{<path>}(<coor name>){<label>}[<angle>] +% syntax: +\tzXpoint*[<opt>]{<path>}{<path>} + (<coor name>)[<nth>]{<label>}[<[<label opt>]angle>](<dotsize>) +% defaults + [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt) +\end{tzdef} + + + +\begin{tzcode}{.3} +% \tzXpoint* +\begin{tikzpicture}[scale=.5] +\tzhelplines(10,10) +\tzaxes(10,10) +\def\bgt{8-\x} +\def\Fx{\x} +\def\IC{7/\x} +\tzfn\bgt[0:8] % name path=bgt +\tzfn\Fx[0:8]{ray}[red,ar] % name path=Fx +\tzfn"IC"\IC[.8:8]{$u$}[r] % name path=IC +\tzXpoint*{bgt}{Fx}(A){A}[0] % <angle> +\tzproj[dashed](A){$x$}{$y$} +\tzXpoint*[fill=none,red]{bgt}{IC}(B){B}[0](4pt) +\tzdot*[blue](B-2){B2}[[red]45](4pt) +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{Vertical intersection points} +\label{s:tzvXpointat} + +\subsection{\protect\cmd{\tzvXpointat(*)}} +\label{ss:tzvXpointat} + +\icmd{\tzvXpointat} determines vertical intersection points of a path at a specified value of $x$. +So it takes |{<path>}| and |{<x-val>}| as mandatory arguments. + +\remark +Internally, |\tzvXpointat| depends on |current bounding box|, which generally does not cause a problem because it is used after paths to be intersected is drawn. +In case of any problem of no intersection point, you can use |\tzbbox| or |\tzaxes*| or \Tikz's |\useasboundingbox| to fix a bounding box. + +\begin{tzdef}{} +% syntax: minimal +\tzvXpointat{<path>}{<x-val>}(<coor name>) +% syntax: medium +\tzvXpointat{<path>}{<x-val>}(<coor name>){<label>}[<angle>] +% syntax: full +\tzvXpointat[<opt>]{<path>}{<x-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>] +% defaults + []{<m>}{<m>}()[1]{}[] +\end{tzdef} + +\xem{Everything else is the same as in} |\tzXpointat|. + + +The starred version \icmd{\tzvXpointat*} additionally prints a node dot of the size |2.4pt|, by default, at the (first) intersection point. + +\begin{tzdef}{} +% syntax: minimum +\tzvXpointat*{<path>}{<x-val>} +% syntax: medium +\tzvXpointat*{<path>}{<x-val>}(<coor name>){<label>}[<angle>] +% syntax: full +\tzvXpointat*[<opt>]{<path>}{<x-val>} + (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt) +\end{tzdef} + +\begin{tzcode}{.3} +% \tzvXpointat(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\def\Fx{.5*(\x-2)^2} +\tzfn\Fx[0:4] % name path=Fx +\tzvfnat[dashed]{1} +\tzvXpointat{Fx}{1}(A) +\tzdot(A){A}[45] +\tzvXpointat*{Fx}{3.2}{B}[-45] +\end{tikzpicture} +\end{tzcode} + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzvXpoint(*)}} +\label{ss:tzvXpoint} + +\icmd{\tzvXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find vertical intersection points of a path at the $x$ value of the coordinate, ignoring the $y$ value. +For example, |\tzvXpoint{mypath}(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvXpointat{mypath}{3}|. + +\xem{Everything else is the same as in} |\tzvXpointat|. + +\begin{tzdef}{} +% syntax +\tzvXpoint[<opt>]{<path>}{<coor>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>] +% defaults + []{<m>}(<m>)[1]{}[]() +\end{tzdef} + +The starred version \icmd{\tzvXpoint*} just adds a node dot to |\tzvXpoint|. + +\begin{tzdef}{} +% syntax +\tzvXpoint*[<opt>]{<path>}(<coor>) + (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt]{<m>}(<m>)()[1]{}[](2.4pt) +\end{tzdef} + +|\tzvXpoint*| prints, at the first intersection point, a node dot of the size 2.4pt by default. + +\begin{tzcode}{.3} +% \tzvXpoint(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\def\Fx{.5*(\x-2)^2} +\tzfn\Fx[0:4] % name path=Fx +\tzcoors(1,0)(A)(3.2,0)(B); +\tzvfn[dashed](1,0) +\tzvXpoint{Fx}(A)(Ax) +\tzdot(Ax){Ax}[45] +\tzvXpoint*{Fx}(B){B}[-45] +\end{tikzpicture} +\end{tzcode} + + + + + + + + +%%------------------------------------------------------------ +\section{Horizontal intersection points} +\label{s:tzhXpointat} + +\subsection{\protect\cmd{\tzhXpointat(*)}} +\label{ss:tzhXpointat} + +\icmd{\tzhXpointat} determines vertical intersection points of a path at a specified value of $y$. +So it takes |{<path>}| and |{<y-val>}| as mandatory arguments. + +\begin{tzdef}{} +% syntax: minimal +\tzhXpointat{<path>}{<y-val>}(<coor name>) +% syntax: medium +\tzhXpointat{<path>}{<y-val>}(<coor name>){<label>}[<angle>] +% syntax: full +\tzhXpointat[<opt>]{<path>}{<y-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>] +% defaults + []{<m>}{<m>}()[1]{}[] +\end{tzdef} + +\xem{Everything else is the same as in} |\tzXpoint|. + + +The starred version \icmd{\tzhXpoint*} additionally prints a node dot of the size 2.4pt by default at the intersection point. + +\begin{tzdef}{} +% syntax: minimum +\tzhXpointat*{<path>}{<y-val>} +% syntax: medium +\tzhXpointat*{<path>}{<y-val>}(<coor name>){<label>}[<angle>] +% syntax: full +\tzhXpointat*[<opt>]{<path>}{<y-val>} + (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt) +\end{tzdef} + +\begin{tzcode}{.3} +% \tzhXpointat(*) +\begin{tikzpicture} +\tzhelplines*(4,3) +\def\Fx{.5*(\x-2)^2} +\tzfn\Fx[0:4] % name path=Fx +\tzhXpointat{Fx}{1}(A) +\tzdot(A){A}[0] +\tzhfnat[dashed]{1.5} +\tzhXpointat*{Fx}{1.5}(X){X}[45] +\tzdot*(X-2){Y}[135] +\end{tikzpicture} +\end{tzcode} + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzhXpoint(*)}} +\label{ss:tzhXpoint} + +\icmd{\tzhXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find vertical intersection points of a path at the $y$ value of the coordinate, ignoring the $x$ value. +For example, |\tzhXpoint{mypath}(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhXpointat{mypath}{3}|. + +\xem{Everything else is the same as in} |\tzhXpointat|. + +\begin{tzdef}{} +% syntax +\tzhXpointat[<opt>]{<path>}{<y-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>] +% defaults + []{<m>}{<m>}()[1]{}[]() +\end{tzdef} + +The starred version \icmd{\tzhXpoint*} just adds a node dot to |\tzhXpoint|. + +\begin{tzdef}{} +% syntax +\tzhXpoint*[<opt>]{<path>}(<coor>) + (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt]{<m>}(<m>)()[1]{}[](2.4pt) +\end{tzdef} + +|\tzhXpoint*| prints, at the first intersection point, a node dot of the size |2.4pt|, by default. + +\begin{tzcode}{.3} +% \tzhXpoint(*) +\begin{tikzpicture} +\tzhelplines*(4,3) +\def\Fx{.5*(\x-2)^2} +\tzfn\Fx[0:4] % name path=Fx +\tzcoors(0,1)(A)(0,1.5)(B); +\tzhXpoint{Fx}(A)(A) +\tzdot(A){A}[0] +\tzhfn[dashed](0,1.5) +\tzhXpoint*{Fx}(X){X}[45] +\tzdot*(X-2){Y}[135] +\end{tikzpicture} +\end{tzcode} + + + + + +%%================================== +\chapter{Secant and Tangent Lines} +\label{c:tangent} + +%%------------------------------------------------------------ +\section{Secant lines} +\label{s:secant} + +\subsection{\protect\cmd{\tzsecantat}} +\label{ss:tzsecantat} + +\icmd{\tzsecantat} draws a chord or a secant line of a curve, on the |behind| layer by default. +You need to specify a path name and two values of $x$. +With \icmd{\settzsecantlayer}, you can change the layer, like |\settzsecantlayer{main}|. + +\begin{tzdef}{} +% syntax: minium +\tzsecantat{<path>}{<from-x>}{<to-x>} +% syntax: medium +\tzsecantat{<path>}{<from-x>}{<to-x>}[<domain>]{<text>}[<node opt>] +% syntax: full +\tzsecantat[<opt>]<shift coor>"path name" + {<path>}{<from-x>}{<to-x>}[<domain>]{<text>}[<node opt>]<code.append> +% defaults + []<>""{<m>}{<m>}{<m>}[]{}[]<> +\end{tzdef} + +\paragraph{Domain} +The domain should be of the form |[<from num:to num>]|. +Without specifying the optional domain, |\tzsecantat| draws a chord. + +\begin{tzcode}{.3} +% \tzsecantat +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5) +\tzsecantat[thick,red]{curve}{1}{3} +\tzsecantat[thick,red]{curve}{1}{4} +\tzsecantat[thick,red]{curve}{1}{7} +\end{tikzpicture} +\end{tzcode} + +You can optionally specify the |[<domain>]|. + +\begin{tzcode}{.3} +% \tzsecantat: domain +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a] +\tzsecantat[thick,red]{curve}{1}{4} +\tzsecantat[blue,dashed]{curve}{1}{7}[0:8] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Shift} +You can move |\tzsecantat| by specifying the option |<shift coor>|. + +\begin{tzcode}{.3} +% \tzsecantat: domain +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzsecantat[thick,red]{curve}{1}{4} +\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a] +\tzsecantat[blue]<1,-1>{curve}{1}{3}[0:5]{shifted}[r] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming paths} +By specifying the option |"<path name">| you can name a path of |\tzsecantat|. + +\begin{tzcode}{.3} +% \tzsecantat: shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzsecantat[thick,red]{curve}{1}{4} +\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a] +\tzsecantat[blue]<1,-1>"shift"{curve}{1}{3}[0:5] %% +\tzvXpointat*{shift}{3}{X}[-45] +\tzticksx(-1mm:2mm){3/$x=3$}[scale=.7] +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{<code.append>}} +You can extend the path of |\tzsecantat| by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzsecantat: <code.append> +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a] +\tzsecantat[blue,->]<1,-1>"shift"{curve}{1}{3}[0:5] %% + < --++(1,-3) node [red,b] {Ends!} > +\tzvXpointat*{shift}{3}{X}[-45] +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzsecant}} +\label{ss:tzsecant} + +\icmd{\tzsecant} uses two \xem{coordinates instead of two values} to draw a chord or a secant line of a curve, on the |behind| layer by default. +You need to specify a path name and two coordinates, then |\tzsecant| uses the $x$ values of the two coordinates. + +\xem{Everything else is the same as in} |\tzsecantat|. + +You can change the layer with \icmd{\settzsecantlayer}. + +\begin{tzdef}{} +% syntax: minium +\tzsecant{<path>}(<coor>)(<coor>) +% syntax: medium +\tzsecant{<path>}(<coor>)(<coor>)[<domain>]{<text>}[<node opt>] +% syntax: full +\tzsecant[<opt>]<shift coor>"path name" + {<path>}(<coor>)(<coor>)[<domain>]{<text>}[<node opt>]<code.append> +% defaults + []<>""{<m>}{<m>}{<m>}[]{}[]<> +\end{tzdef} + +The domain should be of the form |[<from num:to num>]|. +Without specifying the optional domain, |\tzsecant| draws a chord. + +\begin{tzcode}{.3} +% \tzsecant: domain +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzcoor(1,0)(K) +\tzsecant[blue]{curve}(K)(3,0)[0:5]{secant line}[a] +\tzsecant[thick,red]{curve}(K)(4,0) +\tzsecant[blue,dashed]{curve}(K)(7,0)[0:8] +\end{tikzpicture} +\end{tzcode} + +You can move the secant line and extend the path. + +\begin{tzcode}{.3} +% \tzsecantat: <code.append> +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(-1,-1)(8,6){$x$}{$y$} +\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar] +\tzcoor(1,0)(K) +\tzsecant[blue]{curve}(K)(3,0)[0:5]{secant line}[a] +\tzsecant[blue,->]<1,-1>"shift"{curve}(K)(3,0)[0:5] %% + < --++(1,-3) node [red,b] {Ends!} > +\tzvXpointat*{shift}{3}{X}[-45] +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{Tangent lines} +\label{s:tangent} + +\subsection{\protect\cmd{\tztangentat}} +\label{ss:tztangentat} + +\icmd{\tztangentat} draws a tangent line to a curve at a specified value of $x$. +By default, the tangent line is drawn on the |behind| layer, which can be changed by \icmd{\settztangentlayer}, like |\settztangentlayer{main}|. + +\begin{tzdef}{} +% syntax: minimum +\tztangentat{<path>}{<x-val>}[<domain>] +% syntax: medium +\tztangentat{<path>}{<x-val>}[<domain>]{<text>}[<node opt>] +% syntax: full +\tztangentat[<opt>]<shift coor>"<path name>" + {<path>}{<x-val>}(<epsilon1>,<epsilon2>) + [<domain>]{<text>}[<node opt>]<code.append> +% defaults + []""<>{<m>}{<m>}(.01,.01)[<m>]{}[]<> +\end{tzdef} + +To calculate the slope at $x$, $x$ varies over the interval $(x-\varepsilon_1,x+\varepsilon_2)$ and $\varepsilon_1=\varepsilon_2=0.01$ by default. +So the slope of tangent line is only \xem{approximate}. + +\paragraph{Domain} +|\tztangentat| takes three mandatory arguments: |{<path>}|, |{<x-val>}|, and |[<domain>]|. The mandatory argument |[<domain>]| should be of the form |[<from num:to num>]|. + +\begin{tzcode}{.3} +% \tztangentat +\begin{tikzpicture}[scale=.5] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangentat{AA}{2}[.5:4] +\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b] +\tzvXpointat*{AA}{4} +\tzticksx{1,7} +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} +You can move the tangent line by specifying the option |<shift coor>|. + +\begin{tzcode}{.3} +% \tztangentat: shift +\begin{tikzpicture}[scale=.5] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangentat{AA}{2}[.5:4] +\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b] +\tztangentat[blue]<2,1>{AA}{4}[1:7]{tangent'}[r] +\tzvXpointat*{AA}{4} +\tzticksx{1,7} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming paths} +By specifying the option |"<path name">|, you can name the path of |\tztangentat|. + +\begin{tzcode}{.3} +% \tztangentat: name path +\begin{tikzpicture}[scale=.5,font=\footnotesize] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangentat{AA}{2}[.5:4] +\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b] +\tzvXpointat*{AA}{4} +\tztangentat[blue] + <2,1>"BB"{AA}{4}[1:7]{tangent'}[r] +\tzvXpointat*[blue]{BB}{5}(X){$x$}[45](3pt) +\tzproj(X){$x_1$}{$x_2$} +\end{tikzpicture} +\end{tzcode} + +\paragraph{\texttt{<code.append>}} +You can extend the path of |\tztangentat| by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tztangentat: <code.append> +\begin{tikzpicture}[scale=.5,font=\footnotesize] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangentat{AA}{2}[.5:4] +\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b] +\tzvXpointat*{AA}{4} +\tztangentat[blue,->]<2,1>"BB"{AA}{4}[1:7] + < to [bend right] ++(-1,3) node [a] {Ends!} > +\tzvXpointat*[blue]{BB}{5}(X){$x$}[45](3pt) +\tzproj(X){$x_1$}{$x_2$} +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{Variations} +The slope of the tangent line is approximate, so sometimes you may want to change the variation interval to get better results. +You can change $\varepsilon_1$ and $\varepsilon_2$ by specifying the option |(epsilon1,epsilon2)| immediately after the mandatory argument |<x-val>|. +Or you can change the variations with the macro \icmd{\settztangentepsilon}, +like |\settztangentepsilon{|$\varepsilon_1$|}{|$\varepsilon_2$|}|. The effect remains until the end of |tikzpicture| environment unless changed again. + +\begin{tzcode}{.3} +% \tztangentat: variations, shift +\begin{tikzpicture}[scale=.5,font=\footnotesize] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangentat[blue!50,dashed]{AA}{4}[1:7] +\settztangentepsilon{0.005}{0.01} +\tztangentat[blue]{AA}{4}[1:7]{corrected}[r] +\tztangentat[red]<0,1>{AA}{4}[1:7]{shifted}[r] +\end{tikzpicture} +\end{tzcode} + + + + +\subsection{\protect\cmd{\tztangent}} +\label{ss:tztangent} + + +\icmd{\tztangent} uses a \xem{coordinate instead of a value} of $x$ to draw a tangent line. +For example, |\tztangent{curve}(4,0)| is equivalent to |\tztangentat{curve}{4}|. + +\xem{Everything else is the same as in} |\tztangentat|. + +\begin{tzdef}{} +% syntax: minimum +\tztangent{<path>}(<coor>)[<domain>] +% syntax: medium +\tztangent{<path>}(<coor>)[<domain>]{<text>}[<node opt>] +% syntax: full +\tztangent[<opt>]<shift coor>"<path name>" + {<path>}(<coor>)(<epsilon1>,<epsilon2>) + [<domain>]{<text>}[<node opt>]<code.append> +% defaults + []""<>{<m>}(<m>)(.01,.01)[<m>]{}[]<> +\end{tzdef} + + + +\begin{tzcode}{.3} +% \tztangent +\begin{tikzpicture}[scale=.5] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tzcoors(2,0)(K2)(4,0)(K4); +\tztangent{AA}(K2)[.5:4] +\tztangent[blue]{AA}(K4)[1:7]{tangent}[red,b] +\tzvXpoint*{AA}(K4) +\tzticksx{1,7} +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tztangent: shift, <code.append> +\begin{tikzpicture}[scale=.5,font=\footnotesize] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tzcoors(2,0)(K2)(4,0)(K4); +\tztangent{AA}(K2)[.5:4] +\tztangent[blue]{AA}(K4)[1:7]{tangent}[red,b] +\tzvXpoint*{AA}(K4) +\tztangent[blue,->]<2,1>"BB"{AA}(K4)[1:7] + < to [bend right] ++(-1,3) node [a] {Ends!} > +\tzvXpoint*[blue]{BB}(5,0)(X){$x$}[45](3pt) +\tzproj(X){$x_1$}{$x_2$} +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tztangent: variations, shift +\begin{tikzpicture}[scale=.5,font=\footnotesize] +\tzhelplines(9,8) +\tzaxes(9,8) +\tzplotcurve"AA"(1,7)(3,3)(8,1); +\tztangent[blue!50,dashed]{AA}(4,0)[1:7] +\settztangentepsilon{0.005}{0.01} +\tztangent[blue]{AA}(4,0)[1:7]{corrected}[r] +\tztangent[red]<0,1>{AA}(4,0)[1:7]{shifted}[r] +\end{tikzpicture} +\end{tzcode} + + +%%================================== +\chapter{Miscellany} +\label{c:misc} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzbrace(')}} +\label{s:tzbrace} + +\icmd{\tzbrace} takes two coordinates as mandatory arguments to draw a calligraphic brace connecting them. + +\begin{tzdef}{} +% syntax: minimum +\tzbrace(<coor>)(<coor>) +% syntax: medium +\tzbrace(<coor>)(<coor>){<text>}[<node opt>] +% syntax: full +\tzbrace[<draw opt>]{<raise>}[<decoration opt>]<shift coor> + (<coor>)(<coor>){<text>}[<node opt>] +% defaults + []{5pt}[amplitude=5pt]<>(<m>)(<m>){}[] +\end{tzdef} + +The amplitude of a brace is |5pt| by default. +The |raise| value of a brace is |5pt| by default and the value can be changed by the first curly brace optional argument |{<raise>}|. + +\begin{tztikz}{} +\tzbrace[thick](0,0)(3,1) % works like: + \draw [thick,decorate,decoration={calligraphic brace, amplitude=5pt, raise=5pt}] + (0,0) to (3,1); +\end{tztikz} + +The swap version \icmd{\tzbrace'} swaps the coordinates. +So it prints a mirror image of |\tzbrace|. + +\begin{tzcode}{.3} +% \tzbrace(') +\begin{tikzpicture}[sloped] +\tzhelplines(4,2) +\tzline(0,0)(3,1) +\tzbrace(0,0)(3,1){AAA}[above=10pt,blue] +\tzbrace'[red](0,0)(3,1){BBB}[below=10pt] +\end{tikzpicture} +\end{tzcode} + +You can change the style of the decorating brace by the second bracket optional argument |[<decoration opt>]|. + +The color of the calligraphic brace can be changed by the option |pen colour| in the list of |[<draw option>]|. + +\begin{tzcode}{.3} +% \tzbrace('): decoration options +\begin{tikzpicture}[sloped] +\tzhelplines(4,3) +\tzline(0,0)(3,1) +\tzbrace [very thick,pen colour=blue][amplitude=10pt] + (0,0)(3,1){AAA}[a=15pt] +\tzbrace'[red,very thick]{10pt}[brace,amplitude=10pt] + (0,0)(3,1){BBB}[b=20pt] +\end{tikzpicture} +\end{tzcode} + +You can also move a brace by specifying the option |<shift coor>| immediately before the the first mandatory coordinate. + +\begin{tzcode}{.3} +% \tzbrace('): shift +\begin{tikzpicture}[sloped] +\tzhelplines(4,3) +\tzline(0,0)(3,1) +\tzbrace [very thick,pen colour=blue][amplitude=10pt] + <.5,.5>(0,0)(3,1){AAA}[a=15pt] +\tzbrace'[red,very thick]{10pt}[brace,amplitude=10pt] + (0,0)(3,1){BBB}[b=20pt] +\end{tikzpicture} +\end{tzcode} + + + + diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc.pdf b/graphics/pgf/contrib/tzplot/tzplot-doc.pdf Binary files differnew file mode 100644 index 0000000000..0e4633ea06 --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc.pdf diff --git a/graphics/pgf/contrib/tzplot/tzplot-doc.tex b/graphics/pgf/contrib/tzplot/tzplot-doc.tex new file mode 100644 index 0000000000..ea53095183 --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-doc.tex @@ -0,0 +1,375 @@ +%!TEX program = arara +% arara: xelatex: {shell: yes, synctex: yes} +% arara: xelatex: {shell: yes, synctex: yes} +% arara: makeindex: {style: tzplot} +% arara: xelatex: {shell: yes, synctex: yes} +% arara: xelatex: {shell: yes, synctex: yes} + +%% 2021/02/28 v1.0 +\def\tmpdate{2021/02/28} +\def\tmpversion{1.0} + +%------------------------------------------------------ +\def\myincludeonly{% +\includeonly{% +tzplot-doc-A-v\tmpversion, % getting ready +tzplot-doc-B-v\tmpversion, % intuitive introductions (getting started) +tzplot-doc-C-v\tmpversion, % points, lines, and curves +tzplot-doc-D-v\tmpversion, % plotting graphs +%tzplot-eco-v\tmpversion, % economics +}} +%------------------------------------------------------ + +\documentclass[a4paper,amsmath,chapter]{oblivoir} + +\gdef\clearforchapter{} % no clearpage for chapter + +\usepackage{tzplot} + +% ndh +\usepackage{etoolbox} +\input{tzplot-oblivoirpartstyle} + +\usepackage{fapapersize} +\usefapapersize{*,*,30mm,*,28mm,*} +%\setsecnumdepth{subsubsection} +%\settocdepth{subsubsection} +%\setlength\cftsubsubsectionindent{4.5em} + +\renewcommand*\contentsname{Contents} +\renewcommand*\figurename{Figure} +\renewcommand*\tablename{Table} +\renewcommand*\abstractname{Abstract} +\renewcommand*\indexname{Index} +\renewcommand*\pagerefname{\kern-4pt} + +\hypersetup{pdfborder={0 0 0}} % to suppress the hyperlink red box + +%%====================================== (ndh) +\SetHangulspace{1.025}{1} +%%% part +\renewcommand*\prepartnum{\noindent\partnamefont\textsc{Part}\space} +\renewcommand*\partnamenum{} +\renewcommand*\postpartnum{} +\renewcommand*\hparttitlehead{Part\space\thepart} +\renewcommand*\beforepartskip{\vskip 0pt plus 2pt minus 0pt} +\renewcommand*\midpartskip{\newline} +\renewcommand*\afterpartskip{\vskip 2\onelineskip} + +%\makeatletter +%\patchcmd\@part{\centering}{}{}{} +%\makeatother +\renewcommand*\obparttitlealignment{} + +\renewcommand\partnumfont{\bfseries\Large} +\renewcommand\partnamefont{\partnumfont} +\renewcommand\parttitlefont{\bfseries\LARGE} + +%%% for toc +\setlength\cftpartnumwidth{5.2em} +\setlength\cftchapternumwidth{1.8em} +\setlength\cftsectionindent{1.8em} +\setlength\cftsectionnumwidth{2.7em} +\setlength\cftsubsectionindent{4.5em} +\setlength\cftsubsectionnumwidth{3em} + +%%% chapter style +\makechapterstyle{tzdoc}{% + \reparticle + \renewcommand\prechapternum{} + \renewcommand\postchapternum{} + \renewcommand\hchaptertitlehead{\thechapter} +} +%%================================ + +%\usepackage{xparse} %% oblivoir loads xparse +\usepackage{tikz} + + +\usepackage{makecell} +\usepackage{multido} +\usepackage[normalem]{ulem} % [normalem] to correct the pdf bookmark broken characters +\usepackage{idxlayout} + + +\usepackage{tcolorbox} +\tcbuselibrary{minted,listings,breakable} +\tcbset{% + listing engine=minted,breakable, + after={\par\vspace{.5\baselineskip}\noindent} +} +\tcbset{% + colback=yellow!5!white, + colframe=blue!30, + listing outside text, + righthand width=.3\linewidth, + center upper, + center lower, + sidebyside gap=5pt, + listing options={% + style=tcblatex, + keywordstyle=\color{blue}, + commentstyle=\color{black!20!green}, + morekeyword={ + tzline,tzlines,tzdot,tzdots, + tznode,tznodes + }, + } +} + +\newtcblisting{tzdef}[1]{colback=blue!5!white,listing only,#1} +\newtcblisting{tzsty}[1]{colback=green!5!white,listing only,#1} +\newtcblisting{tztikz}[1]{colback=white,colframe=gray!15,listing only,#1} +\newtcblisting{tzcode}[2][]{righthand width=\expandafter#2\linewidth,#1} + +\NewDocumentEnvironment{mytcblisting}{O{}} +{ \medskip + \begin{tcblisting}{#1} +} +{ \end{tcblisting} + \medskip +} + + +\linespread{1} + +\newcommand*\Tikz{Ti\textit{k}Z} +\let\TikZ\Tikz + +\newenvironment{keywords}{% + \par\vskip2pt + \noindent\hangfrom{\textsc{Keywords: }}% +} + + +%% index +%\renewcommand\cmd[1]{\cmdprint{#1}} +\ExplSyntaxOn +\renewcommand \cmd [1] +{ + \texorpdfstring + { \cmdprint {#1} } + { \textbackslash \cs_to_str:N #1 } +} +\ExplSyntaxOff + +\newcommand\xem[1]{\emph{#1}} +\newcommand\xw[1]{\cmd{#1}} +\newcommand\xttw[1]{\texttt{#1}} +\newcommand\pkg[1]{\textsf{#1}} +\newcommand\env[1]{\textsf{#1}} +% index +\newcommand\isw[1]{#1\index{#1}} % simple word in text/index +\newcommand\ixsw[1]{\cmd{#1}\index{#1}} % texttt in text, simple word in index +\newcommand\iisw[1]{\textit{#1}\index{#1}} % textit in text, simple word in index +\newcommand\iscw[1]{\textsc{#1}\index{#1@\textsc{#1}}} % textsc in text/index +\newcommand\ixxw[1]{\texttt{#1}\index{#1@\texttt{#1}}} % texttt in text/index +\newcommand\ixw[1]{\textsf{#1}\index{#1@\textsf{#1}}} % textsf in text/index +\newcommand\ixttw[1]{\texttt{#1}\index{#1@\texttt{#1}}} % texttt in text/index +\newcommand\ipkg[1]{\textsf{#1}\index{#1@\textsf{#1}}} +\newcommand\ienv[1]{\textsf{#1}\index{#1@\textsf{#1}}} + +\makeatletter +\newcommand{\icmd}[1]{\cmdprint{#1}% + \index{\expandafter\@gobble\string#1@\string\cmdprint{\string#1}}} +\makeatother + +\makeindex + + +%% lazy macros +\newcommand\mysection[1]{\pagebreak[3]\section[\normalsize #1]{\Huge #1}} +\NewDocumentCommand\mysubsection{sm} +{\IfBooleanTF #1 + {\pagebreak[3]\subsection{#2}} + {\pagebreak[3]\subsection{\protect\cmd{#2}}} +} +\NewDocumentCommand\mysubsubsection{sm} +{\IfBooleanTF #1 + {\pagebreak[3]\subsubsection{#2}} + {\pagebreak[3]\subsubsection{\protect\cmd{#2}}} +} + +\NewExpandableDocumentCommand\xcol{mO{c|}m} + {\multicolumn{#1}{#2}{\ensuremath{#3}}} + +%% more lazy macros +\newcommand\xbigskip[1]{\multido{}{#1}\bigskip} +\newcommand\xmedskip[1]{\multido{}{#1}\medskip} +\newcommand\xsmallskip[1]{\multido{}{#1}\smallskip} +\def\hpara{\hangpara{1.52em}{1}} +\def\listdivider{\leavevmode\smallskip\hrule width 1.5em\smallskip} + +\newcommand\remark{\bigskip\noindent \textbf{Remark: }} +\newcommand\warning{\bigskip\noindent \textbf{Warning: }} +\newcommand\threeways{\textsc{Three Ways}} + + +%\parindent=0pt + +\title{\texttt{tzplot.sty} \\ Plot Graphs with \Tikz\ Abbreviations}\author{In-Sung Cho \\ \texttt{ischo <at> ktug.org}} +\date{Economics, Kongju National University\\[3pt] + \tmpdate\quad version \tmpversion} + +\def\tmpclearpage{\clearpage} + +\AtBeginDocument{\MakeShortVerb{\|}} + +%%% english based document: \flushbottom +%%% korean document: \raggedbottom (by default in oblivoir) +\AddToHook{env/document/before}{\flushbottom} +%%% same as \AtBeginDocument +\AddToHook{env/document/begin}{% + \chapterstyle{tzdoc} +% \pagestyle{headings} +} + +\myincludeonly + +%============================================================= +\begin{document} + +\frontmatter +\maketitle + +\renewcommand{\abstracttextfont}{\normalfont\small\noindent\ignorespaces} +\begin{abstract} +This is a \LaTeX{} package that provides \Tikz\ based macros to make it easy to draw graphs. +The macros provided in the \pkg{tzplot} package are just \emph{abbreviations} for \Tikz\ codes, which can be complicated, but using the package, hopefully, makes drawing easier, especially when drawing repeatedly. The macros were chosen and developed with an emphasis on drawing graphs in \emph{economics}. + +\begin{keywords} +lines, dots, curves, axes, functions, +projection, ticks, intersections, tangent lines +\end{keywords} +\end{abstract} + +\tableofcontents* + +\mainmatter + +\include{tzplot-doc-A-v\tmpversion} + +\include{tzplot-doc-B-v\tmpversion} + +\include{tzplot-doc-C-v\tmpversion} + +\include{tzplot-doc-D-v\tmpversion} + +%\include{tzplot-eco-v\tmpversion} + + +\chapter*{Version history} +\addcontentsline{toc}{chapter}{Version history} + +\begin{itemize} +\item v\tmpversion (\tmpdate) upload to CTAN +\item v0.999a (2021/02/27) + \begin{itemize} + \item writing document + \item some |\tz<...>AtBegin| and |\tz<...>AtEnd| not documented + \end{itemize} +\item v0.999 (2021/02/24) + \begin{itemize} + \item fixed the title. ``Plot Graphs with \Tikz\ Abbreviations" + \item changed the default |\tzpathstyle| and |\tzlinkstyle| from `|--|' to `|to|' (no harm) + \item added |\tzpathlayer| and |\settzpathlayer|, for later use. (currently not used) + \item removed explanation of the option |<+or++>| in the document (considering to remove later) + \item changed the delimiter |<path style>| to |[<path style>]| in |\tzpath| and |\tzlink(s)| (critical change) + \item added |text opactiy=1| everywhere |fill opacity=.3| is used + \end{itemize} +%%%\item v0.99j (2021/02/18) +%%% \begin{itemize} +%%% \item added |\tzplotcurve*| to show dots +%%% \item discarded |<code.append>| for |\tznode| and the like. +%%% \end{itemize} +%%%\item v0.99i (2021/02/17) +%%% \begin{itemize} +%%% \item added |\tzaxes*| to set the current state as a |bounding box| +%%% \item redefined |\tztangentat| and |\tztangent| +%%% \begin{itemize} +%%% \item Now the tangent line is drawn over the domain, which is mandatory. +%%% \end{itemize} +%%% \item redefined |\tzsecantat| and |\tzsecant| +%%% \begin{itemize} +%%% \item Now the secant line is drawn over the domain, when the optional domain is given. +%%% \item If there is no domain option, it draw a secant line segment. +%%% \end{itemize} +%%% \end{itemize} +%%%\item v0.99h (2021/02/12) +%%% \begin{itemize} +%%% \item redefined |\tztangentat| and |\tztangent| +%%% \begin{itemize} +%%% \item to resolve the discrepancy issue, when repeated +%%% \item if two mandatory arguments are the same, no redefine |(bbTop)| and |(bbBottom)| +%%% \item and clear for every start of |\tikzpicture| +%%% \end{itemize} +%%% \item redefined |\tzslopeat| and |\tzslope| to resolve the discrepancy issue +%%% \item redefined |\tzbezier+| +%%% to make the last coordinate relative to the first +%%% \item redefined |\tzparabola+| +%%% to make the last coordinate relative to the first +%%% \end{itemize} +%%%\item v0.99g (2021/02/10) +%%% \begin{itemize} +%%% \item added |\tzbbox| +%%% \item added |\tzhelplines*| to make it serve as a bounding box +%%% \item added |\tzspy| +%%% \end{itemize} +%%%\item v0.99f (2021/02/01) +%%% \begin{itemize} +%%% \item added |\settztangentlayer|, |\tzsecantlayer|, and |\tzslopelayer| +%%% \item corrected |\tzvfn|, |\tzhfn| for |<shift coor>| +%%% \item corrected |\tztangent|, |\tztangentat| to resolve `inconsistent' issue +%%% \item changed |\xdef| to |\def| +%%% \end{itemize} +%%%\item v0.99e (2021/01/25) +%%% \begin{itemize} +%%% \item redefined |\tzsecant| to resolve \Tikz\ issue of path name with layer. +%%% \item added |\tzsnake|. +%%% \end{itemize} +%%%\item v0.99d (2021/01/20) +%%% \begin{itemize} +%%% \item applied |<shift coor>| to (almost) all macros. +%%% \end{itemize} +%%%\item v0.99c (2021/01/14) +%%% \begin{itemize} +%%% \item redesigned macros for |<shift coor>| +%%% \end{itemize} +%%%\item v0.99b (2021/01/14) +%%% \begin{itemize} +%%% \item corrected y ticks position with ticks: |\tztikcs|, |\tzticksy| +%%% \item changed the order of arguments for consistency: |\tzplot|, |\tzplotcurve| +%%% \item redefined |\tzhfn| and |\tzvfn| to have a mandatory argument +%%% \item added |<shift coor>| to macros related to lines or curves: +%%% \end{itemize} +%%%\item v0.99a (2021/01/12) +%%% \begin{itemize} +%%% \item to do: |<shift coor>| for |\tzto|, |\tzfn|, |\tzline|, ... +%%% \item to do: |\tzconvexcomb| and |\tzconvexcombs| +%%% \end{itemize} +\end{itemize} + + +\chapter*{Acknowledgement} +\addcontentsline{toc}{chapter}{Acknowledgement} + +I am grateful to Kangsoo Kim of KTUG (Korean TeX Users Group) who wrote many packages including |oblivoir.cls| for helping to implement the idea of the semicolon version with |expl3|. + +\chapter*{References} +\addcontentsline{toc}{chapter}{Reference} + +\hpara{}Casteleyn, Jean Pierre~(2016), ``Visual PSTricks," version 2.30. + +\hpara{}\uline{\hphantom{Casteleyn, Jean Pierre}}~(2018), ``Visual TikZ," version 0.66. + +\hpara{}Tantau, Till~(2020), ``\TikZ\ and PGF: Manual for version 3.1.8b," \url{http://sourceforge.net/projects/pgf}. + +\clearpage +\printindex + +\end{document} + +%% ==================================================== +%% ==================================================== +%% ==================================================== + diff --git a/graphics/pgf/contrib/tzplot/tzplot-oblivoirpartstyle.tex b/graphics/pgf/contrib/tzplot/tzplot-oblivoirpartstyle.tex new file mode 100644 index 0000000000..39fd26bf46 --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot-oblivoirpartstyle.tex @@ -0,0 +1,38 @@ +\makeatletter + +\@ifclasslater{oblivoir}{2021/05/20}{}% +{% + \def\obparttitlealignment{} + \long\def\@part[#1]#2{% + \M@gettitle{#1}% + \def\f@rtoc{#1}% + \@nameuse{part@f@rtoc@before@write@hook}% + \phantomsection + \mempreaddparttotochook + \ifnum \c@secnumdepth >-2\relax + \refstepcounter{part}% + \addcontentsline{toc}{part}% + {\protect\partnumberline{\hparttitlehead}\f@rtoc}% + \mempartinfo{\thepart}{\f@rtoc}{#2}% + \else + \addcontentsline{toc}{part}{\f@rtoc}% + \mempartinfo{}{\f@rtoc}{#2}% + \fi + \mempostaddparttotochook + \partmark{#1}% + {% + \obparttitlealignment + \interlinepenalty \@M + \parskip\z@ + \normalfont + \ifnum \c@secnumdepth >-2\relax + \prepartnum \partnamenum \printpartnum \partnamenum \postpartnum + \midpartskip + \fi + \printparttitle{#2}\par}% + \@endpart} +} + + + +\makeatother
\ No newline at end of file diff --git a/graphics/pgf/contrib/tzplot/tzplot.ist b/graphics/pgf/contrib/tzplot/tzplot.ist new file mode 100644 index 0000000000..813fdbce59 --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot.ist @@ -0,0 +1,16 @@ +preamble "\\begin{theindex}\n +\\def\\hindexhead#1{\\ifcase#1ㄱ\\or ㄴ\\or ㄷ\\or ㄹ\\or + ㅁ\\or ㅂ\\or ㅅ\\or ㅿ\\or ㅇ\\or ㆁ\\or ㅈ\\or ㅊ\\or ㅋ\\or + ㅌ\\or ㅍ\\or ㅎ\\or ㆆ\\or ㅏ\\or ㅑ\\or ㅓ\\or ㅕ\\or ㅗ\\or + ㅛ\\or ㅜ\\or ㅠ\\or ㅡ\\or ㅣ\\or ㆍ\\else 종성\\fi}\n\n" + +headings_flag 1 +group_skip "\n\n\\indexspace\n" +item_0 "\n\\item " +heading_prefix "{\\sffamily【 " +heading_suffix " 】}\\nopagebreak\n" +%symhead_positive "Symbols" +%numhead_positive "Numbers" +delim_0 "\\quad " +delim_1 "\\quad " +delim_2 "\\quad "
\ No newline at end of file diff --git a/graphics/pgf/contrib/tzplot/tzplot.sty b/graphics/pgf/contrib/tzplot/tzplot.sty new file mode 100644 index 0000000000..593659b03f --- /dev/null +++ b/graphics/pgf/contrib/tzplot/tzplot.sty @@ -0,0 +1,4590 @@ +%% file: tzplot.sty +%% +%% tzplot +%% +%% (C) Copyright 2017-2021 In-Sung Cho <ischo at ktug.org> +%% +%% This work may be distributed and/or modified +%% under the conditions of the LaTeX Project Public License, +%% either version 1.3c of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt. +%% +%% ------------------------------------------------- +\ProvidesPackage{tzplot-v1.0}[2021/02/28 v1.0 Plot Graphs with TikZ Abbreviations] + +% expl3,xparse: LPPL +% tikz: LPPL and/or GNU GPL +\RequirePackage{expl3,xparse} +\RequirePackage{tikz} + +\usetikzlibrary{ +calc,backgrounds,positioning,intersections, +arrows,shapes,patterns, +plotmarks, % for \tzplot[mark] +decorations.pathreplacing, % for tzshowcontrols/show path construction, tzbrace +calligraphy, % for calligraphic brace (load after decorations.pathreplacing) +} + + +%% backgrounds +\pgfdeclarelayer{background} +\pgfdeclarelayer{behind} +\pgfdeclarelayer{above} +\pgfdeclarelayer{foreground} + +\pgfsetlayers{background,behind,main,above,foreground} +%% usage: \begin{pgfonlayer}{foreground} ... \end{pgfonlayer} + + +%%%%% defaults +\def\tz@default@radius{1.2pt} % fixed +\def\tz@initial@radius{\tz@default@radius} % changeable +\NewDocumentCommand\settzdotradius{m}{\renewcommand\tz@initial@radius{#1}} +\newcommand\tzdotradius{\tz@initial@radius} + +% circle dot (using radius) +\def\tz@default@Cdot@radius{1.2pt} % fixed +\def\tz@initial@Cdot@radius{\tz@default@Cdot@radius} % changeable +\NewDocumentCommand\settzcdotradius{m}{\renewcommand\tz@initial@Cdot@radius{#1}} +\newcommand\tzCdotradius{\tz@initial@Cdot@radius} + +% node dot (using minimum size) +\def\tz@default@dot@size{2.4pt} % fixed +\def\tz@initial@dot@size{\tz@default@dot@size} % changeable +\NewDocumentCommand\settzdotsize{m}{\renewcommand\tz@initial@dot@size{#1}} +\newcommand\tzdotsize{\tz@initial@dot@size} + +% mark (using mark size, which is a radius) % tikz initial = 2pt +\def\tz@default@mark@size{2pt} % fixed +\def\tz@initial@mark@size{\tz@default@mark@size} % changeable +\NewDocumentCommand\settzmarksize{m}{\renewcommand\tz@initial@mark@size{#1}} +\newcommand\tzmarksize{\tz@initial@mark@size} + +% opacity +\def\tz@default@fill@opacity{0.3} % fixed +\def\tz@initial@fill@opacity{\tz@default@fill@opacity} % changeable +\NewDocumentCommand\settzfillopacity{m}{\renewcommand\tz@initial@fill@opacity{#1}} +\newcommand\tzfillopacity{\tz@initial@fill@opacity} + +% fillcolor +\def\tz@default@fill@color{black!50} % fixed +\def\tz@initial@fill@color{\tz@default@fill@color} % changeable +\NewDocumentCommand\settzfillcolor{mg} +{% + \renewcommand\tz@initial@fill@color{#1} + \IfValueT {#2} {\renewcommand\tz@initial@fill@opacity{#2}} +} +\newcommand\tzfillcolor{\tz@initial@fill@color} + +% link style +\def\tz@default@link@style{to} % fixed +\def\tz@initial@link@style{\tz@default@link@style} % changeable +\NewDocumentCommand\settzlinkstyle{m}{\renewcommand\tz@initial@link@style{#1}} +\newcommand\tzlinkstyle{\tz@initial@link@style} + +% path style +\def\tz@default@path@style{to} % fixed +\def\tz@initial@path@style{\tz@default@path@style} % changeable +\NewDocumentCommand\settzpathstyle{m}{\renewcommand\tz@initial@path@style{#1}} +\newcommand\tzpathstyle{\tz@initial@path@style} + +% tangent epsilon + +\def\tz@default@tangent@epsilonL{.01} +\def\tz@default@tangent@epsilonR{.01} +\def\tz@initial@tangent@epsilonL{\tz@default@tangent@epsilonL} +\def\tz@initial@tangent@epsilonR{\tz@default@tangent@epsilonL} +\NewDocumentCommand\settztangentepsilon{mg} +{% + \renewcommand\tz@initial@tangent@epsilonL{#1} + \IfNoValueTF {#2} + {\renewcommand\tz@initial@tangent@epsilonR{#1}} + {\renewcommand\tz@initial@tangent@epsilonR{#2}} +} +\newcommand\tztangentepsilonL{\tz@initial@tangent@epsilonL} +\newcommand\tztangentepsilonR{\tz@initial@tangent@epsilonR} +\let\tztangentatepsilonL\tztangentepsilonL +\let\tztangentatepsilonR\tztangentepsilonR + +% tzpath layer %% (NOT USED!!!) (to be considered later) +\def\tz@default@tzpath@layer{main} % fixed +\def\tz@initial@tzpath@layer{\tz@default@tzpath@layer} % changeable +\NewDocumentCommand\settzpathlayer{m}{\renewcommand\tz@initial@tzpath@layer{#1}} +\newcommand\tzpathlayer{\tz@initial@tzpath@layer} + +% tangent layer +\def\tz@default@tangent@layer{behind} % fixed +\def\tz@initial@tangent@layer{\tz@default@tangent@layer} % changeable +\NewDocumentCommand\settztangentlayer{m}{\renewcommand\tz@initial@tangent@layer{#1}} +\newcommand\tztangentlayer{\tz@initial@tangent@layer} +\let\tztangentatlayer\tztangentlayer + +% secant layer +\def\tz@default@secant@layer{behind} % fixed +\def\tz@initial@secant@layer{\tz@default@secant@layer} % changeable +\NewDocumentCommand\settzsecantlayer{m}{\renewcommand\tz@initial@secant@layer{#1}} +\newcommand\tzsecantlayer{\tz@initial@secant@layer} +\let\tzsecantatlayer\tzsecantlayer + +%%%%% TikZ alias styles + +\tikzset{ + a/.style={above=#1}, + b/.style={below=#1}, + c/.style={centered=#1}, + l/.style={left=#1}, + r/.style={right=#1}, + al/.style={above left=#1}, + ar/.style={above right=#1}, + bl/.style={below left=#1}, + br/.style={below right=#1}, +} + +%%%%% tzplot styles + +\tikzset{>=stealth} % to revert use {>=to} + +%% tzdot (for node dot style) +\tikzset{ + tzdot/.style= + {draw,solid,thin,circle,inner sep=0pt,minimum size=#1}, + tzdot/.default=\tzdotsize +} + +%% tzdot options (for node dot style) +\tikzset{ + tzdot options/.style={tzdot=\tzdotsize,#1} +} + +%% tzmark +\tikzset{ + tzmark/.style= + {mark options={solid,thin},mark size=#1}, + tzmark/.default=\tzmarksize +} + +%% tznode (NOT USED!) -- user choice +\tikzset{ + tznode/.style= + {solid,thin,circle,inner sep=0pt,minimum size=#1}, + tznode/.default=0pt +} + +%% tzdotted +\tikzset{% + tzdotted/.style={% + dotted=none, + line cap=round, + dash pattern=on 0pt off 1cm/(#1) + }, + tzdotted/.default=10 +} + +%% tzdashed +\tikzset{ + tzdashed/.style={% + dashed=none, + dash pattern=on 5mm/(#1) off 5mm/(#1) + }, + tzdashed/.default=10 +} + +%% tzhelplines +\tikzset{% + tzhelplines/.style={help lines,-,tzdotted} +} + +%% tzshorten +\tikzset{% + tzshorten/.style 2 args ={shorten <=#1, shorten >=#2}, + tzshoretn/.default={2pt}{2pt} +} + +%% tzextend (negative tzshorten) +\tikzset{% + tzextend/.style 2 args ={shorten <=-#1, shorten >=-#2}, + tzextend/.default={2pt}{2pt} +} + + +%% tzshowcontrols % (for \tzbezier: tikz manual p.645) +\tikzset{% + tzshowcontrols/.style={% + postaction={% + decoration={% + show path construction, + curveto code={% + \draw [dotted,#1] + (\tikzinputsegmentfirst) + -- (\tikzinputsegmentsupporta) + -- (\tikzinputsegmentsupportb) + -- (\tikzinputsegmentlast); + } + }, + decorate + } + } +} + +%===================================================== +%%===================================================== +%%===================================================== +\ExplSyntaxOn +%%===================================================== +%%===================================================== + + +%%%%% help lines +\NewDocumentCommand\tzhelplines{ s O{} r() d() } +{ + \IfBooleanTF { #1 } + { + \IfNoValueTF { #4 } + { \draw [ tzhelplines , use~as~bounding~box , #2 ] (0,0) grid (#3); } + { \draw [ tzhelplines , use~as~bounding~box , #2 ] (#3) grid (#4); } + } + { + \IfNoValueTF { #4 } + { \draw [ tzhelplines , #2 ] (0,0) grid (#3); } + { \draw [ tzhelplines , #2 ] (#3) grid (#4); } + } +} + + +%%%%% \tzbbox +\NewDocumentCommand\tzbbox{ r() d() } +{ + \IfNoValueTF { #2 } + { + \useasboundingbox (0,0) rectangle (#1); + } + { + \useasboundingbox (#1) rectangle (#2); + } +} + +%%%%% \tzgetxyval +\NewDocumentCommand\tzgetxyval{ r() m m } +{ + \tikz@scan@one@point\pgfutil@firstofone(#1)\relax% + \pgfmathparse{\the\pgf@x/28.45274}% convert pt to cm + \edef#2{\pgfmathresult}% + \pgfmathparse{\the\pgf@y/28.45274}% convert pt to cm + \edef#3{\pgfmathresult}% +} + +%%% --- end of \tzgetxyval + +%%%%%% \tzgetxyval (experimental) +%%%%%% seems not working +%\NewDocumentCommand\tzgetxyval{ g r() m m } +%{ +% \IfNoValueTF { #1 } +% { +% \def\tzptToDim{28.45274} % cm: default +% } +% { +% \str_case:nnTF { #1 } +% { +% {pt} { \def\tzptToDim{1} } +% {mm} { \def\tzptToDim{2.845274} } +% {cm} { \def\tzptToDim{28.45274} } +% {bp} { \def\tzptToDim{1.00374} } +% {dd} { \def\tzptToDim{1.07} } +% {pc} { \def\tzptToDim{12} } +% {in} { \def\tzptToDim{72.26999} } +% } +% { +% \def\tzptToDim{1} % default unit in tikz +% } +% } +% \tikz@scan@one@point\pgfutil@firstofone(#2)\relax% +% \pgfmathparse{\the\pgf@x/\tzptToDim}% convert pt to dim +% \edef#3{\pgfmathresult}% +% \pgfmathparse{\the\pgf@y/\tzptToDim}% convert pt to dim +% \edef#4{\pgfmathresult}% +%} +% +%%%% --- end of \tzgetxyval + + +%%%%% Dots + +%%% Node Dots %%% (basic: using minimum size) + +%%% \tzdot +%%% *[opt]<shift>(coor){text}[pos,opt](size) + +\bool_new:N \l_tzdot_shift_coor_bool + +\NewDocumentCommand\tzdot{ s O{} d<> r() +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzdot_cmd_tl + + \IfValueT { #7 } + { \renewcommand\tzdotsize{ #7 } } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzdot_shift_coor_tl { #3 } + \bool_set_true:N \l_tzdot_shift_coor_bool + } + { + \tl_clear:N \l_tzdot_shift_coor_tl + \bool_set_false:N \l_tzdot_shift_coor_bool + } + + \bool_if:NTF \l_tzdot_shift_coor_bool + { + \tl_put_right:Nx \l_tzdot_cmd_tl + { + ( [ shift = { (\l_tzdot_shift_coor_tl) } ]#4 ) node + } + } + { \tl_put_right:Nn \l_tzdot_cmd_tl { (#4) node } } + + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tzdot_cmd_tl + { [ tzdot , fill , } + } + { + \tl_put_right:Nn \l_tzdot_cmd_tl + { [ tzdot , } + } + \tl_put_right:Nx \l_tzdot_cmd_tl + { + label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } , + } + \tl_put_right:Nn \l_tzdot_cmd_tl + { + minimum~size = \tzdotsize , #2 ] {} + } + \exp_last_unbraced:Nf \path \l_tzdot_cmd_tl ; +} + +%%% --- end of \tzdot + + +%%% multiple dots +%%% coding CAUTION! : _tzdot_ changed to _tzdots_ + +%%% \tzdots +%%% repeat pattern: (coor){label}[pos] + +\tl_new:N \l_tzdots_opt_tl +\tl_new:N \l_tzdots_cmd_tl +\bool_new:N \l_tzdots_shift_coor_bool + +\NewDocumentCommand\tzdots{ s O{} d<> } +{ + \tl_clear:N \l_tzdots_cmd_tl + + \IfBooleanTF { #1 } + { \tl_set:Nn \l_tzdots_STYLE_fill_tl { fill } } + { \tl_set:Nn \l_tzdots_STYLE_fill_tl { fill = none } } + + \tl_if_empty:nTF { #2 } + { \tl_set:Nn \l_tzdots_opt_tl { tzdot } } + { \tl_set:Nn \l_tzdots_opt_tl { tzdot , #2 } } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzdots_shift_coor_tl { #3 } + \bool_set_true:N \l_tzdots_shift_coor_bool + } + { + \tl_clear:N \l_tzdots_shift_coor_tl + \bool_set_false:N \l_tzdots_shift_coor_bool + } + + \tzdots_check_token:n +} + +\cs_new:Npn \tzdots_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzdots_sub_fn #1 } +% { \tzdots_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzdots_sub_fn #1 } + { ; } { \tzdots_late_opt_fn } + } + { + \tzdots_stop_action + } +} + + +\NewDocumentCommand\tzdots_sub_fn { r() +G{} O{} } +{ + \bool_if:NTF \l_tzdots_shift_coor_bool + { + \tl_put_right:Nx \l_tzdots_cmd_tl + {% if shift + ( [ shift = { (\l_tzdots_shift_coor_tl) } ]#1 ) + } + } + { \tl_put_right:Nn \l_tzdots_cmd_tl { (#1) } } + + \tl_put_right:Nx \l_tzdots_cmd_tl + { + node + [ + \l_tzdots_STYLE_fill_tl , + minimum~size = \exp_not:n { \tzdotsize } , + label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } , + } + \tl_put_right:No \l_tzdots_cmd_tl % expand `once' + { + \l_tzdots_opt_tl + ] {} + } + \tzdots_check_token:n +} + +\NewDocumentCommand\tzdots_late_opt_fn { D(){\tz@initial@dot@size} } +{ + \renewcommand\tzdotsize{ #1 } + + \tzdots_stop_action +} + + +\NewDocumentCommand\tzdots_stop_action {} +{ + \exp_last_unbraced:Nf \path \l_tzdots_cmd_tl ; +} + +%%% --- end of \tzdots + + +%%%%% Circle Dots -- (code original, using radius) + +\keys_define:nn { keytzCdot } +{ + tzcdot .tl_set:N = \key_tzCdot_radius_tl +} + + +%% (keep) +%% \tzcdot --- circle dot (original) +%%% *[<opt>]<shift>(coor){label}[angle](radius) + +\clist_new:N \l_tzCdot_opt_clist +\bool_new:N \l_tzCdot_shift_coor_bool + +\NewDocumentCommand\tzcdot{ s o d<> r() +G{} O{} d() } +{ + \tl_clear:N \l_tzCdot_opt_tl % (needed) + \tl_clear:N \l_tzCdot_cmd_tl + + % default dot radius == arg specifier D<>{\tz@initial@radius} + \renewcommand\tzCdotradius{\tz@initial@Cdot@radius} + + \IfValueT { #7 } + { \renewcommand\tzCdotradius{ #7 } } + + \IfBooleanTF { #1 } + { \tl_set:Nn \l_tzCdot_fill_tl { fill , solid, thin } } + { \tl_set:Nn \l_tzCdot_fill_tl { solid , thin } } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzCdot_shift_coor_tl { #3 } + \bool_set_true:N \l_tzCdot_shift_coor_bool + } + { + \tl_clear:N \l_tzCdot_shift_coor_tl + \bool_set_false:N \l_tzCdot_shift_coor_bool + } + + \IfNoValueTF { #2 } + { + \tl_clear:N \l_tzCdot_opt_tl % arg specifier O{} + } + { + \clist_clear:N \l_tzCdot_opt_tested_clist + \clist_set:Nn \l_tzCdot_opt_input_clist { #2 } + \clist_map_inline:Nn \l_tzCdot_opt_input_clist + { + \str_if_in:nnTF { ##1 } { tzcdot } + { % (matched item) + \clist_pop:NN \l_tzCdot_opt_input_clist \l_tmpa_tl + \keys_set:nV { keytzCdot } \l_tmpa_tl % form: { tzcdot=\l_tmpa_tl } + \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } + \clist_map_break: + % non-tested list remains + } + { % (tested items -> list) + \clist_pop:NN \l_tzCdot_opt_input_clist \l_tmpb_tl + \clist_put_right:NV \l_tzCdot_opt_tested_clist \l_tmpb_tl + } + } + \clist_concat:NNN \l_tzCdot_opt_clist + \l_tzCdot_opt_tested_clist % tested list + \l_tzCdot_opt_input_clist % remained list + \clist_if_empty:NF \l_tzCdot_opt_clist + { % expand x needed + \tl_set:Nx \l_tzCdot_opt_tl { \clist_use:Nn \l_tzCdot_opt_clist {,} } + } + } + + \tl_put_right:Nx \l_tzCdot_cmd_tl + { + [ \l_tzCdot_fill_tl , + } + \tl_put_right:No \l_tzCdot_cmd_tl % expand `once' + { + \l_tzCdot_opt_tl + ] + } + \bool_if:NTF \l_tzCdot_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzCdot_cmd_tl + { + ( [ shift = { (\l_tzCdot_shift_coor_tl) } ]#4 ) + } + } + { \tl_put_right:Nn \l_tzCdot_cmd_tl { ( #4 ) } } % no shift (normal) + + \tl_put_right:Nn \l_tzCdot_cmd_tl + { + circle ( \tzCdotradius ) + } + \tl_put_right:Nx \l_tzCdot_cmd_tl + { + node + [ inner~sep = 0pt , + label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } + ] {} + } + \exp_last_unbraced:No \draw \l_tzCdot_cmd_tl ; +} + +%%% --- end of \tzcdot + + +%%% multiple dots +%%% coding CAUTION! : _tzCdot_ changes to _tzCdots + +%%% *[<opt>]<shift> (){}[] (){}[] repeated (){}[] ; (radius) +%%% repeat pattern: (coor){label}[angle] + +\clist_new:N \l_tzCdots_opt_clist +\bool_new:N \l_tzCdots_size_call_bool +\bool_new:N \l_tzCdots_shift_coor_bool + +\NewDocumentCommand\tzcdots{ s o d<> } +{ + \renewcommand\tzCdotradius{\tz@initial@Cdot@radius} + + \tl_clear:N \l_tzCdots_opt_tl % (needed) + \tl_clear:N \l_tzCdots_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzCdots_shift_coor_tl { #3 } + \bool_set_true:N \l_tzCdots_shift_coor_bool + } + { + \tl_clear:N \l_tzCdots_shift_coor_tl + \bool_set_false:N \l_tzCdots_shift_coor_bool + } + + \IfNoValueTF { #2 } + { + \tl_clear:N \l_tzCdots_opt_tl % arg specifier O{} + } + { + \clist_clear:N \l_tzCdots_opt_tested_clist + \clist_set:Nn \l_tzCdots_opt_input_clist { #2 } + \clist_map_inline:Nn \l_tzCdots_opt_input_clist + { + \str_if_in:nnTF { ##1 } { tzcdot } + { + \clist_pop:NN \l_tzCdots_opt_input_clist \l_tmpa_tl + \keys_set:nV { keytzCdot } \l_tmpa_tl + \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } + \bool_set_true:N \l_tzCdots_size_call_bool + \clist_map_break: + } + { + \clist_pop:NN \l_tzCdots_opt_input_clist \l_tmpb_tl + \clist_put_right:NV \l_tzCdots_opt_tested_clist \l_tmpb_tl + } + } + \clist_concat:NNN \l_tzCdots_opt_clist + \l_tzCdots_opt_tested_clist + \l_tzCdots_opt_input_clist + \clist_if_empty:NF \l_tzCdots_opt_clist + { + \tl_set:Nx \l_tzCdots_opt_tl { \clist_use:Nn \l_tzCdots_opt_clist {,} } + } + } + + \tzCdots_check_token:n +} + +\cs_new:Npn \tzCdots_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzCdots_sub_fn #1 } +% { \tzCdots_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzCdots_sub_fn #1 } + { ; } { \tzCdots_late_opt_fn } + } + { + \tzCdots_stop_action + } +} + +\NewDocumentCommand\tzCdots_sub_fn { r() +G{} O{} } +{ + \bool_if:NTF \l_tzCdots_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzCdots_cmd_tl + { + ( [ shift = { (\l_tzCdots_shift_coor_tl) } ]#1 ) circle (\tzCdotradius) + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzCdots_cmd_tl { (#1) circle (\tzCdotradius) } + } + + \tl_put_right:Nx \l_tzCdots_cmd_tl + { + node + [ inner~sep = 0pt , + label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + ] {} + } + \tzCdots_check_token:n +} + +\NewDocumentCommand\tzCdots_late_opt_fn { d() } +{ + \IfValueT { #1 } + { + \bool_if:NF \l_tzCdots_size_call_bool + { \renewcommand\tzCdotradius { #1 } } + } + + \tzCdots_stop_action +} + +\NewDocumentCommand\tzCdots_stop_action {} +{ + \tl_if_empty:NTF \l_tzCdots_opt_tl + { + \tl_put_left:Nn \l_tzCdots_cmd_tl { ] } + } + { + \tl_put_left:No \l_tzCdots_cmd_tl { \l_tzCdots_opt_tl ] } % expand `once' + } + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_left:Nn \l_tzCdots_cmd_tl { [ fill , solid , thin , } + } + { + \tl_put_left:Nn \l_tzCdots_cmd_tl { [ solid , thin , } + } + + \exp_last_unbraced:Nf \draw \l_tzCdots_cmd_tl ; + + \bool_set_false:N \l_tzCdots_size_call_bool +} + +%%% --- end of \tzcdots + + +%%% \tzshoworigin (node text and dot at the origin) + +\NewDocumentCommand\tzshoworigin + { s O{} d<> D(){0,0} +g O{} D(){\tz@initial@dot@size} } +{ + \IfValueTF { #5 } + {% if shift + \IfValueTF { #3 } + { + \path [ shift = {(#3)} ] (#4) node + [ text~height = 1.25ex , text~depth=.25ex , below~left , #6 ] + { #5 } ; + \IfBooleanT { #1 } { \tzdot* [ #2 ] ([shift={(#3)}] #4) (#7) } + } + {% no shift + \path (#4) node + [ text~height = 1.25ex , text~depth=.25ex , below~left , #6 ] + { #5 } ; + \IfBooleanT { #1 } { \tzdot* [ #2 ] (#4) (#7) } + } + } + { + \IfValueTF { #3 } + {% if shift + \IfBooleanTF { #1 } + { + \tzdot* [ #2 ] ([shift={(#3)}] #4) (#7) + } + { + \path [ shift = {(#3)} ] (#4) node + [ text~height = 1.25ex , text~depth=.25ex , below~left , #6 ] + { 0 } ; + } + } + {% no shift + \IfBooleanTF { #1 } + { + \tzdot* [ #2 ] (#4) (#7) + } + { + \path (#4) node + [ text~height = 1.25ex , text~depth=.25ex , below~left , #6 ] + { 0 } ; + } + } + } +} + +%%% --- end of \tzshoworigin + + +%%%%% Coordinates + +%%% \tzcoor()(){label}[pos] +\NewDocumentCommand\tzcoor{ s O{} d<> r() r() +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzcoor_cmd_tl + + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + { + \path ([shift={(#3)}]#4) coordinate (#5) ; + \tzdot*[#2]([shift={(#3)}]#4){#6}[#7](#8) + } + { + \path (#4) coordinate (#5) ; + \tzdot*[#2](#4){#6}[#7](#8) + } + } + { + \IfValueTF { #3 } + { + \tl_put_right:Nn \l_tzcoor_cmd_tl + { + ([shift={(#3)}]#4) coordinate + } + } + { \tl_put_right:Nn \l_tzcoor_cmd_tl { (#4) coordinate } } + + \tl_put_right:Nn \l_tzcoor_cmd_tl + { + [ inner~sep = 0pt , + } + \tl_put_right:Nx \l_tzcoor_cmd_tl + { + label = { \exp_not:n { #7 } \c_colon_str \exp_not:n { #6 } } + } + \tl_put_right:Nn \l_tzcoor_cmd_tl + { + ] (#5) + } + \exp_last_unbraced:No \path \l_tzcoor_cmd_tl ; + } +} + +%%% --- end of \tzcoor + + +%%% \tzcoors + +\bool_new:N \l_tzcoors_shift_coor_bool + +%%% \tzcoors*[opt]<radius> ()(){}[] ()(){}[] repeated ()(){}[]; +%% repeat pattern: (coor)(name){label}[pos] +\NewDocumentCommand\tzcoors{ s O{} d<> } +{ + \tl_clear:N \l_tzcoors_cmd_tl + \tl_clear:N \l_tzcoors_tzdot_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #2 } + { \tl_set:Nn \l_tzcoors_opt_tl { #2 } } + { \tl_clear:N \l_tzcoors_opt_tl } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzcoors_shift_coor_tl { #3 } + \bool_set_true:N \l_tzcoors_shift_coor_bool + } + { + \tl_clear:N \l_tzcoors_shift_coor_tl + \bool_set_false:N \l_tzcoors_shift_coor_bool + } + + \tzcoors_check_token:n +} + +\cs_new:Npn \tzcoors_check_token:n #1 +{ +% \str_if_eq:nnTF { #1 } { ( } +% { \tzcoors_sub_fn ( } +% { \tzcoors_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzcoors_sub_fn #1 } + { ; } { \tzcoors_late_opt_fn } + } + { + \tzcoors_stop_action + } +} + +\NewDocumentCommand\tzcoors_sub_fn { r() r() +G{} O{} } +{ + \bool_if:NTF \l_tmpa_bool + { + % collect only coor info + \bool_if:NTF \l_tzcoors_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_cmd_tl + { ([ shift = { (\l_tzcoors_shift_coor_tl) } ]#1) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzcoors_cmd_tl { (#1) } + } + \tl_put_right:Nn \l_tzcoors_cmd_tl + { coordinate (#2) } + % collect dot info: (coor) [ dot opt ] {} + \bool_if:NTF \l_tzcoors_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_tzdot_cmd_tl + { ([ shift = { (\l_tzcoors_shift_coor_tl) } ]#1) } + } + {% no shift + \tl_put_right:Nn \l_tzcoors_tzdot_cmd_tl { (#1) } + } + \tl_put_right:Nn \l_tzcoors_tzdot_cmd_tl + { + node + [ fill , tzdot = \tzdotsize , + } + \tl_put_right:Nx \l_tzcoors_tzdot_cmd_tl + { + label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } , + } + \tl_put_right:No \l_tzcoors_tzdot_cmd_tl + { + \l_tzcoors_opt_tl % expand `once' + ] {} + } + } + { + \bool_if:NTF \l_tzcoors_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_cmd_tl + { ([ shift = { (\l_tzcoors_shift_coor_tl) } ]#1) coordinate } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzcoors_cmd_tl + { (#1) coordinate } + } + \tl_put_right:Nx \l_tzcoors_cmd_tl + { [ label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } ] } + \tl_put_right:Nn \l_tzcoors_cmd_tl + { (#2) } + } + \tzcoors_check_token:n +} + +\NewDocumentCommand\tzcoors_late_opt_fn { D(){\tz@initial@dot@size} } +{ + \renewcommand\tzdotsize{ #1 } + + \tzcoors_stop_action +} + +\cs_new:Npn \tzcoors_stop_action +{ + \exp_last_unbraced:Nf \path \l_tzcoors_cmd_tl ; + \bool_if:NT \l_tmpa_bool + { \exp_last_unbraced:Nf \path \l_tzcoors_tzdot_cmd_tl ; } +} + +%%% --- end of \tzcoors + + +%%% \tzcoorsquick --- with labels (quick view) + +\bool_new:N \l_tzcoors_quick_shift_coor_bool + +\NewDocumentCommand\tzcoorsquick { s O{} d<> } +{ + \tl_clear:N \l_tzcoors_quick_cmd_tl + \tl_clear:N \l_tzcoors_quick_tzdot_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #2 } + { \tl_set:Nn \l_tzcoors_quick_opt_tl { #2 } } + { \tl_clear:N \l_tzcoors_quick_opt_tl } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzcoors_quick_shift_coor_tl { #3 } + \bool_set_true:N \l_tzcoors_quick_shift_coor_bool + } + { + \tl_clear:N \l_tzcoors_quick_shift_coor_tl + \bool_set_false:N \l_tzcoors_quick_shift_coor_bool + } + + \tzcoors_quick_check_token:n +} + +\cs_new:Npn \tzcoors_quick_check_token:n #1 +{ +% \str_if_eq:nnTF { #1 } { ( } +% { \tzcoorsquick_sub_fn ( } +% { \tzcoorsquick_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzcoorsquick_sub_fn #1 } + { ; } { \tzcoorsquick_late_opt_fn } + } + { + \tzcoorsquick_stop_action + } +} + +% repetition *** +\NewDocumentCommand\tzcoorsquick_sub_fn { r() r() +g O{} } +{ + \IfValueTF { #3 } + { \tl_set:Nx \l_tmpa_tl { \exp_not:n { #3 } } } + { \tl_set:Nn \l_tmpa_tl { #2 } } % automatic view + \tl_if_empty:nTF { #4 } + { + \bool_if:NTF \l_tmpa_bool + { \tl_set:Nn \l_tmpb_tl { } } % texts with dots (tikz default: above) + { \tl_set:Nn \l_tmpb_tl { center } } % only texts + } + { + \tl_set:Nx \l_tmpb_tl { \exp_not:n { #4 } } + } + + \bool_if:NTF \l_tmpa_bool + { %% glancing labels with dots + % collect only coor info + % collect only coor info + \bool_if:NTF \l_tzcoors_quick_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_quick_cmd_tl + { ([ shift = { (\l_tzcoors_quick_shift_coor_tl) } ]#1) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzcoors_quick_cmd_tl { (#1) } + } + \tl_put_right:Nn \l_tzcoors_quick_cmd_tl + { coordinate (#2) } + % collect dot info: (coor) [ dot opt ] {} + \bool_if:NTF \l_tzcoors_quick_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_quick_tzdot_cmd_tl + { ([ shift = { (\l_tzcoors_quick_shift_coor_tl) } ]#1) } + } + {% no shift + \tl_put_right:Nn \l_tzcoors_quick_tzdot_cmd_tl { (#1) } + } + \tl_put_right:Nn \l_tzcoors_quick_tzdot_cmd_tl + { + node + [ fill , tzdot = \tzdotsize , + } + \tl_put_right:Nx \l_tzcoors_quick_tzdot_cmd_tl + { + label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } , + } + \tl_put_right:No \l_tzcoors_quick_tzdot_cmd_tl + { + \l_tzcoors_quick_opt_tl % expand `once' + ] {} + } + } + { %% glancing just labels (right on the coors) + % collect coor and node info + \bool_if:NTF \l_tzcoors_quick_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzcoors_quick_cmd_tl + { ([ shift = { (\l_tzcoors_quick_shift_coor_tl) } ]#1) coordinate } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzcoors_quick_cmd_tl + { (#1) coordinate } + } + \tl_put_right:Nx \l_tzcoors_quick_cmd_tl + { [ label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } ] } + \tl_put_right:Nn \l_tzcoors_quick_cmd_tl + { (#2) } + } + + \tzcoors_quick_check_token:n +} + +\NewDocumentCommand\tzcoorsquick_late_opt_fn{ D(){\tz@initial@dot@size} } +{ + \renewcommand\tzdotsize{ #1 } + + \tzcoorsquick_stop_action +} + +\cs_new:Npn \tzcoorsquick_stop_action +{ + \exp_last_unbraced:Nf \path \l_tzcoors_quick_cmd_tl ; + \bool_if:NT \l_tmpa_bool + { \exp_last_unbraced:Nf \path \l_tzcoors_quick_tzdot_cmd_tl ; } +} + +%%% --- end of \tzcoorsquick + + + +%%%%% Lines + +%%% \tzline +%% do not use: inner sep=0pt + +%%% \tzline + +\bool_new:N \l_tzline_shift_coor_bool + +%%% \tzline +\NewDocumentCommand\tzline{ s t+ o d<> d"" } +{ + \tl_clear:N \l_tzline_cmd_tl + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzline_shift_coor_tl { #4 } + \bool_set_true:N \l_tzline_shift_coor_bool + } + { + \tl_clear:N \l_tzline_shift_coor_tl + \bool_set_false:N \l_tzline_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzline_opt_tl { #3 } } + { \tl_clear:N \l_tzline_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzline_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tzline_namepath_tl } + + \tzline_check_token:n +} + +\cs_new:Npn \tzline_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzline_sub_fn ( } +% \tzline_stop_action +} + +%% structure: (coorA) -- node [pos] {text} (coorB) node [pos] {text} +\NewDocumentCommand\tzline_sub_fn{ r() +G{} O{} d<> r() +G{} O{} D<>{} } +{ + % determine connect line STYLE + \tl_set:Nn \l_tzline_STYLE_A_tl { -- } + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzline_STYLE_C_tl { #4 } + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzline_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzline_STYLE_C_tl { } } + } + % insert connect line STYLE + \bool_if:NTF \l_tzline_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzline_cmd_tl + { ([ shift = { (\l_tzline_shift_coor_tl) } ]#1) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzline_cmd_tl { (#1) } + } + + \tl_put_right:No \l_tzline_cmd_tl % once + { + \l_tzline_STYLE_A_tl %% just -- + } + \tl_put_right:Nn \l_tzline_cmd_tl + { + ~ node [ above , #3 ] { #2 } + } + \tl_put_right:No \l_tzline_cmd_tl % once + { + \l_tzline_STYLE_C_tl + } + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzline_cmd_tl { (#5) } + } + {% no ++ + \bool_if:NTF \l_tzline_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzline_cmd_tl + { ([ shift = { (\l_tzline_shift_coor_tl) } ]#5) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzline_cmd_tl { (#5) } + } + } + + \tl_put_right:Nn \l_tzline_cmd_tl + { node [ #7 ] { #6 } } + + % final action + \tl_put_left:No \l_tzline_cmd_tl + { + \l_tzline_opt_tl ] % expand `once' + } + + \tl_put_left:Nx \l_tzline_cmd_tl + { [ \l_tzline_namepath_tl , } + + \exp_last_unbraced:Nf \draw \l_tzline_cmd_tl #8 ; +} + +%%% --- end of \tzline + + +%%% \tzlines + +\bool_new:N \l_tzlines_shift_coor_bool + +%% do not use: inner sep=0pt +\NewDocumentCommand\tzlines{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tzlines_cmd_tl + \tl_clear:N \l_tzlines_STYLE_tl + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzlines_shift_coor_tl { #4 } + \bool_set_true:N \l_tzlines_shift_coor_bool + } + { + \tl_clear:N \l_tzlines_shift_coor_tl + \bool_set_false:N \l_tzlines_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzlines_opt_tl { #3 } } + { \tl_clear:N \l_tzlines_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzlines_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tzlines_namepath_tl } + + \int_zero:N \l_tmpa_int + \tzlines_check_token:n +} + +\cs_new:Npn \tzlines_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzlines_sub_fn #1 } +% { \tzlines_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzlines_sub_fn #1 } + { ; } { \tzlines_late_opt_fn } + } + { + \tzlines_stop_action + } +} + +\NewDocumentCommand\tzlines_sub_fn{ r() +G{} O{} d<> } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tzlines_cmd_tl { \l_tzlines_STYLE_tl } + \tl_clear:N \l_tzlines_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzlines_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzlines_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzlines_cmd_tl + { ([ shift = { (\l_tzlines_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzlines_cmd_tl + { ([ shift = { (\l_tzlines_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzlines_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tzlines_STYLE_A_tl { -- } + % save node info (for later use, at the end) + \tl_set:Nn \l_tzlines_STYLE_B_tl { ~ node [ #3 ] { #2 } } + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzlines_STYLE_C_tl { #4 } % empty, + , or ++ + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzlines_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzlines_STYLE_C_tl { } } + } + + \tl_put_right:No \l_tzlines_STYLE_tl { \l_tzlines_STYLE_A_tl } + \tl_put_right:No \l_tzlines_STYLE_tl { \l_tzlines_STYLE_B_tl } + \tl_put_right:No \l_tzlines_STYLE_tl { \l_tzlines_STYLE_C_tl } + + \tzlines_check_token:n +} + +\NewDocumentCommand\tzlines_late_opt_fn { D<>{} } +{ + \tl_set:Nn \l_tzlines_code_at_end_tl { #1 } + \tzlines_stop_action +} + +\NewDocumentCommand\tzlines_stop_action {} +{ + \tl_put_right:No \l_tzlines_cmd_tl { \l_tzlines_STYLE_B_tl } + \tl_clear:N \l_tzlines_STYLE_tl + % gathering options + \tl_put_left:No \l_tzlines_cmd_tl + { + \l_tzlines_opt_tl ] % expand `once' needed + } + \tl_put_left:Nx \l_tzlines_cmd_tl + { [ \l_tzlines_namepath_tl , } + % final action + \exp_last_unbraced:Nf + \draw \l_tzlines_cmd_tl \l_tzlines_code_at_end_tl ; +} + +%%% --- end of \tzlines + + +%%% \tzpolygon (closed path of \tzlines) + +\bool_new:N \l_tzpolygon_shift_coor_bool + +%% do not use: inner sep=0pt +\NewDocumentCommand\tzpolygon{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tzpolygon_cmd_tl + \tl_clear:N \l_tzpolygon_STYLE_tl + + \IfBooleanTF { #1 } % fill(*) or not + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzpolygon_shift_coor_tl { #4 } + \bool_set_true:N \l_tzpolygon_shift_coor_bool + } + { + \tl_clear:N \l_tzpolygon_shift_coor_tl + \bool_set_false:N \l_tzpolygon_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nx \l_tzpolygon_opt_tl { #3 } } + { \tl_clear:N \l_tzpolygon_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzpolygon_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tzpolygon_namepath_tl } + + \int_zero:N \l_tmpa_int + \tzpolygon_check_token:n +} + +\cs_new:Npn \tzpolygon_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzpolygon_sub_fn #1 } +% { \tzpolygon_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzpolygon_sub_fn #1 } + { ; } { \tzpolygon_late_opt_fn } + } + { + \tzpolygon_stop_action + } +} + +\NewDocumentCommand\tzpolygon_sub_fn{ r() +G{} O{} d<> } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tzpolygon_cmd_tl { \l_tzpolygon_STYLE_tl } + \tl_clear:N \l_tzpolygon_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzpolygon_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzpolygon_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzpolygon_cmd_tl + { ([ shift = { (\l_tzpolygon_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzpolygon_cmd_tl + { ([ shift = { (\l_tzpolygon_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzpolygon_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tzpolygon_STYLE_A_tl { -- } + % save node info (for later use, at the end) + \tl_set:Nn \l_tzpolygon_STYLE_B_tl { ~ node [ #3 ] { #2 } } + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzpolygon_STYLE_C_tl { #4 } % empty, + , or ++ + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzpolygon_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzpolygon_STYLE_C_tl { } } + } + + \tl_put_right:No \l_tzpolygon_STYLE_tl { \l_tzpolygon_STYLE_A_tl } + \tl_put_right:No \l_tzpolygon_STYLE_tl { \l_tzpolygon_STYLE_B_tl } + \tl_put_right:No \l_tzpolygon_STYLE_tl { \l_tzpolygon_STYLE_C_tl } + + \tzpolygon_check_token:n +} + +\NewDocumentCommand\tzpolygon_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{ #1 } + \tl_set:Nn \l_tzpolygon_code_at_end_tl { #2 } + \tzpolygon_stop_action +} + +\NewDocumentCommand\tzpolygon_stop_action {} +{ + \tl_put_right:No \l_tzpolygon_cmd_tl { \l_tzpolygon_STYLE_B_tl } + \tl_clear:N \l_tzpolygon_STYLE_tl + % fill or not + \tl_put_left:No \l_tzpolygon_cmd_tl + { + \l_tzpolygon_opt_tl ] % expand `once' needed + } + \bool_if:NTF \l_tmpa_bool + { + \tl_put_left:Nx \l_tzpolygon_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + \l_tzpolygon_namepath_tl , + } + } + { + \tl_put_left:Nx \l_tzpolygon_cmd_tl + { [ \l_tzpolygon_namepath_tl , } + } + % final action + \exp_last_unbraced:Nf + \draw \l_tzpolygon_cmd_tl \l_tzpolygon_code_at_end_tl -- cycle ; +} + +%%% --- end of \tzpolygon + + +%%% \tzpath +%% draw=none version of \tzlinks (mainly for filling area) + +\bool_new:N \g_tzpath_BEGIN_cmd_bool +\bool_new:N \g_tzpath_END_cmd_bool +\bool_new:N \l_tzpath_shift_coor_bool + +%% \tzpathAtBegin +\NewDocumentCommand\tzpathAtBegin{ m } +{ + \bool_gset_true:N \g_tzpath_BEGIN_cmd_bool + \tl_gset:No \g_tzpath_BEGIN_cmd_tl { #1 } +} + +%% \tzpathAtEnd +\NewDocumentCommand\tzpathAtEnd{ m } +{ + \bool_gset_true:N \g_tzpath_END_cmd_bool + \tl_gset:No \g_tzpath_END_cmd_tl { #1 } +} + +%%% \tzpath +%% do not use: inner sep=0pt +\NewDocumentCommand\tzpath{ s t+ G{\tz@initial@path@style} O{} d<> D""{} } +{ + \tl_clear:N \l_tzpath_cmd_tl + \tl_clear:N \l_tzpath_STYLE_tl + + \IfValueT { #3 } + { \renewcommand\tzpathstyle{ #3 } } + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzpath_shift_coor_tl { #5 } + \bool_set_true:N \l_tzpath_shift_coor_bool + } + { + \tl_clear:N \l_tzpath_shift_coor_tl + \bool_set_false:N \l_tzpath_shift_coor_bool + } + + \IfValueTF { #4 } + { \tl_set:Nx \l_tzpath_opt_tl { #4 } } + { \tl_clear:N \l_tzpath_opt_tl } + + \IfValueTF { #6 } + { \tl_set:Nn \l_tzpath_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzpath_namepath_tl } + + \int_zero:N \l_tmpa_int + \tzpath_check_token:n +} + +\cs_new:Npn \tzpath_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzpath_sub_fn #1 } +% { \tzpath_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzpath_sub_fn #1 } + { ; } { \tzpath_late_opt_fn } + } + { + \tzpath_stop_action + } +} + +\NewDocumentCommand\tzpath_sub_fn{ r() O{} +G{} O{} d<> } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_tl } + \tl_clear:N \l_tzpath_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzpath_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzpath_cmd_tl + { ([ shift = { (\l_tzpath_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzpath_cmd_tl + { ([ shift = { (\l_tzpath_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_if_empty:nTF { #2 } + { \tl_set:Nn \l_tzpath_STYLE_A_tl { ~ \tzpathstyle ~ } } + { \tl_set:Nn \l_tzpath_STYLE_A_tl { #2 } } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tzpath_STYLE_B_tl + } + { + \tl_set:Nn \l_tzpath_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzpath_STYLE_C_tl { #5 } + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzpath_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzpath_STYLE_C_tl { } } + } + + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_A_tl } + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_B_tl } + \tl_put_right:No \l_tzpath_STYLE_tl { \l_tzpath_STYLE_C_tl } + + \tzpath_check_token:n +} + +\NewDocumentCommand\tzpath_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{ #1 } + \tl_set:Nn \l_tzpath_code_at_end_tl { #2 } + \tzpath_stop_action +} + +\NewDocumentCommand\tzpath_stop_action {} +{ + \tl_if_empty:NF \l_tzpath_STYLE_B_tl + { + \tl_put_right:No \l_tzpath_cmd_tl { \l_tzpath_STYLE_B_tl } + } + \tl_clear:N \l_tzpath_STYLE_tl + %% add at begin/end + \bool_if:NT \g_tzpath_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzpath_cmd_tl { \g_tzpath_BEGIN_cmd_tl } } + \bool_if:NT \g_tzpath_END_cmd_bool + { \tl_put_right:Nx \l_tzpath_cmd_tl { \g_tzpath_END_cmd_tl } } + %% collect options + \tl_put_left:No \l_tzpath_cmd_tl + { \l_tzpath_opt_tl ] } % expand `once' needed + % * or not + \bool_if:NTF \l_tmpa_bool + { + \tl_put_left:Nx \l_tzpath_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + \l_tzpath_namepath_tl , + } + } + { + \tl_put_left:Nx \l_tzpath_cmd_tl + { [ \l_tzpath_namepath_tl , } + } + %% final action + \exp_last_unbraced:Nf + \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path + + \bool_gset_false:N \g_tzpath_BEGIN_cmd_bool + \bool_gset_false:N \g_tzpath_END_cmd_bool +} + +%%% --- end of \tzpath + + +%%% \tzto + +\bool_new:N \g_tzto_BEGIN_cmd_bool +\bool_new:N \g_tzto_END_cmd_bool +\bool_new:N \l_tzto_shift_coor_bool + +%% \tztoAtBegin +\NewDocumentCommand\tztoAtBegin{ m } +{ + \bool_gset_true:N \g_tzto_BEGIN_cmd_bool + \tl_gset:No \g_tzto_BEGIN_cmd_tl { #1 } +} + +%% \tztoAtEnd +\NewDocumentCommand\tztoAtEnd{ m } +{ + \bool_gset_true:N \g_tzto_END_cmd_bool + \tl_gset:No \g_tzto_END_cmd_tl { #1 } +} + +%%% \tzto (main) +\NewDocumentCommand\tzto{ s t+ o d<> d"" } +{ + \tl_clear:N \l_tzto_cmd_tl + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzto_shift_coor_tl { #4 } + \bool_set_true:N \l_tzto_shift_coor_bool + } + { + \tl_clear:N \l_tzto_shift_coor_tl + \bool_set_false:N \l_tzto_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzto_opt_tl { #3 } } + { \tl_clear:N \l_tzto_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzto_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tzto_namepath_tl } + + \tzto_check_token:n +} + +\cs_new:Npn \tzto_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzto_sub_fn ( } +% \tzto_stop_action +} + +\NewDocumentCommand\tzto_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } +{ + + \bool_if:NTF \l_tzto_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzto_cmd_tl + { ([ shift = { (\l_tzto_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzto_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tzto_cmd_tl + { to ~node [ above , #3 ] { #2 } } + + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzto_cmd_tl { ++ (#4) } + } + {% no ++ + \bool_if:NTF \l_tzto_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzto_cmd_tl + { ([ shift = { (\l_tzto_shift_coor_tl) } ]#4) } + } + { \tl_put_right:Nn \l_tzto_cmd_tl { (#4) } } + } + + \tl_put_right:Nn \l_tzto_cmd_tl + { node [ #6 ] { #5 } } + + % add at begin/end + \bool_if:NT \g_tzto_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzto_cmd_tl { \g_tzto_BEGIN_cmd_tl } } + \bool_if:NT \g_tzto_END_cmd_bool + { \tl_put_right:Nx \l_tzto_cmd_tl { \g_tzto_END_cmd_tl } } + + % final action + \tl_put_left:No \l_tzto_cmd_tl + { + \l_tzto_opt_tl ] % expand `once' needed + } + + \tl_put_left:Nx \l_tzto_cmd_tl + { [ \l_tzto_namepath_tl , } + + \exp_last_unbraced:Nf \draw \l_tzto_cmd_tl #7 ; + + \bool_gset_false:N \g_tzto_BEGIN_cmd_bool + \bool_gset_false:N \g_tzto_END_cmd_bool +% \tl_clear:N \g_tzto_BEGIN_cmd_tl +% \tl_clear:N \g_tzto_END_cmd_tl +} + +%%% --- end of \tzto + + +%%% \tztos (longer version of \tzto) + +\bool_new:N \g_tztos_BEGIN_cmd_bool +\bool_new:N \g_tztos_END_cmd_bool +\bool_new:N \l_tztos_shift_coor_bool + +%% \tztosAtBegin +\NewDocumentCommand\tztosAtBegin{ m } +{ + \bool_gset_true:N \g_tztos_BEGIN_cmd_bool + \tl_gset:No \g_tztos_BEGIN_cmd_tl { #1 } +} + +%% \tztosAtEnd +\NewDocumentCommand\tztosAtEnd{ m } +{ + \bool_gset_true:N \g_tztos_END_cmd_bool + \tl_gset:No \g_tztos_END_cmd_tl { #1 } +} + +%%% \tztos (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tztos{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tztos_cmd_tl + \tl_clear:N \l_tztos_STYLE_tl + +% \IfValueT { #3 } +% { \renewcommand\tztostyle{ #3 } } + + \IfBooleanTF { #1 } % (*) or not (NOT USED!) + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % (+) or not + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tztos_shift_coor_tl { #4 } + \bool_set_true:N \l_tztos_shift_coor_bool + } + { + \tl_clear:N \l_tztos_shift_coor_tl + \bool_set_false:N \l_tztos_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tztos_opt_tl { #3 } } + { \tl_clear:N \l_tztos_opt_tl } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tztos_namepath_tl { name~path = #5 } } + { \tl_clear:N \l_tztos_namepath_tl } + + \int_zero:N \l_tmpa_int + \tztos_check_token:n +} + +\cs_new:Npn \tztos_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tztos_sub_fn #1 } +% { \tztos_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tztos_sub_fn #1 } + { ; } { \tztos_late_opt_fn } + } + { + \tztos_stop_action + } +} + +%% (coor)[to opt]{text}[node opt] +\NewDocumentCommand\tztos_sub_fn{ r() O{} +G{} O{} } +{ + \int_incr:N \l_tmpa_int + % (from the second round) put line STYLE before the next cmd-tl + \int_compare:nT { \l_tmpa_int > 1 } + { + \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_tl } + \tl_clear:N \l_tztos_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tztos_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tztos_cmd_tl + { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tztos_cmd_tl + { ([ shift = { (\l_tztos_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tztos_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tztos_STYLE_A_tl { ~ to [ #2 ] } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tztos_STYLE_B_tl + } + { + \tl_set:Nn \l_tztos_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tztos_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tztos_STYLE_C_tl { } } + + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_A_tl } + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_B_tl } + \tl_put_right:No \l_tztos_STYLE_tl { \l_tztos_STYLE_C_tl } + + \tztos_check_token:n +} + +\NewDocumentCommand\tztos_late_opt_fn { D<>{} } +{ + \tl_set:Nn \l_tztos_code_at_end_tl { #1 } + \tztos_stop_action +} + +\NewDocumentCommand\tztos_stop_action {} +{ + \tl_if_empty:NF \l_tztos_STYLE_B_tl + { + \tl_put_right:No \l_tztos_cmd_tl { \l_tztos_STYLE_B_tl } + } + \tl_clear:N \l_tztos_STYLE_tl + % add at begin/end + \bool_if:NT \g_tztos_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tztos_cmd_tl { \g_tztos_BEGIN_cmd_tl } } + \bool_if:NT \g_tztos_END_cmd_bool + { \tl_put_right:Nx \l_tztos_cmd_tl { \g_tztos_END_cmd_tl } } + % fill or not + \tl_put_left:No \l_tztos_cmd_tl + { + \l_tztos_opt_tl ] % expand `once' needed for user convenience + } + \tl_put_left:Nx \l_tztos_cmd_tl + { [ \l_tztos_namepath_tl , } + % final action + \exp_last_unbraced:Nf + \draw \l_tztos_cmd_tl \l_tztos_code_at_end_tl ; %% draw + + \bool_gset_false:N \g_tztos_BEGIN_cmd_bool + \bool_gset_false:N \g_tztos_END_cmd_bool +% \tl_clear:N \g_tztos_BEGIN_cmd_tl +% \tl_clear:N \g_tztos_END_cmd_tl +} + +%%% --- end of \tztos + + +%%%%% Figures: circles, frames, ellipses, triangles, etc. + +%%% \tzcircle + +\NewDocumentCommand\tzcircle + { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#7} + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = #7 , + text~opacity = 1 , + name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = #7 , + text~opacity = 1 , + name~path = #4 , #2 ] (#5) circle (#6) ; + } + } + { + \IfValueTF { #3 } + { \draw [ #2 ] ([shift={(#3)}]#5) circle (#6) ; } + { \draw [ #2 ] (#5) circle (#6) ; } + } +} + +%%% \tzellipse + +\NewDocumentCommand\tzellipse + { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#7} + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = #7 , + text~opacity = 1 , + name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = #7 , + text~opacity = 1 , + name~path = #4 , #2 ] (#5) ellipse (#6) ; + } + } + { + \IfValueTF { #3 } + { \draw [ name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) ; } + { \draw [ name~path = #4 , #2 ] (#5) ellipse (#6) ; } + } +} + + +%%% \tzframe + +\NewDocumentCommand\tzframe + { s t+ O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#8} + \IfBooleanTF { #1 } + { + \IfBooleanTF { #2 } + { + \IfValueTF { #4 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ++ (#7) ; + } + {% no shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + (#6) rectangle ++ (#7) ; + } + } + { + \IfValueTF { #4 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) ; + } + {% no shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + name~path = #5 , #3 ] + (#6) rectangle (#7) ; + } + } + } + { + \IfBooleanTF { #2 } + { + \IfValueTF { #4 } + {% if shift + \draw [ name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ++ (#7) ; + } + {% no shift + \draw [ name~path = #5 , #3 ] (#6) rectangle ++ (#7) ; + } + } + { + \IfValueTF { #4 } + {% if shift + \draw [ name~path = #5 , #3 ] + ([shift={(#4)}]#6) rectangle ([shift={(#4)}]#7) ; + } + {% no shift + \draw [ name~path = #5 , #3 ] (#6) rectangle (#7) ; + } + } + } +} + + +%%% \tzparabola + +\bool_new:N \l_tzparabola_shift_coor_bool + +\NewDocumentCommand\tzparabola +{ s t+ O{} d<> D""{} } +{ + \tl_clear:N \l_tzparabola_cmd_tl + + \IfBooleanTF { #1 } % NOT USED!!! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzparabola_pathname_tl { name~path = #5 } } + { \tl_clear:N \l_tzparabola_pathname_tl } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzparabola_shift_coor_tl { #4 } + \bool_set_true:N \l_tzparabola_shift_coor_bool + } + { + \tl_clear:N \l_tzparabola_shift_coor_tl + \bool_set_false:N \l_tzparabola_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzparabola_opt_tl { #3 } } + { \tl_clear:N \l_tzparabola_opt_tl } + + \tzparabola_check_token:n +} + +\cs_new:Npn \tzparabola_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzparabola_sub_fn ( } +% \tzparabola_stop_action +} + +\NewDocumentCommand\tzparabola_sub_fn + { r() r() d() +G{} O{} G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#6} %% NOT USED! (to be removed) + + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#1) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { (#1) } + } + + \IfNoValueTF { #3 } + {%% 2 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#2)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola ($(#1)+(#2)$) } + } + } + {% no + (absolute coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { parabola ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { parabola (#2) } + } + } + } + {%% 3 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzparabola_cmd_tl + { parabola~bend + (#2) } + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]$(#1)+(#3)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { ($(#1)+(#3)$) } + } + } + {% no + (absolute coor) + \bool_if:NTF \l_tzparabola_shift_coor_bool + { + \tl_put_right:Nx \l_tzparabola_cmd_tl + { + parabola~bend + ([shift = { (\l_tzparabola_shift_coor_tl) } ]#2) + } + } + { + \tl_put_right:Nn \l_tzparabola_cmd_tl + { parabola~bend (#2) } + } + \bool_if:NTF \l_tzparabola_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzparabola_cmd_tl + { ([shift = { (\l_tzparabola_shift_coor_tl) } ]#3) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzparabola_cmd_tl { (#3) } + } + } + } + + \tl_put_left:No \l_tzparabola_cmd_tl + { \l_tzparabola_opt_tl ] } % expand `once' + \tl_put_left:Nx \l_tzparabola_cmd_tl + { [ \l_tzparabola_pathname_tl , } + % final action + \exp_last_unbraced:Nf + \draw \l_tzparabola_cmd_tl node [ #5 ] { #4 } #7 ; +} + +%%% -- end of \tzparabola + + +%%% \tzbezier + +\bool_new:N \l_tzbezier_shift_coor_bool + +\NewDocumentCommand\tzbezier{ s t+ O{} d<> D""{tzplot~path} } +{ + \tl_clear:N \l_tzbezier_cmd_tl + + \IfBooleanTF { #1 } %% NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_true:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #5 } + { \tl_set:Nn \l_tzbezier_pathname_tl { name~path = #5 } } + { \tl_clear:N \l_tzbezier_pathname_tl } + + \IfValueTF { #4 } + { + \tl_set:Nn \l_tzbezier_shift_coor_tl { #4 } + \bool_set_true:N \l_tzbezier_shift_coor_bool + } + { + \tl_clear:N \l_tzbezier_shift_coor_tl + \bool_set_false:N \l_tzbezier_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzbezier_opt_tl { #3 } } + { \tl_clear:N \l_tzbezier_opt_tl } + + \tzbezier_check_token:n +} + +\cs_new:Npn \tzbezier_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzbezier_sub_fn ( } +% \tzbezier_stop_action +} + +\NewDocumentCommand\tzbezier_sub_fn{ r() r() r() d() +G{} O{} D<>{} } +{ + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { ([shift = { (\l_tzbezier_shift_coor_tl) } ]#1) .. controls } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#1) .. controls } + } + + \IfNoValueTF { #4 } + {%% 3 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) } + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#3)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#3)$) } + } + } + {% no + (absolute coor) + % control coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) } + } + %% end coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#3) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#3) } + } + } + } + {%% 4 coors + \bool_if:NTF \l_tmpb_bool + {% if + (relative coor) + \tl_put_right:Nn \l_tzbezier_cmd_tl { + (#2) and + (#3) } + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]$(#1)+(#4)$) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. ($(#1)+(#4)$) } + } + } + {% no + (absolute coor) + %% control coors + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { + ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#2) + and + ([ shift = { (\l_tzbezier_shift_coor_tl) } ]#3) + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { (#2) and (#3) } + } + %% end coor + \bool_if:NTF \l_tzbezier_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzbezier_cmd_tl + { .. ([shift = { (\l_tzbezier_shift_coor_tl) } ]#4) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzbezier_cmd_tl { .. (#4) } + } + } + } + + \tl_put_left:No \l_tzbezier_cmd_tl { \l_tzbezier_opt_tl ] } + \tl_put_left:Nx \l_tzbezier_cmd_tl + { [ \l_tzbezier_pathname_tl , } + % final action + \exp_last_unbraced:Nf \draw \l_tzbezier_cmd_tl node [ #6 ] { #5 } #7 ; +} + +%%% -- end of \tzbezier + + +%%% \tzarc + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarc + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + + \tl_clear:N \l_tzarc_cmd_tl + + \tzarc_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzarcAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcAngleB } + + \tl_put_right:Nn \l_tzarc_cmd_tl + { [ name~path = #5 , #3 ] } + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarc_cmd_tl + { ([shift={(#4)}]#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzarc_cmd_tl + { (#6) ++ (\tzarcAngleA \c_colon_str \tzarcRadius) } + } + + \tl_put_right:Nx \l_tzarc_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcAngleA + \c_colon_str + \IfBooleanTF {#2} + {\tzarcAngleB - 360} + {\tzarcAngleB} + \c_colon_str + \tzarcRadius ) + } + { + arc ( \IfBooleanTF {#2} + {\tzarcAngleA - 360} + {\tzarcAngleA} + \c_colon_str + \tzarcAngleB + \c_colon_str + \tzarcRadius ) + } + } + + \tzarc_sub_fn:n +} + +\NewDocumentCommand\tzarc_args_process{ m m m } +{ + \def\tzarcAngleA{#1} + \def\tzarcAngleB{#2} + \def\tzarcRadius{#3} +} + +\cs_new:Npn \tzarc_sub_fn:n +{ + \tzarc_final_actions +} + +\NewDocumentCommand\tzarc_final_actions{ +G{} O{} D<>{} } +{ + \tl_put_right:Nn \l_tzarc_cmd_tl + { node [ #2 ] { #1 } #3 } + + \exp_last_unbraced:Nf \draw \l_tzarc_cmd_tl ; +} + +%%% --- end of \tzarc + + + +%%% \tzarcfrom % (works like tikz original) + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarcfrom + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + + \tl_clear:N \l_tzarcfrom_cmd_tl + + \tzarcfrom_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzarcfromAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcfromAngleB } + + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { [ name~path = #5 , #3 ] } + + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { ([shift={(#4)}]#6) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { (#6) } % ++ (\tzarcfromAngleA \c_colon_str \tzarcfromRadius) + } + + \tl_put_right:No \l_tzarcfrom_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcfromAngleA + \c_colon_str + \IfBooleanTF {#2} + {\tzarcfromAngleB - 360} + {\tzarcfromAngleB} + \c_colon_str + \tzarcfromRadius ) + } + { + arc ( \IfBooleanTF {#2} + {\tzarcfromAngleA - 360} + {\tzarcfromAngleA} + \c_colon_str + \tzarcfromAngleB + \c_colon_str + \tzarcfromRadius ) + } + } + + \tzarcfrom_sub_fn:n + +} + +\NewDocumentCommand\tzarcfrom_args_process{ m m m } +{ + \def\tzarcfromAngleA{#1} + \def\tzarcfromAngleB{#2} + \def\tzarcfromRadius{#3} +} + +\cs_new:Npn \tzarcfrom_sub_fn:n +{ + \tzarcfrom_final_actions +} + +\NewDocumentCommand\tzarcfrom_final_actions{ +G{} O{} D<>{} } +{ + \tl_put_right:Nn \l_tzarcfrom_cmd_tl + { node [ #2 ] { #1 } #3 } + \exp_last_unbraced:Nf \draw \l_tzarcfrom_cmd_tl ; +} + +%%% --- end of \tzarcfrom + + +%%% \tzarcsfrom % (works like tikz original) + +\tl_new:N \l_tzarcsfrom_code_at_end_tl + +\NewDocumentCommand\tzarcsfrom { s t' O{} d<> D""{} r() } +{ + \IfBooleanTF { #1 } {}{} % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \tl_clear:N \l_tzarcsfrom_cmd_tl + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { [ name~path = #5 , #3 ] } + + \IfValueTF { #4 } + {% if shift + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { ([shift={(#4)}]#6) } + } + {% no shift + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { (#6) } % ++ (\tzarcsfromAngleA \c_colon_str \tzarcsfromRadius) + } + + \tzarcsfrom_check_token:n +} + +\cs_new:Npn \tzarcsfrom_check_token:n #1 +{ + \str_case:nnF { #1 } + { + { ( } { \tzarcsfrom_sub_fn #1 } + { ; } { \tzarcsfrom_late_opt_fn } + } + { + \tzarcsfrom_stop_action + } +} + + +\use:x{ + \NewDocumentCommand \exp_not:N \tzarcsfrom_sub_fn + { >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() +G{} O{} + } +} +{ + \tzarcsfrom_args_process #1 + \fp_set:Nn \l_tmpa_fp { \tzarcsfromAngleA } + \fp_set:Nn \l_tmpb_fp { \tzarcsfromAngleB } + + \tl_put_right:Nx \l_tzarcsfrom_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzarcsfromAngleA + \c_colon_str + \bool_if:NTF \l_tmpb_bool + {\tzarcsfromAngleB - 360} + {\tzarcsfromAngleB} + \c_colon_str + \tzarcsfromRadius ) + } + { + arc ( \bool_if:NTF \l_tmpb_bool + {\tzarcsfromAngleA - 360} + {\tzarcsfromAngleA} + \c_colon_str + \tzarcsfromAngleB + \c_colon_str + \tzarcsfromRadius ) + } + } + \tl_put_right:Nn \l_tzarcsfrom_cmd_tl + { node [ #3 ] { #2 } } + + \tzarcsfrom_check_token:n +} + +\NewDocumentCommand\tzarcsfrom_late_opt_fn { D<>{} } +{ + \tl_set:Nn \l_tzarcsfrom_code_at_end_tl { #1 } + \tzarcsfrom_stop_action +} + +\NewDocumentCommand\tzarcsfrom_stop_action {} +{ + \tl_put_right:No \l_tzarcsfrom_cmd_tl + { \l_tzarcsfrom_code_at_end_tl } + \exp_last_unbraced:Nf \draw \l_tzarcsfrom_cmd_tl ; +} + +\NewDocumentCommand\tzarcsfrom_args_process{ m m m } +{ + \def\tzarcsfromAngleA{#1} + \def\tzarcsfromAngleB{#2} + \def\tzarcsfromRadius{#3} +} + +%%% --- end of \tzarcsfrom + + + +%%% \tzwedge + +\use:x{ + \NewDocumentCommand \exp_not:N \tzwedge + { s t' O{} d<> D""{} r() + >{ \SplitArgument {2} { \tl_to_str:n {:} } } r() + } +} +{ + \tl_clear:N \l_tzwedge_cmd_tl + + \tzwedge_args_process #7 + \fp_set:Nn \l_tmpa_fp { \tzwedgeAngleA } + \fp_set:Nn \l_tmpb_fp { \tzwedgeAngleB } + + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { + [ fill=\tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + name~path = #5 , #3 ] + } + } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { [ name~path = #5 , #3 ] } + } + + \IfValueTF { #4 } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { ([shift={(#4)}]#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } + } + { + \tl_put_right:Nn \l_tzwedge_cmd_tl + { (#6) -- ++ (\tzwedgeAngleA \c_colon_str \tzwedgeRadius) } + } + + \tl_put_right:No \l_tzwedge_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzwedgeAngleA + \c_colon_str + \IfBooleanTF {#2} + {\tzwedgeAngleB - 360} + {\tzwedgeAngleB} + \c_colon_str + \tzwedgeRadius ) + } + { + arc ( \IfBooleanTF {#2} + {\tzwedgeAngleA - 360} + {\tzwedgeAngleA} + \c_colon_str + \tzwedgeAngleB + \c_colon_str + \tzwedgeRadius ) + } + } + + \tzwedge_sub_fn:n +} + +\cs_new:Npn \tzwedge_sub_fn:n +{ + \tzwedge_final_actions +} + +\NewDocumentCommand\tzwedge_final_actions{ +G{} O{} G{.3} } +{ + \tl_if_empty:nTF { #3 } + { \renewcommand\tzfillopacity{\tz@initial@fill@opacity} } + { \renewcommand\tzfillopacity{#3} } + + \tl_put_right:Nn \l_tzwedge_cmd_tl + { + node [ midway , #2 ] { #1 } + } + + \exp_last_unbraced:Nf \draw \l_tzwedge_cmd_tl -- cycle ; +} + +\NewDocumentCommand\tzwedge_args_process{ m m m } +{ + \def\tzwedgeAngleA{#1} + \def\tzwedgeAngleB{#2} + \def\tzwedgeRadius{#3} +} + +%%% --- end of \tzwedge + + +%%%%% plot of Tikz + +%%% \tzplot + +\bool_new:N \l_tzplot_shift_coor_bool + +\NewDocumentCommand\tzplot{ s O{} G{0} O{} d<> D""{} } +{ + \tl_clear:N \l_tzplot_opt_cmd_tl + \tl_clear:N \l_tzplot_cmd_tl + \tl_clear:N \l_tzplot_nodes_cmd_tl + \tl_clear:N \l_tzplot_coors_cmd_tl + \tl_clear:N \l_tzplot_code_at_end_tl + + \renewcommand\tzmarksize{\tz@initial@mark@size} + + \tl_put_right:Nn \l_tzplot_opt_cmd_tl + { + [ + name~path = #6 , + tension = #3 , + smooth , + tzmark = \tzmarksize , + } + + \IfBooleanT { #1 } + { + \tl_put_right:Nn \l_tzplot_opt_cmd_tl + { mark = * , draw = none , } + } + + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzplot_shift_coor_tl { #5 } + \bool_set_true:N \l_tzplot_shift_coor_bool + } + { + \tl_clear:N \l_tzplot_shift_coor_tl + \bool_set_false:N \l_tzplot_shift_coor_bool + } + + \tl_put_right:Nn \l_tzplot_opt_cmd_tl + { + #2 + ] + plot [ #4 ] coordinates + } + \tzplot_check_token:n +} + +\cs_new:Npn \tzplot_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzplot_sub_fn #1 } +% { \tzplot_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzplot_sub_fn #1 } + { ; } { \tzplot_late_opt_fn } + } + { + \tzplot_stop_action + } +} + +\NewDocumentCommand\tzplot_sub_fn{ r() +G{} O{} } +{ + % collect coordinates only + \bool_if:NTF \l_tzplot_shift_coor_bool + { + \tl_put_right:Nx \l_tzplot_coors_cmd_tl + { ([shift = { (\l_tzplot_shift_coor_tl) } ]#1) } + } + { + \tl_put_right:Nn \l_tzplot_coors_cmd_tl { (#1) } + } + % collect nodes information + \bool_if:NTF \l_tzplot_shift_coor_bool + { + \tl_put_right:Nx \l_tzplot_nodes_cmd_tl + { ([shift = { (\l_tzplot_shift_coor_tl) } ]#1) } + } + { + \tl_put_right:Nn \l_tzplot_nodes_cmd_tl { (#1) } + } + \tl_put_right:Nx \l_tzplot_nodes_cmd_tl + { + node + [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + ] {} + } + \tzplot_check_token:n +} + +\NewDocumentCommand\tzplot_late_opt_fn { d() D<>{} } +{ + \IfValueTF { #1 } + { \edef\tztmpMarkSize { #1 } } + { \edef\tztmpMarkSize { \tz@initial@mark@size } } + \tl_put_right:Nn \l_tzplot_code_at_end_tl { #2 } + \tzplot_stop_action +} + +\NewDocumentCommand\tzplot_stop_action {} +{ + \renewcommand\tzmarksize{ \tztmpMarkSize } + % final action + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_cmd_tl % [opt] plot coordinates + { \l_tzplot_coors_cmd_tl } % { (coor-1)(coor-2)...(coor-n) } + \l_tzplot_code_at_end_tl % should precede _nodes_cmd_tl + \l_tzplot_nodes_cmd_tl % (coor-i) node [opt] {text}, for all i + ; +} + +%%% --- end of \tzplot + + +%%% \tzplotcurve + +\bool_new:N \l_tzplotcurve_shift_coor_bool + +\NewDocumentCommand\tzplotcurve{ s O{} G{1} O{} d<> D""{} } +{ + \IfBooleanT { #1 } {}{} % NOT USED! + + \tl_clear:N \l_tzplotcurve_opt_cmd_tl + \tl_clear:N \l_tzplotcurve_cmd_tl + \tl_clear:N \l_tzplotcurve_nodes_cmd_tl + \tl_clear:N \l_tzplotcurve_coors_cmd_tl + \tl_clear:N \l_tzplotcurve_code_at_end_tl + + \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl + { + [ name~path = #6 , + tension = #3 , + smooth , + tzmark = \tzmarksize , + } + + \IfBooleanT { #1 } + { + \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl + { mark = * , } + } + + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzplotcurve_shift_coor_tl { #5 } + \bool_set_true:N \l_tzplotcurve_shift_coor_bool + } + { + \tl_clear:N \l_tzplotcurve_shift_coor_tl + \bool_set_false:N \l_tzplotcurve_shift_coor_bool + } + + \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl + { + #2 + ] + plot [ #4 ] coordinates + } + \tzplotcurve_check_token:n +} + +\cs_new:Npn \tzplotcurve_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzplotcurve_sub_fn #1 } +% { \tzplotcurve_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzplotcurve_sub_fn #1 } + { ; } { \tzplotcurve_late_opt_fn } + } + { + \tzplotcurve_stop_action + } +} + +\NewDocumentCommand\tzplotcurve_sub_fn{ r() +G{} O{} } +{ + % collect coordinates only + \bool_if:NTF \l_tzplotcurve_shift_coor_bool + { + \tl_put_right:Nx \l_tzplotcurve_coors_cmd_tl + { ([shift = { (\l_tzplotcurve_shift_coor_tl) } ]#1) } + } + { + \tl_put_right:Nn \l_tzplotcurve_coors_cmd_tl { (#1) } + } + % collect nodes information + \bool_if:NTF \l_tzplotcurve_shift_coor_bool + { + \tl_put_right:Nx \l_tzplotcurve_nodes_cmd_tl + { ([shift = { (\l_tzplotcurve_shift_coor_tl) } ]#1) } + } + { + \tl_put_right:Nn \l_tzplotcurve_nodes_cmd_tl { (#1) } + } + \tl_put_right:Nx \l_tzplotcurve_nodes_cmd_tl + { node + [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + ] {} + } + \tzplotcurve_check_token:n +} + +\NewDocumentCommand\tzplotcurve_late_opt_fn { d() D<>{} } +{ + \IfValueTF { #1 } + { \edef\tztmpMarkSize { #1 } } + { \edef\tztmpMarkSize { \tz@initial@mark@size } } + \tl_put_right:Nn \l_tzplotcurve_code_at_end_tl { #2 } + \tzplotcurve_stop_action +} + +\NewDocumentCommand\tzplotcurve_stop_action {} +{ + \renewcommand\tzmarksize{ \tztmpMarkSize } + % final action + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_cmd_tl % [opt] plot [ smooth ] coordinates + { \l_tzplotcurve_coors_cmd_tl } % { (coor-1)(coor-2)...(coor-n) } + \l_tzplotcurve_code_at_end_tl % should precede _nodes_cmd_tl + \l_tzplotcurve_nodes_cmd_tl % (coor-i) node [opt] {text}, for all i + ; +} + +%%% --- end of \tzplotcurve + + +%%% \tzLFn -- plot Linear Function (LF) + +\bool_new:N \g_tzLFn_BEGIN_cmd_bool +\bool_new:N \g_tzLFn_END_cmd_bool + +%% \tzLFnAtBegin +\NewDocumentCommand\tzLFnAtBegin{ m } +{ + \bool_gset_true:N \g_tzLFn_BEGIN_cmd_bool + \tl_gset:No \g_tzLFn_BEGIN_cmd_tl { #1 } +} + +%% \tzLFnAtEnd +\NewDocumentCommand\tzLFnAtEnd{ m } +{ + \bool_gset_true:N \g_tzLFn_END_cmd_bool + \tl_gset:No \g_tzLFn_END_cmd_tl { #1 } +} + +%%% \tzLFn +%% \tzLFn : variable = \x (default) +%% \tzLFn': variable = \y + +\NewDocumentCommand \tzLFn { t' o D<>{0,0} d"" } +{ + \tl_clear:N \l_tzLFn_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzLFn_shift_tl + { shift = { (#3) } } + } + { \tl_clear:N \l_tzLFn_shift_tl } + + \IfValueTF { #2 } + { \tl_set:Nn \l_tzLFn_opt_tl { #2 } } + { \tl_clear:N \l_tzLFn_opt_tl } + + \IfValueTF { #4 } + { \tl_set:Nn \l_tzLFn_namepath_tl { name~path = #4 } } + { \tl_clear:N \l_tzLFn_namepath_tl } + + \tzLFn_check_token:n +} + +\cs_new:Npn \tzLFn_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzLFn_sub_fn ( } +} + +\use:x{ + \NewDocumentCommand \exp_not:N \tzLFn_sub_fn + { r() d() G{1} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] + G{} O{} D<>{} + } +} +{ + \tzLFn_domain_process #4 + + \tl_put_right:Nx \l_tzLFn_cmd_tl + { + [ + \l_tzLFn_namepath_tl , + domain = \tzLFnFromVal \c_colon_str \tzLFnToVal , %%% [here?] +% samples = 200 , + \bool_if:NTF \l_tmpa_bool + { variable = \exp_not:n { \y } } + { variable = \exp_not:n { \x } } , + \l_tzLFn_shift_tl , + } + \tl_put_right:No \l_tzLFn_cmd_tl + { + \l_tzLFn_opt_tl + ] + } + \bool_if:NT \g_tzLFn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_BEGIN_cmd_tl } } + + % define LF + \tzgetxyval(#1){\tzLFAval}{\tzLFBval} + \IfNoValueTF { #2 } + { + \bool_if:NTF \l_tmpa_bool + { \def\tzLFnDEF{#3*(\y-\tzLFBval)+\tzLFAval} } + { \def\tzLFnDEF{#3*(\x-\tzLFAval)+\tzLFBval} } + } + { + \tzgetxyval(#2){\tzLFAAval}{\tzLFBBval} + \bool_if:NTF \l_tmpa_bool + { + \edef\tzLFSlope{(\tzLFAAval-\tzLFAval)/(\tzLFBBval-\tzLFBval)} + \def\tzLFnDEF{\tzLFSlope*(\y-\tzLFBval)+\tzLFAval} + } + { + \edef\tzLFSlope{(\tzLFBBval-\tzLFBval)/(\tzLFAAval-\tzLFAval)} + \def\tzLFnDEF{\tzLFSlope*(\x-\tzLFAval)+\tzLFBval} + } + } + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:Nn \l_tzLFn_cmd_tl + { plot ( { \tzLFnDEF } , \y ) } % \y should not be expanded + } + { + \tl_put_right:Nn \l_tzLFn_cmd_tl + { plot ( \x , { \tzLFnDEF } ) } % \x should not be expanded + } + \bool_if:NT \g_tzLFn_END_cmd_bool + { \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_END_cmd_tl } } + \tl_put_right:Nn \l_tzLFn_cmd_tl + { node [ #6 ] { #5 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzLFn_cmd_tl #7 ; + + \bool_gset_false:N \g_tzLFn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzLFn_END_cmd_bool +} + +\NewDocumentCommand\tzLFn_domain_process{ m m } +{ + \def\tzLFnFromVal{#1} + \def\tzLFnToVal{#2} +} + +%%% --- end of \tzLFn + + +%% \tzfn (variable=\x -- default) + +\bool_new:N \g_tzfn_BEGIN_cmd_bool +\bool_new:N \g_tzfn_END_cmd_bool + +%% \tzfnAtBegin +\NewDocumentCommand\tzfnAtBegin{ m } +{ + \bool_gset_true:N \g_tzfn_BEGIN_cmd_bool + \tl_gset:No \g_tzfn_BEGIN_cmd_tl { #1 } +} + +%% \tzfnAtEnd +\NewDocumentCommand\tzfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzfn_END_cmd_bool + \tl_gset:No \g_tzfn_END_cmd_tl { #1 } +} + +%% \tzfn (variable=\x) +%% \tzfn' (variable=\y) -- equivalent to \tzfnofy +\use:x{ + \NewDocumentCommand \exp_not:N \tzfn + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzfn_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzfn_domain_process #6 + + \tl_set:No \l_tmpa_tl { \tl_to_str:n { #5 } } + \tl_set:No \l_tzfn_pathname_tl { \tl_tail:N \l_tmpa_tl } + \tl_put_right:Nx \l_tzfn_cmd_tl + { + [ + name~path = + \tl_if_empty:nTF { #4 } { \l_tzfn_pathname_tl } { #4 } , + domain = \tzfnFromVal \c_colon_str \tzfnToVal , + samples = 200 , + shift = { (#3) } , + \bool_if:NTF \l_tmpa_bool + { variable = \exp_not:n { \y } } + { variable = \exp_not:n { \x } } , + \exp_not:n { #2 } + ] + } + \bool_if:NT \g_tzfn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_BEGIN_cmd_tl } } + \bool_if:NTF { \l_tmpa_bool } + { + \tl_put_right:Nn \l_tzfn_cmd_tl + { plot ( { #5 } , \y ) } % \y should not be expanded + } + { + \tl_put_right:Nn \l_tzfn_cmd_tl + { plot ( \x , { #5 } ) } % \x should not be expanded + } + \bool_if:NT \g_tzfn_END_cmd_bool + { \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_END_cmd_tl } } + \tl_put_right:Nn \l_tzfn_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfn_cmd_tl #9 ; + + \bool_gset_false:N \g_tzfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfn_END_cmd_bool +} + +\NewDocumentCommand\tzfn_domain_process{ m m } +{ + \def\tzfnFromVal{#1} + \def\tzfnToVal{#2} +} + +%%% --- end of \tzfn + + +%% \tzvfnat +\use:x{ + \NewDocumentCommand \exp_not:N \tzvfnat + { O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzvfnat_cmd_tl + + \IfValueT { #5 } { \tzvfnat_domain_process #5 } + + \tl_put_right:Nx \l_tzvfnat_cmd_tl + { + [ + name~path = #3 , + shift = { (#2) } , +% samples = 200 , + \exp_not:n { #1 } + ] + } + \IfValueTF { #5 } + { + \tl_put_right:Nn \l_tzvfnat_cmd_tl + { (#4,\tzvfnatFromVal) -- (#4,\tzvfnatToVal) } + } + { + \tl_put_right:Nn \l_tzvfnat_cmd_tl + { + (#4,0 |- current~bounding~box.south) + -- (#4,0 |- current~bounding~box.north) + } + } + \tl_put_right:Nn \l_tzvfnat_cmd_tl + { node [ #7 ] { #6 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzvfnat_cmd_tl #8 ; +} + +\NewDocumentCommand\tzvfnat_domain_process{ m m } +{ + \def\tzvfnatFromVal{#1} + \def\tzvfnatToVal{#2} +} + +%%% --- end of \tzvfnat + + +%%% \tzvfn (On) -- vertical line through (x,y) + + +%%% \tzvfn +\use:x{ + \NewDocumentCommand \exp_not:N \tzvfn + { O{} d<> D""{} r() + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzvfn_cmd_tl + + \IfValueT { #5 } { \tzvfn_domain_process #5 } + + \tl_put_right:Nx \l_tzvfn_cmd_tl + { + [ + name~path = #3 , + \exp_not:n { #1 } + ] + } + \IfValueTF { #5 } + { + \IfValueTF { #2 } + { + \tl_put_right:Nn \l_tzvfn_cmd_tl + { + ([shift = { (#2) }]#4 |- 0,\tzvfnFromVal) -- + ([shift = { (#2) }]#4 |- 0,\tzvfnToVal) } + } + { + \tl_put_right:Nn \l_tzvfn_cmd_tl + { (#4 |- 0,\tzvfnFromVal) -- (#4 |- 0,\tzvfnToVal) } + } + } + { + \IfValueTF { #2 } + { + \tl_put_right:Nn \l_tzvfn_cmd_tl + { + ([shift = { (#2) }]#4 |- current~bounding~box.south) -- + ([shift = { (#2) }]#4 |- current~bounding~box.north) + } + } + { + \tl_put_right:Nn \l_tzvfn_cmd_tl + { + (#4 |- current~bounding~box.south) -- + (#4 |- current~bounding~box.north) + } + } + } + \tl_put_right:Nn \l_tzvfn_cmd_tl + { node [ #7 ] { #6 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzvfn_cmd_tl #8 ; +} + +\NewDocumentCommand\tzvfn_domain_process{ m m } +{ + \def\tzvfnFromVal{#1} + \def\tzvfnToVal{#2} +} + +%%% --- end of \tzvfn + + +%% \tzhfnat +\use:x{ + \NewDocumentCommand \exp_not:N \tzhfnat + { O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzhfnat_cmd_tl + + \IfValueT { #5 } { \tzhfnat_domain_process #5 } + + \tl_put_right:Nx \l_tzhfnat_cmd_tl + { + [ + name~path = #3 , + shift = { (#2) } , + variable = \exp_not:n { \x } , + \exp_not:n { #1 } + ] + } + \IfValueTF { #5 } + { + \tl_put_right:Nn \l_tzhfnat_cmd_tl + { (\tzhfnatFromVal,#4) -- (\tzhfnatToVal,#4) } + } + { + \tl_put_right:Nn \l_tzhfnat_cmd_tl + { + (0,#4 -| current~bounding~box.west) + -- (0,#4 -| current~bounding~box.east) + } + } + \tl_put_right:Nn \l_tzhfnat_cmd_tl + { node [ #7 ] { #6 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzhfnat_cmd_tl #8 ; +} + +\NewDocumentCommand\tzhfnat_domain_process{ m m } +{ + \def\tzhfnatFromVal{#1} + \def\tzhfnatToVal{#2} +} + +%%% --- end of \tzhfnat + + +%%% \tzhfn (On) -- horizontal line through (x,y) + +%% \tzhfn +\use:x{ + \NewDocumentCommand \exp_not:N \tzhfn + { O{} d<> D""{} r() + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzhfn_cmd_tl + + \IfValueT { #5 } { \tzhfn_domain_process #5 } + + \tl_put_right:Nx \l_tzhfn_cmd_tl + { + [ + name~path = #3 , + variable = \exp_not:n { \x } , + \exp_not:n { #1 } + ] + } + \IfValueTF { #5 } + { + \IfValueTF { #2 } + { + \tl_put_right:Nn \l_tzhfn_cmd_tl + { + ([shift = { (#2) }]\tzhfnFromVal,0 |- #4) -- + ([shift = { (#2) }]\tzhfnToVal,0 |- #4) + } + } + { + \tl_put_right:Nn \l_tzhfn_cmd_tl + { + (\tzhfnFromVal,0 |- #4) -- + (\tzhfnToVal,0 |- #4) + } + } + } + { + \IfValueTF { #2 } + { + \tl_put_right:Nn \l_tzhfn_cmd_tl + { + ([shift = { (#2) }]#4 -| current~bounding~box.west) + -- ([shift = { (#2) }]#4 -| current~bounding~box.east) + } + } + { + \tl_put_right:Nn \l_tzhfn_cmd_tl + { + (#4 -| current~bounding~box.west) + -- (#4 -| current~bounding~box.east) + } + } + } + \tl_put_right:Nn \l_tzhfn_cmd_tl + { node [ #7 ] { #6 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzhfn_cmd_tl #8 ; +} + +\NewDocumentCommand\tzhfn_domain_process{ m m } +{ + \def\tzhfnFromVal{#1} + \def\tzhfnToVal{#2} +} + +%%% --- end of \tzhfn + + +%%%%% Intersections + +%%% \tzXpoint -- intersection point of two paths +\NewDocumentCommand\tzXpoint + { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzXpoint_cmd_tl + \path [ name~intersections = { of = #3 ~ and ~ #4 , name = #5 } ] ; + \tl_put_right:Nn \l_tzXpoint_cmd_tl + { + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzXpoint_cmd_tl + { + label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + } + + \tl_put_right:Nn \l_tzXpoint_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzXpoint_cmd_tl ; +} + +%%% --- end of \tzXpoint + + +%%% \tzvXpointat -- vertical intersection point at x +%%% *[<opt>]{<path>}(<coor>)(<coor name>)[<nth>]{<label>}[<[<opt>]angle>](<dotsize>) +\NewDocumentCommand\tzvXpointat + { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzvXpointat_cmd_tl + + \tzvfnat[draw=none]"tzvXpoint-At" {#4} % depends on (current bounding box) + + \path [ name~intersections = { of = tzvXpoint-At ~and~ #3 , name = #5 } ] ; + + \tl_put_right:Nn \l_tzvXpointat_cmd_tl + { + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzvXpointat_cmd_tl + { + label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + } + + \tl_put_right:Nn \l_tzvXpointat_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzvXpointat_cmd_tl ; + \tl_clear:N \tzvXpointat_cmd_tl +} + +%%% --- end of \tzvXpointat + + +%%% \tzvXpoint (On) +%%% -- vertical intersection point at (x,y) of a path +%%% *[<opt>]{<path>}(<coor>)(<coor name>)[<nth>]{<label>}[<[<opt>]angle>](<dotsize>) +\NewDocumentCommand\tzvXpoint + { s O{} m r() D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzvXpoint_cmd_tl + + \tzvfn[draw=none]"tzvXpoint-On"(#4) % depends on (current bounding box) + + \path [ name~intersections = { of = tzvXpoint-On ~and~ #3 , name = #5 } ] ; + \tl_put_right:Nn \l_tzvXpoint_cmd_tl + { + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzvXpoint_cmd_tl + { + label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + } + + \tl_put_right:Nn \l_tzvXpoint_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzvXpoint_cmd_tl ; + \tl_clear:N \l_tzvXpoint_cmd_tl +} + +%%% --- end of \tzvXpoint + + + +%%% \tzhXpointat -- horizontal intersection point at y +\NewDocumentCommand\tzhXpointat + { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzhXpointat_cmd_tl + + \tzhfnat[draw=none]"tzhXpoint-At"{#4} % depends on (current bounding box) + + \path [ name~intersections = { of = tzhXpoint-At ~and~ #3 , name = #5 } ] ; + \tl_put_right:Nn \l_tzhXpointat_cmd_tl + { + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzhXpointat_cmd_tl + { + label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + } + + \tl_put_right:Nn \l_tzhXpointat_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzhXpointat_cmd_tl ; + \tl_clear:N \l_tzhXpointat_cmd_tl +} + +%%% --- end of \tzhXpointat + + +%%% \tzhXpoint (On) -- horizontal intersection point at (x,y) +\NewDocumentCommand\tzhXpoint + { s O{} m r() D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzhXpoint_cmd_tl + + \tzhfn[draw=none]"tzhXpoint-On"(#4) % depends on (current bounding box) + + \path [ name~intersections = { of = tzhXpoint-On ~and~ #3 , name = #5 } ] ; + + \tl_put_right:Nn \l_tzhXpoint_cmd_tl + { + (#5-#6) coordinate (#5) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzhXpoint_cmd_tl + { + label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + } + + \tl_put_right:Nn \l_tzhXpoint_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \path \l_tzhXpoint_cmd_tl ; + \tl_clear:N \l_tzhXpoint_cmd_tl +} + +%%% --- end of \tzhXpoint + + + +%%%%% Axes + +%%% \tzaxes + +\NewDocumentCommand\tzaxes{ s O{} D<>{0,0} r() d() +G{} O{} +G{} O{} } +{ + \IfNoValueTF { #5 } + { + \draw [ -> , #2 ] + ( 0,0 |- #3 ) -- ( #4 |- #3 ) node [ right , #7 ] { #6 } ; + \draw [ -> , #2 ] + ( #3 |- 0,0 ) -- ( #3 |- #4 ) node [ above , #9 ] { #8 } ; + } + { + \draw [ -> , #2 ] + ( #4 |- #3 ) -- ( #5 |- #3 ) node [ right , #7 ] { #6 } ; + \draw [ -> , #2 ] + ( #3 |- #4 ) -- ( #3 |- #5 ) node [ above , #9 ] { #8 } ; + } + \IfBooleanT { #1 } + { + \coordinate (bbxOpposite) at (current~bounding~box.north~east) ; + \coordinate (bbxOrigin) at (current~bounding~box.south~west) ; + \useasboundingbox (bbxOrigin) rectangle (bbxOpposite) ; + } +} + +%%% \tzaxesL -- simpler version of \tzaxes + +\NewDocumentCommand\tzaxesL{ t' O{} d<> r() r() +G{} O{} +G{} O{} } +{ + \IfBooleanTF { #1 } + { + \draw [ #2 ] + \IfValueTF { #3 } + { + ( [shift={(#3)}]#5 ) -- ( [shift={(#3)}]#4 |- #5 ) + } + { + ( #5 ) -- ( #4 |- #5 ) + } + node [ left , #7 ] { #6 } ; + \draw [ #2 ] + \IfValueTF { #3 } + { + ( [shift={(#3)}]#5 ) -- ( [shift={(#3)}]#5 |- #4 ) + } + { + ( #5 ) -- ( #5 |- #4 ) + } + node [ below , #9 ] { #8 } ; + } + { + \draw [ #2 ] + \IfValueTF { #3 } + { + ( [shift={(#3)}]#4 ) -- ( [shift={(#3)}]#5 |- #4 ) + } + { + ( #4 ) -- ( #5 |- #4 ) + } + node [ right , #7 ] { #6 } ; + \draw [ #2 ] + \IfValueTF { #3 } + { + ( [shift={(#3)}]#4 ) -- ( [shift={(#3)}]#4 |- #5 ) + } + { + ( #4 ) -- ( #4 |- #5 ) + } + node [ above , #9 ] { #8 } ; + } +} + +%%% -- end of \tzaxesL + +%%% \tzaxisx + +\NewDocumentCommand\tzaxisx{ s O{} D<>{0} m m G{} O{} } +{ + \draw [ -> , #2 ] + ( #4 , #3 ) -- ( #5 , #3 ) node [ right , #7 ] { #6 } ; +} + +%%% \tzaxisy + +\NewDocumentCommand\tzaxisy{ s O{} D<>{0} m m G{} O{} } +{ + \draw [ -> , #2 ] + ( #3 , #4 ) -- ( #3 , #5 ) node [ above , #7 ] { #6 } ; +} + + +%%%%% Ticks + +%%% \tztikcs : (combine \tzticksx and \tzticksy) + +\use:x{ + \NewDocumentCommand \exp_not:N \tzticks + { s O{} D<>{0,0} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d() m O{} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d() G{} O{} + } +} +{ + \tzgetxyval(#3){\tzticksXshift}{\tzticksYshift} + \IfValueT { #4 } { \tzticks_Xlength_process #4 } + %% ------ + \IfValueT { #7 } { \tzticks_Ylength_process #7 } + + \IfBooleanTF { #1 } + { + \IfNoValueT { #4 } + { + \def\tzticksXFromVal{0pt} + \def\tzticksXToVal{3pt} + } + \foreach \xx / \tzXtext in { #5 } + \draw [ shift = {(0,\tzticksYshift)} , #2 ] + (\xx , \tzticksXFromVal) + -- (\xx , \tzticksXToVal) ; % ignores \txXtext + %% -------- + \IfNoValueT { #7 } + { + \def\tzticksYFromVal{0pt} + \def\tzticksYToVal{3pt} + } + \foreach \yy/\tzYtext in { #8 } + \draw [ shift = {(\tzticksXshift,0)} , #2 ] + (\tzticksYFromVal , \yy) + -- (\tzticksYToVal , \yy) ; % ignores \txXtext + } + { + \IfNoValueT { #4 } + { + \def\tzticksXFromVal{0pt} + \def\tzticksXToVal{0pt} + } + \foreach \xx / \tzXtext in { #5 } + \draw [ shift = {(0,\tzticksYshift)} , #2 ] + (\xx ,\tzticksXFromVal) + -- (\xx , \tzticksXToVal) + (\xx , 0 ) node + [ text~height = 1.25ex , + text~depth = .25ex , + below , #6 ] {\tzXtext} ; + %% -------- + \IfNoValueT { #7 } + { + \def\tzticksYFromVal{0pt} + \def\tzticksYToVal{0pt} + } + \foreach \yy / \tzYtext in { #8 } + \draw [ shift = {(\tzticksXshift,0)} , #2 ] + (\tzticksYFromVal , \yy) + -- (\tzticksYToVal , \yy) + (0 , \yy) + node [ left , #9 ] { \tzYtext } ; + } +} + +\NewDocumentCommand\tzticks_Xlength_process { m m } +{ + \def\tzticksXFromVal{#1} + \def\tzticksXToVal{#2} +} +%% -------- +\NewDocumentCommand\tzticks_Ylength_process { m m } +{ + \def\tzticksYFromVal{#1} + \def\tzticksYToVal{#2} +} + +%%% --- end of \tzticks + + +%%% \tztikcsx -- ticks and labels along the x axis + +\use:x{ + \NewDocumentCommand \exp_not:N \tzticksx + { s O{} D<>{0} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d() m O{} + } +} +{ + \IfValueT { #4 } { \tzticksx_length_process #4 } + + \IfBooleanTF { #1 } + { + \IfNoValueT { #4 } + { + \def\tzticksxFromVal{0pt} + \def\tzticksxToVal{3pt} + } + \foreach \xx / \tzxtext in { #5 } + \draw [ shift = {(0,#3)} , #2 ] + (\xx , \tzticksxFromVal) + -- (\xx , \tzticksxToVal) ; + } + { + \IfNoValueT { #4 } + { + \def\tzticksxFromVal{0pt} + \def\tzticksxToVal{0pt} + } + \foreach \xx / \tzxtext in { #5 } + \draw [ shift = {(0,#3)} , #2 ] + (\xx ,\tzticksxFromVal) + -- (\xx , \tzticksxToVal) + (\xx , 0 ) node + [ text~height = 1.25ex , + text~depth = .25ex , + below , #6 ] {\tzxtext} ; + + } +} + +\NewDocumentCommand\tzticksx_length_process { m m } +{ + \def\tzticksxFromVal{#1} + \def\tzticksxToVal{#2} +} + +%%% --- end of \tzticksx + + +%%% \tztikcsy -- ticks and labels along with the y axis + +\use:x{ + \NewDocumentCommand \exp_not:N \tzticksy + { s O{} D<>{0} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } d() m O{} + } +} +{ + + \IfValueT { #4 } { \tzticksy_length_process #4 } + + \IfBooleanTF { #1 } + { + \IfNoValueT { #4 } + { + \def\tzticksyFromVal{0pt} + \def\tzticksyToVal{3pt} + } + \foreach \yy/\tzytext in { #5 } + \draw [ shift = {(#3,0)} , #2 ] + (\tzticksyFromVal , \yy) + -- (\tzticksyToVal , \yy) ; + } + { + \IfNoValueT { #4 } + { + \def\tzticksyFromVal{0pt} + \def\tzticksyToVal{0pt} + } + \foreach \yy / \tzytext in { #5 } + \draw [ shift = {(#3,0)} , #2 ] + (\tzticksyFromVal , \yy) + -- (\tzticksyToVal , \yy) + (0 , \yy) + node [ left , #6 ] { \tzytext } ; + } +} + +\NewDocumentCommand\tzticksy_length_process { m m } +{ + \def\tzticksyFromVal{#1} + \def\tzticksyToVal{#2} +} + +%%% --- end of \tzticksy + + +%%%%% Projections +%% lines and tick labels of projection onto x/y axis + +%%% \tzproj + +\NewDocumentCommand\tzproj + { s O{} d<> r() G{} O{} G{} O{} D(){\tz@initial@dot@size} } +{ + \IfValueTF { #3 } + { \coordinate (tzProj) at (#3) ; } + { \coordinate (tzProj) at (0,0) ; } + \draw [ dotted , #2 ] + (#4 |- tzProj) + node [ text~height = 1.25ex , + text~depth = .25ex , + below , #6 ] { #5 } + -- (#4) -- (tzProj |- #4) + node [ left , #8 ] {#7} ; + \IfBooleanT {#1} { \tzdot*(#4)(#9) } +} + +%%% \tzprojx + +\NewDocumentCommand\tzprojx + { s O{} d<> r() G{} O{} D(){\tz@initial@dot@size} } +{ + \IfValueTF { #3 } + { \coordinate (tzProjx) at (#3) ; } + { \coordinate (tzProjx) at (0,0) ; } + \draw [ dotted , #2 ] (#4) + -- (#4 |- tzProjx) + node [ text~height = 1.25ex , + text~depth = .25ex , + below , #6 ] { #5 } ; + \IfBooleanT { #1 } { \tzdot*(#4)(#7) } +} + +%%% \tzprojy + +\NewDocumentCommand\tzprojy + { s O{} d<> r() G{} O{} D(){\tz@initial@dot@size} } +{ + \IfValueTF { #3 } + { \coordinate (tzProjy) at (#3) ; } + { \coordinate (tzProjy) at (0,0) ; } + \draw [ dotted , #2 ] (#4) + -- (#4 -| tzProjy) + node [ left , #6 ] { #5 } ; + \IfBooleanT { #1 } { \tzdot*(#4)(#7) } +} + + +%%%%% Nodes + +%%% \tznode -- putting texts (and labels as option) + +\NewDocumentCommand\tznode{ s O{} d<> r() D(){tzNodeName} +G{} O{} } +{ + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + { \node [ draw , #2 ] (#5) at ([shift={(#3)}]#4) [ #7 ] { #6 } ; } + { \node [ draw , #2 ] (#5) at (#4) [ #7 ] { #6 } ; } + } + { + \IfValueTF { #3 } + { \node [ #2 ] (#5) at ([shift={(#3)}]#4) [ #7 ] { #6 } ; } + { \node [ #2 ] (#5) at (#4) [ #7 ] { #6 } ; } + } +} + + +%%% \tznodedot +\NewDocumentCommand\tznodedot + { s O{} d<> r() D(){tzNodeName} +G{} O{} D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tznodedot_cmd_tl + + \renewcommand\tzdotsize{ #8 } + + \IfValueTF { #3 } + {% if shift + \tl_put_right:Nn \l_tznodedot_cmd_tl + { ([shift={(#3)}]#4) node (#5) } + } + {% no shift (normal) + \tl_put_right:Nn \l_tznodedot_cmd_tl + { (#4) node (#5) } + } + \IfBooleanTF { #1 } + { + \tl_put_right:Nn \l_tznodedot_cmd_tl { [ tzdot , fill , } + } + { + \tl_put_right:Nn \l_tznodedot_cmd_tl { [ tzdot , } + } + \tl_put_right:Nx \l_tznodedot_cmd_tl + { + label = { \exp_not:n { #7 } \c_colon_str \exp_not:n { #6 } } , + } + \tl_put_right:Nn \l_tznodedot_cmd_tl + { + minimum~size = \tzdotsize , #2 ] {} + } + \exp_last_unbraced:Nf \path \l_tznodedot_cmd_tl ; +} + +%%% --- end of \tznodedot + + + +%%% \tznodeframe + +\NewDocumentCommand\tznodeframe + { s O{} d<> r() D(){tzNodeName} +G{} O{} G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#8} + \IfBooleanTF { #1 } + { + \node [ + draw , rectangle , + fill , + fill~opacity = \tzfillopacity , text~opacity = 1 , + #2 + ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ draw = black , text = black , #7 ] { #6 } ; + } + { + \node [ draw , rectangle , #2 ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ text = black , #7 ] { #6 } ; + } +} + + +%%% \tznodebox \tznoderectangle +\let\tznodebox\tznodeframe +\let\tznoderectangle\tznodeframe + + +%%% \tznodecircle + +\NewDocumentCommand\tznodecircle + { s O{} d<> r() D(){tzNodeName} +G{} O{} G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#8} + \IfBooleanTF { #1 } + { + \node [ + draw , circle , + fill , + fill~opacity = \tzfillopacity , text~opacity = 1 , + #2 + ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ draw = black , text = black , #7 ] { #6 } ; + } + { + \node [ draw , circle , #2 ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ text = black , #7 ] { #6 } ; + } +} + +%%% \tznodeellipse + +\NewDocumentCommand\tznodeellipse + { s O{} d<> r() D(){tzNodeName} +G{} O{} G{\tz@initial@fill@opacity} } +{ + \renewcommand\tzfillopacity{#8} + \IfBooleanTF { #1 } + { + \node [ + draw , ellipse , + fill , + fill~opacity = \tzfillopacity , text~opacity = 1 , + #2 + ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ draw = black , text = black , #7 ] { #6 } ; + } + { + \node [ draw , ellipse , #2 ] + (#5) at \IfValueTF { #3 } { ([shift={(#3)}]#4) } { (#4) } + [ text = black , #7 ] { #6 } ; + } +} + +%%% \tznodeoval +\let\tznodeoval\tznodeellipse + + + +%%%%% Secant lines + +%% secant line + +%%% \tzsecantat + +\use:x{ + \NewDocumentCommand \exp_not:N \tzsecantat + { s O{} d<> D""{} m m m + >{ \SplitArgument { 1 } { \tl_to_str:n {:} } } o + } +} +{ + \tl_clear:N \l_tzsecantat_cmd_tl + + \IfBooleanTF { #1 } % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + % define two points + \tzvXpointat{#5}{#6}(LX-point) % vertical X point + \tzvXpointat{#5}{#7}(RX-point) % vertical X point + + % collect cmd_tl + + \IfNoValueTF { #8 } + { + \IfValueTF { #3 } + {% if shift + \tl_put_right:Nn \l_tzsecantat_cmd_tl + { + [ name~path = #4 , #2 ] + ([ shift = { (#3) } ]LX-point) -- ([ shift = { (#3) } ]RX-point) + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzsecantat_cmd_tl + { + [ name~path = #4 , #2 ] + (LX-point) -- (RX-point) + } + } + } + { + \tzsecantat_domain_process #8 + \tzgetxyval(LX-point){\tzTANLLX}{\tzTANLLY} + \tzgetxyval(RX-point){\tzTANRRX}{\tzTANRRY} + + \edef\tzTANSlope{(\tzTANRRY-\tzTANLLY)/(\tzTANRRX-\tzTANLLX)} + \def\tzsecantatLFn{\tzTANSlope*(\x-\tzTANLLX)+\tzTANLLY} + + \IfValueTF { #3 } + {% shift + \tl_put_right:Nn \l_tzsecantat_cmd_tl + { + [ name~path = #4 , + shift = { (#3) } , + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzsecantat_cmd_tl + { + [ name~path = #4 , + } + } + + \tl_put_right:Nx \l_tzsecantat_cmd_tl + { + domain = \tzsecantatFromVal \c_colon_str \tzsecantatToVal , + } + \tl_put_right:Nn \l_tzsecantat_cmd_tl + { + #2 ] + plot ( \x , { \tzsecantatLFn } ) % \x should not be expanded + } + } + + \tzsecantat_sub_fn:n +} + +\NewDocumentCommand\tzsecantat_domain_process{ m m } +{ + \def\tzsecantatFromVal{#1} + \def\tzsecantatToVal{#2} +} + +\cs_new:Npn \tzsecantat_sub_fn:n +{ + \tzsecantat_final_actions +} + +\NewDocumentCommand\tzsecantat_final_actions { +G{} O{} D<>{} } +{ + \begin{pgfonlayer}{\tzsecantlayer} + \exp_last_unbraced:Nf \draw \l_tzsecantat_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzsecantat_cmd_tl ; +} + +%%% --- end of \tzsecantat + + +%%% \tzsecant + +\use:x{ + \NewDocumentCommand \exp_not:N \tzsecant + { s O{} d<> d"" m r() r() + >{ \SplitArgument { 1 } { \tl_to_str:n {:} } } o + } +} +{ + \tl_clear:N \l_tzsecant_cmd_tl + + \IfBooleanTF { #1 } % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + % define two points + \tzvXpoint{#5}(#6)(LX-point) % vertical X point + \tzvXpoint{#5}(#7)(RX-point) % vertical X point + + % collect cmd_tl + \IfNoValueTF { #8 } + { + \IfValueTF { #3 } + {% if shift + \tl_put_right:Nn \l_tzsecant_cmd_tl + { + [ name~path = #4 , #2 ] + ([ shift = { (#3) } ]LX-point) -- ([ shift = { (#3) } ]RX-point) + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzsecant_cmd_tl + { + [ name~path = #4 , #2 ] + (LX-point) -- (RX-point) + } + } + } + { + \tzsecant_domain_process #8 + \tzgetxyval(LX-point){\tzTANLLX}{\tzTANLLY} + \tzgetxyval(RX-point){\tzTANRRX}{\tzTANRRY} + + \edef\tzTANSlope{(\tzTANRRY-\tzTANLLY)/(\tzTANRRX-\tzTANLLX)} + \def\tzsecantLFn{\tzTANSlope*(\x-\tzTANLLX)+\tzTANLLY} + + \IfValueTF { #3 } + {% shift + \tl_put_right:Nn \l_tzsecant_cmd_tl + { + [ name~path = #4 , + shift = { (#3) } , + } + } + {% no shift (normal) + \tl_put_right:Nn \l_tzsecant_cmd_tl + { + [ name~path = #4 , + } + } + + \tl_put_right:Nx \l_tzsecant_cmd_tl + { + domain = \tzsecantFromVal \c_colon_str \tzsecantToVal , + } + \tl_put_right:Nn \l_tzsecant_cmd_tl + { + #2 ] + plot ( \x , { \tzsecantLFn } ) % \x should not be expanded + } + } + + \tzsecant_sub_fn:n +} + +\NewDocumentCommand\tzsecant_domain_process{ m m } +{ + \def\tzsecantFromVal{#1} + \def\tzsecantToVal{#2} +} + +\cs_new:Npn \tzsecant_sub_fn:n +{ + \tzsecant_final_actions +} + +\NewDocumentCommand\tzsecant_final_actions { +G{} O{} D<>{} } +{ + \begin{pgfonlayer}{\tzsecantlayer} + \exp_last_unbraced:Nf \draw \l_tzsecant_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzsecant_cmd_tl ; +} + +%%% --- end of \tzsecant + + +%%%%% Slope and Tangent + +%%% to **resolve** the discrepancy issue due to bounding box +%%% for \tzslope(at) and \tztangent(at) +%%% (ndh) + +\NewDocumentCommand \IfNodeDefined { m m m } +{ + \@ifundefined{pgf@sh@ns@#1} + {#3} + {#2} +} + +\AddToHook{env/tikzpicture/before}{% + \@ifundefined{pgf@sh@ns@bbxBottom} + {} + { \cs_undefine:N \pgf@sh@ns@bbxBottom } + \def\TANCurve{} \def\TANWhere{} +} +%\AddToHook{env/tikzpicture/before}{% +% \@ifundefined{pgf@sh@ns@bbxBottom} +% {} +% { \cs_undefine:N \pgf@sh@ns@bbxBottom } +%} + +%%% Do not forget to declare, before final action, +%%% \gdef\TANCurve{<#m>}\gdef\TANWhere{<#n>} + + +%%%%% Tangent lines + +%%% ref. \settztangentepsilon + +\bool_new:N \l_tztangentat_bbox_bool + +%%% \tztangentat -- tangent to a path at x +%%% [<opt>]<shift coor>"<path name>"{<path>}{<x>}(<epsilon1>,<epsilon2>)[<from>:<to>]{<text>}[<pos,opt>]<code.append> + +\use:x{ + \NewDocumentCommand \exp_not:N \tztangentat + { s O{} d<> D""{} m m + >{ \SplitArgument { 1 } { , } } d() + >{ \SplitArgument { 1 } { \tl_to_str:n {:} } } r[] } + } +{ + \tl_clear:N \l_tztangentat_cmd_tl + + \IfBooleanTF { #1 } % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #5 } && + \str_if_eq_p:ee { \TANWhere } { #6 } + } + { \bool_set_true:N \l_tztangentat_bbox_bool } + { \bool_set_false:N \l_tztangentat_bbox_bool } + + % for local change of epsilon_1 and _2 + \IfValueT { #7 } + { + \tztangentat_epsilon_process #7 + \renewcommand\tztangentepsilonL{\tztangentatEpsilonOne} + \renewcommand\tztangentepsilonR{\tztangentatEpsilonTwo} + } + + \tztangentat_domain_process #8 + + % getting ready + \coordinate (LXcoor) at ($(#6,0)-(\tztangentepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#6,0)+(\tztangentepsilonR,0)$) ; + + \bool_if:NTF \l_tztangentat_bbox_bool + { + \IfNodeDefined{bbxBottom}{} + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + } + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + + % find vertical X points + \path [ name~path = C-vline ] (#6,0 |- bbxBottom) -- (#6,0 |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ R-vline , name = RXcut } ] ; + + % move to tangent point + \coordinate (tzXproj) + at ($(LXcut-1)!(TANp-1)!(RXcut-1)$); % projection + \coordinate (LLpoint) + at ($(LXcut-1)+(TANp-1)-(tzXproj)$); % move + \coordinate (RRpoint) + at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move + + % determine final extended points + \tl_set:Nx \l_tmpa_tl + { + (RRpoint) -- (TANp-1) -- + ([turn]0 \c_colon_str ~ -\tztangentatFromVal) coordinate (final-LL) + } + \tl_set:Nx \l_tmpb_tl + { + (LLpoint) -- (TANp-1) -- + ([turn]0 \c_colon_str ~ \tztangentatToVal) coordinate (final-RR) + } + + \exp_last_unbraced:Nf \path \l_tmpa_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tzgetxyval(LLpoint){\tzTANLLX}{\tzTANLLY} + \tzgetxyval(RRpoint){\tzTANRRX}{\tzTANRRY} + + \edef\tzTANSlope{(\tzTANRRY-\tzTANLLY)/(\tzTANRRX-\tzTANLLX)} + \def\tztangentatLFn{\tzTANSlope*(\x-\tzTANLLX)+\tzTANLLY} + + \IfValueTF { #3 } + { + \tl_put_right:Nn \l_tztangentat_cmd_tl + { + [ name~path = #4 , + shift = { (#3) } , + } + } + { + \tl_put_right:Nn \l_tztangentat_cmd_tl + { + [ name~path = #4 , + } + } + + \tl_put_right:Nx \l_tztangentat_cmd_tl + { + domain = \tztangentatFromVal \c_colon_str \tztangentatToVal , + } + + \tl_put_right:Nn \l_tztangentat_cmd_tl + { + #2 ] + plot ( \x , { \tztangentatLFn } ) % \x should not be expanded + } + + \gdef\TANCurve{#5}\gdef\TANWhere{#6} + + \tztangentat_sub_fn:n +} + +\NewDocumentCommand\tztangentat_epsilon_process{ m m } +{ + \def\tztangentatEpsilonOne{#1} + \def\tztangentatEpsilonTwo{#2} +} + +\NewDocumentCommand\tztangentat_domain_process{ m m } +{ + \def\tztangentatFromVal{#1} + \def\tztangentatToVal{#2} +} + +\cs_new:Npn \tztangentat_sub_fn:n +{ + \tztangentat_final_actions +} + +\NewDocumentCommand\tztangentat_final_actions { +G{} O{} D<>{} } +{ + \begin{pgfonlayer}{\tztangentlayer} + \exp_last_unbraced:Nf \draw \l_tztangentat_cmd_tl + node [ black , above~right , #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tztangentat_cmd_tl ; +} + +%%% --- end of \tztangentat + + +\bool_new:N \l_tztangent_bbox_bool + +%%% \tztangent (On) -- tangent to a path at (x,y) +%%% [<opt>]<shift coor>"<path name>"{<path>}(<coor>)(<epsilon1>,<epsilon2>)[<from>:<to>]{<text>}[<pos,opt>]<code.append> + +\use:x{ + \NewDocumentCommand \exp_not:N \tztangent + { s O{} d<> D""{} m r() + >{ \SplitArgument { 1 } { , } } d() + >{ \SplitArgument { 1 } { \tl_to_str:n {:} } } r[] } + } +{ + \tl_clear:N \l_tztangent_cmd_tl + + \IfBooleanTF { #1 } % NOT USED! + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #5 } && + \str_if_eq_p:ee { \TANWhere } { #6 } + } + { \bool_set_true:N \l_tztangent_bbox_bool } + { \bool_set_false:N \l_tztangent_bbox_bool } + + % for local change of epsilon_1 and _2 + \IfValueT { #7 } + { + \tztangent_epsilon_process #7 + \renewcommand\tztangentepsilonL{\tztangentEpsilonOne} + \renewcommand\tztangentepsilonR{\tztangentEpsilonTwo} + } + + \tztangent_domain_process #8 + + % getting ready + \coordinate (LXcoor) at ($(#6)-(\tztangentepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#6)+(\tztangentepsilonR,0)$) ; + + \bool_if:NTF \l_tztangent_bbox_bool + { + \IfNodeDefined{bbxBottom}{} + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + } + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + + % find vertical X points + \path [ name~path = C-vline ] (#6 |- bbxBottom) -- (#6 |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #5 ~ and ~ R-vline , name = RXcut } ] ; + + % move to tangent point + \coordinate (tzXproj) + at ($(LXcut-1)!(TANp-1)!(RXcut-1)$); % projection + \coordinate (LLpoint) + at ($(LXcut-1)+(TANp-1)-(tzXproj)$); % move + \coordinate (RRpoint) + at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move + + % determine final extended points + \tl_set:Nx \l_tmpa_tl + { (RRpoint) -- (TANp-1) -- + ([turn]0 \c_colon_str ~ -\tztangentFromVal) coordinate (final-LL) } + \tl_set:Nx \l_tmpb_tl + { (LLpoint) -- (TANp-1) -- + ([turn]0 \c_colon_str ~ \tztangentToVal) coordinate (final-RR) } + + \exp_last_unbraced:Nf \path \l_tmpa_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tzgetxyval(LLpoint){\tzTANLLX}{\tzTANLLY} + \tzgetxyval(RRpoint){\tzTANRRX}{\tzTANRRY} + + \edef\tzTANSlope{(\tzTANRRY-\tzTANLLY)/(\tzTANRRX-\tzTANLLX)} + \def\tztangentLFn{\tzTANSlope*(\x-\tzTANLLX)+\tzTANLLY} + + \IfValueTF { #3 } + { + \tl_put_right:Nn \l_tztangent_cmd_tl + { + [ name~path = #4 , + shift = { (#3) } , + } + } + { + \tl_put_right:Nn \l_tztangent_cmd_tl + { + [ name~path = #4 , + } + } + + \tl_put_right:Nx \l_tztangent_cmd_tl + { + domain = \tztangentFromVal \c_colon_str \tztangentToVal , + } + + \tl_put_right:Nn \l_tztangent_cmd_tl + { + #2 ] + plot ( \x , { \tztangentLFn } ) % \x should not be expanded + } + + \gdef\TANCurve{#5}\gdef\TANWhere{#6} + + \tztangent_sub_fn:n +} + +\NewDocumentCommand\tztangent_epsilon_process{ m m } +{ + \def\tztangentEpsilonOne{#1} + \def\tztangentEpsilonTwo{#2} +} + +\NewDocumentCommand\tztangent_domain_process{ m m } +{ + \def\tztangentFromVal{#1} + \def\tztangentToVal{#2} +} + +\cs_new:Npn \tztangent_sub_fn:n +{ + \tztangent_final_actions +} + +\NewDocumentCommand\tztangent_final_actions { +G{} O{} D<>{} } +{ + \begin{pgfonlayer}{\tztangentlayer} + \exp_last_unbraced:Nf \draw \l_tztangent_cmd_tl + node [ black , above~right , #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tztangent_cmd_tl ; +} + +%%% --- end of \tztangent + + +%%%%% \tzbrace + +%%% \tzbrace'[<opt>]{<raise>}[<brace opt>] +%%% <shift coor>(<coor>)(<coor>){<text>}[<pos,opt>] +\NewDocumentCommand\tzbrace{ t' O{} G{5pt} O{} d<> r() r() +G{} O{} } +{ + \IfBooleanTF { #1 } + { + \draw [ decorate , decoration = + { calligraphic~brace , mirror , + amplitude = 5pt, raise = #3 , #4 } , #2 + ] + } + { + \draw [ decorate , decoration = + { calligraphic~brace , + amplitude = 5pt, raise = #3 , #4 } , #2 + ] + } + \IfValueTF { #5 } + { + ([shift={(#5)}]#6) to node [ midway , #9 ] { #8 } + ([shift={(#5)}]#7) ; + } + { + (#6) to node [ midway , #9 ] { #8 } (#7) ; + } +} + +%%% -- end of \tzbrace + + +%===================================================== +%===================================================== +\ExplSyntaxOff +%===================================================== +%===================================================== + + +\endinput + |