diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-28 21:03:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-28 21:03:55 +0000 |
commit | c6af17d6534c584aa61deb68dfd0e2745691ea45 (patch) | |
tree | 6dd531110ae6166acf3080a643c962d5f5646353 | |
parent | f11c72529e2b5e7d6343e6ea8b9b3ebd3414524d (diff) |
tzplot (28feb22)
git-svn-id: svn://tug.org/texlive/trunk@62288 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v1.0.1.tex | 134 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v2.0.tex | 339 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v2.0.tex (renamed from Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v1.0.1.tex) | 196 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v2.0.tex (renamed from Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v1.0.1.tex) | 2247 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C1-v2.0.tex | 1691 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C2-v2.0.tex | 1533 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v2.0.tex (renamed from Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v1.0.1.tex) | 1373 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc-E-v2.0.tex | 476 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc.pdf | bin | 827727 -> 1263240 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tzplot/tzplot-doc.tex | 292 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tzplot/tzplot.sty | 4445 |
11 files changed, 10352 insertions, 2374 deletions
diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v1.0.1.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v1.0.1.tex deleted file mode 100644 index 1d949a67682..00000000000 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v1.0.1.tex +++ /dev/null @@ -1,134 +0,0 @@ -%!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 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(A)(B) % is an abbreviation of: - \draw (A) -- (B); -\end{tztikz} -% -\begin{tztikz}{} -\tzline[blue](A)(B){my line}[r] % 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|, |xparse|, 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:stylenames} - -This package does not provide any environment. -Since all the drawing macros prefixed by |\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 \iisw{abbreviations} of \Tikz's basic placement options as follows: -\label{abbreviations} - -\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} -You can use these abbreviations to place \Tikz's \iisw{main node}\xem{s} but not \iisw{label node}\xem{s}. To place label nodes, use non-abbreviated options or angles instead. - - -The |tzplot| package also defines graphic 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 straight line from |main| (default) to |background| as follows: - -\begin{tzcode}[listing only]{1} -\begin{tikzpicture} -\tzhelplines(4,3) - <tzplot macros> - <tikz macros> -\begin{pgfonlayer}{background} - \tzline[blue](0,0)(3,1) -\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 introduced 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/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v2.0.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v2.0.tex new file mode 100644 index 00000000000..6f7f1d38508 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-A-v2.0.tex @@ -0,0 +1,339 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%================= +%\part{Getting Ready} +\part{Prelimiaries} +%%%================= +\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 typing \Tikz\ code. + +\paragraph{What you can do with \texttt{tzplot}} +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(A)(B) % is an abbreviation of: + \draw (A) -- (B); +\end{tztikz} +% +\begin{tztikz}{} +\tzline[blue](A)(B){my line}[r] % 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|. + +\paragraph{How to load} +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|, |xparse|, and |expl3|. +And it uses the following \Tikz\ libraries: +\begin{verbatim} + arrows,backgrounds,calc,intersections,patterns,plotmarks,positioning,shapes, + decorations.pathreplacing,calligraphy +\end{verbatim} + +In the version 2, more libraries are added to the list of preloaded libraries: +\begin{verbatim} + arrows.meta, bending, % (for middle arrow tips) + decorations.markings, % (for decoration) + decorations.pathmorphing, % (for snaked lines) + fpu, % (for angle computation) + spy % (for later use) +\end{verbatim} + +\paragraph{More comments} +This package sets the basic \xem{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. +\xem{To make good use of this package, you need to familiarize yourself with \Tikz}. + +%%------------------------------------------------------------ +\section{Preoccupied style names} +\label{s:stylenames} + +This package does not provide any environment. +Since all the drawing macros prefixed by |\tz| are just abbreviations of \Tikz\ code, +you can use the macros in the |tikzpicture| environment together with any \Tikz\ commands. + +\paragraph{Preoccupied styles} +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} + +\paragraph{Abbreviated styles} +Following the manual of \Tikz, this package also predefines \iisw{abbreviations} (or aliases) of \Tikz's basic placement options for main nodes as follows: +\label{abbreviations} + +\begin{tzsty}{} +% preoccupied (alias) styles for main node options +\tikzset{% + a/.style={above=#1}, + b/.style={below=#1}, + c/.style={centered=#1}, % centered, not center + 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} + +By these abbreviations (or aliases), we mean that, with the |\tzplot| package, we can use these alias styles in the |\tikzpicture| environment as follows: + +\begin{tztikz}{} +\draw (0,0) -- (1,0) node [ar] {line}; % [ar] = [above right] +\end{tztikz} + +\paragraph{Layers} +The |tzplot| package also defines graphic 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 straight line from |main| (default) to |background| as follows: + +\begin{tzcode}[listing only]{1} +\begin{tikzpicture} +\tzhelplines(4,3) + <tzplot macros> + <tikz macros> +\begin{pgfonlayer}{background} + \tzline[blue](0,0)(3,1) +\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 introduced 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. + + +%%================================== +\chapter{Changes} + +%%------------------------------------------------------------ +\section{What's New} + +\subsection{New macros} + +New macros have been added. + +\begin{itemize}\tightlist +\item |\tzfn'|: (swap version) inverse function of |\tzfn| +\item |\tzfnofy|, |\tzfnofy'|: function of |\y| +\item |\tzdeffn|, |\tzdeffnofy|: to define functions +\item |\tzdefLFn|, |\tzdefLFnofy|: define linear functions +\item |\tzLFn(')|, |\tzLFnofy(')|: linear functions +\item |\tzLFnXpoint(*)|: linear function intersection points +\item |\tzfnmin(')|, |\tzfnmax(')|: envelope curves +% +\listdivider +\item |\tzfnarea(*)|, |\settzfnarealayer|, |\tzfnarealine(')|: to fill the area under graphs +\item |\settzfnarealinestyle| +\item |\tzpdfZ|, |\tzpdfN(*)|: probability density functions of a normal distribution +\item |\tzprojs(*)|, |\tzprojsx(*)|, |\tzprojsy(*)|: multiple projection lines +\item |\settzpathlayer|: |main| layer by default +% +\listdivider +\item |\tzslope|, |\tzslopeat| +\item |\settzslopelayer|, |\settzslopeatlayer|, |\settzslopeepsilon| +% +\listdivider +\item |\tzlink(+)|, |\tzlinks(*)(+)|, |\settzlinkstyle|, |\settzpathstyle| +\item |\tzedge(+)|, |\tzedges(+)| +% +\listdivider +\item |\tznodes(*)|: multiple nodes +\item |\tznodedots(*)|: multiple node dots +\item |\tznoderectangle(*)|, |\tznodebox(*)|, |\tznodeoval(*)|: aliases +% +\listdivider +\item |\tzring(*)|, |\tzcirclering(*)| +\item |\tzellipsering(*)|, |\tzovalring(*)| +\item |\tzrectanglering(*)|, |\tzframering(*)|, |\tzboxring(*)| +\item |\tzbox(*)| +% +\listdivider +\item |\tzpointangle|: angle between points +\item |\tzanglemark(*)(')|, |\tzrightanglemark(*)|: angle marks +\item |\tzangleresult|, |\tzangleONE|, |\tzangleTWO|: after |\tzanglemark| +\item |\settzAAlinestyle|, |\settzanglelayer|, |\settzAAradius|, |\settzRAsize|. +% +\listdivider +\item |\settzmidarrow|: to control middle arrow tips +\item |\tzsnake|: snake lines +%\item |\tzspy| % (not documented) +%%%\item |\tzplotfile| % (not documented) +\end{itemize} + + +\subsection{Extending paths: \texttt{\bs tz<...>AtBegin} and \texttt{\bs<...>AtEnd}} + +\begin{itemize}\tightlist +\item |\tztoAtBegin|, |\tztoAtEnd|, |\tztosAtBegin|, |\tztosAtEnd| (version 1) +\item |\tztoAtBegin|, |\tztoAtEnd|, |\tztosAtBegin|, |\tztosAtEnd| (version 1) +\item |\tzlineAtBegin|, |\tzlineAtEnd|, |\tzlinesAtBegin|, |\tzlinesAtEnd| +\item |\tzlinkAtBegin|, |\tzlinkAtEnd|, |\tzlinksAtBegin|, |\tzlinksAtEnd| +\item |\tzbezierAtBegin|, |\tzbezierAtEnd| +\item |\tzparabolaAtBegin|, |\tzparabolaAtEnd| +% +\listdivider +\item |\tzvfn(at)AtBegin|, |\tzvfn(at)AtEnd| +\item |\tzhfn(at)AtBegin|, |\tzhfn(at)AtEnd| +% +\listdivider +\item |\tzfnAtBegin|, |\tzfnAtEnd| (version 1) +\item |\tzfnofyAtBegin|, |\tzfnofyAtEnd| +\item |\tzLFnAtBegin|, |\tzLFnAtEnd| +\item |\tzLfnofyAtBegin|, |\tzLFnofyAtEnd| +\item |\tzfnminAtBegin|, |\tzfnminAtEnd|, |\tzfnmaxAtBegin|, |\tzfnmaxAtEnd| +\item |\tzplotAtBegin|, |\tzplotAtEnd|, |\tzplotcurveAtBegin|, |\tzplotcurveAtEnd| +\end{itemize} + + + +\subsection{New coordinates} + +\begin{itemize}\tightlist +\item |(tzAAmid)|: angle arc midpoint, depending on |\tzanglemark| +\item |(tzRAvertex)|: right angle mark vertex, depending on |\tzrightanglemark| +\end{itemize} + +\subsection{Error messages} + +Some macros, called \iisw{semicolon version}s, accept any number of coordinates. You MUST indicate when the coordinate iteration ends with a \xem{semicolon} |;|. Without the semicolon, an error occurs with the \iisw{error message}: +\begin{verbatim} +! Package tzplot Error: You may have forgotten a semicolon here or above! +\end{verbatim} + +Knowing two coordinates, you can use |\tzLFn| and related macros to graph a linear function through the two points without writing an explicit function. +If you inadvertently try \xem{infinite} slopes, you will get an error with the \xem{error message}: +\begin{verbatim} +! Package tzplot Error: Perhaps you are trying an 'infinite slope' here or above! +\end{verbatim} + +\subsection{Abridged strings to place labels for coordinates, dots, and points} +\label{ss:string-replacement} + +In \Tikz, a label to a main node is placed by the |label| option. The syntax of the |label| option is |label={[<label opt>]<angle>:{<label>}}|. +In \Tikz, The position of labels is specified by \xem{angles}. The positioning words like |above|, |below|, |below right|, and so on can be used and they are interpreted in \Tikz\ as the corresponding angles. + +\xem{Just to avoid frequent coding errors}, from the version 2, the |tzplot| package provides the \xem{abridged strings} |a|, |b|, |c|, |br|, and so on that you can use instead of angles. With the |tzplot| package, the user input |a| is replaced by |above|, |[b]| by |below|, |c| by |center| (\xem{not} |centered| for the main node option), |br| by |below right|, and similarly for other abridged strings. + +\remark This is just a \iisw{string replacement} that is not related to the function of \Tikz. By this we mean that we \xem{cannot use} these abridged strings to place labels, instead of angels, in the |tikzpicture| environment without using the related |\tz<...>| macros. + +The macros related to this issue are as follows: + +\begin{itemize}\tightlist +\item dots: |\tzdot(s)|, |\tzcdots(s)|, |\tznodedot(s)| +\item coordinates: |\tzcoor(s)|, |\tzcoorsquick| +\item intersection points: |\tzXpoint|, |\tzvXpoint|, |\tzhXpoint|, |\tzLFnXpoint| +\item plot coordinates: |\tzplot|, |\tzplotcurve| +\item and their starred versions. +\end{itemize} + +\subsection{New styles for middle arrow tips} + +Some styles for drawing the the \iisw{middle arrow tip}\xem{s} on a path are predefined. +\begin{itemize}\tightlist +\item |-->--|: (controllable) middle arrow tip + \begin{itemize} + \item \icmd{\settzmidarrow} controls the positions and styles of middle arrow tips + \end{itemize} +\item |--o--|: the circle middle arrow tip +\item |--x--|: the cross middle arrow tip +\item |--/--|: the diagonal middle arrow tip +\end{itemize} + +You can use these styles to draw middle arrow tips as follows: + +\begin{tztikz}{} +\tzlines[-->--,red](0,0)(1,0)(3,1); % default=0.5 +\tzlines[-->--=0.7](0,0)(1,0)(3,3); % work like + \draw [-->--,red](0,0) -- (1,0) -- (3,1); + \draw [-->--=0.7](0,0) -- (1,0) -- (3,1); +\end{tztikz} + +%%------------------------------------------------------------ +\section{Remarks} + + +Some macros have been modified in order to add new features. This does not cause any harm to existing users. +\begin{itemize}\tightlist +\item |\tznode|: to add new option |<node.code>| + \begin{itemize} + \item This allows you to use full features (including |foreach|) of the \Tikz's |node| operation. + \end{itemize} +\item |\tzframe|, |\tzcircle|, |\tzellipse|: to add new option |<code.append>| + \begin{itemize} + \item Now you can use |even odd rule| to draw rings with these macros. + \end{itemize} +\end{itemize} + +\bigskip +Some macros are ``experimental" and their syntax may change in the future. + +\paragraph{Styles of middle arrow tips in the \texttt{istgame} package} +The package |istgame| to draw game trees predefines the styles of the middle arrow tips including |->-|, |-o->|, and |-x-|. +\begin{itemize}\firmlist +\item The style |->-| defined in |istgame| and |-->--| defined in |tzplot| are a little different from each other in the default values. + \begin{itemize} + \item Still you may want to use the style |->-| instead of |-->--|. In that case, you can do like this: + \begin{verbatim} + \tikzset{->-/.style={-->--}} + \end{verbatim} + \item \xem{However}, it is important to understand that changing the style to |->-| may override the style of |->-| defined in other package, depending on which package is loaded first. + \item The best way to use |->-| instead of |-->--| is to upload the |istgame| and follow the instruction of the manual. + \end{itemize} +\item The styles |--o--| and |--x--| differ in definition and usage from the styles |-o-| and |-x-| of the |istgame| package. +\end{itemize} + + diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v1.0.1.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v2.0.tex index 6cd6e61fab6..4dbb93b4e5b 100644 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v1.0.1.tex +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-B-v2.0.tex @@ -68,7 +68,7 @@ You can change of the size of a dot by specifying the \xem{radius} of the circle \begin{tztikz}{} \tzcdot*[green](3,2)(3pt) % is an abbreviation for: - \draw [fill,green] (0,0) circle (3pt); + \draw [fill,green] (3,2) circle (3pt); \end{tztikz} \begin{tzcode}{.3} @@ -203,7 +203,7 @@ The starred version \icmd{\tzcoor*} prints a filled node dot at a specified coor \subsection{\protect\cmd{\tzto(0,0)(4,2)}} \label{ssi:tzto} -\icmd{\tzto} connects two points with a line or a curve. +\icmd{\tzto} connects two points with a line or a curve using the |to| operation of \Tikz. \begin{tzcode}{.3} \begin{tikzpicture} @@ -222,8 +222,8 @@ The starred version \icmd{\tzcoor*} prints a filled node dot at a specified coor \subsection{\protect\cmd{\tzbezier}} \label{ssi:tzbezier} -\icmd{\tzbezier} draws a B\'{e}zier curve with one or two control points. -The style |tzshowcontrols|, which is predefined in the package, reveals the control point(s). +\icmd{\tzbezier} draws a B\'{e}zier curve with \xem{one or two} control points from the first coordinate to the last coordinate. +The style |tzshowcontrols| predefined in the package reveals the control point(s). \begin{tzcode}{.3} \begin{tikzpicture} @@ -244,6 +244,7 @@ The style |tzshowcontrols|, which is predefined in the package, reveals the cont \label{ssi:tzparabola} \icmd{\tzparabola} draws a parabola controlled by several options of \Tikz's |parabola| operation. +The macro \icmd{\tzparabola} accepts \xem{two or three} coordinate arguments to draw a parabola and the parabola bends at the second coordinate if it exists. \begin{tztikz}{} \tzparabola(0,0)(2,4) % works like: @@ -311,7 +312,7 @@ When a \iisw{main node} with text in it is placed at a specific point, its \iisw \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. Note that the angle expression \xem{cannot} be used for placing a main node. +Instead of angles, you can use the corresponding placement words. In \Tikz, for example, |above| is replaced by |90| degree, |right| by |0| degree, |below left| by |-135| degree, and the like. Note that the angle expression \xem{cannot} be used for placing main nodes. \xmedskip1 \remark @@ -323,10 +324,11 @@ There is one exception: |\tzshoworigin|. |\tzshoworigin| can have a label, but i (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.} +\subsection{Abbreviations of \Tikz\ basic placement option styles: \texttt{a}, \texttt{r}, \texttt{ar}, \texttt{bl}, etc.} \label{ssi:abbreviations} -You can use \isw{abbreviations} |a| for |above|, |r| for |right|, |bl| for |below left|, and so on to place \iisw{main node}\xem{s}. +You can use \isw{abbreviations} (or aliases) |a| for |above|, |c| for |centered|, |r| for |right|, |bl| for |below left|, and so on to place \iisw{main node}\xem{s}. +(Again, you \xem{cannot} use angels to place main nodes.) \begin{tzcode}{.3} \begin{tikzpicture}[font=\ttfamily,text=blue] @@ -339,9 +341,6 @@ You can use \isw{abbreviations} |a| for |above|, |r| for |right|, |bl| for |belo \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} @@ -376,10 +375,7 @@ To change the size of a dot, you need to specify the last option |(<dimension>)| \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} +\textsc{Remember} the order of arguments is |(<coor>)(<name>){<label>}[<angle>]|. \begin{tzdef}{} % syntax: simplified @@ -479,6 +475,11 @@ To add text to a line or a curve drawn by \icmd{\tzto}, just specify the optiona \end{tikzpicture} \end{tzcode} +\begin{tztikz}{} +\tzto(0,0){route A}(3,0) % works like: + \draw (0,3) to node [above] {route A} (3,0); +\end{tztikz} + 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} @@ -512,7 +513,6 @@ You can add text to the curve drawn by |\tzbezier| using the optional arguments \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{following the last coordinate}. The text is placed at (by default) or around the last coordinate according to |[<node opt>]|. @@ -532,19 +532,38 @@ The text is placed at (by default) or around the last coordinate according to |[ %%------------------------------------------------------------ \section{Linking many coordinates: Semicolon versions} -\label{si:manycoordinates} +\label{si:liknmanycoordinates} \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 |;|. +\icmd{\tzlines} connects with line segments an arbitrary number of coordinates. The coordinate iteration must end with a semicolon |;|. Here, the \xem{semicolon} `|;|' indicates \xem{the end of repetition} of coordinates. Let us call this kind of macro a \iisw{semicolon version} macro. +\remark: Without the semicolon |;|, an error occurs with the the \iisw{error message}: + \begin{verbatim} + ! Package tzplot Error: You may have forgotten a semicolon here or above! + \end{verbatim} + +\begin{tzdef}{} +% syntax: minimal +\tzlines[<opt>](<coor>)(<coor>)..repeated..(<coor>); +% syntax: simplified +\tzlines[<opt>]"<path name>" + (<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>]; +% defaults + []""(<m>){}[]..repeated..(){}[]; +% <m> means mandatory +\end{tzdef} + + \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); +\tzlines(0,0)(1,2)(3,0) + (4,1)(2,2)(3,3) + (0,3)(0,1)(4,2) ; % semicolon \end{tikzpicture} \end{tzcode} @@ -556,7 +575,7 @@ With the optional argument |{<text>}| followed by |[<node opt>]| \xem{in-between \tzlines[dashed,->](0,0){up}[l] (1,2){down}[r] (3,0){up}[r] - (4,1); + (4,1) ; % semicolon \end{tikzpicture} \end{tzcode} @@ -568,7 +587,7 @@ The optional argument |{<text>}| \xem{following the last coordinate} can be used \tzlines[dashed,->](0,0){up} (1,2){down} (3,0){up} - (4,1){Weight}[r,blue] ; + (4,1){Weight}[r,blue] ; % semicolon \end{tikzpicture} \end{tzcode} @@ -581,13 +600,13 @@ DO NOT FORGET to indicate when the repetition ends by typing a semicolon. So it \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| but with |text opacity=1|. (Changing the |fill opacity| is not an issue in this introduction. See Section \ref{s:tzpolygon} on page \pageref{s:tzpolygon} for more details.) +The starred version |\tzpolygon*| does the same thing as |\tzpolygon| except for one thing. +|\tzpolygon*|, by default, fills the interior of the polygon with |black!50| with |fill opacity=.3| but with |text opacity=1|. (Changing the |fill opacity| is not an issue in this introduction. See Section \ref{ss:tzpolygon} on page \pageref{ss: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); +\tzpolygon(1,3)(0,2)(2,0)(3,1)(4,2)(2,3); % semicolon \end{tikzpicture} \end{tzcode} @@ -624,7 +643,8 @@ 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); +\tzpath[draw](1,3)(0,2)(2,0) + (3,1)(4,2)(2,3); % semicolon \end{tikzpicture} \end{tzcode} @@ -652,7 +672,18 @@ You can fill the interior of a path formed by |\tzpath| (after being closed) wit -The starred version \icmd{\tzpath*} takes the default options |fill=black!50|, |fill opacity=.3| to fill the area. +The starred version \icmd{\tzpath*} takes the default options |fill=black!50|, |fill opacity=.3|, and |text opacity=1| to fill the area. + +\begin{tzdef}{} +% syntax: simplified +\tzpath*[<opt>](<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>]; +% defaults + *[fill=black!50,fill opacity=.3,text opacity=1](<m>){}[]..repeated..(){}[]; +% <m> means mandatory +\end{tzdef} + +The macros |\tzpath| and |\tzpath*| are much more flexible. See Section \ref{s:tzpath} on page \pageref{s:tzpath} for more details. + \begin{tzcode}{.3} \begin{tikzpicture} @@ -676,7 +707,6 @@ How to change the |fill opacity| with |\tzpath*| is not discussed in this introd - %%------------------------------------------------------------ \section{Many dots: Semicolon versions} \label{si:manydots} @@ -691,7 +721,7 @@ How to change the |fill opacity| with |\tzpath*| is not discussed in this introd \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); +\tzcdots*[red](0,3)(1,3)(2,3)(3,3)(4,2); % semicolon \end{tikzpicture} \end{tzcode} @@ -717,11 +747,23 @@ Each coordinate can be labeled by specifying the optional argument |{<label>}| f \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{tzdef}{} +% syntax: minimum +\tzdots*(<coor>)(<coor>)..repeated..(<coor>); +% syntax: simplified +\tzdots*[<opt>](<coor>){<label>}[<angle>]..repeated.. + (<coor>){<label>}[<angle>]; (<dot size>) +% defaults + *[tzdot=2.4pt](<m>){}[]..repeated..(){}[]; (2.4pt) +% <m> means mandatory +\end{tzdef} + + \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); +\tzdots*[red](0,3)(1,3)(2,3)(3,3)(4,2); % semicolon \end{tikzpicture} \end{tzcode} @@ -748,7 +790,7 @@ Each coordinate can be labeled by specifying the optional argument |{<label>}| f \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 coordinate repetition ends. +The semicolon version macro \icmd{\tzcoors} accepts \xem{an arbitrary number of pairs} to define multiple coordinates. A semicolon `|;|' is necessary to indicate when the repetition ends. \begin{tzcode}{.3} \begin{tikzpicture} @@ -758,11 +800,11 @@ Each coordinate can be labeled by specifying the optional argument |{<label>}| f (2,1)(C) (3,3)(D) (4,2)(E); -\tzlines(A)(B)(C)(D)(E); +\tzlines(A)(B)(C)(D)(E); % semicolon \end{tikzpicture} \end{tzcode} -The options |{<label>}| and |[<angle>]| following each pair of |(<coor>)| and |(<name>)| allow you to put |<label>| in the direction of |<angle>| around the coordinate. +The options |{<label>}| and |[<angle>]| following \xem{each pair} of |(<coor>)| and |(<name>)| allow you to put |<label>| in the direction of |<angle>| around the coordinate. Here, the repeating pattern is the quadruple |(<coor>)(<name>){<label>}[<angle>]|. The first two parenthesis arguments are mandatory and others are optional. The pattern is repeated until |\tzcoors| meets a semicolon |;|. \begin{tzcode}{.3} @@ -778,7 +820,7 @@ Here, the repeating pattern is the quadruple |(<coor>)(<name>){<label>}[<angle>] \end{tzcode} -The starred version \icmd{\tzcoors*} does one more thing: prints node dots. +The starred version \icmd{\tzcoors*} does one more thing: to print node dots. \begin{tzcode}{.3} \begin{tikzpicture} @@ -806,7 +848,7 @@ The starred version \icmd{\tzcoors*} does one more thing: prints node dots. (1,1)(Best) (2,1)(Case) (3,3)(Done) - (4,2)(End); + (4,2)(End); % semicolon \end{tikzpicture} \end{tzcode} @@ -834,7 +876,7 @@ The starred version \icmd{\tzcoorsquick*} prints node dots and automatically put \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). +\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. Since this is a semicolon version, the repetition of coordinates must be ended by |;|. \begin{tzcode}{.3} \begin{tikzpicture} @@ -843,7 +885,7 @@ The starred version \icmd{\tzcoorsquick*} prints node dots and automatically put (1,1) (2,1) (3,3) - (4,2); + (4,2) ; % semicolon \end{tikzpicture} \end{tzcode} @@ -861,7 +903,7 @@ Each coordinate can be labeled by specifying the optional argument |{<text>}| fo (1,1){Best} (2,1){Case} (3,3){Done} - (4,2){END!}[[blue]0];(1.2pt) + (4,2){END!}[[blue]0] ; (1.2pt) \end{tikzpicture} \end{tzcode} @@ -889,9 +931,8 @@ Each coordinate can be labeled by specifying the optional argument |{<text>}| fo \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). +\icmd{\tzplot*}|[draw]| prints bullet marks at the specified coordinates and draws line segments connecting them. The repetition of coordinates must be ended by |;| (semicolon version). \begin{tzcode}{.3} \begin{tikzpicture} @@ -908,7 +949,7 @@ Each coordinate can be labeled by specifying the optional argument |{<text>}| fo \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 an arbitrary number of coordinates. +\icmd{\tzplotcurve} plots any number of coordinates with the default option |[smooth,tension=1]|, resulting in a \xem{curve} connecting the specified coordinates. The repetition of coordinates must be ended by |;| (semicolon version). \begin{tzcode}{.3} @@ -918,7 +959,7 @@ The repetition of coordinates must be ended by |;| (semicolon version). (1,1) (2,1) (3,3) - (4,2){END!}[[blue]0]; + (4,2){END!}[[blue]0] ; % semicolon \end{tikzpicture} \end{tzcode} @@ -944,7 +985,7 @@ You can change the tension value by specifying the optional argument |{<tension> \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[red]{.55}(1,3)(A)(4,0); % TikZ default \tzplotcurve[dashed]{0}(1,3)(A)(4,0); \end{tikzpicture} \end{tzcode} @@ -1030,7 +1071,7 @@ The starred version \icmd{\tzaxes*} is just to set the current state to a \iisw{ \end{tikzpicture} \end{tzcode} -\icmd{\tzshoworigin*} prints a node dot with the size of |2.4pt| (by default) at the origin. +\icmd{\tzshoworigin*} prints a \xem{node dot} with the size of |2.4pt| (by default) at the origin. \begin{tzcode}{.3} \begin{tikzpicture}[scale=.5] @@ -1052,12 +1093,12 @@ The starred version \icmd{\tzaxes*} is just to set the current state to a \iisw{ \end{tikzpicture} \end{tzcode} -Notice that, in the above example, the two axes intersect at |(7,4)| by the shift option |<7,4>|. +Notice that, in the previous 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. +\icmd{\tzaxisx} draws an x-axis from |<x1>| to |<x2>|. \begin{tzdef}{} % syntax: simplified @@ -1066,7 +1107,7 @@ Notice that, in the above example, the two axes intersect at |(7,4)| by the shif [->,>=stealth]<0>{<m>}{<m>}{}[right] \end{tzdef} -|\tzaxisy| works similarly for the y-axis. +\icmd{\tzaxisy} works similarly for the y-axis, except for the axis label position: |above| by default. \begin{tzcode}{.3} \begin{tikzpicture}[scale=.5] @@ -1163,6 +1204,8 @@ You can change the length of tick marks, for example, like |(-2pt:3pt)| and |(-5 \end{tikzpicture} \end{tzcode} +You can see more details on |\tzticks| and its friends in Chaper \ref{c:ticks} on page \pageref{c:ticks}. + %%------------------------------------------------------------ \section{Projections on the axes} @@ -1172,7 +1215,7 @@ You can change the length of tick marks, for example, like |(-2pt:3pt)| and |(-5 \subsection{\protect\cmd{\tzprojx(*)}, \protect\cmd{\tzprojy(*)}} \label{ssi:tzprojx} -\icmd{\tzprojx} draws a dotted (by default) line from a specified coordinate to its projection point on the x-axis and prints text around (|[below]| by default) the projection point. +\icmd{\tzprojx} draws a \xem{dotted line} (by default) from a specified coordinate to its projection point 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. @@ -1186,7 +1229,7 @@ You can change the length of tick marks, for example, like |(-2pt:3pt)| and |(-5 \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. +\icmd{\tzprojx*} does one more thing. It prints a node dot (with |\tzdot*|) at a specified coordinate. |\tzprojy*| works similarly but for the projection point on the y-axis. \begin{tzcode}{.3} @@ -1206,7 +1249,7 @@ You can change the length of tick marks, for example, like |(-2pt:3pt)| and |(-5 \label{ssi:tzproj} \icmd{\tzproj} combines |\tzprojx| and |\tzprojy|. -And \icmd{\tzproj*} combines |\tzprojx*| and |\tzprojy*|, so it suppresses tick labels. +And \icmd{\tzproj*} combines |\tzprojx*| and |\tzprojy*|. \begin{tzcode}{.3} @@ -1214,7 +1257,7 @@ And \icmd{\tzproj*} combines |\tzprojx*| and |\tzprojy*|, so it suppresses tick %\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[<->,solid,draw=red](3,2){$x_1$}{$x_2$} \tzproj*(1.5,2.5){$a$}[xshift=3pt,text=blue]{$b$} \end{tikzpicture} \end{tzcode} @@ -1230,6 +1273,14 @@ And \icmd{\tzproj*} combines |\tzprojx*| and |\tzprojy*|, so it suppresses tick \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>}| with |[<node opt>]| as shown in the following example. +\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] \tzhelplines(5,5) @@ -1241,15 +1292,13 @@ Optionally, you can add |{<text>}| with |[<node opt>]| as shown in the following \end{tikzpicture} \end{tzcode} +\begin{tztikz}{} +\tzfn[dashed]{(\x-2)^2+1}[1:4]{$g(x)$}[r] % works like: + \draw [dashed] plot [domain=1:4] (\x,{(\x-2)^2+1}) node [right] {$g(x)$}; +\end{tztikz} + 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] @@ -1270,7 +1319,7 @@ If the curly brace mandatory argument consists of \xem{only a macro name} like | \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 left to right of the \ixxw{current bounding box}. +\icmd{\tzhfnat} accepts a value of $y$ and draws a horizontal line (the graph of a constant function) at $y$ from left to right of the \ixxw{current bounding box}, by default, unless you specify the optional argument |[<from:to>]|. \begin{tzdef}{} % syntax @@ -1284,11 +1333,11 @@ If the curly brace mandatory argument consists of \xem{only a macro name} like | \begin{tzcode}{.3} \begin{tikzpicture} \tzhelplines(4,3) -\tzhfnat{0} -\tzhfnat[dashed]{1}[1:4]{Two}[l,at start] +\tzhfnat{0} % value of y +\tzhfnat[dashed]{1}[1:4]{Two}[l,at start] % value of y \tzcoors(0,2)(A)(0,3)(B); -\tzhfn[blue](A)[0:3]{Three}[b,near end] -\tzhfn[->](B)[0:3]{Four}[r] +\tzhfn[blue](A)[0:3]{Three}[b,near end] % coordinate +\tzhfn[->](B)[0:3]{Four}[r] % cooridnate \end{tikzpicture} \end{tzcode} @@ -1323,7 +1372,7 @@ If the curly brace mandatory argument consists of \xem{only a macro name} like | \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 one point, |(<coor1>)|, with the slope of |<slope>|. If both of the two coordinates are specified the option |{<slope>}| is ignored. The domain in the form of |[a:b]| is also a required argument. +|\tzLFn(<coor1>){<slope>}...| draws a linear function passing through one point, |(<coor1>)|, with the slope of |<slope>|. If two coordinates and a slope are all specified the option |{<slope>}| is ignored. The domain in the form of |[a:b]| is also a required argument. \begin{tzcode}{.3} \begin{tikzpicture}[scale=.7,font=\footnotesize] @@ -1354,11 +1403,7 @@ In this package, all macros (with a few exceptions) related to lines and curves \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... @@ -1454,11 +1499,11 @@ The starred version \icmd{\tzhXpoint*} prints a node dot at the (first) intersec \end{tikzpicture} \end{tzcode} - +You can see more details on |\tzXpoint| and its friends in Chapter \ref{c:intersections} on page \pageref{c:intersections}. %%------------------------------------------------------------ -\section{Tangent lines} +\section{Tangent lines and secant lines} \label{si:tangentlines} \subsection{\protect\cmd{\tztangentat}} @@ -1481,7 +1526,7 @@ The slope of a tangent line drawn by |\tztangentat| is just approximate. The line is drawn on the |behind| layer, by default. -You can also add some text next to the line by specifying the optional arguments |{<text>}| and |[<node opt>]|, after the domain. +You can also add some text next to the tangent line by specifying the optional arguments |{<text>}| and |[<node opt>]|, after the domain. \begin{tzcode}{.3} \begin{tikzpicture}[scale=.7] @@ -1521,6 +1566,8 @@ You can also add some text next to the line by specifying the optional arguments \end{tzcode} +See Section \ref{s:tangent} on page \pageref{s:tangent} for more details on |\tztangent| and |\tztangentat|. + \subsection{\protect\cmd{\tzsecantat}, \protect\cmd{\tzsecant}} \label{ssi:tzsecant} @@ -1556,7 +1603,7 @@ You can also add some text next to the line by specifying the optional arguments 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>]|. +You can also add some text next to the secant line by specifying the optional arguments |{<text>}| and |[<node opt>]|. \begin{tzcode}{.3} \begin{tikzpicture}[scale=.7] @@ -1569,6 +1616,7 @@ You can also add some text next to the line by specifying the optional arguments \end{tikzpicture} \end{tzcode} +See Section \ref{s:secant} on page \pageref{s:secant} for more details on |\tzsecant| and |\tzsecantat|. %%================================== \chapter{Examples: Economics} @@ -1643,6 +1691,7 @@ Here, we are using |\tzto|. \begin{enumerate}[{Step} 1{:}] \item Determine the size of the graph. +\end{enumerate} \begin{tzcode}{.3} \begin{tikzpicture}[scale=.035,font=\scriptsize] @@ -1651,10 +1700,11 @@ Here, we are using |\tzto|. \end{tikzpicture} \end{tzcode} +\begin{enumerate}\addtocounter{enumi}{1}\renewcommand{\labelenumi}{{Step} \theenumi{:}}\firmlist \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 Project both of 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} @@ -1839,8 +1889,8 @@ Here, we are using |\tzto|. \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 +\tzXpoint*{sFk}{ndk}(E)[2]{$E$}[135] % (E)=(E-2) +\tzvXpoint*{Fk}(E)(YE) % 2nd X point \tzproj(YE){$k^*$}{$y^*$} \tzvXpointat*{Fk}{2}(A) \tzvXpointat*{sFk}{2}(B) diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v1.0.1.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v2.0.tex index 6b2dd29562e..9afc4fc6685 100644 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v1.0.1.tex +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C-v2.0.tex @@ -128,6 +128,7 @@ Similarly for |tzdashed|. \tzbbox(<coor1>)(<coor2>) % defaults (0,0)(<m>) +% <m>: mandatory \end{tzdef} \begin{tztikz}{} @@ -161,16 +162,16 @@ The \xem{radius} of the circle is |1.2pt|, by default. % defaults *[ solid,thin,tzcdot=1.2pt ]<>(<m>){}[](1.2pt) % tzcdot is a predefined key (in this package). -% (<m>): mandatory +% <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|. +There are \textsc{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)|. +\item The simplest way is to use the \xem{last parenthesis option}, like |\tzcdot(0,0)(3pt)|. \begin{tztikz}{} \tzcdot(0,0) % is an abbreviation of: @@ -206,7 +207,7 @@ If both the |tzcdot| key-value and the last parenthesis option are used, the for \end{tzcode} \item -Another way to change the radius is to use a macro, like |\settzcdotradius{3pt}|, +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} @@ -223,8 +224,7 @@ It is effective within the |tizpicture| environment unless changed by \icmd{\set \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.) +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>]|. \begin{tztikz}{} \tzcdot(0,0){A} % is an abbreviation of: @@ -246,14 +246,14 @@ You can add a label to a specified coordinate by adding the optional argument |{ \end{tikzpicture} \end{tzcode} -The label position does not depend on the size of circle dots. +In \Tikz, the distance from the coordinate center to a label does not depend on the size of circle dots. \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(*) +% \tzcdot(*): color, fill \begin{tikzpicture} \draw [help lines] (0,0) grid (4,3); \tzcdot(0,0){A} @@ -266,7 +266,7 @@ You can also change the color of a label, as shown in the following example. \paragraph{Shift} -Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed. +Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcdot: shift @@ -298,18 +298,17 @@ Dots can be shifted by specifying the optional argument |<shift coor>| immediate \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. +The macro \icmd{\tzcdots} takes an \xem{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} macro. \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 `|(|' work like the semicolon `|;|' to indicate the end of iteration. - But it is highly recommended to use `|;|' for consistency. - \end{itemize} -\item Without the semicolon |;|, the macro does nothing or a compile error occurs. +\item Without the semicolon |;|, an error occurs with the the \iisw{error message}: + \begin{verbatim} + ! Package tzplot Error: You may have forgotten a semicolon here or above! + \end{verbatim} \end{itemize} @@ -330,13 +329,13 @@ The starred version |\tzcdots*| prints multiple filled dots. \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); +\tzcdots*(0,3)(1,2)(2,2)(3,3)(4,3); % semicolon \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>]|. +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>]|. In \Tikz, |<angle>| can have the label option like |<[label opt]angle>|. \begin{tzcode}{.3} % \tzcdots: label @@ -346,14 +345,14 @@ Each coordinate can be followed by the optional arguments |{<label>}| and |[<ang (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); + (4,0){E}[[red,draw]45]; +\tzcdots*(0,3)(1,2){B}[-135](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. +There are \textsc{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]...|. @@ -431,7 +430,7 @@ The starred version \icmd{\tzdot*} prints a filled dot \tikz \tzdot*(0,0);. |\tzdot(*)| accepts one mandatory argument, denoted by |(|\ixxw{<m>}|)|. All others are optional. -The style \ixxw{tzdot} is defined as follows: +The style \ixxw{tzdot} is predefined in this package as follows: \begin{tzsty}{} % style: tzdot @@ -457,7 +456,7 @@ There are \iscw{Three Ways} to change the \xem{diameter} (or |minimum size|) of \node [tzdot,minimum size=2.4pt] at (0,0) {}; \end{tztikz} -\item The simplest way is to use the \xem{last} parenthesis optional argument, like |\tzdot(0,0)(5pt)|, which yields the same result as in |\tzdot[tzdot=5pt](0,0)|. +\item The simplest way is to use the \xem{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} @@ -469,7 +468,7 @@ If both options are used, the |tzdot| (or |minimum size|) option overwrites the \end{tikzpicture} \end{tzcode} -\item To change the size of all node dots drawn by |\tzdot*|, you can use the macro |\settzdotsize|. Its effect remains valid until the end of |tikzpicture| environment unless changed again. +\item You can use the macro |\settzdotsize| to change the size (or diameter) of all node dots drawn by |\tzdot*|. It is effective within the |tikzpicture| environment unless changed again. \begin{tzcode}{.3} % \settzdotsize @@ -487,8 +486,7 @@ If both options are used, the |tzdot| (or |minimum size|) option overwrites the \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>}|. +You can also change the label position by the option |[<angle>]| or |[<[label opt]angle>]| following |{<label>}|. \begin{tztikz}{} \tzdot(0,0){A}(3pt) % works like: @@ -507,10 +505,18 @@ You can also change the label position by the option |[<angle>]| following |{<la \tzdot(1,1){B}[0](8pt) \tzdot*(2,1){C}[45](4pt) \tzdot*(3,0){D}[-90](6pt) -\tzdot(4,3){E}[-90](12pt) +\tzdot(4,3){E}[[red,draw]br](12pt) % string replacement \end{tikzpicture} \end{tzcode} +\paragraph{String replacement} +(See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement}.) +\begin{itemize}\firmlist +\item In \Tikz, to place labels you can use |<angle>| or the positional words such as |[above]|, |[below]|, |[center]| (\xem{not} |[centered]| for the main node option), |[below right]|, and so on. +\item \xem{Just to avoid frequent coding errors}, from the version 2 of the |tzplot| package, you can use the abridged strings |[a]|, |[b]|, |[c]|, |[br]|, and so on. +\item So |[[blue,draw]-45]|, |[[blue,draw]below right]|, and |[[blue,draw]br]| give the same result. +\end{itemize} + Unlike |\tzcdot|, the |\tzdot|'s label position depends on the size of a circle node. In \Tikz\ jargon, |{<label>}| is in a \iisw{label node} for a \iisw{main node} that is a circle node with no text in it, so |<label>| moves accordingly as the main node dot gets bigger or smaller. @@ -520,10 +526,10 @@ Unlike |\tzcdot|, the |\tzdot|'s label position depends on the size of a circle 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 following example. -\remark -\begin{itemize} +\remark +\begin{itemize}\firmlist \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>]|. +\item |[<label opt>]| is used in the form of |[<[<label opt>]angle>]|. \end{itemize} \begin{tzcode}{.3} @@ -545,7 +551,7 @@ You can also change the label color using |[<label opt>]| as shown in the follow \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*[red,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} @@ -564,7 +570,7 @@ Dots can be shifted by specifying the optional argument |<shift coor>| immediate \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*[red,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} @@ -611,7 +617,7 @@ circle \tzcdot \tzcdots \settzcdotradius [tzcdot=1.2pt] % radius \end{tzcode} \remark -\begin{itemize} +\begin{itemize}\firmlist \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} @@ -634,13 +640,12 @@ So, you can apply the \threeways\ (on page \pageref{ss:threeways}) to change the This is a \iisw{semicolon version} macro, with the repeating pattern |(<coor>){<label>}[<angle>]|, which means that you need to type a \xem{semicolon} `|;|' at the end of the coordinate repetition. The \xem{semicolon} says, ``\xem{The repetition ends here}." \remark -\begin{itemize} +\begin{itemize}\firmlist \item DO NOT FORGET to enter `|;|' at the end of iteration. - \begin{itemize} - \item Tokens such as `|!|' and `|#|' other than the open parenthesis `|(|' work like the semicolon `|;|' to indicate the end of iteration. - But it is highly recommended to use `|;|' for consistency. - \end{itemize} -\item Without the semicolon |;|, the macro does nothing or a compile error occurs. +\item Without the semicolon |;|, an error occurs with the error message: + \begin{verbatim} + ! Package tzplot Error: You may have forgotten a semicolon here or above! + \end{verbatim} \end{itemize} The starred version \icmd{\tzdots*} prints multiple filled node dots. @@ -660,13 +665,14 @@ The starred version \icmd{\tzdots*} prints multiple filled node dots. \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); +\tzdots*(0,3)(1,2)(2,2)(3,3)(4,3); % semicolon \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. +(To avoid frequent coding errors, you can also use \xem{string replacement} instead of angles. See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement} \begin{tzcode}{.3} % \tzdots: label @@ -675,13 +681,14 @@ Each coordinate can be followed by the optional arguments |{<label>}| and |[<ang \tzdots(0,0){A} (1,1) (2,1){C}[0] - (3,2){D}[-90] + (3,2){D}[b] % string replacement (4,0){E}; \tzdots*(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 \threeways\ of changing the \xem{diameter} of node dots, as discussed in Section \ref{ss:threeways} on page \pageref{ss:threeways}. @@ -730,7 +737,7 @@ You can also change the color of each label by |[<label opt>]|. \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 |[<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 examples: \end{itemize} @@ -763,7 +770,7 @@ You can also change the color of each label by |[<label opt>]|. \paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzdots: shift @@ -776,6 +783,7 @@ The empty shift option |<>| is not allowed. \end{tzcode} + %%================================== \chapter{Coordinates} \label{c:coordinates} @@ -829,7 +837,7 @@ You can put a label to a coordinate by specifying the optional arguments |{<labe \paragraph{Shift} You can move the coordinate by specifying the optional argument |<shift coor>| before |(<coor>)|. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoor: shift @@ -893,14 +901,14 @@ To change the size of dots, you can apply the \threeways\ (see Subsection \ref{s \tzhelplines(4,3) \tzcoor(1,1)(A){A} \tzcoor*(2,1)(B){B}[0] -\tzcoor*[red](1,2)(C){C}[180] +\tzcoor*[red](1,2)(C){C}[[blue,draw]l] % abb \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|. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoor*: shift @@ -919,7 +927,7 @@ The empty shift option |<>| is not allowed. \subsection{\protect\cmd{\tzcoors}} \label{ss:tzcoors} -The macro \icmd{\tzcoors} takes an arbitrary number of pairs of coordinates and their names as arguments. +The macro \icmd{\tzcoors} takes an \xem{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 the coordinate |(0,0)| is represented by the name |(A)|, |(1,1)| by |(B)|, and |(2,2)| by |(C)|. \begin{tzdef}{} @@ -965,7 +973,7 @@ You can add a label to each specified coordinate by adding the optional argument \end{tzcode} By the option |<shift coor>|, all specified coordinates are shifted. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoors @@ -979,10 +987,14 @@ The empty shift option |<>| is not allowed. \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. +The starred version \icmd{\tzcoors*} takes an \xem{arbitrary number of pairs} of coordinates and names as mandatory arguments to print node dots at the coordinates. + +The 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 @@ -1003,7 +1015,7 @@ You can label each dot by specifying the optional arguments |{<label>}| and |[<a \tzcoors*(0,0)(A) (1,1)(B){B} (2,1)(C) - (3,3)(D){D}[0] ; + (3,3)(D){D}[0] ; % semicolon \end{tikzpicture} \end{tzcode} @@ -1022,7 +1034,7 @@ You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the dot \end{tzcode} By specifying the optional argument |<shift coor>| immediately before the first coordinate, you can move all specified coordinates. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoors*: shift @@ -1037,13 +1049,13 @@ The empty shift option |<>| is not allowed. %%------------------------------------------------------------ -\section{\protect\cmd{\tzcoorsquick} and \protect\cmd{\tzcoorsquick*}} +\section{\protect\cmd{\tzcoorsquick} and \protect\cmd{\tzcoorsquick*}: Semicolon versions} \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. +You can see the coordinate array at a glance using \icmd{\tzcoorsquick}, which displays specified names as text at the |center| (by default) of the coordinates. \begin{tzdef}{} % syntax: minimum @@ -1062,12 +1074,12 @@ You can see the coordinate array at a glance using \icmd{\tzcoorsquick}, which d \tzcoorsquick(0,0)(A) (1,1)(Ben) (2,1)(Cate) - (3,2)(Daniel); + (3,2)(Daniel); % semicolon \end{tikzpicture} \end{tzcode} A label can be suppressed by the empty braces |{}|. -You can move the coordinates by specifying |<shift coor>| immediately before the first coordinate. The empty option |<>| is not allowed. +You can move the coordinates by specifying |<shift coor>| immediately before the first coordinate. The \xem{empty} option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoorsquick: shift, color @@ -1108,7 +1120,7 @@ The starred version \icmd{\tzcoorsquick*} prints node dots on the coordinates an 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. The empty shift option |<>| is not allowed. +You can shift the coordinate by specifying |<shift coor>| immediately before the first coordinate. The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzcoorsquick*: size, color, shift @@ -1123,16 +1135,17 @@ You can shift the coordinate by specifying |<shift coor>| immediately before the \end{tzcode} \remark -The first optional argument of |\tzcoorsquick*| is for only dots. +The first optional argument |[<dot opt>]| 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}] +% \tzcoorsquick*: every label/.style +\begin{tikzpicture} \tzhelplines(4,3) +\tikzset{every label/.style={draw,red}} %% \tzcoorsquick*[fill=none,blue,very thick] - (0,0)(A)(1,1)(B-1)(2,1)(C)(3,3)(D)[[blue]0];(8pt) + (0,0)(A)(1,1)(B-1)(2,1)(C)(3,3)(D)[[blue]-45];(8pt) \end{tikzpicture} \end{tzcode} @@ -1176,7 +1189,8 @@ For example, |\tzgetxyval(3,2){\xval}{\yval}| results in |\xval=3| and |\yval=2| \section{\protect\cmd{\tzplot} and \protect\cmd{\tzplot*}: Syntax} \label{s:tzplot} -\icmd{\tzplot} takes an arbitrary number of coordinates as arguments. +\icmd{\tzplot} takes an \xem{arbitrary number of coordinates} as arguments. Internally, |\tzplot| uses the |plot coordinates| operation of |\Tikz|. + 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. @@ -1193,8 +1207,13 @@ The macro |\tzplot| draws connected line segments that link specified coordinate (){}[] ; (<mark size>) <code.append> % defaults [tzmark=2pt]{0}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <> + - [<plot opt>] is [smooth] by default + - It can be changed to [smooth cycle] \end{tzdef} +The starred version |\tzplot*| prints dot marks at specified coordinates, without drawing line segments connecting the coordinates, by default. + +|\tzplot*| is equivalent to |\tzplot[draw=none,mark=*]|. The style \ixxw{tzmark} is defined as follows: \begin{tzsty}{} @@ -1210,8 +1229,6 @@ The style \ixxw{tzmark} is defined as follows: The value of |\tzmarksize| can be changed by the macro \icmd{\settzmarksize}, like |\settzmarksize{3pt}|. -The starred version |\tzplot*| prints dot marks at specified coordinates, without drawing line segments connecting the coordinates, by default. - %%------------------------------------------------------------ @@ -1232,7 +1249,7 @@ You can change the mark color and mark style using the first bracket optional ar \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*[mark=o](0,3)(1,3)(2,2)(3,1) ; % semicolon \tzplot*[red](0,2)(1,2)(2,0)(3,2); \end{tikzpicture} \end{tzcode} @@ -1243,11 +1260,11 @@ You can also add labels to specified coordinates with the optional arguments |{< \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}] {} ; + (0,0) node [label={90:A}] {} + (3,3) node [label={0:D}] {} ; \end{tztikz} -There are three ways to change the mark size. +There are \textsc{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}. @@ -1259,13 +1276,26 @@ There are three ways to change the mark size. % \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*(0,0){A}[-135](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} +\remark You can use strings such as |a|, |b|, |ar|, and so on, instead of angles, from the version 2 of the |tzplot| package. These strings are replaced by the corresponding positioning words such as |above|, |below|, |above right|, and so on. (See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement} for more details.) + +\begin{tzcode}{.3} +% \tzplot*: label: strings instead of angles +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzplot*(0,0){A}[bl](1,1)(2,1)(3,3){D}[[blue]r];(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]r](3,2){D}; +\end{tikzpicture} +\end{tzcode} + With |\tzplot*|, you can draw line segments by giving the \Tikz's option |draw| in the first bracket optional argument, like |\tzplot*[draw]|. \begin{tzcode}{.3} @@ -1273,9 +1303,12 @@ With |\tzplot*|, you can draw line segments by giving the \Tikz's option |draw| \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); +\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} @@ -1286,26 +1319,56 @@ With |\tzplot*|, you can draw line segments by giving the \Tikz's option |draw| \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); +\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). -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. + \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]; +\tzcoors(1,3)(A)(2,3)(B)(3,3)(C)(4,3)(D); +\tzplot*[draw] (A){A}(B)(C)(D){D}[0]; +\tzplot*[draw,red]<-1,-1>(A){A}(B)(C)(D){D}[0]; +\tzplot*[draw,blue]<0,-3>(A){A}(B)(C)(D){D}[0]; \end{tikzpicture} \end{tzcode} +\paragraph{Extending path} +You can use |<code.append>| as the last optional argument after a semicolon. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplot*[draw](0,0)(1,1)(2,2){C}(3,2){D}; + < arc (-90:0:1cm) node [a] {ends here!}> +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzplotAtBegin} and \icmd{\tzplotAtEnd} are also available. +These work with |\tzplot*[draw]| and |\tzplot| to extend the paths at the beginning and at the end, respectively. Specifying |<code.append>| extends the path after |\tzplotAtEnd|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotAtBegin{(0,2) to [bend right]} +\tzplotAtEnd{arc (90:0:1cm) node [b] {here?}} +\tzplot*[draw,blue](0,0)(1,1)(2,2){C}(3,2){D}; + <arc (-90:0:1cm) node [r] {ends here!}> +\tzplot*[draw,red]<.5,1>(0,0)(1,1)(2,2){C}(3,2){D}; + <arc (-90:0:1cm) node [r] {ends here!}> +\end{tikzpicture} +\end{tzcode} %%------------------------------------------------------------ @@ -1315,11 +1378,14 @@ The empty shift option |<>| is not allowed. |\tzplot| draws connected line segments connecting specified coordinates. (By default, |tension=0|.) + \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} +|\tzplot*| is equivalent to |\tzplot[draw=none,mark=*]|. + \paragraph{Options: draw, mark, mark options, etc.} You can use the optional argument |[<opt>]| to change the style of lines and marks. @@ -1345,7 +1411,7 @@ To close the path of |\tzplot| you can use the option |smooth cycle| in the firs \tzplot[dashed,mark=o,smooth cycle] (0,3)(1,3)(2,2)(3,1); \tzplot[red,mark=*,mark options={blue}] - [smooth cycle] %% + [smooth cycle] %% default tension=0 (0,1)(1,2)(2,0)(3,2); \end{tikzpicture} \end{tzcode} @@ -1366,13 +1432,14 @@ To close the path of |\tzplot| you can use the option |smooth cycle| in the firs \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). -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \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]; +\tzcoors(0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D); +\tzplot <1,0>(A)(B)(C)(D){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} @@ -1409,6 +1476,8 @@ In order to \xem{extend a path}, formed by |\tzplot|, \xem{from the last coordin \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzplotAtBegin} and \icmd{\tzplotAtEnd} to extend the path of |\tzplot| at the beginning and at end, respectively. Specifying |<code.append>| extends the path after |\tzploAtEnd|. + %%------------------------------------------------------------ \section{\protect\cmd{\tzplot}: Curves} @@ -1427,7 +1496,7 @@ You can draw a curve with |\tzplot|, by specifying the optional argument |{<tens \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} +\tzplot*[draw,red,smooth cycle]{1} % tension=1 (0,1)(1,2)(2,0)(3,2); \end{tikzpicture} \end{tzcode} @@ -1448,7 +1517,7 @@ With |\tzplot|, you can draw bars or combs, using the \Tikz\ options |ybar|, |xb \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) +\tzplot[dashed,red,mark=heart](0,1)(1,2)(2,0)(3,2); \end{tikzpicture} \end{tzcode} @@ -1496,7 +1565,7 @@ Do not use |<shift coor>| for plotting bars or combs to avoid getting unexpected %\end{tzcode} \item -It can be a mess when using the \Tikz\ option |shift={(coor)}| with the type of mixed coordinates: native and named coordinates. +It can be a mess when using the \Tikz\ option |shift={(coor)}| with the type of \xem{mixed} coordinates: \xem{native} and \xem{named} coordinates. %\begin{tzcode}{.3} %% \tzplot(*) @@ -1523,7 +1592,7 @@ It can be a mess when using the \Tikz\ option |shift={(coor)}| with the type of \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]|. +Basically, this is equivalent to |\tzplot*[draw,tension=1]|. \begin{tzdef}{} % syntax: minimum @@ -1587,6 +1656,16 @@ To close the path of |\tzplotcurve|, you can use the \Tikz\ option |smooth cycle \end{tikzpicture} \end{tzcode} +\begin{tzcode}{.3} +% abridges strings: label position +\begin{tikzpicture} +\tzhelplines(4,3) +\tzplotcurve*[red,text=blue][smooth cycle] + (0,0)(1,2){B}[[red]l](2,2)(3,3)(4,1){E}[[draw]r];(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 of |tension| (|tension=1| by default) by specifying the option |{<tension>}| before the coordinates or between the two bracket options if they exist. @@ -1603,15 +1682,16 @@ You can change the value of |tension| (|tension=1| by default) by specifying the \end{tzcode} -\paragraph{Shift} Use the optional argument |<shift coor>| before the first coordinate (to be precise, immediately before |"<path name>"|, if exists). +\paragraph{Shift} Use the optional argument |<shift coor>| before the first coordinate (to be precise, immediately before |"<path name>"|, if it exists). The empty shift option |<>| is not allowed. \begin{tzcode}{.3} % \tzplotcurve(*): shift \begin{tikzpicture} \tzhelplines(4,3) +\tzcoors(0,0)(A)(1,2)(B)(2,2)(C)(3,3)(D)(4,1)(E); \tzplotcurve*[red,text=blue,smooth cycle] - <0,1>(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %% + <0,1>(A)(B){B}(C)(D)(E){E}[0];(3pt) %% \tzplotcurve*[smooth cycle] (1,.5)(2,3)(3,2)(2,1)(3,1); \end{tikzpicture} @@ -1646,6 +1726,21 @@ You can also use |<--cycle>| to \xem{close} the path \xem{with a straight line} \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzplotcurveAtBegin} and \icmd{\tzplotcurveAtEnd} to extend the path of |\tzplotcurve| at the beginning and at the end, respectively. +Specifying |<code.append>| extends the path after |\tzplotcurveAtEnd|. + +\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]; +\tzplotcurveAtBegin{(0,2) |-} +\tzplotcurveAtEnd{arc (180:270:1cm) node {End!}} +\tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1); +\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. @@ -1672,8 +1767,8 @@ You can name the path of |\tzplotcurve| by specifying the option |"<path name>"| \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 \iisw{node coordinate} later. +The macro \icmd{\tznode} allows you to put \xem{text} at a specified \xem{coordinate}. |\tznode| expects two mandatory arguments: |(<coor>)| and |{<text>}|. +You can also \xem{optionally} name a node so that you can refer to the \iisw{node coordinate} later. The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draws the perimeter of the specified node. The default node shape is a |rectangle|. @@ -1681,9 +1776,9 @@ The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draw % syntax: minimal \tznode(<coor>){<text>} % syntax: full -\tznode[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>] -% defaults - []<>(<m>)(){}[] +\tznode[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]<node.code> +% defaults: two mandatory arguments + []<>(<m>)(){<m>}[]<> \end{tzdef} \begin{tztikz}{} @@ -1698,13 +1793,13 @@ The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draw \node [draw] (A) at (0,0) [above right] {text}; \end{tztikz} -|\tznode*| prints the perimeter of a node, which is a |rectangular| by default. +|\tznode*| prints the perimeter of a node, which is a |rectangle| by default. \begin{tzdef}{} % syntax: minimal \tznode*(<coor>){<text>} % syntax: full -\tznode*[<opt>]<shift coor>(<coor>)(<name>){<text>}[<node opt>]<code.append> +\tznode*[<opt>]<shift coor>(<coor>)(<name>){<text>}[<node opt>]<node.code> % defaults *[draw]<>(<m>)(){}[]<> \end{tzdef} @@ -1728,17 +1823,14 @@ The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draw \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. (See also Section \ref{s:stylenames} on page \pageref{s:stylenames}.) +\paragraph{Abbreviations} You can use \xem{abbreviations} (or aliases) 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. (See also Section \ref{s:stylenames} on page \pageref{s:stylenames}.) \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}. +\remark +\begin{itemize}\firmlist +\item A \iisw{label node} is placed by angles or the corresponding positioning words. +\item A \iisw{main node} is placed by the placement words or their aliases. +\item You cannot use angles to place main nodes. \end{itemize} \end{quote} @@ -1790,15 +1882,144 @@ The empty shift option |<>| is not allowed. \end{tzcode} +\paragraph{Repetition: \texttt{foreach}} +The \xem{last} optional argument |<node.code>| can be used to iterate over to place multiple nodes. + +\begin{tzcode}{.3} +% \tznode(*): foreach, shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tznode(\x,0){\x} + < foreach \x in {1,2,3} > +\tznode*<1,2>(\x,0){\x}[circle,blue,fill=yellow] + < foreach \x in {1,2,3} > +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tznode(\x,0){\x}<foreach \x in {1,2,3}> % works like + \node foreach \x in {1,2,3} at (\x,0) {\x}; +\end{tztikz} + +\begin{tzcode}{.3} +% \tznode: foreach +\begin{tikzpicture} +\tzhelplines(4,3) +\tznode(\x,\y){$P_{\x\y}$} + < foreach \x in {1,2,3,4} + foreach \y in {1,2,3} > +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodes} and \protect\cmd{\tznodes*}: Semicolon versions} +\label{s:tznodes} + +\icmd{\tznodes} accepts any number of \xem{mandatory} pairs of coordinates and their names to defined node coordinates at specified coordinates. + +\begin{tzdef}{} +% syntax: minimum +\tznodes(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ; +% syntax: medimum +\tznodes(<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ; +% syntax: full +\tznodes[<every node opt>]<shift coor> + (<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ; +% defaults + [] <> (<m>)(<m>){}[]..repeated..()(){}[] ; + *[draw]<> (<m>)(<m>){}[]..repeated..()(){}[] ; +\end{tzdef} + +Each pair of a coordinate and a node coordinate name can be followed by the optional arguments |{<text>}| and |[<node opt>]| to print node text. +Since this is a semicolon version, it is required to type a semicolon |;| to indicate when the repetition ends. +|\tznodes| works similarly to |\tzcoors|, but the former uses main nodes and the latter uses label nodes. + +The starred version \icmd{\tznodes*} is equivalent to |\tznodes[draw]|. That is, all node perimeters are drawn. + +\begin{tzcode}{.3} +% \tznodes +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodes(0,0)(A){A} + (1,1)(B){B} + (2,1)(C){C}[r] + (3,2)(D){D}[b] + (4,0)(E){E}; % semicolon +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzdef}{} +% syntax: minimum +\tznodes(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ; +% syntax: medimum +\tznodes(<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ; +% syntax: full +\tznodes[<every node opt>]<shift coor> + (<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ; +% defaults + [] <> (<m>)(<m>){}[]..repeated..()(){}[] ; + *[draw]<> (<m>)(<m>){}[]..repeated..()(){}[] ; +\end{tzdef} + + + +\begin{tzcode}{.3} +% \tznodes*: retangle nodes (default) +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodes*(0,0)(A){A} + (1,1)(B){B} + (2,1)(C){C}[r] + (3,2)(D){D}[b] + (4,0)(E){E}; % semincolon +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tznodes*: ellipse nodes +\begin{tikzpicture} +\tzhelplines*(5,4) +\tznodes*[ellipse,fill=yellow,text=blue] + (0,0)(A){Ann} + (1,1)(B){Bryn} + (2,0)(C){C}[r] + (3,2)(D){Donald}[b,font=\scshape] + (4,0)(E){End!}[rectangle,fill=green]; +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tznodes: shift +\begin{tikzpicture} +\tzhelplines*(5,4) +\tznodes*[ellipse,fill=yellow,text=blue] + <1,1>(0,0)(A){Ann} + (1,1)(B){Bryn} + (2,0)(C){C}[r] + (3,2)(D){Donald}[b,font=\scshape] + (4,0)(E){End!}[rectangle,fill=green]; +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + + %%------------------------------------------------------------ \section{\protect\cmd{\tznodedot(*)}} \label{s:tznodedot} -\icmd{\tznodedot} names a node and prints a circle node dot. +\icmd{\tznodedot} names a node and prints a circle node dot (of the size |2.4pt|, by default). |\tznodedot| is basically 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. +The starred version \icmd{\tznodedot*} prints a filled circle node dot (of the size |2.4pt|, by default), just like |\tzdot*|. But it \xem{optionally} names a node. \begin{tzdef}{} % syntax: medium @@ -1807,15 +2028,22 @@ The starred version \icmd{\tznodedot*} prints a filled circle node dot (of the s \tznodedot*[<opt>]<shift coor> (<coor>)(<node name>){<label>}[<[label opt]angle>] (<dot size>) % defaults - *[]<>(<m>)(){}[](2.4pt) + [tzdot] <>(<m>)(){}[](2.4pt) + *[tzdot,fill]<>(<m>)(){}[](2.4pt) \end{tzdef} Since |\tznodedot(*)| prints a node dot, its |<label>| is placed by |<angle>|. +\begin{tztikz}{} +\tznodedot*(1,1)(A){Ace}[180] % works like: + \path (1,1) node (A) [tzdot,fill,label={180:Ace}] {} ; +\end{tztikz} + \begin{tzcode}{.3} % \tznodedot(*): label, color \begin{tikzpicture} \tzhelplines(4,3) +\tznodedot(0,0) \tznodedot(1,1)(A){A}[180] \tznodedot*(2,3)(B){\textbf{B}} \tznodedot[rectangle](4,1)(C){C}[[red]0] @@ -1857,6 +2085,118 @@ The empty shift option |<>| is not allowed. \end{tikzpicture} \end{tzcode} +You can use the abridges strings instead of angles. (See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement}.) + +\begin{tzcode}{.3} +% abridged strings: label position +\begin{tikzpicture} +\tzhelplines(4,3) +\settzdotsize{5pt} +\tznodedot(1,1)(A){A}[[draw,blue]l] +\tznodedot*(2,3)(B){B} +\tznodedot[rectangle]<-1,-1>(4,1)(C){C}[br](10pt) %% +\tzline[->](A)(B) +\tzto[->,bend left,dashed](B)(C) +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tznodedots(*)}: Semicolon versions} +\label{s:tznodedots} + +\icmd{\tznodedots} accepts any number of \xem{mandatory} pairs of coordinates and their names to print multiple node circle dots at specified coordinates. +It works just like |\tzdots|, for one exception. It names multiple node coordinates. +Everything else is the same as in |\tzdots|. + +The starred version \icmd{\tznodedots*} prints filled node circle dots. + +\begin{tzdef}{} +% syntax: minimum +\tznodedots(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ; +% syntax: full +\tznodedots[<dot opt>]<shift coor> + (<coor>)(<node name>){<label>}[<[label opt]angle>] + ..repeated.. ()(){}[] ; (<dot size>) +% defaults + [tzdot=2.4pt] <> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt) + *[tzdot=2.4pt,fill]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt) +\end{tzdef} + + + +\begin{tzcode}{.3} +% \tznodedots: label +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodedots(0,0)(A){A} + (1,1)(B) + (2,1)(C){C}[0] + (3,2)(D){D}[-90] + (4,0)(E){E} ; % semicolon +\tzlines[red](A)(B)(C)(D)(E); +\tznodedots* + (0,3)(A)(1,2)(B){B}(2,2)(C){C}[45](3,3)(D)(4,3)(E); +\tzlines(A)(B)(C)(D)(E); +\end{tikzpicture} +\end{tzcode} + + + +The simple first bracket option of |\tznodedots(*)| controls dots rather than labels. +If you want to control all the labels, you can use \Tikz's |every label| style as follows: + +\begin{tzcode}{.3} +% every label/.style +\begin{tikzpicture} +\tzhelplines(4,3) +\begin{scope}[every label/.style={draw,text=red}] +\tznodedots*[green] + (0,0)(Ace){Ace}[[font=\LARGE\ttfamily]-90] + (2,1)(Bob){\textbf{Bob}}[[blue]135] + (3,2)(Cate){$C_1$\\$N_o$}[[align=center]0] + (4,0)(D){Done!};(5pt) +\end{scope} +\end{tikzpicture} +\end{tzcode} + + + +\remark Comparison of connecting nodes and coordinates: + + +\begin{tzcode}{.3} +% connecting \tznodedots +\begin{tikzpicture} +\tzhelplines(4,3) +\tznodedots(0,0)(A){A} + (1,1)(B) + (2,1)(C){C}[[red]-90] + (3,2)(D){D}[[draw,blue]a] + (4,0)(E){E}; (6pt) +\tzlines[thick](A)(B)(C)(D)(E); % connects nodes +\end{tikzpicture} +\end{tzcode} + +While the previous example shows that |\tzlines| connects nodes, +the following example shows that |\tzlines| connects coordinates. + + +\begin{tzcode}{.3} +% connecting \tzcoors +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*[fill=none](0,0)(A){A} + (1,1)(B) + (2,1)(C){C}[[red]-90] + (3,2)(D){D}[[draw,blue]a] + (4,0)(E){E}; (6pt) +\tzlines[thick](A)(B)(C)(D)(E); % connects coordinates +\end{tikzpicture} +\end{tzcode} + @@ -1864,7 +2204,7 @@ The empty shift option |<>| is not allowed. \section{\protect\cmd{\tznodeframe} and \protect\cmd{\tznodeframe*}} \label{s:tznodeframe} -\icmd{\tznodeframe} draws and names a rectangle node with text in it. +\icmd{\tznodeframe} draws and \xem{optionally} names a rectangle node with (black, by default) text in it. %\icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|. @@ -1872,9 +2212,14 @@ The empty shift option |<>| is not allowed. % syntax: \tznodeframe[<opt>](<coor>)(<node name>){<text>}[<node opt>] % defaults - []<>(<m>)(){}[text=black] + [draw]<>(<m>)(){}[text=black] \end{tzdef} +\begin{tztikz}{} +\tznodeframe(2,1)(A){Here}[a] % works like + \node [draw,rectangle] (A) at (2,1) [above] {Here} ; +\end{tztikz} + \begin{tzcode}{.3} % \tznodeframe @@ -1901,7 +2246,7 @@ The empty shift option |<>| is not allowed. \end{tikzpicture} \end{tzcode} -The starred version |\tznodeframe*| fills the rectangle with color (|black!50| by default) with |fill opacity=.3| but with |text opacity=1|, by default. +The starred version |\tznodeframe*| fills the rectangle with color (|black!50| by default) with |fill opacity=.3| and |text opacity=1|, by default. %\icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|. @@ -1930,18 +2275,23 @@ While |\tznode*| draws the perimeter of a node, |\tznodeframe*| fills a node wit \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. -(The empty shift coor |<>| is not allowed.) +\icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|. +\icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|. + + +You can change the |fill opacity| of \icmd{\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. +(The \xem{empty} shift option |<>| is \xem{not allowed}.) + \begin{tzcode}{.3} % \tznodeframe(*): opacity, shift \begin{tikzpicture} \tzhelplines[solid](4,3) \tznodebox(0,0) -\tznodeframe*(1,2)(A){A}{.1} % opacity +\tznoderectangle*(1,2)(A){A}{.1} % opacity \tznodeframe[fill=yellow](2,2)(B){B} \tznodeframe*[red](3,2)(C){Cat} -\tznodeframe[fill=green]<-1,-2>(4,2)(D){Dog} % shift +\tznodebox[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} @@ -1967,7 +2317,7 @@ The default fill color is |black!50|. You can use the macro \icmd{\settzfillcolo % syntax \tznodecircle[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>] % defaults - [circle]<>(<m>)(){}[text=black] + [draw,circle]<>(<m>)(){}[text=black] \end{tzdef} \icmd{\tznodecircle*} works just like |\tznodeframe*| but with a circle node. @@ -1987,14 +2337,14 @@ The default fill color is |black!50|. You can use the macro \icmd{\settzfillcolo \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} +\tzline[red,thick](A)(B) +\tznodecircle[blue,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. -(The empty shift coor |<>| is not allowed.) +The \xem{empty} shift coordinate option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % opacity, shift @@ -2036,6 +2386,7 @@ The starred version \icmd{\tznodeellipse*} works just like |\tznodeframe*| but w (<m>)(){}[draw=black,text=black]{.3} \end{tzdef} + \begin{tzcode}{.3} % \tznodeellipse \begin{tikzpicture} @@ -2049,16 +2400,18 @@ The starred version \icmd{\tznodeellipse*} works just like |\tznodeframe*| but w \end{tikzpicture} \end{tzcode} +\icmd{\tznodeoval} and \icmd{\tznodeoval*} are aliases of |\tznodeellipse| and |\tznodeellipse*|, respectively. + 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. -(The empty shift coor |<>| is not allowed.) +The \xem{empty} shift option |<>| is \xem{not allowed}. \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} +\tznodeoval*(1,2)(A){A}{.1} % opacity +\tznodeoval[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) @@ -2113,7 +2466,7 @@ You can use the first optional argument |[<opt>]| to control the line styles. \begin{tikzpicture} \tzhelplines(4,3) \tzline[blue,->](0,0)(3,3) -\tzline[*-o](0,2)(3,0) +\tzline[<->](0,2)(3,0) \tzline[dashed](1,2)(4,0) \tzdots*(1,2)(4,0); \end{tikzpicture} @@ -2137,12 +2490,12 @@ With the options |{<text1>}[<node opt1>]| \xem{in-between} two coordinates, you \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[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. (For more details, see page \pageref{abbreviations}.) +You can use the \xem{abbreviations} (or aliases) of \Tikz\ basic placement options such as |a| for |above|, |bl| for |below left|, and so on. (For more details, see page \pageref{abbreviations}.) \paragraph{Text at or around the last coordinate} @@ -2150,7 +2503,7 @@ You can use the \xem{abbreviations} of \Tikz\ basic placement options such as |a You can also add text at (by default) or around the second coordinate by specifying |{<text2>}| and |[<node opt2>]| immediately \xem{after} the second coordinate. \begin{tztikz}{} -\tzline[blue](0,1)(2,1){my line}[right] % works like: +\tzline[blue](0,1)(2,1){my line}[r] % works like: \draw [blue] (0,1) -- (2,1) node [right] {my line}; \end{tztikz} @@ -2160,7 +2513,7 @@ You can also add text at (by default) or around the second coordinate by specify \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[<->](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} @@ -2182,7 +2535,7 @@ You can also add text at (by default) or around the second coordinate by specify %\begin{tikzpicture} %\tzhelplines(4,3) %\tzline[blue,->](0,0) (3,3) {A}[r] -%\tzline[*-o] (0,2){b} <+>(3,-2){B}[r] +%\tzline[<->] (0,2){b} <+>(3,-2){B}[r] %\tzline[dashed] (1,2){c}<++>(3,-2){C}[r] %\tzdots*(1,2)(4,0); %\end{tikzpicture} @@ -2195,7 +2548,7 @@ You can also add text at (by default) or around the second coordinate by specify %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}} +\subsection{Moving lines: \texttt{shift}} \label{ss:tzline:shift} You can move the line generated 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). @@ -2215,7 +2568,7 @@ The empty shift coor |<>| is not allowed. -\subsection{Extending the path} +\subsection{Extending paths} \label{ss:tzline:extendingpath} You can extend the path of |\tzline| from the last coordinate, by writing \Tikz\ code in the last optional argument |<code.append>|. @@ -2230,8 +2583,22 @@ You can extend the path of |\tzline| from the last coordinate, by writing \Tikz\ \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzlineAtBegin} and \icmd{\tzlineAtEnd} to extend a path of |\tzline| at the beginning and at end, respectively. +Specifying |<code.append>| extends the path after |\tzlineAtEnd|. + +\begin{tzcode}{.3} +% \tzline: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[blue,->](0,0)(3,3)<arc(0:-60:1cm)> +\tzlineAtBegin{(2,3) -|} +\tzlineAtEnd{ arc (-90:90:.5) node [a] {here?} } +\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} +\subsection{Naming paths: 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 of |[<opt>]|. @@ -2285,7 +2652,7 @@ The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| \begin{tikzpicture} \tzhelplines(4,3) \tzline+[blue,->](0,1)(3,2) {A}[r] -\tzline+[*-o] (0,2){b}(3,-2){B}[r] +\tzline+[<->] (0,2){b}(3,-2){B}[r] \tzline+[dashed]<1,0>(0,2){b}(3,-2){B}[r] \end{tikzpicture} \end{tzcode} @@ -2296,6 +2663,7 @@ The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| \begin{tikzpicture} \tzhelplines(4,3) \tzline+[blue,->] "dem" (0,0)(3,3){demand}[r] +\tzlineAtBegin{(0,1) to [bend left] } \tzline+[dashed,->]"supp"(1,2)(3,-2){supply}[ar] % intersection point \tzXpoint*{dem}{supp} @@ -2307,7 +2675,7 @@ The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| \section{Styles: \texttt{tzshorten} and \texttt{tzextend}} \label{s:tzshorten} -The styles \ixxw{tzshorten} and \ixxw{tzextend} are defined as follows. +The styles \ixxw{tzshorten} and \ixxw{tzextend} are defined as follows: \begin{tzsty}{} % tzshorten @@ -2382,7 +2750,7 @@ Use the first optional argument |[<opt>]| to control the style of the connected % \tzlines: line style \begin{tikzpicture} \tzhelplines(4,3) -\tzlines[blue,<->](0,1)(1,2)(3,1)(4,3); +\tzlines[blue,<->](0,1)(1,2)(3,1)(4,3); % semicolon \tzlines[dashed](0,0)(1,1)(2,1)(3,0); \end{tikzpicture} \end{tzcode} @@ -2441,6 +2809,7 @@ You can move the connected line by specifying |<shift coor>| before the first co \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. @@ -2459,8 +2828,10 @@ You can name the path of |\tzlines| by specifying the option |"<path name>"| imm \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>|. + + +\paragraph{Extending paths} +You can extend the path of |\tzlines| by writing \Tikz\ code in the \xem{last} (even \xem{after the semicolon}) optional argument |<code.append>|. \begin{tzcode}{.3} % \tzlines: <code.append> @@ -2494,6 +2865,27 @@ You can close the path with a straight line by |<--cycle>|. \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzlinesAtBegin} and \icmd{\tzlinesAtEnd} to extend a path of |\tzlines| at the beginning and at the end, respectively. +Specifying |<code.append>| extends the path after |\tzlinesAtEnd|, if it exists. + +\begin{tzcode}{.3} +% \tzlines: extending paths +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinesAtBegin{(1,3) to [bend right]} +\tzlinesAtEnd{arc(0:90:1cm)} +\tzlines[red,thick,<->,text=blue] + (0,1){Up} + (1,2){Down}[a,sloped] + (3,1){Up} + (4,3) ; +\tzlinesAtEnd{to[bend right] ++(2,2) node{Here!}} +\tzlines[dashed] + (0,0)(1,1)(2,1)(3,0){not here}[b]; + < -| ++(-1,-1) node [draw,b] {Ends here!!} > +\end{tikzpicture} +\end{tzcode} + %%------------------------------------------------------------ \section{\protect\cmd{\tzlines+}: Relative coordinates: Semicolon version} @@ -2507,6 +2899,8 @@ It is also required to enter a \xem{semicolon} to indicate when the coordinate i \begin{tzdef}{} +% syntax: minimum +\tzlines+ (<coor>)(<coor>) ..repeat.. (<coor>) ; % syntax: full \tzlines+[<opt>]<shift coor>"<path name>" (<coor>){<text>}[<node opt>] @@ -2550,1582 +2944,21 @@ It is also required to enter a \xem{semicolon} to indicate when the coordinate i -%%================================== -\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's |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[dashed](1,1)(3,2) % works like: - \draw [dashed] (1,1) to (3,2); -\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{in-between} the two coordinates. - -\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} - - -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 it exists. -(The empty shift option |<>| is not allowed.) - -\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's |to| operation. Since this is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate iteration ends. - -\begin{tzdef}{} -% syntax -\tztos[<opt>]<shift coor>"<path name>" - (<coor1>)[<to opt>]{<text>}[<node opt>]..repeated..()[]{}[] ; <code.append> -% defaults - []<>""(<m>)[]{}[]..repeated..()[]{}[]<> -\end{tzdef} - -The quadruple |(<coor>)[<to opt>]{<text>}[<node opt>]| is -the whole repeating pattern. -Here, |[<to opt>]| is for the options of \Tikz's |to| operation such as |[bend right]|, |[bend left]|, |[bend left=<angle>]|, |[out=<angle>,in=<angle>]| and so on. - -\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,in=45] (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 the options of \Tikz's |to| operation 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>]| \xem{in-between} coordinates or \xem{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>]|. - -\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 the option |"<path name">|, if any. -(The empty shift option |<>| is not allowed.) - \begin{tzcode}{.3} -% \tztos: shift +% \tzlines+: 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} for intersections} -You can name the path of |\tztos| by specifying |"<path name>"| immediately before the first mandatory coordinate. - -\begin{tzcode}{.3} -% \tztos: name path, 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 paths} -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}: Semicolon version} -\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 \iisw{semicolon version} macro, you need to enter a \xem{semicolon} `|;|' to indicate where the coordinate iteration ends. - - -\begin{tzdef}{} -% syntax: minimal -\tzpath (<coor>)(<coor>) ..repeated.. (<coor>) ; -% syntax: full -\tzpath{<path style>}[<opt>]<shift coor>"<path name>" - (<coor>)[<path style>]{<text>}[<node opt>] - ..repeated.. ()[]{}[] ; {<fill opacity>} <code.append> -% defaults: \tzpath - {to}[]<>"" (<m>)[]{}[] ..repeated.. ()[]{}[] ; {}<> -\end{tzdef} - -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. - - -\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{in-between} coordinates. \xem{Path extension operation} can be selected from `|--|', `|to|', `\verb+|-+', `\verb+-|+', etc. -You can use \xem{the first brace option} |{<path style>}| to change all the |<path style>| in-between coordinates. - - -\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} - -The default path style is `|to|' and can also be changed by \icmd{\settzpathstyle}, like, for example, |\settzpathstyle{--}|. The effect remains valid until the end of |tikzpicture| environment unless changed again. - -\begin{tzcode}{.3} -% \tzpath: \settzpathstyle -\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>|. -So |<--cycle>| closes the path with a straight line. - -\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} - -\section{\protect\cmd{\tzpath*}: Semicolon version} -\label{s:tzpath*} - -The starred version \icmd{\tzpath*} additionally fills the interior of |\tzpath| with |black!50| with |fill opacity=.3| and |text opacity=1|, by default. - -|\tzpath*| works like |\tzpath[fill=black!50,fill opacity=.3,text opacity=1]|. -You can change the defaults by \icmd{\settzfillcolor} and \icmd{\settzfillopacity}. - -\begin{tzdef}{} -% syntax: minimal -\tzpath*(<coor>)(<coor>) ..repeated.. (<coor>) ; {<fill opacity>} -% syntax: full -\tzpath*{<path style>}[<opt>]<shift coor>"<path name>" - (<coor>)[<path style>]{<text>}[<node opt>] - ..repeated.. ()[]{}[] ; {<fill opacity>} <code.append> -% defaults: \tzpath* - *{to}[fill=black!50,fill opacity=.3,text opacity=1]<>"" - (<m>)[]{}[] ..repeated.. ()[]{}[] ; {.3}<> -\end{tzdef} - - -\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} - -You can also change the fill opacity by specifying the \xem{last} curly brace optional argument |{<fill opacity>}|, \xem{after the semicolon}. - -\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} - -You can also use the macros |\settzfillcolor| and |\settzfillopacity| to change the defaults. -The effect remains valid until the end of the |tikzpicture| environment, unless changed again. - -\begin{tzcode}{.3} -% \tzpath*: \settzfillcolor -\begin{tikzpicture} -\tzhelplines(4,3) -\settzfillcolor{red} -\tzpath*[blue](0,1)(1,2)[-|](3,1)(4,3); - < to [bend right=60] (0,1) > -\tzpath* - (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{B\'{e}zier curves} -\label{s:beziercurves} - -\icmd{\tzbezier} draws a B\'{e}zier 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 as arguments. - -\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 of |\tzbezier| by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if any. -The empty shift option |<>| is not allowed. - -\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, intersection -\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 paths} -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 a quadratic function $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. -The empty shift option |<>| is not allowed. - -\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, intersection -\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 paths} -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:curves:tzto} - -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|. - - -%%------------------------------------------------------------ -\section{\protect\cmd{\tzfn}} -\label{s:curves:tzfn} - -With \icmd{\tzfn}, you can plot functions such as $f(x)=\frac13(x-1)^3+1$, $g(x)=\sin x$, $h(x)=\sqrt{x-1}$, and so on. -See Section \ref{s:tzfn} on page \pageref{s:tzfn}, for more details on |\tzfn|. - - - - -%%================================== -\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: full -\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{in-between} 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. -The empty shift option |<>| is not allowed. - -\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| but with |text opacity=1|, by default. - -\begin{tzdef}{} -% syntax: minimum -\tzpolygon*(<coor>)(<coor>)..repeated..(<coor>) ; -% syntax: medium -\tzpolygon*(<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt] ; -% syntax: full -\tzpolygon*[<opt>]<shift coor>"<path name>" - (<coor>){<text>}[<node opt>] - ..repeated.. (){}[] ; {<fill opacity>} <code.append> -% defaults - *[fill=black!50,fill opacity=.3,text opacity=1]<>"" - (<m>){}[] .. repeated.. (){}[] ; {} <> -\end{tzdef} - -You can change the fill opacity by specifying the the last curly brace option |{<fill opacity>}| immediately \xem{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 (with |++|) 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]; % works like: - \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>)<code.append> -% defaults - []<>""(<m>)(<m>)<> -\end{tzdef} - -\icmd{\tzrectangle} is an alias of |\tzframe|. - -\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. \icmd{\tzrectangle+} is an alias of |\tzframe+|. - -\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. -(\icmd{\tzrectangle*} is an alias of |\tzframe*|.) - -|\tzframe+| has also its starred version \icmd{\tzframe*+}. -(\icmd{\tzrectangle*+} is an alias of |\tzframe*+|.) - -\begin{tzdef}{} -% syntax -\tzframe*[<opt>]<shift coor>"<path name>" - (<coor1>)(<coor2>){<fill opacity>}<code.append> -% 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 variants by specifying the option |<shift coor>| immediately before the first mandatory coordinate. -The empty shift option |<>| is not allowed. - -\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} - -You can extend the path by the option |<code.append>|. - -\begin{tzcode}{.3} -% \tzframe(*), \tzrectangle(*): <code.append> -\begin{tikzpicture} -\tzhelplines(4,4) -\tzcoors(2,2)(A)(3,1)(B); -\tzrectangle*[blue,even odd rule](0,0)(3,2) - <(.5,.5) rectangle (2.5,1.5)> -\tzframe[fill=green,even odd rule](2,1)(4,4) - <(2.3,1.2) rectangle (3.5,3.6)> -\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. -The coordinate and the radius are mandatory. - -\begin{tzdef}{} -% syntax -\tzcircle[<opt>]<shift coor>"<path name>"(<coor>)(<radius>)<code.append> -% 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>}<code.append> -% 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. -The empty shift option |<>| is not allowed. - -\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} - -You can extend the path by the option |<code.append>|. - -\begin{tzcode}{.3} -% \tzcircle(*): <code.append> -\begin{tikzpicture} -\tzhelplines(4,4) -\tzcoors(2,2)(A)(3,1)(B); -\tzcircle*[blue,even odd rule](2,2)(1) - <(2,2) circle (1.5)> -\tzcircle[fill=green,even odd rule](3,1)(1) - <(3,1) circle (.7)> -\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>)<code.append> -% defaults - []<>""(<m>)(<m>)<> -\end{tzdef} - -\icmd{\tzoval} is an alias of |\tzellipse|. - -\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>}<code.append> -% 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. -The empty shift option |<>| is not allowed. - -\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} - -You can extend the path by the option |<code.append>|. -Note also that \icmd{\tzoval*} is an alias of |\tzellipse*|. - -\begin{tzcode}{.3} -% \tzellipse(*), \tzoval(*): <code.append> -\begin{tikzpicture} -\tzhelplines(4,4) -\tzcoors(2,2)(A)(3,1)(B); -\tzoval*[blue,even odd rule](2,2)(1.5 and 1) - <(2,2) ellipse (2 and 1.5)> -\tzellipse[fill=green,even odd rule](3,1)(1 and 1) - <(3,1) ellipse (.5 and .8)> -\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 coordinate. - -\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 specified 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} - -The macro \icmd{\tzarcsfrom} (i.e. |\tzarcs + from|) accepts an arbitrary number of parenthesis arguments in the form of |(<angA:AngB:radius>)| following the start coordinate. You need to enter a \xem{semicolon} to indicate when the repetition ends. - -\begin{tzdef}{} -% syntax: minimum -\tzarcsfrom(<start coor>) - (<angA:angB:radius>)..repeated..(<angA:angB:radius>) ; -% syntax: full -\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} -\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} - - -\begin{tzcode}{.4} -% flag: shift -\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]<.1,.3>(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>}[<node opt>] -% defaults - []<>""(<m>)(<m>){}[midway] -\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 macro \icmd{\tzwedge'} is the \iisw{swap version} of \icmd{\tzwedge}. -It 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*} - -The starred version \icmd{\tzwedge*} works just like |\tzwedge|, but it fills wedges with |black!50| with |fill opacity=.3| and |fill opacity=1|, by default. -You can change the defaults with |\settzfillcolor| and |\settzfillopacity|. -You can also change the fill opacity by specifying the last optional argument |{<fill opacity>}|. - -\begin{tzdef}{} -% syntax -\tzwedge*[<opt>]<shift coor>"<path name>" - (<coor>)(<angA:angB:radius>){<text>}[<node opt>]{<fill opacity>} -% defaults - [fill=black!50,fill opacity=.3,text opacity=1]<>""(<m>)(<m>){}[midway]{.3} -\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, fill opacity -\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*[blue]<2,0>(1,1)(300:240:1){B}[b]{.7} +\tzhelplines*(4,3) +\tzlines+[red,thick,<->,text=blue] + <1,1> (0,1){Up} + (1,1){Down}[a,sloped] + (2,-1){Up} + (1,2){line A} ; +\tzcoors(0,0)(A)(1,1)(B)(1,0)(C)(1,-1)(D); +\tzlines+[dashed,auto,text=red] + <-1,.5> (A){A} + (B){B} + (C){C} + (D){line B}[blue,draw,r] ; \end{tikzpicture} \end{tzcode} diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C1-v2.0.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C1-v2.0.tex new file mode 100644 index 00000000000..4e61cbd6958 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C1-v2.0.tex @@ -0,0 +1,1691 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%%%=====CNONTINUED============ +%%%%%%========================== +%%%\part{Points, Lines, and Curves} +%%%%%%========================== +%%%\label{p:linesandcurves} + + +%%================================== +\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's |to| operation. +So |\tzto| is more general than |\tzline|, which only 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[dashed](1,1)(3,2) % works like: + \draw [dashed] (1,1) to (3,2); +\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) +\settzmidarrow{o}[very thick,red] +\tzarc(2,2)(180:45:1cm) +\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{in-between} the two coordinates. + +\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} + + +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 it exists. +(The \xem{empty} shift option |<>| is \xem{not allowed}.) + +\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} + +You can also use \icmd{\tztoAtBegin} and \icmd{\tztoAtEnd} to extend a path of |\tzto| at the beginning and at the end, respectively. +Specifying |<code.append>| extends the path after |\tztoAtEnd|. + +\begin{tzcode}{.3} +% \tzto: extending path +\begin{tikzpicture} +\tzhelplines(4,3) +\tztoAtBegin{(0,2) to [bend left]} +\tztoAtEnd{--([turn]0:1cm) node [b] {extended}} +\tzto[bend right=45,blue,thick,->](1,3)(4,0) +\tztoAtEnd{--([turn]0:1cm) node [r] {extended}} +\tzto[out=0](0,0)(4,2) +\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} + + +\begin{tzcode}{.3} +% \tzto: extending path +\begin{tikzpicture} +\tzhelplines(4,3) +\tztoAtBegin{(0,2) to [bend left]} +\tztoAtEnd{--([turn]0:1cm) node [b] {extended}} +\tzto+[bend right=45,blue,thick,->](1,3)(3,-3) +\tztoAtEnd{--([turn]0:1cm) node [r] {extended}} +\tzto+[out=0](0,0)(4,2) +\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 the \Tikz's |to| operation. |\tztos| is much more flexible than |\tzlines|. Since this is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate iteration ends. + +\begin{tzdef}{} +% syntax +\tztos[<opt>]<shift coor>"<path name>" + (<coor1>)[<to opt>]{<text>}[<node opt>]..repeated..()[]{}[] ; <code.append> +% defaults + []<>""(<m>)[]{}[]..repeated..()[]{}[];<> +\end{tzdef} + +The quadruple |(<coor>)[<to opt>]{<text>}[<node opt>]| is +the whole repeating pattern. +Here, |[<to opt>]| is for the options of \Tikz's |to| operation such as |[bend right]|, |[bend left]|, |[bend left=<angle>]|, |[out=<angle>,in=<angle>]| and so on. + +\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,in=45] (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 the options of \Tikz's |to| operation 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} + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(0,0)(A)(1,2)(B){B}[b](3,3)(C)(4,2)(D); +\tztos(A)[out=80,in=180] + (B)[out=0,in=180] + (C)[out=0,in=180] + (D){End!}[r]; +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} +You can add text next to lines or curves by specifying the options |{<text>}| and |[<node opt>]| \xem{in-between} coordinates or \xem{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>]|. + +\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 the option |"<path name">|, if any. +(The empty shift option |<>| is not allowed.) + +\begin{tzcode}{.3} +% \tztos: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdot(0,0) +\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{Naming paths: intersections} +You can name the path of |\tztos| by specifying |"<path name>"| immediately before the first mandatory coordinate. + +\begin{tzcode}{.3} +% \tztos: name path, intersection points +\begin{tikzpicture} +\tzhelplines(4,3) +\tzdot(0,0) +\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 paths} +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} + +You can also use \icmd{\tztosAtBegin} and \icmd{\tztosAtEnd} to extend a path of |\tztos| at the beginning and at the end, respectively. +Specifying the option |<code.append>| extends the path after |\tztosAtEnd|. + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tztos[blue](0,1)(1,2)(3,1)(4,3);<--cycle> +\tztosAtBegin{ (1,3) -| } +\tztosAtEnd{ to ([turn]0:1.5cm) } +\tztos[red,thick] + (0,0)[bend right] + (1,1) + (2,1)[out=-135,in=45] + (3,0); +\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} + + + +\section{\protect\cmd{\tzlink}: Two points} +\label{s:tzlink} + +\icmd{\tzlink} is a \xem{generalized version} of |\tzline|. +You can decide the style that links two coordinates. + +The default link style is |to|, which can be changed with the \xem{second} optional argument |[<code1>]| \xem{between two coordinates} like, for example, \verb+(<coor1>)[-|](<coor2>)+. +Another way is to use the \xem{first} curly brace option |{<link style>}|. +You can also change it by \icmd{\settzlinkstyle} like, for example, \verb+\settzlinkstyle{-|}+, which is effective until the end of the |tikzpicture| environment. + +\begin{tzdef}{} +% syntax: minimum +\tzlink(<coor1>)(<coor2>) % default: to +% syntax: medium +\tzlink[<opt>](<coor1>)[<code1>](coor2>) % change link style by [<code1>] +% syntax: full +\tzlink{<link style>}[<opt>]<shift coor>"<path name>" + (<coor1>)[<code1>]{<text1>}[<node opt1>]<code2> + (<coor2>){<text2>}[<node opt2>]<code.append> +% remark: + - {<link style>}: % default: to + - [<code1>]: --, -|, to, edge, etc. (optionally more appropriate tikz code) + - <code2>: + or ++ (possibly with other tikz code) + - {<text1>}: node text next to line + - {<text2>}: node text at the last coordinate +% defaults + {to}[]<>""(<m>)[]{}[above]<>(<m>){}[]<> +\end{tzdef} + +\begin{tztikz}{} +\tzlink(1,0)(3,1) % works like: + \draw (1,0) to (3,1); +\end{tztikz} + +\begin{tztikz}{} +\tzlink(1,0)[-|]<++>(3,1) % works like: + \draw (1,0) -| ++ (3,1); +\end{tztikz} + + +\paragraph{Link styles} You can change the link style (|to| by default) using the optional argument |[<code1>]| \xem{immediately after} the first coordinate. + +\begin{tzcode}{.3} +% \tzlink: to (default link style) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink[->](0,0)(1,0) +\tzlink[->,bend right](0,2)(3,0) +\tzlink[->](1,2)[-|](4,1) +\end{tikzpicture} +\end{tzcode} + +You can also use \icmd{\settzlinkstyle} to change the link style. Its effect is valid until the end of the |tikzpicture| environment, unless changed again. + +\begin{tzcode}{.3} +% \settzlinkstyle +\begin{tikzpicture} +\tzhelplines(4,3) +\settzlinkstyle{to[bend left]} %% +\tzlink[->](0,0)(1,0) +\tzlink[->](0,2)[--](3,0) % local change +\tzlink[->](1,2)(4,1) +\end{tikzpicture} +\end{tzcode} + +The \iisw{plus version} \icmd{\tzlink+} uses the second coordinate relative (with |++|, by default) to the first one. +Everything else is the same as in |\tzlink|. + + +\begin{tztikz}{} +\tzlink (1,0)[to[bend right]]{A}[a]<++>(3,1) % or +\tzlink+(1,0)[to[bend right]]{A}[a] (3,1) % works like: + \draw (1,0) to[bend right] node [above] {A} ++ (3,1); +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzlink(+): various link styles +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink[->,blue,out=90,in=180](0,2)(3,0) +\tzlink+[->,dashed,blue](1,2)[to[bend left]](3,-1) +\tzlink[->](0,0)[..controls (1,1) and (3,0)..](4,2) +\tzlink+[red,thick](1,0)[edge[bend left]](2,3) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Adding text} + +You can add text next to the line or curve of |\tzlink| by specifying the option |{<text1>}| followed by the optional argument |[<node opt1>]| \xem{between} two coordinates (or after the option |[<code1>]| if it exists). + +You can name the line or curve of |\tzlink| by specifying the optional arguments |{<text2>}| and |[<node opt2>]| \xem{after} the second coordinate. The option |[<node opt2>]| is often for the position of node text at or around the second coordinate. + +\begin{tzcode}{.3} +% \tzlink +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink[->](1,3){line A}(4,3) +\tzlink[blue](0,3){line B}[sloped](3,0){E}[r] +\tzlink[->,red](1,0){Start}[at start,l](4,2){Line C}[r] +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzlink(+) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink[->](0,0){A}(1,0) +\tzlink+[bend right](0,2){curve}[sloped](3,-2){End}[r] +\tzlink[->,auto](1,2)[-|]{B}(4,1){Goal!}[b,draw,blue] +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Shift} +You can move the line or curve by specifying the option |<shift coor>| \xem{before} the first coordinate (or ever before the option |"<path name>"| if it exists). + +\begin{tzcode}{.3} +% \tzlink(+): shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink+[bend right](0,2)(3,-2){A}[r] +\tzlink+[bend right]<.5,.5>(0,2)(3,-2){A-shifted}[r] +\tzlink[->](1,2)[-|](4,1) +\tzlink[->,dashed]<-.2,.3>(1,2)[-|](4,1) +\end{tikzpicture} +\end{tzcode} + +\paragraph{Naming paths: Intersections} +You can name the path of |\tzlink| by specifying the quote option |"<path name>"| \xem{immediately before} the first coordinate. +You can use the path names of two paths to find an intersection point. + +\begin{tzcode}{.3} +% \tzlink(+): path name: intersection +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlink[blue]"BB"(0,3){line B}[sloped](3,0) +\tzlink+[->,red,bend right]"CC"(1,0)(3,2){Line C}[r] +\tzXpoint{BB}{CC}(E) % instersection +\tzdot*(E){E}[a] +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Extending paths} +You can extend the path of |\tzlink| by specifying \Tikz\ code in the last optional argument |<code.append>|. +You can also use the macros \icmd{\tzlinkAtBegin} and \icmd{\tzlinkAtEnd} to extend the path at the beginning and at the end, respectively. +Specifying the option |<code.append>| extends the path after |\tzlinkAtEnd|. + +\begin{tzcode}{.3} +% \tzlink(+): path name: intersection +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinkAtBegin{(1,1) to[bend left]} +\tzlinkAtEnd{arc (180:90:1cm) node [r,draw] {BB}} +\tzlink[blue]"BB"(0,3){line B}[sloped](3,0) +\tzlink+[->,red,bend right]"CC"(1,0)(3,2){Line C}[r] + < -| ++(-1,1) node [a] {End!} > +\tzXpoint{BB}{CC}(E) +\tzdot*(E){E}[a] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzlinks}: All in one: Semicolon versions} +\label{s:tzlinks} + +\subsection{\protect\cmd{\tzlinks}: Standard version} +\label{ss:tzlinks} + +The macro \icmd{\tzlinks} is a \iisw{semicolon version} of |\tzlink|. |\tzlinks| accepts any number of coordinates to connect them with connected line segments or curves. +You can change how two adjacent points are connected. +|\tzlinks| is quite \xem{flexible} that you can think of it as a \xem{generalized version} of |\tzlines|. + + +\begin{tzdef}{} +% syntax: minimum +\tzlinks (<coor>)(<coor>) ..repeated.. (<coor>) ; +% syntax: full +\tzlinks{<path style>}[<opt>]<shift coor>"<path name>" + (<coor>)[<code1>]{<text>}[<node opt>]<code2> + ..repeated.. ()[]{}[]<> ; {<fill opacity>} <code.append> +% remark: + - <code1> must be link style, such as --, to, -|, etc. + (possibly followed by other code) + - <code2> is especially for + or ++ + (possibly with other code) + - repetition MUST be ended by ; (semicolon) + - full repeating pattern is ()[]{}[]<>..repeated..()[]{}[]<> + - {<fill opacity>} works only in \tzlinks* +% defaults: \tzlinks, \tzlinks*, \tzlinks+, \tzlinks*+ + {to}[]<>"" (<m>)[]{}[]<> ..repeated.. ()[]{}[]<> ; { }<> + *{to}[fill=black!50,fill opacity=.3,text opacity=1] + <>"" (<m>)[]{}[]<> ..repeated.. ()[]{}[]<> ; {.3}<> + +{to}[]<>"" (<m>)[]{}[]<++> ..repeated.. ()[]{}[]<> ; { }<> +\end{tzdef} + +\paragraph{How to change link styles} +There are three ways of changing link styles: +\begin{itemize}\firmlist +\item The fist curly brace option |{<link style>}| controls the link style of connecting any two coordinates. +\item The second bracket option |[<code1>]| (locally) changes the link style of two adjacent coordinates. |[<code1>]| (locally) overrides |{<link style>}|. +\item The effect of the macro |\settzlinkstyle| remains until the end of |tikzpicture| environment, unless changed again. +\end{itemize} + +\begin{tztikz}{} +% standard version +\tzlinks(1,1)(2,2)(3,1)(4,3); % works like: + \draw (1,1) to (2,2) to (3,1) to (4,3); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzlinks +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks(0,1)(1,2)(3,1)(4,3); +\end{tikzpicture} +\end{tzcode} + +The default path style is |to|, which can be by \icmd{\settzlinkstyle}. +The effect remains valid until the end of |tikzpicture| environment unless changed again. + +\begin{tzcode}{.3} +% \tzlinks: \settzlinkstyle +\begin{tikzpicture} +\tzhelplines(4,3) +\settzlinkstyle{to[bend right]} %% +\tzlinks[dashed](0,1)(1,2)[-|](3,1)(4,3); +\tzlinks[blue] + (0,0) + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzlinks: various link styles +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks[->](1,2)[-|] + (0,0)[..controls (1,2) and (2,0)..] + (3,1)[to[bend left]]<++> + (1,2); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzlinks: various link styles +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks[->](1,1)<++> + (1,1)[[rounded corners=10pt]--] + (0,3) + (0,0)[[sharp corners]--] + (4,0)<++> + (-1,2); +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzlinks: edge +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks(0,1)(1,2)[edge[dashed]]<(3,1)>(3,1)(4,3); +\end{tikzpicture} +\end{tzcode} + +\remark +In \Tikz, |edge| is not part of the main path. +So you need to be careful when you move the path or find intersection points. + + + +\subsection{\protect\cmd{\tzlinks+}, \protect\cmd{\tzlinks*}, \protect\cmd{\tzlinks*+}: Variants} +\label{ss:tzlinks-variants} + +The \iisw{plus version} \icmd{\tzlinks+} treats a coordinate as relative (with |++| by default) to the previous coordinate, except the first coordinate. + +\begin{tztikz}{} +% plus (+) version +\tzlinks+(1,1)(2,2){--}(3,1)(4,3); % works like: + \draw (1,1) to ++(2,2) -- ++(3,1) to ++(4,3); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzlinks+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks+(0,1)(1,1)[to[bend right]](2,-1)(1,2); +\end{tikzpicture} +\end{tzcode} + +The \xem{starred version} \icmd{\tzlinks*} is to fill the closed area formed by |\tzlinks| with color or pattern. The related default value is |[fill=black!50, fill opacity=.3, text opacity=1]|. +In fact, |\tzlinks*[draw=none]| is (almost) the same as |\tzpath*| (See Section \ref{s:tzpath*} on page \pageref{s:tzpath*} for more details). + +\begin{tztikz}{} +% starred (*) version +\tzlinks*(1,1)(2,2)(3,1)(4,3); % works like: + \draw [fill=black!50,fill opacity=.3,text opacity=1] + (1,1) to (2,2) to (3,1) to (4,3); +\end{tztikz} + +\icmd{\tzlinks*+} is the plus version of |\tzlinks*|. + +\begin{tzcode}{.3} +% \tzlinks*+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks*+[thick](0,1)(1,1)[to[bend right]](2,-1)(1,2); +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzlinks: fill, fill opacity +\begin{tikzpicture} +\tzhelplines(4,3) +\tzline[red,very thick](0,3)(4,0) +\tzlinks[fill](0,0)(3,1)(2,3)(0,2); % default opacity=1 +\tzlinks[fill=green,fill opacity=.5] + <1,-1>(0,0)(3,1)(2,3)(0,2); +\end{tikzpicture} +\end{tzcode} + +You can also change the fill opacity by specifying the \xem{last} curly brace optional argument |{<fill opacity>}|, \xem{after the semicolon} (or before the option |<code.append>| it it exists). + +\begin{tzcode}{.3} +% \tzlinks* +\begin{tikzpicture} +\tzhelplines(4,3) +\settzfillcolor{green} +\tzline[red,very thick](0,3)(4,0) +\tzlinks*[blue](0,0)(3,1)(2,3)(0,2);{1} +\tzlinks*%[green] + <1,-1>(0,0)(3,1)(2,3)(0,2); {.5} %% +\end{tikzpicture} +\end{tzcode} + +You can also use the macros |\settzfillcolor| and |\settzfillopacity| to change the defaults. +The effect remains valid until the end of the |tikzpicture| environment, unless changed again. + +%%------------------------------------------------------------ +\subsection{Putting text, shift, intersections, and extending paths} +\label{ss:tzlinks-add} + + +\paragraph{Adding text} +You can add text next to connected line segment or around the last coordinate by specifying options |{<text>}[<node option>]|. + +\begin{tztikz}{} +\tzlinks+[dashed]"AA"(1,1){A}(2,2)[--]{B}[a]<+>(3,1){C}[b]; % works like + \draw [dashed,name path=AA] + (1,1) to node {A} + ++(2,2) -- node [above] {B} + +(3,1) to node [below] {C} ; +\end{tztikz} + + +\begin{tzcode}{.3} +% \tzlinks: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks[blue](0,0){Ace} + (1,1){Beth}[sloped,a] + (3,0){C} [near start] + (4,2){End!}[draw,a=3pt]; +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzlinks: adding text +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks[->](1,1){start}[sloped,b]<++> + (1,1)[[rounded corners=10pt]--]{K}[at end,a] + (0,3){Rounded}[scale=0.7,font=\scshape,at end,ar] + (0,0)[[sharp corners]--] + (4,0)<++> + (-1,2){End!}[draw,blue,a=3pt]; +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzlinks: edge +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks(0,1){start}[at start,b] + (1,2)[edge[dashed,bend right]]{Go!}[sloped,b]<(3,1)> + (3,1) + (4,3){End\\here!}[align=center,r,draw,red] ; +\end{tikzpicture} +\end{tzcode} + +\remark Note that |edge| is not part of the main path. + +\paragraph{Shift} +You can move the path of |\tzlinks| with the option |<shift coor>|. +An \xem{empty} option |<>| is \xem{not allowed}. + + +\begin{tzcode}{.3} +% \tzlinks: +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks<.5,-1>(0,1){start}[at start,b] % shift + (1,2)[to[dashed,bend right]]{Go!}[sloped,b] + (3,1) + (4,3){End\\here!}[align=center,r,draw,red] ; +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Naming paths: intersections} +You can name the path of |\tzlinks| \xem{immediately befor} the first coordinate and use it to find intersection points. + +\begin{tzcode}{.3} +% \tzlinks: edge +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks"AA"(0,1){start}[at start,b] + (1,2)[edge[dashed,bend right]]{Go!}[sloped,b]<(3,1)> + (3,1) + (4,3){End\\here!}[align=center,r,draw,red] ; +\tzhXpointat{AA}{1.5}(A) % horizontal intersections +\tzdots*(A){\texttt{(A)}}(A-2){\texttt{(A-2)}}[0]; +\end{tikzpicture} +\end{tzcode} + +In the previous example, since |edge| is not part of the main path of |\tzlinks|, +the second horizontal intersection point |(A-2)| is not on the |edge| curve. + +\paragraph{Extending paths} + +You can extend the path of |\tzlinks| by writing \Tikz\ code in the last (after the semicolon) optional argument |<code.append>|. +So |<--cycle>| closes the path with a straight line. + +\begin{tzcode}{.3} +% \tzlinks* <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinks*[blue](0,1)(1,2)[-|](3,1)(4,3); + < to [bend right=60] (0,1) -- cycle > +\tzlinks*[fill=red] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); % not closed +\end{tikzpicture} +\end{tzcode} + +You can also use \icmd{\tzlinksAtBegin} and \icmd{\tzlinksAtEnd} to extend the path of |\tzlinks| at the beginning and at the end, respectively. +Specifying the option |<code.append>| extends the path after |\tzlinksAtEnd|. + +\begin{tzcode}{.3} +% \tzlinks*: extending paths +\begin{tikzpicture} +\tzhelplines(4,3) +\tzlinksAtBegin{(0,2) to[bend left]} +\tzlinksAtEnd{ to [out=210] (1,3) } +\tzlinks*[blue](0,1)(1,2)[-|](3,1)(4,3); + < -| (0,2) > +\tzlinks*[fill=red] + (0,0)[to[bend right]] + (1,1) + (2,1)[to[out=-135,in=45]] + (3,0); <--cycle> +\end{tikzpicture} +\end{tzcode} + + + + +%%================================== +\chapter{Filling Area} +\label{c:fillingarea} + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzpath}: Semicolon version} +\label{s:tzpath} + + +\icmd{\tzpath} is the same as |\tzlinks[draw=none]|. In other words, |\tzpath| creates a path connecting an arbitrary number of coordinates, but it does not stroke the path. Since |\tzpath| is a \iisw{semicolon version} macro, you need to enter a \xem{semicolon} `|;|' to indicate where the coordinate iteration ends. + +You can visualize the path with |\tzpath[draw]|, which is the same as |\tzlinks|. + + +\begin{tzdef}{} +% syntax: minimal +\tzpath (<coor>)(<coor>) ..repeated.. (<coor>) ; +% syntax: full +\tzpath {<path style>}[<opt>]<shift coor>"<path name>" + (<coor>)[<code1>]{<text>}[<node opt>]<code2> + ..repeated.. ()[]{}[]<> ; <code.append> +% remark: + - <code1> must be link style, such as --, to, -|, etc. + (possibly followed by other codes) + - <code2> is especially for + and ++ + (possibly with other codes) + - repetition MUST be ended by ; (semicolon) +% defaults: \tzpath + {to}[]<>"" (<m>)[]{}[]<> ..repeated.. ()[]{}[]<> ; <> +\end{tzdef} + +\remark +\begin{itemize} +\item 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. +\item Use \icmd{\settzpathlayer}, like |\settzpathlayre{behind}|, to change the layer of |\tzpath| (default: |main|). +\end{itemize} + +\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{in-between} coordinates. \xem{Path extension operation} can be selected from `|--|', `|to|', `\verb+|-+', `\verb+-|+', etc. +You can use \xem{the first brace option} |{<path style>}| to change all the |<path style>| in-between coordinates. + + +\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} + +The default path style is `|to|' and can also be changed by \icmd{\settzpathstyle}, like, for example, |\settzpathstyle{--}|. |\settzpathstyle| is an alias of |\settzlinkstyle|. The effect remains valid until the end of |tikzpicture| environment unless changed again. + +\begin{tzcode}{.3} +% \tzpath: \settzpathstyle +\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} + +\begin{tzcode}{.3} +% \tzpath: \settzpathstyle +\begin{tikzpicture} +\tzhelplines(4,3) +\settzpathstyle{to[bend right]} +\tzlinks(0,1)(1,2)[-|](3,1)(4,3); +\tzlinks + (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>|. +So |<--cycle>| closes the path with a straight line. + +\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} + +\section{\protect\cmd{\tzpath*}: Semicolon version} +\label{s:tzpath*} + +The starred version \icmd{\tzpath*} is the (almost) same as |\tzlinks*[draw=none]|. It fills the interior of |\tzpath| with |fill=black!50| with |fill opacity=.3| and |text opacity=1|, by default. +The only difference between |\tzpath*| and |\tzlinks*[draw=none]| is that the layer of |\tzpath*| can be changed by |\settzpathlayer|, like |\settzpathlayer{behind}|. + +|\tzpath*| works like |\tzpath[fill=black!50,fill opacity=.3,text opacity=1]|. +You can change the defaults by \icmd{\settzfillcolor} and \icmd{\settzfillopacity}. + +\begin{tzdef}{} +% syntax: minimal +\tzpath*(<coor>)(<coor>) ..repeated.. (<coor>) ; {<fill opacity>} +% syntax: full +\tzpath*{<path style>}[<opt>]<shift coor>"<path name>" + (<coor>)[<code1>]{<text>}[<node opt>]<code2> + ..repeated.. ()[]{}[]<> ; {<fill opacity>} <code.append> +% remark: + - <code1> must be link style, such as --, to, -|, etc. + (possibly followed by other codes) + - <code2> is especially for + and ++ + (possibly with other codes) + - repetition MUST be ended by ; (semicolon) +% defaults: \tzpath* + *{to}[fill=black!50,fill opacity=.3,text opacity=1]<>"" + (<m>)[]{}[]<> ..repeated.. ()[]{}[]<> ; {.3}<> +\end{tzdef} + + + +\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} + +You can also change the fill opacity by specifying the \xem{last} curly brace optional argument |{<fill opacity>}|, \xem{after the semicolon}. + +\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*[green] + <1,-1>(0,0)(3,1)(2,3)(0,2); {.5} %% +\end{tikzpicture} +\end{tzcode} + +You can also use the macros |\settzfillcolor| and |\settzfillopacity| to change the defaults. +The effect remains valid until the end of the |tikzpicture| environment, unless changed again. + +\begin{tzcode}{.3} +% \tzpath*: \settzfillcolor +\begin{tikzpicture} +\tzhelplines(4,3) +\settzfillcolor{red} +\tzpath*[blue](0,1)(1,2)[-|](3,1)(4,3); + < to [bend right=60] (0,1) > +\tzpath* + (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} + +You can change the layer (|main| by default) using |\settzpathlayer|. + +\begin{tzcode}{.3} +% \settzpathlayer +\begin{tikzpicture} +\tzhelplines(4,3) +\settzpathlayer{behind} %% layer +\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{B\'{e}zier curves} +\label{s:beziercurves} + +\subsection{\protect\cmd{\tzbezier}} +\label{ss:tzbezier} + +\icmd{\tzbezier} accepts \xem{three or four} coordinates to draw a B\'{e}zier curve from the first coordinate to the last coordinate, with \xem{one or two} control points. + +\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>)|. + +\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>]| \xem{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 of |\tzbezier| by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if it exists. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +\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{Naming paths: intersections} +You can name the path of |\tzbezier| by specifying the option |"<path name>"| \xem{immediately before} the first coordinate. + +\begin{tzcode}{.3} +% \tzbezier: name path, intersection +\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] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Extending paths} +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 [below] {B} > +\end{tikzpicture} +\end{tzcode} + +You can also use \icmd{\tzbezierAtBegin} and \icmd{\tzbezierAtEnd} to extend the path of |\tzbezier| at the beginning and at the end, respectively. +Specifying the option |<code.append>| extends the path after |\tzbezierAtEnd|. + +\begin{tzcode}{.3} +% \tzbezier: extending path +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezierAtEnd + { to [bend right] ++(-1,-1) node [below] {A} } +\tzbezier[red](0,3)(1,2)(2,4)(4,3){bezier}[near end,a] +\tzbezierAtBegin{ (0,0) to [out=45,in=-30] } +\tzbezierAtEnd{ |- ++(-2,1) } +\tzbezier[blue,->](0,2)(1,.5)(4,0){B}[b] + < arc (0:90:1) node [a] {End!} > +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzbezier+}: Relative coordinates} +\label{ss:tzbezier+} + +For the \iisw{plus version} \icmd{\tzbezier+}, the last coordinate is \xem{relative} to the first coordinate. +And the first control point is \xem{relative} to the first coordinate. + +\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} + +In \Tikz, the second control point is \xem{relative} to the last coordinate. + +Therefore, for |\tzbezier+(A)(B)(C)(D)|, |(B)| and |(D)| are \xem{relative} to |(A)|, and the second control point |(C)| is \xem{relative} to the last coordinate |(D)|. + +\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} + + +\begin{tzcode}{.3} +% \tzbezierAtBegin, \tzbezierAtEnd +\begin{tikzpicture} +\tzhelplines(4,4) +\tzbezierAtEnd + { to [bend right] ++(-1,-1) node [below] {A} } +\tzbezier+(0,3)(1,-1)(-2,1)(4,0){bezier}[near end,a] +\tzbezierAtBegin{ (1,0) to [out=150,in=30] } +\tzbezierAtEnd{ |- ++(-2,1) node [a] {here!} } +\tzbezier+[blue,->](0,2)(1,-1.5)(4,-2){B}[b] +\end{tikzpicture} +\end{tzcode} + + +%%----------------------------------- +%%------------------------------------------------------------ +\section{Parabolas} +\label{s:parabolas} + + +\subsection{\protect\cmd{\tzparabola}} +\label{ss:tzparabola} + +\icmd{\tzparabola} accepts \xem{two or three} coordinates to draw a parabola from the first coordinate to the last coordinate. +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 a quadratic function $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 \xem{last coordinate} by specifying the options |{<text>}| and |[<node opt>]| \xem{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 it exist. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +\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{Naming paths: intersections} +You can name the path of |\tzparabola| by specifying the option |"<path name>"| \xem{immediately before} the first coordinate. + +\begin{tzcode}{.3} +% \tzparabola: name path, intersection +\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 paths} +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} + +You can also use the macros \icmd{\tzparabolaAtBegin} and \icmd{\tzparabolaAtEnd} to extend the path of |\tzparabola| at the beginning and at the and, respectively. +Specifying the option |<code.append>| extends the path after |\tzparabolaAtEnd|. + +\begin{tzcode}{.3} +% \tzparabola: extending path +\begin{tikzpicture} +\tzhelplines(4,3) +\tzparabolaAtEnd{ -- ++ (-1,1) } +\tzparabola[blue,->]"AC"(0,3)(2,1)(4,2) +\tzparabolaAtBegin{ (0,1) to [bend right ] } +\tzparabolaAtEnd{ -| ++ (1,1) node [right] {End!} } +\tzparabola"BB"(1,0)(2,2)(3,0){K!}[bl] + < arc (-90:0:1) node [a] {here!} > +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzparabola+}: Relative coordinates} +\label{ss:tzparabola+} + +The \iisw{plus version} \icmd{\tzparabola+} use the second and the third coordinates xem{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{Edges} +\label{s:edge} + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzedge(+)}} +\label{ss:tzedge} + +The macro \icmd{\tzedge} connects two coordinates with a straight or curved line, using the \Tikz\ |edge| operation. + + +\begin{tzdef}{} +% syntax +\tzedge[<opt>]<shift coor> + (<coor>){<text>}[<opt>](<coor>){<text>}[<opt>]<code.append> +% defaults + []<>(<m>){}[](<m>){}[]<> +\end{tzdef} + +\remark In \Tikz, the |edge| operation works like the |to| operation, but it is independently drawn after a main path is drawn and does not form a main path. So the option |"<path name>"| (for finding intersections) is not provided in |\tzedge|. + + +\begin{tztikz}{} +\tzedge(1,1)(3,2) % works like: + \draw (1,1) edge (3,2); +\end{tztikz} + +\begin{tztikz}{} +\tzedge[->,bend right](1,1){A}[near start](3,2) % works like: + \draw (1,1) edge [->,bend right] node [near start] {A} (3,2); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzedge +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedge[->](0,1)(2,3) +\tzedge[out=0,dashed] + (0,0){edge}[near start,sloped,a](4,2) +\tzedge[in=90,blue](2,0)(4,1){C}[r] +\end{tikzpicture} +\end{tzcode} + +The \xem{plus version} \icmd{\tzedge+} use the second coordinate \xem{relative} to the first coordinate. + +\begin{tztikz}{} +\tzedge+(1,1)(3,2) % works like: + \draw (1,1) edge ++(3,2); +\end{tztikz} + +\begin{tztikz}{} +\tzedge+[->,bend right](1,1){A}[near start](3,2){B}[right] % works like: + \draw (1,1) edge [->,bend right] node [near start] {A} ++(3,2) + ++(3,2) node [right] {B}; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzedge+: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedge+[->](0,1)(2,2) +\tzedge+[out=0,dashed] + (0,0){edge}[near start,sloped,a](4,2) +\tzedge+[in=90,blue]<-.5,.5>(2,0)(2,1){shifted}[b,draw] +\end{tikzpicture} +\end{tzcode} + + +\remark |edge| in the option |<code.append>| works with the second coordinate, but it works with the last node if the second option |{<text>}| is not empty. +(In \Tikz, if |edge| is preceded by |node|, the node is its start point.) + +\begin{tzcode}{.3} +% <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedge[->](0,1)(2,3)<edge[bend left,red] ++(1,-2)> +\tzedge[out=0,dashed] + (0,0){edge}[near start,sloped,a] + (4,2){A}[draw] + <edge[bend left,thick] ++ (-1,-2)> +\end{tikzpicture} +\end{tzcode} + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzedges(+)}: Semicolon versions} +\label{ss:tzedges} + +The macro \icmd{\tzedges} accepts any number of coordinates to draw edges from the first coordinate to each of the next using the \Tikz\ |edge| operation. That is, the first coordinate is the unique start coordinate, and all others are target coordinates. +|\tzedges| is a semicolon version, so you need to type |;| to indicate when the coordinate iteration ends. + + +\begin{tzdef}{} +% syntax: minimum +\tzedges(<coor>)(<coor>)..repeated..(<coor>); +% syntax: full +\tzedges[<opt>]<shift coor> + (<coor>)[<edge opt>]{<text>}[<opt>]..repeated..()[]{}[] ; <code.append> +% defaults + [](<m>)[]{}[]..repeated..()[]{}[]; +\end{tzdef} + +\remark In \Tikz, the |edge| operation works like |to| operation, but it is added after main path is formed, like |node| does. +\begin{itemize}\firmlist +\item Each |edge| is drawn independently from a main path as well as any other |edge|'s. (See \Tikz\ manual for more details.) +\item The |edge| operation of \Tikz\ does not change change anything about a main path, so the current point is not changed by |\tzedges|. This means that the last node (with |{<text>}| and |[<node opt>]|) works with the first (namely, start) coordinate. +\end{itemize} + + + + + +\begin{tzcode}{.3} +% \tzedges +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedges(0,1){A} (1,2) + [blue,thick]{edge}[b](3,1) + (4,3); +\end{tikzpicture} +\end{tzcode} + +\begin{tztikz}{} +\tzedges(0,1){A}(1,2)[blue,thick]{edge}[a](3,1)(4,3); % works like + \draw (0,1) edge node {A} (1,2) + edge [blue,thick] node [above] {edge} (3,1) + edge (4,3) ; +\end{tikzpicture} +\end{tztikz} + +\begin{tzcode}{.3} +% \tzedges: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedges[bend right]<1,-1> % shift + (0,1)[->,thick,blue]{A} + (1,2)[dotted]{Beta}[b] + (3,1)[dashed]{Cate}[near end,sloped,a] + (4,3); +\end{tikzpicture} +\end{tzcode} + + +The \xem{plus version} \icmd{\tzedges+} uses the second and next coordinates \xem{relative} to the first coordinate. + +\begin{tztikz}{} +\tzedges+(0,1)(2,1)(3,0)(4,2); % works like + \draw (0,1) edge ++ (2,1) + edge ++ (3,0) + edge ++ (4,2); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzedges+ +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedges+[bend right](0,1)[bend right=0]{A} + (1,1)[dotted]{Beta}[b] + (3,0)[dashed]{Cate}[near end,sloped,a] + (4,2); +\end{tikzpicture} +\end{tzcode} + + +\remark The option |<code.append>| works with the first coordinate because |edge| and |node| do not change the current point. + + +\begin{tzcode}{.3} +% <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzedges+(0,1)[bend right=0,->]{A}[fill=white] + (1,1)[bend right,dotted]{Beta}[midway] + (3,0)[bend right,dashed]{Cate}[near end] + (4,2); + < edge [bend left,thick,blue] (1,3) > +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{More curves} + +\subsection{\protect\cmd{\tzplotcurve}, \protect\cmd{\tzplot}} + +You can draw curves with |\tzplotcurve| and |\tzplot|. + +\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} + + +See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve}, for more details on |\tzplotcurve|. + +See Section \ref{s:tzplot} on page \pageref{s:tzplot}, for more details on |\tzplot|. + + +\subsection{\protect\cmd{\tzto}, \protect\cmd{\tztos}} +\label{ss:curves:tzto} + +You can draw curves with |\tzto| and |\tztos|. +|\tztos| are quite useful to draw various curves. + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(0,0)(A)(1,2)(B){B}[b](3,3)(C)(4,2)(D); +\tztos(A)[out=80,in=180] + (B)[out=0,in=180] + (C)[out=0,in=180] + (D){End!}[r]; +\end{tikzpicture} +\end{tzcode} + +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|. + +\subsection{\protect\cmd{\tzlink}, \protect\cmd{\tzlinks}} +\label{ss:curves:tzlink} + +You can also draw curves with |\tzlink| and |\tzlinks|. + +\begin{tzcode}{.3} +% \tztos +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(0,0)(A)(1,2)(B){B}[b](3,3)(C)(4,2)(D); +\tzlinks(A)[to[out=80,in=180]] + (B)[to[out=0,in=180]] + (C)[to[out=0,in=180]] + (D){End!}[r]; +\end{tikzpicture} +\end{tzcode} + +See Section \ref{s:tzlink} on page \pageref{s:tzlink}, for more details on |\tzlink|. + +See Section \ref{s:tzlink} on page \pageref{s:tzlinks}, for more details on |\tztos|. + +\subsection{\protect\cmd{\tzfn}} +\label{ss:curves:tzfn} + +With \icmd{\tzfn}, you can plot functions such as $f(x)=\frac13(x-1)^3+1$, $g(x)=\sin x$, $h(x)=\sqrt{x-1}$, and so on. +See Section \ref{s:tzfn} on page \pageref{s:tzfn}, for more details on |\tzfn|. + + + + + + diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C2-v2.0.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C2-v2.0.tex new file mode 100644 index 00000000000..f7a05fca540 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-C2-v2.0.tex @@ -0,0 +1,1533 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%%%=====CNONTINUED============ +%%%%%%========================== +%%%\part{Points, Lines, and Curves} +%%%%%%========================== +%%%\label{p:linesandcurves} + + +%%================================== +\chapter{Polygons and Circles} +\label{c:polygons} + +%%------------------------------------------------------------ +\section{Polygons: \protect\cmd{\tzpolygon}: Semicolon versions} +\label{s:polygons} + +\subsection{\protect\cmd{\tzpolygon}} +\label{ss:tzpolygon} + +\icmd{\tzpolygon} connects an arbitrary number of coordinates to draw a polygon, a closed figure. |\tzpolygon| is equivalent to a \xem{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: full +\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{in-between} 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. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +\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} + + + +\subsection{\protect\cmd{\tzpolygon*}} +\label{ss:tzpolygon*} + +The starred version \icmd{\tzpolygon*} paints the interior of the polygon with the default options |fill=black!50| with |fill opacity=.3| and |text opacity=1|. + +\begin{tzdef}{} +% syntax: minimum +\tzpolygon*(<coor>)(<coor>)..repeated..(<coor>) ; +% syntax: medium +\tzpolygon*(<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt] ; +% syntax: full +\tzpolygon*[<opt>]<shift coor>"<path name>" + (<coor>){<text>}[<node opt>] + ..repeated.. (){}[] ; {<fill opacity>} <code.append> +% defaults + *[fill=black!50,fill opacity=.3,text opacity=1]<>"" + (<m>){}[] .. repeated.. (){}[] ; {.3} <> +\end{tzdef} + +You can change the fill opacity by specifying the the last curly brace option |{<fill opacity>}| immediately \xem{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 |\settzfillopacity|. + + +\subsection{\protect\cmd{\tzpolygon+}, \protect\cmd{\tzpolygon*+}: Relative coordinates: Semicolon versions} +\label{ss:tzpolygon+} + +The plus version \icmd{\tzpolygon+} uses each coordinate (except the first one) relative (with |++|) 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]; % works like: + \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{Rectangles} +\label{s:rectangles} + +\subsection{\protect\cmd{\tzframe} and its variants} +\label{ss: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>)<code.append> +% defaults + []<>""(<m>)(<m>)<> +\end{tzdef} + +\icmd{\tzrectangle} and \icmd{\tzbox} are aliases of |\tzframe|. + +\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. \icmd{\tzrectangle+} and \icmd{\tzbox+} are aliases of |\tzframe+|. + +\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| and |text opacity=1|, by default. +(\icmd{\tzrectangle*} and \icmd{\tzbox*} are aliases of |\tzframe*|.) + +|\tzframe+| has also its starred version \icmd{\tzframe*+}. +(\icmd{\tzrectangle*+} and \icmd{\tzbox*+} are aliases of |\tzframe*+|.) + +\begin{tzdef}{} +% syntax +\tzframe*[<opt>]<shift coor>"<path name>" + (<coor1>)(<coor2>){<fill opacity>}<code.append> +% defaults + *[fill=black!50,fill opacity=.3,text opacity=1]<>""(<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 variants by specifying the option |<shift coor>| immediately before the first mandatory coordinate. +The empty shift option |<>| is not allowed. + +\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} + +You can use the last option |<code.append>| to add more \Tikz\ code. + +\begin{tzcode}{.3} +% \tzframe(*), \tzrectangle(*): <code.append> +\begin{tikzpicture} +\tzhelplines(4,4) +\tzframe*[blue,even odd rule](0,0)(3,2) + <(.5,.5) rectangle (2.5,1.5)> +\tzframe[fill=green,even odd rule](2,1)(4,4) + <(2.3,1.2) rectangle (3.5,3.6)> +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzrectanglering(*)}} + +\icmd{\tzrectanglering*} draws two rectangles and draws a rectangle ring by filling the interior with the default options \ixxw{even odd rule}, |fill=black!50|, |fill opacity=.3|, and |text opacity=1|. + +\begin{tzdef}{} +% syntax: minimal +\tzrectanglering*(<coorA1>)(<coorA2>)(<coorB1>)(<coorB2>) +% syntax: full +\tzrectanglering*[<opt>]<shift coor> + (<coorA1>)(<coorA2>)(<coorB1>)(<coorB2>) + {<fill opacity>}<code.append> +% defaults: + *[even odd rule,fill=black!50,fill opacity=.3,text opacity=1] + <>(<m>)(<m>)()(){.3}<> +\end{tzdef} + +\begin{tztikz}{} +\tzrectanglering*(A1)(A2)(B1)(B2) % works like: + \draw [fill=black!50,fill opacity=.3,text opacity=1, even odd rule] + (A1) rectangle (A2) + (B1) rectangle (B2) ; +\end{tztikz} + +\begin{tzcode}{.3} +% \tzrectanglering* +\begin{tikzpicture} +\tzhelplines(4,2) +\tzrectanglering*[blue](0,0)(3,2)(.5,.5)(2.5,1.5) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzrectanglering*: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzrectanglering*[blue](0,0)(3,2)(.5,.5)(2.5,1.5) +\tzrectanglering*[red]<.9,.9>(0,0)(3,2)(.5,.5)(2.5,1.5) +\end{tikzpicture} +\end{tzcode} + + + + +\icmd{\tzrectanglering} draws two rectangles with the default option |even odd rule|. + + +\begin{tzdef}{} +% syntax: minimal +\tzrectanglering(<coorA1>)(<coorA2>)(<coorB1>)(<coorB2>) +% syntax: full +\tzrectanglering[<opt>]<shift coor>(<coorA1>)(<coorA2>) + (<coorB1>)(<coorB2>)<code.append> +% defaults + [even odd rule]<>(<m>)(<m>)()()<> +\end{tzdef} + +\begin{tztikz}{} +\tzrectanglering(0,0)(2,2)(.5,.5)(1.5,1.5) % works like: + \draw (0,0) rectangle (2,2) + (.5,.5) rectangle (1.5 and 1.5); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzrectanglering: shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzrectanglering[blue](0,0)(3,2)(.5,.5)(2.5,1.5) +\tzrectanglering[red,fill=green]<.9,.9> + (0,0)(3,2)(.5,.5)(2.5,1.5) +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.3} +% \tzrectanglering* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzrectanglering*[blue](0,0)(3,2)(1.5,1.5)(4,3) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzrectanglering(*): nonzero rule, fill opacity +\begin{tikzpicture} +\tzhelplines(4,3) +\tzrectanglering*[red,draw=none,nonzero rule] + (0,0)(3,2)(1.5,1.5)(4,3){1} +\tzrectanglering[fill=white](0,0)(3,2)(1.5,1.5)(4,3) +\end{tikzpicture} +\end{tzcode} + +With the last option |<code.append>| you can add some more \Tikz\ code. + +\begin{tzcode}{.3} +% \tzframering(*), \tzboxring(*) +\begin{tikzpicture} +\tzhelplines(4,4) +\tzframering*[blue](0,0)(3,4) + < (1.3,1.3) circle (1cm) (2,3) circle (.5) > +\tzboxring[pattern=bricks](1,1)(4,3) + < (2.5,2) ellipse (1 and .7) > +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzframering} and \icmd{\tzboxring} are aliases of |\tzrectaglering|. + +\icmd{\tzframering*} and \icmd{\tzboxring*} are aliases of |\tzrectaglering*|. + +%%------------------------------------------------------------ +\section{Circles and rings} +\label{s:circleandring} + +\subsection{\protect\cmd{\tzcircle(*)}} +\label{ss:tzcircle} + +\icmd{\tzcircle} draws a circle around a specified coordinate with a specified radius. +The coordinate and the radius are mandatory. + +\begin{tzdef}{} +% syntax +\tzcircle[<opt>]<shift coor>"<path name>"(<coor>)(<radius>)<code.append> +% defaults + []<>""(<m>)(<m>)<> +\end{tzdef} + +\begin{tztikz}{} +\tzcircle(0,0)(1cm) % works like: + \draw (0,0) circle (1cm); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzcircle: "name path" and intersections +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcircle(1,1)(1cm) +\tzcircle[blue,dashed]"AA"(2,2)(1cm) +\tzvXpointat{AA}{2.5}(A) % intersections +\tzdots*(A-1){$A_1$}[r](A-2){$A_2$}[r]; +\end{tikzpicture} +\end{tzcode} + + +The starred version \icmd{\tzcircle*} fills the interior +with |fill=black!50| with |fill opacity=.3| and |text opacity=1|, by default. +You can change the fill opacity using the curly brace option |{<fill opacity>}| \xem{right after} the option |(<radius>)|. + +\begin{tzdef}{} +% syntax +\tzcircle*[<opt>]<shift coor>"<path name>" + (<coor>)(<radius>){<fill opacity>}<code.append> +% defaults + *[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3}<> +\end{tzdef} + + +You can move the circles by specifying the option |<shift coor>| \xem{before} the center coordinate or \xem{immediately before} the option |"<path name>"| if it exists. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +\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} + +With the last option |<code.append>|, you can add some \Tikz\ code. + +\begin{tzcode}{.3} +% \tzcircle(*): <code.append> +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzcircle*[blue,even odd rule](A)(1cm) + <(2,2) circle (1.5)> +\tzcircle[fill=green,even odd rule](B)(1cm) + <(3,1) circle (.7)> +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzring(*)}} + +\icmd{\tzring*} draws two circles and draws a circle ring by filling the interior with the default options \ixxw{even odd rule}, |fill=black!50|, |fill opacity=.3|, and |text opacity=1|. + +\begin{tzdef}{} +% syntax: minimal +\tzring*(<coor>)(<radius>)(<coor>)(<radius>) +% syntax: full +\tzring*[<opt>]<shift coor> + (<coor>)(<radius>)(<coor>)(<radius>){<fill opacity>}<code.append> +% defaults: + *[even odd rule,fill=black!50,fill opacity=.3,text opacity=1] + <>(<m>)(<m>)()(){.3}<> +\end{tzdef} + +\begin{tztikz}{} +\tzring*(0,0)(1cm)(0,0)(1.5cm) % works like: + \draw [fill=black!50,fill opacity=.3,text opacity=1, even odd rule] + (0,0) circle (1cm) (0,0) circle (1.5cm); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzring*: fill opacity +\begin{tikzpicture} +\tzhelplines(4,4) +\tzring*[green](2,2)(1)(2,2)(1.5) +\tzring*[fill=blue](3,1)(1)(3,1)(.7){1} % +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzring*: nonzero rule +\begin{tikzpicture} +\tzhelplines(4,2) +\tzring*[fill=red,nonzero rule](1,1)(1)(2,1)(1) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzring*: nonzero rule +\begin{tikzpicture} +\tzhelplines(4,2) +\tzring*[fill=red,nonzero rule](1,1)(1)(2,1)(1){1} +\tzring*[fill=white](1,1)(1)(2,1)(1){1} +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzring*: nonzero rule +\begin{tikzpicture} +%\tzhelplines(4,3) +\tzframe(0,0)(4,3) +\tzring*[blue](1.5,1.5)(1)(2.5,1.5)(1) +\end{tikzpicture} +\end{tzcode} + + +\icmd{\tzring} draws two circles with the default option \ixxw{even odd rule}. + + +\begin{tzdef}{} +% syntax: minimal +\tzring*(<coor>)(<radius>)(<coor>)(<radius>) +% syntax: full +\tzring*[<opt>]<shift coor> + (<coor>)(<radius>)(<coor>)(<radius>)<code.append> +% defaults: + [even odd rule]<>(<m>)(<m>)()()<> +\end{tzdef} + +\begin{tzcode}{.3} +% \tzring: shift +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzring[blue](2,2)(1)(2,2)(1.5) +\tzring[fill=green]<-1,0>(3,1)(1)(3,1)(.7) % shift +\end{tikzpicture} +\end{tzcode} + +You can add some \Tikz\ code with the last option |<code.append>|. + + +\begin{tzcode}{.3} +% \tzring(*): <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzring*[blue](2,2)(1)< (1.5,2) circle (.3 and .5) > +\tzring*[pattern=bricks](3,1)(1) + < (2.5,.5) rectangle ++(1,1) > +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzring(*): nonzero rule, fill opacity +\begin{tikzpicture} +\tzhelplines(4,3) +\tzring*[fill=red,draw=none,nonzero rule](1,1)(1){1} + <(3,.5) rectangle (1.5,3)> +\tzcirclering[fill=white](1,1)(1) + <(3,.5) rectangle (1.5,3)> +\end{tikzpicture} +\end{tzcode} + + + +\icmd{\tzcirclering} and \icmd{\tzcirclering*} are aliases of |\tzring| and |\tzring*|, respectively. + + + + +%%------------------------------------------------------------ +\section{Ellipses} +\label{s:ellipses} + +\subsection{\protect\cmd{\tzellipse(*)}} +\label{ss:tzellipse} + + +\icmd{\tzellipse} draws an ellipse around a specified coordinate with the specified x-radius and y-radius. + +The starred version \icmd{\tzellipse*} fills the interior +with |fill=black!50| with |fill opacity=.3| and |text opacity=1|, by default. + +|\tzellise(*)| is basically the same as |\tzcircle(*)|. + +\begin{tzdef}{} +% syntax +\tzellipse*[<opt>]<shift coor>"<path name>" + (<coor>)(<x and y radius>){<fill opacity>}<code.append> +% defaults: \tzellipse* + *[fill=black!50,fill opacity=.3,text opacity=1]<>""(<m>)(<m>){.3}<> +% defaults: \tzellipse + *[]<>""(<m>)(<m>)<> +\end{tzdef} + + + +\begin{tztikz}{} +\tzellipse(0,0)(1 and .5) % works like: + \draw (0,0) ellipse (1 and .5); +\end{tztikz} + + +You can move the ellipse by specifying the option |<shift coor>| immediately before the mandatory coordinate. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +Using the last option |{<fill opacity>}|, you can change the fill opacity. + +\begin{tzcode}{.3} +% \tzellipse(*) +\begin{tikzpicture} +\tzhelplines(4,3) +\tzellipse(2,2)(1.5 and 1) +\tzellipse*[blue](2,1)(1 and 1.5){.5} % fill opacity +\tzellipse[fill=green](3,1)(1cm and .5cm) +\tzellipse*[red]<0,-.5>(3,1)(1cm and .5cm) % shift +\end{tikzpicture} +\end{tzcode} + + + +You can add some \Tikz\ code with the option |<code.append>|. + +\begin{tzcode}{.3} +% \tzellipse(*), \tzoval(*): <code.append> +\begin{tikzpicture} +\tzhelplines(4,4) +\tzoval*[blue,even odd rule](2,2)(1.5 and 1) + <(2,2) ellipse (2 and 1.5)> +\tzellipse[fill=green,even odd rule](3,1)(1 and 1) + <(3,1) ellipse (.5 and .8)> +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzoval} is an alias of |\tzellipse| and \icmd{\tzoval*} is an alias of |\tzellipse*|. + + +\subsection{\protect\cmd{\tzellipsering(*)}} + +\icmd{\tzellipse*} draws two ellipses and draws an ellipse ring by filling the interior with the default options \ixxw{even odd rule}, |fill=black!50|, |fill opacity=.3|, and |text opacity=1|. + +\icmd{\tzellipse} draws two ellipses with the default option |even odd rule|. + +|\tzellipsering(*)| is basically the same as |\tzring(*)|. + +\begin{tzdef}{} +% syntax: minimal +\tzellipse*(<coor>)(<x and y radius>)(<coor>)(<x and y radius>) +% syntax: full +\tzellipsering*[<opt>]<shift coor> + (<coor>)(<x and y radius>)(<coor>)(<x and y radius>) + {<fill opacity>}<code.append> +% defaults: \tzellipse* + *[even odd rule,fill=black!50,fill opacity=.3,text opacity=1] + <>(<m>)(<m>)()(){.3}<> +% defaults: \tzellipse + *[even odd rule]<>(<m>)(<m>)()()<> +\end{tzdef} + +\begin{tztikz}{} +\tzellipsering*(2,1)(1cm and 1.5cm)(2,2)(1.5cm and 1.5cm) % works like: + \draw [fill=black!50,fill opacity=.3,text opacity=1, even odd rule] + (2,1) ellipse (1cm and 1.5cm) (2,2) ellipse (1.5cm and 1.5cm); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzring*: fill opacity +\begin{tikzpicture} +\tzhelplines(4,4) +\tzellipsering*[blue](2,2)(1 and 1)(2,2)(1.5cm) +\tzring*[fill=green](2,1)(1 and 1.5)(2,1)(.7 and 1){1} +\end{tikzpicture} +\end{tzcode} + + + + + + +\begin{tzcode}{.3} +% \tzellipsering(*) +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzellipsering*[blue](2,2)(1 and 1.5) + < (1.5,2.5) circle (3mm) > +\tzellipsering[pattern=bricks]<1,0>(2,1)(1 and 1.5) + < (2.5,.5) rectangle ++(1,1) > +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzellipsering(*) +\begin{tikzpicture} +\tzhelplines(4,4) +\tzcoors(2,2)(A)(3,1)(B); +\tzovalring*[fill=red,draw=none,nonzero rule] + (2,2)(1 and 1.5)(3,1)(1 and 1.5){1} +\tzovalring[fill=white] + (2,2)(1 and 1.5)(3,1)(1 and 1.5) +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzovalring} is an alias of |\tzellipsering| and \icmd{\tzovalring*} is an alias |\tzellipsering*|. + + + +%%================================== +\chapter{Arcs, Wedges, and Angle Marks} +\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 \xem{center coordinate}. + +\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>| before the center coordinate or immediately before the option |"<path name>"| if it exists. +The \xem{empty} shift option |<>| is \xem{not allowed}. + +\begin{tzcode}{.3} +% \tzarc('): shift, name path, intersection +\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>"AA"(1,1)(-45:180:1) %% +\tzvXpointat*{AA}{2.5} +\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 the path closed. + + +\begin{tzcode}{.3} +% \tzarc('): <code.append> +\begin{tikzpicture} +\tzhelplines(4,3) +\tzarc [blue,->](1,1)(-45:180:1) + < to[bend left] ++(1,-1) > +\tzarc [red,->] <2,1>(1,1)(-45:180:1)<--cycle> +\end{tikzpicture} +\end{tzcode} + + + +\subsection{Elliptical arcs} +\label{ss:ellipticalarc} + +|\tzarc| draws an \iisw{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,fill=green,fill opacity=.3] + (2,2)(0:-270:1 and 2)<--(2,2)--cycle> % 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 specified 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} + +The macro \icmd{\tzarcsfrom} (i.e. |\tzarcs + from|) accepts an arbitrary number of parenthesis arguments in the form of |(<angA:AngB:radius>)| following the start coordinate. Since |tzarcsfrom| is a semicolon version, you need to enter a \xem{semicolon} to indicate when the repetition ends. + +\begin{tzdef}{} +% syntax: minimum +\tzarcsfrom(<start coor>) + (<angA:angB:radius>)..repeated..(<angA:angB:radius>) ; +% syntax: full +\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} +\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} + + +\begin{tzcode}{.4} +% flag: shift +\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]<.1,.3>(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 \xem{center} coordinate. + +|\tzwedge| works similarly to |\tzarc|, but it forms a closed path from the center coordinate. |\tzwedge| does not have the option |<code.append>|. + +\begin{tzdef}{} +% syntax +\tzwedge[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<node opt>] +% defaults + []<>""(<m>)(<m>){}[midway] +\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 swap version \icmd{\tzwedge'} is the \iisw{swap version} of \icmd{\tzwedge}. +It 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*} + +The starred version \icmd{\tzwedge*} fills the wedges with |fill=black!50| with |fill opacity=.3| and |text opacity=1|, by default. +With |\settzfillcolor| and |\settzfillopacity|, you can change the default values. +You can also change the fill opacity by specifying the last optional argument |{<fill opacity>}|. + +\begin{tzdef}{} +% syntax: +\tzwedge*[<opt>]<shift coor>"<path name>" + (<coor>)(<angA:angB:radius>){<text>}[<node opt>]{<fill opacity>} +% defaults: + *[fill=black!50,fill opacity=.3,text opacity=1]<>""(<m>)(<m>){}[midway]{.3} +\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, fill opacity +\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*[blue]<2,0>(1,1)(300:240:1){B}[b]{.7} +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzwedge*('): name path, intersections +\begin{tikzpicture} +\tzhelplines(3,3) +\tzwedge'[blue]"AA"(0,1)(45:330:2) +\tzvXpointat{AA}{1}(A) +\tzdots*(A){A}[al](A-2); +\tzwedge*'[blue,fill=red] + (0,1)(45:330:2mm){$\theta$}[midway,r] +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{Angle marks} +\label{s:anglemarks} + + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzpointangle}: Angles between points} +\label{ss:tzpointangle} + +\icmd{\tzpointangle}|(<coor1>)(<coor2>)(<\mymacro>)| computes between two points and allows you to use it. + +\begin{tzcode}{.3} +\begin{tikzpicture}[font=\scriptsize] +\tzhelplines(5,4) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[135]; +\tzline[red,dashed](0,1)(5,1) +\tzline[tzextend={1cm}{1cm}](B)(A) % (B): center +\tzpointangle(B)(A){\myAngA} +\tznode(3,1){\myAngA\textdegree}[ar=2mm,absolute] +\tzarc(1,1)(0:\myAngA:2cm) +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.3} +\begin{tikzpicture}[font=\scriptsize] +\tzhelplines(5,4) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[135](2,3)(C){C} ; +\tzline[red,dashed](0,1)(5,1) +\tzline[tzextend={1cm}{1cm}](B)(A) +\tzline[tzextend={1cm}{1cm}](B)(C) +\tzpointangle(B)(A){\myAngA} +\tznode(3,1){\myAngA\textdegree}[ar=2mm,absolute] +\tzarc(1,1)(0:\myAngA:2cm) +\tzpointangle(B)(C){\myAngC} +\tznode(2,2){\myAngC\textdegree}[r=3mm] +\tzarc(1,1)(0:\myAngC:1.5cm) +\tzarc(1,1)(\myAngA:\myAngC:10pt){$\theta$}[ar,midway] +\tzarc(1,1)(\myAngA:\myAngC:11pt) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[font=\scriptsize] +\tzhelplines(5,4) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[135](2,3)(C){C} ; +\tzline[tzextend={1cm}{1cm}](B)(A) +\tzline[tzextend={1cm}{1cm}](B)(C) +\tzpointangle(B)(A){\myAngA} +\tzpointangle(B)(C){\myAngC} +\tzarc(1,1)(\myAngA:\myAngC:10pt){$\theta$}[ar,midway] +\tzarc(1,1)(\myAngA:\myAngC:11pt) +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzanglemark(')}: Angle marks} +\label{ss:tzanglemark} + +\icmd{\tzanglemark} accepts three mandatory coordinates to display an angle mark by an arc (of radius |10pt|, by default) for the second coordinate, on the |behind| layer by default. +You can change the angle arc radius by \icmd{\settzAAradius}. +You can change the layer by \icmd{\settzanglelayer}. Its alias is |\settzanglemarklayer|. + +The default line width of angle marks is |very thin|. You can change the default line with with \icmd{\settzAAlinestyle}. + +\begin{tzdef}{} +% syntax: minimum +\tzanglemark(<coorA>)(<coorB>)(<coorC>) +% syntax: full +\tzanglemark[<opt>](<coorA>)(<coorB>)(<coorC>){<text>}[<node opt>](<arc radius>) +% defaults + [very thin](<m>)(<m>)(<m>){}[pos=1.5](10pt) +\end{tzdef} + +You can add angle text by the options |{<text>}| and |[<node opt>]|. + +\begin{tzcode}{.3} +% simple example +\begin{tikzpicture} +\tzcoors*(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzanglemark(A)(B)(C){$\theta$} % angle mark +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \settzAAradius +\begin{tikzpicture} +\tzcoors(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzlines[thick,blue](A)(2.5,0)(C); +\tzanglemark(A)(B)(C){$\theta$} %% +\settzAAradius{20pt} %% +\tzanglemark(C)(2.5,0)(A){$\alpha$}[pos=.7] %% +\end{tikzpicture} +\end{tzcode} + + +\paragraph{How it works} Every |\tzanglemark| calculates angles (from 0\textdegree to 360\textdegree) and stores the values under the names \icmd{\tzangleONE} and \icmd{\tzangleTWO}. The difference of the two numbers is stored as an absolute value under the name \icmd{\tzangleresult}. +Of course, you can use these values \xem{only after} running |\tzanglemark|. +\begin{itemize}\firmlist +\item |\tzanglemark| draws an angle mark between two angles, |counterclockwise|, from small two large. +\item |\tzanglemark'| draws an angle mark between two angles, |clockwise|, from small to large. +\end{itemize} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzanglemark[->](A)(B)(C){$\theta$} +\tznode[scale=.7](3,1){ONE: \tzangleONE}[r] +\tznode[scale=.7](3,.5){TWO: \tzangleTWO}[r] +\tznode[scale=.7](3,0){$\theta$: \tzangleresult}[r] +\end{tikzpicture} +\end{tzcode} + + +\remark Simple to use: +\begin{itemize}\firmlist +\item +|\tzmarkanlge(A)(B)(C)| draws an angle mark by an arc from |(A)| to |(C)| about |(B)|. +\item +|\tzmarkanlge(C)(B)(A)| draws an angle mark by an arc from |(C)| to |(A)| about |(B)|. +\item Ignoring the direction, |\tzanglemark(A)(B)(C)| and |\tzanglemark(C)(B)(A)| give the same result. +\end{itemize} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzanglemark[->](C)(B)(A){$\theta$} +\tznode[scale=.7](3,1){ONE: \tzangleONE}[r] +\tznode[scale=.7](3,.5){TWO: \tzangleTWO}[r] +\tznode[scale=.7](3,0){$\theta$: \tzangleresult}[r] +\end{tikzpicture} +\end{tzcode} + +\paragraph{Swap version} +The \iisw{swap version} \icmd{\tzanglemark'} draws an angle mark for an angle in $360\text{\textdegree}-\theta$. +In other words, |\tzanglemark'| \xem{switches the direction} of drawing an angle arc from |counterclockwise| to |clockwise|, and vice versa. + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,3)(A){A}(1,2)(B)(3,0)(C){C}[0] ; +\tzlines[thick](A)(B)(C); +\tzanglemark[->](A)(B)(C){$\theta$} +\tznode[scale=.7](3,2){ONE: \tzangleONE}[r] +\tznode[scale=.7](3,1.5){TWO: \tzangleTWO}[r] +\tznode[scale=.7](3,1){$\theta$: \tzangleresult}[r] +\tzanglemark'[->](A)(B)(C){$\theta'$}(15pt) % swap +\end{tikzpicture} +\end{tzcode} + + + +\paragraph{Angle mark text position} +The midpoint of an angle arc is stored under the coordinate name |tzAAmid|. +The angle mark text is put on the line that goes through the middle point and \icmd{(tzAAmid)}. The default |(<arc radius>)| is |10pt| and the default position of angle text is |pos=1.5| in |[<node opt>]|. + +\begin{tzcode}{.3} +% angle marc text position +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzanglemark(C)(B)(A){$\theta$}[pos=.65](20pt) % +\tzdot*(tzAAmid) +\tzline[red,dashed,tzextend={1cm}{2cm}](B)(tzAAmid) +\end{tikzpicture} +\end{tzcode} + +\remark Instead of using the options |{<text>}| and |[<node opt>]|, you can also use the coordinate |(tzAAmid)| to place the angle text wherever you want, without using |\tzanglemark(')|. Of course, you can use the correct |(tzAAmid)| only after running |\tzanglemark|. + + + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzanglemark*(')}: Fill angle marks} +\label{ss:tzanglemark*} + +\icmd{\tzanglemark*} fills (in the |behind| layer, by default) the angle mark area with |fill=black!50| and with the options |fill opacity=.3| and |text opacity=1| by default. It does not draw any lines: |[draw=none]| by default. + +Using the macros such as |\settzfillcolor|, |\settzfillopacity|, and \icmd{\settzanglelayer}, you can change the default values. + + + +\begin{tzdef}{} +% syntax: minimum +\tzanglemark*(<coorA>)(<coorB>)(<coorC>) +% syntax: full +\tzanglemark[<opt>](<coorA>)(<coorB>)(<coorC>){<text>}[<node opt>](<arc radius>) +% defaults + [very thin](<m>)(<m>)(<m>){}[pos=1.5](10pt) +% syntax +\tzanglemark*[<opt>](<coor1>)(<coor2>)(<coor3>) + {<text>}[<node opt>](<arc radius>){<fill opacity>} +% defaults + *[very thin,draw=none,fill=black!50,fill opacity=.3,text opacity=1] + (<m>)(<m>)(<m>){}[pos=1.5](10pt){.3} +\end{tzdef} + + +\begin{tzcode}{.3} +% \tzanglemark* +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,2)(A){A}(1,1)(B){B}[180](2,3)(C){C} ; +\tzlines(A)(B)(C); +\tzanglemark*[red](C)(B)(A){$\theta$} +\end{tikzpicture} +\end{tzcode} + + +\icmd{\tzanglemark*'} is the \iisw{swap version} of |\tzanglemark*|. + +\begin{tzcode}{.3} +% \tzanglemark*(') +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(4,3)(A){A}(1,2)(B)(3,0)(C){C}[0] ; +\tzlines(A)(B)(C); +\tzanglemark*[red](A)(B)(C){$\theta$} +\tzanglemark*'[blue](A)(B)(C){$\theta'$}(15pt) % swap +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzanglemark*('): \settzAAlinestyle +\begin{tikzpicture} +\settzAAlinestyle{thick} +\tzhelplines(4,3) +\tzcoors*(4,3)(A){A}(1,2)(B)(3,0)(C){C}[0] ; +\tzlines[thick,blue](A)(B)(C); +\tzanglemark*[red](A)(B)(C){$\theta$} +\tzanglemark(A)(B)(C) +\settzAAlinestyle{very thin} % default +\tzanglemark'(A)(B)(C)(14pt) +\tzanglemark'(C)(B)(A)(15pt){$\theta'$} +\end{tikzpicture} +\end{tzcode} + + + +%%%% (REMOVED!!!) +%%%%%------------------------------------------------------------ +%%%\section{\protect\cmd{\tzpicangle}: angle marks} +%%%\label{s:tzpicangle} +%%% +%%%\begin{tzdef}{} +%%%% syntax: angle ABC or angle CBA +%%%\tzpicangle(')[<angle pic opt>][<path/draw opt>](<coor1>)(<coor2>)(<coor3>) +%%% {<angle pic text>}[<text eccentricity>](<angle pic arc radius>) +%%%% defaults:(')[][]()()(){}[1.5](10pt) +%%%\end{tzdef} +%%% +%%%When |(coor1) -- (coor2) -- (coor3)| is arranged naturally (counterclockwise), +%%%|\tzarc| draws an arc naturally (counterclockwise), while |tzarc'| draws an arc clockwise. +%%% +%%%When |(coor1) -- (coor2) -- (coor3)| is arranged clockwise, +%%%|\tzarc| draws an arc counterclockwise, while |tzarc'| draws an arc counterclockwise. +%%% +%%%\remark +%%%Internally, |\tzpicangle| is defined to draw an arc by a |pic| operation of \TikZ, so it is not affected by scaling, unless |transform shape| is not used. +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzlines(2,2)(1,1)(3,0); +%%%\tzpicangle[->,draw=red,fill=red!30](2,2)(1,1)(3,0){a} +%%%\tzlines [xshift=1cm](2,2)(1,1)(3,0); +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a} +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzlines(3,0)(1,1)(2,2); +%%%\tzpicangle[->,fill=red!30](3,0)(1,1)(2,2){a} +%%%\tzlines [xshift=1cm](3,0)(1,1)(2,2); +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a}[.5](1cm) +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzlines(2,0)(0,0)(0,2); +%%%\tzpicangle[fill=red!30](2,0)(0,0)(0,2){a} +%%%\tzlines [xshift=1cm](2,2)(1,1)(3,0); +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a}[.5](1cm) +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzpicangle [fill=red!30](2,2)(1,1)(3,0){a} +%%%\tzpicangle'[][xshift=1cm](2,2)(1,1)(3,0){a} +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzpicangle [fill=red!30](3,0)(1,1)(2,2){a} +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a}[.5](1cm) +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture} +%%%\tzhelplines(4,2) +%%%\tzpicangle [fill=red!30](2,0)(0,0)(0,2){a} +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a}[.5](1cm) +%%%\end{tikzpicture} +%%%\end{tzcode} +%%% +%%%\begin{tzcode}{.3} +%%%\begin{tikzpicture}[scale=.5] +%%%\tzhelplines(4,2) +%%%\tzpicangle [fill=red!30](2,0)(0,0)(0,2){a} +%%%\tzpicangle'[->][xshift=1cm](2,2)(1,1)(3,0){a}[.5](1cm) +%%%\end{tikzpicture} +%%%\end{tzcode} + + + + +\subsection{\protect\cmd{\tzrightanglemark}: Right angle marks} +\label{ss:tzrightangle} + +\icmd{\tzrightanglemark} takes three coordinates as mandatory arguments to display a right angle mark for the second coordinate. The mark is drawn on the |behind| layer by default, which can be changed by \icmd{\settzanglelayer}. + +The default line with is |very thin|, which can be changed by the option |[<opt>]|. You can also change the line width using \icmd{\settzRAlinestyle}, which is valid until the end of |tikzpicture| environment. +|\settzRAlinestyle| is an alias of |\settzAAlinestyle|. +The length of the side is |5pt| by default, and it can be changed by the last option |(<size>)|. +You can also change the size with \icmd{\settzRAsize}, which is valid until the end of the |tikzpicture| environment. + +\begin{tzdef}{} +% syntax: minimum +\tzrightanglemark(<coorA>)(<coorB>)(<coorC>) +% syntax: full +\tzrightanglemark[<opt>](<coorA>)(<coorB>)(<coorC>){<text>}[<node opt>](<size>) +% defaults + [very thin](<m>)(<m>)(<m>){}[](5pt) +\end{tzdef} + +\begin{tzcode}{.3} +% simple example (with angle text) +\begin{tikzpicture}[font=\scriptsize] +\tzhelplines(4,3) +\tzcoors(1,2)(A){A}(1,0)(B){B}[180](4,0)(C){C}[0]; +\tzlines(A)(B)(C); +\tzrightanglemark(A)(B)(C){90\textdegree} +\end{tikzpicture} +\end{tzcode} + +\remark +\begin{itemize}\firmlist +\item |\tzrightanglemark(A)(B)(C)| and |\tzrightanglemark(C)(B)(A)| give the same result. +\item |\tzrightanglemark'| is redundant, but it is provided to avoid frequent coding errors. +\end{itemize} + +Each |\tzrightanglemark| defines \icmd{(tzRAvertex)} as the coordinate of the right angle mark vertex. +The angle text is placed on the line going through the second coordinate and |(tzRAvertex)|. The default position is |pos=2| in |[<node opt>]|. + +\begin{tzcode}{.3} +% \settzRAsize +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors(2,3)(A){A}(1,1)(B){B}[180](3,0)(C){C}[0]; +\tzlines(A)(B)(C); +\settzRAsize{15pt} +\tzrightanglemark(A)(B)(C){90\textdegree}[pos=1.7] +\tzdot*(tzRAvertex) +\tzline[red,dashed,tzextend={2mm}{2cm}](B)(tzRAvertex) +\end{tikzpicture} +\end{tzcode} + +\remark You can also use the coordinate |(tzRAvertex)| to place angle text wherever you want, after |\tzrightanglemark|. + + + + +\subsection{\protect\cmd{\tzrightanglemark*}: Fill right angle marks} +\label{ss:tzrightangle*} + +The starred version \icmd{\tzrightanglemark*} fills the interior of right angle marks with |fill=black!50|, with |fill opacity=.3| and |text opacity=1|. It does not draw any line: |[draw=none]| by default. The filled mark is drawn on the |behind| layer by default, which can be changed by \icmd{\settzanglelayer}. +Its alias is \icmd{\settzanglemarklayer}. + +\begin{tzdef}{} +% syntax: minimum +\tzrightanglemark*(<coorA>)(<coorB>)(<coorC>) +% syntax: full +\tzrightanglemark*[<opt>](<coorA>)(<coorB>)(<coorC>) + {<text>}[<node opt>](<size>){<fill opacity>} +% defaults + *[draw=none,very thin,fill=black!50,fill opacity=.3,text opacity=1] + (<m>)(<m>)(<m>){}[](5pt){.3} +\end{tzdef} + +With \icmd{\settzfillcolor} and \icmd{\settzfillopacity}, you can also change the default fill color and fill opacity. + + +\begin{tzcode}{.3} +% \rightanglemark* +\begin{tikzpicture}[scale=.8,font=\scriptsize] +\tzhelplines(5,5) +\tzcoorsquick(0,5)(A)(4,0)(B)(0,1)(C)(5,5)(D); +\tzline"AB"(A)(B) +\tzline"CD"(C)(D) +\tzXpoint{AB}{CD}(E) +\tzrightanglemark*(A)(E)(D){90\textdegree} +\tzrightanglemark*[red](A)(E)(C)(20pt) +\tzrightanglemark*[draw=blue,fill=green](B)(E)(C)(20pt) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \settzRAsize +\begin{tikzpicture}[scale=.8,font=\scriptsize] +\tzhelplines(5,5) +\tzcoorsquick(0,5)(A)(4,0)(B)(0,1)(C)(5,5)(D); +\tzline[dotted]"AB"(A)(B) +\tzline[dotted]"CD"(C)(D) +\tzXpoint{AB}{CD}(E) +\settzRAsize{20pt} %% +\tzrightanglemark*[red](A)(E)(D){$\rho$}[pos=1.3] +\tzrightanglemark[blue,thin](A)(E)(D) +\tzrightanglemark*[draw=blue,thin,fill=green](B)(E)(C) +\end{tikzpicture} +\end{tzcode} + + + diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v1.0.1.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v2.0.tex index d493e6ecf6d..70148a3c9e3 100644 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v1.0.1.tex +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v2.0.tex @@ -11,6 +11,9 @@ \chapter{Axes} \label{c:axes} + + + %%------------------------------------------------------------ \section{Draw axes} \label{s:tzaxes} @@ -18,7 +21,7 @@ \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>|. +Basically, \icmd{\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 formed by the two coordinates. |\tzaxes| takes only one coordinate |(<x2,y2>)| as a mandatory argument, in which case the coordinate |(<x1,y1>)| is considered as |(0,0)|. @@ -350,13 +353,13 @@ You can change the numbered labels to a different format with slashes and other \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] +\tzticks{1/$x_1$,2,5/$x_2$,8/y}[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)|.) +By specifying the options |(<x-from:x-to>)| for $x$ ticks and/or |(<y-from:y-to>)| for $y$ ticks, you can print tick marks. (The default is |(0pt:0pt)| for both options.) \begin{tzcode}{.3} % \tzticks: tick marks with (<a pt:b pt>) @@ -365,15 +368,29 @@ To prints tick marks you need to specify |(<x-from:x-to>)| for $x$ ticks and/or \tzshoworigin \tzaxes(-1,-1)(10,10) \tzticks[draw=red,thick] - (-5pt:10pt){1,...,7,8/$\alpha$} - (0pt:3cm) {2,...,6,7/$\beta$} + (-15pt:10pt){1,...,5,6/$k$,7/$\alpha$,8/$\beta$} + (0pt:3cm) {2,...,6,7/$\gamma$} \end{tikzpicture} \end{tzcode} +The position of tick labels does not depend on the length of the tick marks. +You can change the position of tick labels using |[<node opt>]|. + +\begin{tzcode}{.3} +% \tzticks: position of tick labels +\begin{tikzpicture}[scale=.4,font=\scriptsize] +\tzhelplines(10,10) +\tzshoworigin +\tzaxes(-1,-1)(10,10) +\tzticks[draw=red,thick] + (-15pt:10pt){1,...,6,7/$t$,8/$\alpha$}[b=5pt] + (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|. + +You can move (or shift) tick marks and labels together by specifying 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 @@ -532,26 +549,26 @@ The options |<y-shift>| and |<x-shift>| move x-ticks and y-ticks, respectively. \label{c:projections} %%------------------------------------------------------------ -\section{\protect\cmd{\tzproj(*)}} +\section{\protect\cmd{\tzproj(*)}: Projections on the axes} \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>) +\tzproj(<coor>) % syntax: medium - \tzproj*(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>] +\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>) +\tzproj*[<opt>]<x-shift,y-shift>(<coor>) + {<x-text>}[<node opt>]{<y-text>}[<node opt>](<dot size>) % defaults *[dotted]<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. Internally, the node dot is processed by |\tzdot*|. -The first option |<opt>| does not control the node dot. +The first option |[<opt>]| does not control the node dot. \paragraph{Dot size} You can only control the size of dots by the last optional argument |(<dot size>)| or by the \threeways\ on page \pageref{ss:threeways}. @@ -613,7 +630,7 @@ Specifying the option |<x-shift,y-shift>| moves the projection point and text on \begin{tzdef}{} % syntax: - \tzprojx[<opt>]<x-shift,y-shift>(<coor>){<x-text>}[<node opt>](<dot size>) +\tzprojx[<opt>]<x-shift,y-shift>(<coor>){<x-text>}[<node opt>](<dot size>) % defaults []<0,0>(<m>){}[text height=1.25ex,text depth=.25ex,below](2.4pt) \end{tzdef} @@ -625,7 +642,7 @@ Specifying the option |<x-shift,y-shift>| moves the projection point and text on \begin{tzdef}{} % syntax: - \tzprojy[<opt>]<x-shift,y-shift>(<coor>){<y-text>}[<node opt>](<dot size>) +\tzprojy[<opt>]<x-shift,y-shift>(<coor>){<y-text>}[<node opt>](<dot size>) % defaults []<0,0>(<m>){}[left](2.4pt) \end{tzdef} @@ -663,6 +680,122 @@ Specifying the option |<x-shift,y-shift>| with |\tzprojx(*)| and |\tzprojy(*)| m +%%------------------------------------------------------------ +\section{\protect\cmd{\tzprojs(*)}: Semicolon versions} +\label{s:tzprojs} + +\icmd{\tzprojs} accepts any number of coordinates and draws perpendicular lines onto each axis from the coordinates. The lines are |dotted|, by default. +|\tzprojs| is a semicolon version of |\tzproj|, so a semicolon is needed to indicate when the coordinate iteration ends. Its repeating pattern is |(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>]|. + +\begin{tzdef}{} +% syntax: minimum +\tzprojs(<coor>)(<coor>) ..repeated.. (<coor>); +% syntax: medium +\tzprojs*(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>] + ..repeated.. (){}[]{}[] +% syntax: +\tzprojs*[<opt>]<x-shift,y-shift> + (<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>] + ..repeated.. (){}[]{}[];(<dot size>) +% defaults + *[dotted]<0,0> + (<m>){}[text height=1.25ex,text depth=.25ex,below]{}[left] + ..repeated..(){}[]{}[];(2.4pt) +\end{tzdef} + +\icmd{\tzprojs*} additionally prints |\tzdots*| of the |2.4pt| (by default) on the coordinates. +The first option |[<opt>]| does not control the node dots. + +\begin{tzcode}{.3} +% \tzprojs(*): adding text +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(8,6) +\tzcoors(30:7)(A)(50:6)(B); +\tzprojs*[dashed,text=blue] + (2,3){$x$}{$y$} + (A){$a_1$}{$a_2$} + (B){$x^*$}[green]{$y^*$}[red]; +\end{tikzpicture} +\end{tzcode} + +You can move the projection points and text accordingly, using the option |<x-shift,y-shift>| before the first coordinate. The \xem{empty} shift option |<>| is \xem{not allowed}. +You can also change the dot size with the last option |(<dot size>)| \xem{after} the semicolon, as in |\tzproj(*)|. + +\begin{tzcode}{.3} +% \tzprojs(*): shift and dot size +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,6) +\tzaxes(8,6) +\tzaxes[blue]<1,1>(8,6) +\tzcoors(30:7)(A)(50:6)(B); +\tzprojs*[dashed,text=blue]<1,1> %% + (2,3){$x$}{$y$} + (A){$a_1$}{$a_2$} + (B){$x^*$}[green]{$y^*$}[red];(4pt) %% +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzprojsx(*)} and \protect\cmd{\tzprojsy(*)}: Semicolon versions} +\label{s:tzprojsx} + +\icmd{\tzprojsx} is a semicolon versions of |\tzprojx|. It draws dotted lines, which are perpendicular to the x axis from the specified coordinates, by default. + +\icmd{\tzprojsx*} additionally prints |\tzdots*| of the size |2.4pt|, by default. + + +\begin{tzdef}{} +% syntax: +\tzprojsx*[<opt>]<x-shift,y-shift> + (<coor>){<x-text>}[<node opt>]..repeated..(){}[];(<dot size>) +% defaults + *[]<0,0> (<m>){}[text height=1.25ex,text depth=.25ex,below] + ..repeated..(){}[];(2.4pt) +\end{tzdef} + + +\icmd{\tzprojsy} and \icmd{\tzprojsy*} work simililarly as |\tzprojsx| and |\tzprojsx*| do but to the y axis. + +\begin{tzdef}{} +% syntax: +\tzprojsy*[<opt>]<x-shift,y-shift> + (<coor>){<y-text>}[<node opt>]..repeated..(){}[];(<dot size>) +% defaults + []<0,0> (<m>){}[left]..repeated..(){}[];(2.4pt) +\end{tzdef} + + +\begin{tzcode}{.3} +% \tzprojsx(*), \tzprojsy(*) +\begin{tikzpicture}[scale=.5,font=\scriptsize] +\tzhelplines(-1,-2)(6,6) +\tzshoworigin +\tzaxes(-1,-1)(6,6) +\tzprojsx*[thick] + (4,5){4} + (3,4){$x=3$}[blue] + (5,2){2};(5pt) +\end{tikzpicture} +\end{tzcode} + +Specifying the option |<x-shift,y-shift>| moves the projection points and text accordingly. + +\begin{tzcode}{.3} +% \tzprojsx(*), \tzprojsy(*): shift +\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) +\tzprojsy*[red,solid]<2,1> + (3,4){$x=3$}[blue] + (5,2){2}; +\end{tikzpicture} +\end{tzcode} + + %%================================== \chapter{Plot Functions} @@ -670,7 +803,7 @@ Specifying the option |<x-shift,y-shift>| with |\tzprojx(*)| and |\tzprojy(*)| m %%------------------------------------------------------------ -\section{\protect\cmd{\tzfn}: Plot functions} +\section{\protect\cmd{\tzfn} and \protect\cmd{\tzfn'}: Plot functions and inverse functions} \label{s:tzfn} \subsection{Syntax} @@ -688,31 +821,75 @@ Specifying the option |<x-shift,y-shift>| with |\tzprojx(*)| and |\tzprojy(*)| m {<fn of \x>}[<domain>]{<text>}[<node opt>]<code.append> % [<domain>] should be of the form [<from num:to num>] % defaults - [samples=200]<>""{<m>}[<m>]{}[]<> + [samples=201]<>""{<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}); +\tzfn{.5*(\x)^2-1}[1:5] % works like: + \draw [samples=201,domain=1:5] plot (\x,{.5*(\x)^2-1}); \end{tztikz} +\begin{tzcode}{.3} +% \tzfn : simple example +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(5,5) +\tzaxes*(-2,-2)(5,5) +\tzfn{.5*(\x)^2-1}[0:3.5] +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\subsection{Inverse functions: \protect\cmd{\tzfn'}} +\label{ss:tzfn'} + +The \iisw{swap version} \icmd{\tzfn'} draws the \iisw{inverse function} of |\tzfn|. + +\begin{tztikz}{} +\tzfn'{.5*(\x)^2-1}[1:5] % works like: + \draw [samples=201,domain=1:5] plot ({.5*(\x)^2-1},\x); +\end{tztikz} + +\begin{tzcode}{.3} +% \tzfn' : inverse function (with text) +\begin{tikzpicture}[scale=.5] +\tzhelplines(-2,-2)(5,5) +\tzaxes*(-2,-2)(5,5) +\tzfn{.5*(\x)^2-1}[0:3.5] +\tzfn'[red]{.5*(\x)^2-1}[0:3.5]{inversed}[r] %% +\end{tikzpicture} +\end{tzcode} + +You can add text 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){$Q$}{$P$} +\tzfn{5-5/7*\x}[0:7]{demand}[a=5mm] +\tzfn'[blue]{5-5/7*\x}[0:7] + {inverse\\demand}[r=5mm,align=center] +\tzticks{5,7}{5,7} +\end{tikzpicture} +\end{tzcode} + \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] +\def\Dx{7-\x} % define +\tzfn{\Dx}[0:7]{$D$}[ar] \tzfn{1+\x}[0:7]{$S$}[blue,r] \end{tikzpicture} \end{tzcode} @@ -736,55 +913,61 @@ You can also use the predefined functions of \Tikz\ such as |sin|, |cos|, |ln|, \subsection{Name paths: \texttt{name path}} \label{ss:tzfn:namepath} -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. +You can name the path of |\tzfn| by specifying the option |"<path name>"| \xem{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}); + \draw [samples=201,,domain=1:5,name path=mypath] plot (\x,{\Fx}); \end{tztikz} -\remark -Suppose that the function's expression |<fn of \x>| consists \xem{only of a macro name}, say |\Fx|. Then -\begin{itemize} -\item The macro name |Fx| (\xem{without the backslash}) is \xem{automatically assigned} to |<path name>|, unless you give another name. +\remark Advantage of defining functions: + +Suppose that the function's expression |<fn of \x>| consists \xem{only of a macro name}, say, |\Fx|. Then + +\begin{itemize}\firmlist +\item The macro name |Fx| (\xem{without the backslash}) is + \xem{automatically assigned} to |<path name>|, + unless you give another name. \item That is, |\tzfn\Fx| is equivalent to |\tzfn"Fx"\Fx|. -(\xem{You don't need to type the same thing twice}.) + (\xem{You don't need to type the same thing twice}.) +\end{itemize} + \begin{tztikz}{} \tzfn\Fx[1:5] % works like: - \draw [samples=200,domain=1:5,name path=Fx] plot (\x,{\Fx}); + \draw [samples=201,domain=1:5,name path=Fx] plot (\x,{\Fx}); \end{tztikz} -\end{itemize} \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\Dx{7-\x} \def\Sx{1+\x} -\tzfn"Dx"\Dx[0:7]{$D$}[r] % name path = Dx +\tzfn"Dx"\Dx[0:7]{$D$}[ar] % name path = Dx \tzfn \Sx[0:7]{$S$}[blue,r] % name path = Sx -\tzXpoint*{Dx}{Sx}(E){E} +\tzXpoint*{Dx}{Sx}(E){E} % intersection \end{tikzpicture} \end{tzcode} + \subsection{Move graphs: \texttt{shift}} You can move the graph of |\tzfn| by specifying the option |<shift coor>| \xem{before} the mandatory argument |{<fn of \x>}| or \xem{immediately before} the option |"<path name>"|, if it exists. -The empty shift option |<>| is not allowed. +The \xem{empty} shift option |<>| is \xem{not allowed}. \begin{tzcode}{.3} % \tzfn: shift \begin{tikzpicture}[scale=.6] \tzhelplines(8,8) -\def\Dx{7-2/3*\x} +\def\Dx{7-\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] +\tzfn[dashed]<1,1>"demandA"\Dx[0:7]{$D'$}[r] +\tzfn[dashed]<1,-1>"supplyA"\Sx[0:7]{$S'$}[r] \tzXpoint*{demandA}{supplyA}(E1){$E'$} \end{tikzpicture} \end{tzcode} @@ -794,7 +977,7 @@ The empty shift option |<>| is not allowed. \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 adds the \Tikz\ code to the path \xem{after} the options |{<text>}| and |[<node opt>]|. +You can extend the path of |\tzfn|, by writing \Tikz\ code in the \xem{last optional argument} |<code.append>|. Internally it adds the \Tikz\ code to the path \xem{after} the options |{<text>}| and |[<node opt>]|. \begin{tzcode}{.3} % \tzfn: <code.append> @@ -808,7 +991,7 @@ You can extend the path created by |\tzfn| from the end of the graph, by writing \end{tzcode} \paragraph{\texttt{\bs tzfnAtEnd}} -You can also extend the path with \icmd{\tzfnAtEnd}. +You can also extend the path of |\tzfn| at the end using \icmd{\tzfnAtEnd}. Internally it adds \Tikz\ code immediately \xem{before} the options |{<text>}| and |[<node opt>]|. But you have to use |\tzfnAtEnd| (immediately) \xem{before each} |\tzfn|. \begin{tzcode}{.3} @@ -819,13 +1002,26 @@ Internally it adds \Tikz\ code immediately \xem{before} the options |{<text>}| a \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} + +Specifying the option |<code.append>| extends the path after |\tzfnEnd| if it exists. + +\begin{tzcode}{.3} +% \tzfnAtEnd (before \tzfn) +\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] + < arc (0:90:4cm) node [draw,red,left] {Here!!} > \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|. +You can use \icmd{\tzfnAtBegin} (immediately) \xem{before each} |\tzfn| to insert \Tikz\ code at the beginning of the path of |\tzfn|. \begin{tzcode}{.3} % \tzfnAtBegin (before \tzfn) @@ -833,75 +1029,119 @@ You can use \icmd{\tzfnAtBegin} (immediately) \xem{before each} |\tzfn| to inser \tzhelplines(-2,-2)(8,6) \tzaxes*(-2,-2)(8,6) \def\Fx{sin(\x r)+3} -\tzfnAtBegin{ (0,0) -- } +\tzfnAtBegin{ (1,1) -| } \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. +\remark +\begin{itemize}\firmlist +\item |\tzfn| is based on the |plot| operation of \Tikz. +\item Appending \Tikz\ code at the beginning of |\tzfn| may cause a problem when you use some operations (such as |to| or \verb+|-|+) that expect a coordinate to link. +\item In the version 2 of the |tzplot| package, this issue is internally taken care of by using +|(|\ixxw{current subpath start}|)|, which is a special coordinate pre-defined in \Tikz. (See \Tikz\ manual for more details.) \end{itemize} + + +\section{\protect\cmd{\tzfnofy} and \protect\cmd{\tzfnofy'}: Functions of variable $y$} +\label{ss:tzfnofy} + +\icmd{\tzfnofy} plots a function of |\y|. +Define a function with the (predefined) variable |\y|. + +|\tzfnofy| works just like |\tzfn| but as a function of |\y|. + \begin{tzdef}{} -% syntax -\tzLFn[<opt>]<shift coor>"<path name>" - (<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append> +% syntax: minimum +\tzfnofy{<fn of \y>}[<domain>] +% syntax: medium +\tzfnofy{<fn of \y>}[<domain>]{<text>}[<pos>] +% syntax: full +\tzfnofy[<opt>]<shift coor>"<path name>" + {<fn of \y>}[<domain>]{<text>}[<node opt>]<code.append> +% [<domain>] should be of the form [<from num:to num>] % defaults -[]<>""(<m>)(){1}[<m>]{}[]<> + [samples=201]<>""{<m>}[<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$. -|\tzLFn(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{tztikz}{} +\tzfnofy{2*\y+1}[1:5] % works like: + \draw [samples=201,domain=1:5,variable=\y] plot ({2*\y+1},\y); +\end{tztikz} + +The \iisw{swap version} \icmd{\tzfnofy'} plots the \iisw{inverse function} of |\tzfnofy|. + +\begin{tztikz}{} +\tzfnofy'{2*\y+1}[1:5] % works like: + \draw [samples=201,domain=1:5,variable=\y] plot (\y,{2*\y+1}); +\end{tztikz} + \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) +% \tzfnofy('): variable = \y +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,8) +\tzaxes(8,8){$x$}{$y$} +\tzfnofy{5-5/7*\y}[0:7]{$f(y)$}[r=5mm] +\tzfnofy'[blue]{5-5/7*\y}[0:7] + {$f^{-1}(y)$}[a=5mm,align=center] +\tzticks{5,7}{5,7} +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzfnofy: shift: intersections +\begin{tikzpicture}[scale=.6] +\tzhelplines(8,8) +\def\Fy{7-\y} +\def\Gy{1+\y} +\tzfnofy\Fy[0:7]{$f(y)$}[right] % name path = Fy +\tzfnofy\Gy[0:7]{$g(y)$}[right] % name path = Gy +\tzXpoint*{Fy}{Gy}(E){$E$} +\tzfnofy[dashed]<1,1>"Fyy"\Fy[0:7]{shifted}[r] +\tzfnofy[dashed]<1,-1>"Gyy"\Gy[0:7]{shifted}[r] +\tzXpoint*{Fyy}{Gyy}(E1){$E'$} \end{tikzpicture} \end{tzcode} -You can move the line of |\tzLFn| by specifying the option |<shift coor>| immediately before the option |"<path name>"|. (The empty shift option |<>| is not allowed.) -You can also expand the path of |\tzLFn| by writing \Tikz\ code in the last optional argument |<code.append>|. +You can also extend the path of |\tzfnofy| using the option |<code.append>| or the macros \icmd{\tzfnofyAtBegin} and \icmd{\tzfnofyAtEnd}. + \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!} > +% \tzfnofy: shift: intersections +\begin{tikzpicture}[scale=.5] +\tzhelplines(8,8) +\def\Fy{7/\y} +\tzfnofyAtBegin{(6,3) node [a] {Start} to[bend left]} +\tzfnofyAtEnd{ -| ++(3,-1) } +\tzfnofy[->]\Fy[1:7] + < to[bend right] ++(3,2) node [draw,r] {End!} > \end{tikzpicture} \end{tzcode} + + +%%%\section{\protect\cmd{\tzdeffn} and \protect\cmd{\tzdeffnofy}} +%%%\label{ss:tzdeffn} +%%% +%%%\icmd{\tzdeffn} defines a functions of |\x|. +%%% +%%%\icmd{\tzdeffnofy} defines a function of |\y|. +%%%%% +%%%%%These are redundant, since one can use |\def|. +%%%%% + + + + + %%------------------------------------------------------------ \section{Horizontal lines} \label{s:tzhfn} @@ -922,6 +1162,7 @@ You can also expand the path of |\tzLFn| by writing \Tikz\ code in the last opti []<>""{<m>}[west:east (of current bounding 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}. @@ -947,7 +1188,7 @@ The default domain is from left to right of the \ixxw{current bounding box}. 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>|. +You can also extend the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|. \begin{tzcode}{.3} % \tzhfnat: shift, <code.append> @@ -962,6 +1203,8 @@ You can also expand the path from the end of the line by writing \Tikz\ code in \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzhfnatAtBegin} and \icmd{\tzhfnatAtEnd} to extend the path of |\tzhfnat| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzhfnatAtEnd| if it exists. +(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.) \subsection{\protect\cmd{\tzhfn}} @@ -996,6 +1239,8 @@ For example, |\tzhfn(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhfnat{3}|. \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzhfnAtBegin} and \icmd{\tzhfnAtEnd} to extend the path of |\tzhfn| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzhfnAtEnd| if it exists. +(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.) %%------------------------------------------------------------ @@ -1007,7 +1252,6 @@ For example, |\tzhfn(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhfnat{3}|. \icmd{\tzvfnat} draws a vertical line at a specified value of $x$. - \begin{tzdef}{} % syntax: minimal \tzvfnat{<x-val>}[<domain>] @@ -1036,7 +1280,7 @@ The default domain is from bottom to top of the \ixxw{current bounding box}. 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>|. +You can also extend the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|. \begin{tzcode}{.3} % \tzvfnat: shift, <code.append> @@ -1053,6 +1297,8 @@ You can also expand the path from the end of the line by writing \Tikz\ code in In the previous example, |\tzhelplines*| is used to fix a bounding box. (See Section \ref{s:tzhelplines} on page \pageref{s:tzhelplines}, for more details.) +You can also use \icmd{\tzvfnatAtBegin} and \icmd{\tzvfnatAtEnd} to extend the path of |\tzvfnat| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzvfnatAtEnd| if it exists. +(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.) \subsection{\protect\cmd{\tzvfn}} \label{ss:tzvfn} @@ -1086,6 +1332,669 @@ For example, |\tzvfn(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvfnat{3}|. \end{tikzpicture} \end{tzcode} +You can also use \icmd{\tzvfnAtBegin} and \icmd{\tzvfnAtEnd} to extend the path of |\tzvfn| at the beginning and at the end. Specifying the option |<code.append>| extends the path after |\tzvfnAtEnd| if it exists. +(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.) + + + + + +%%================================== +\chapter{Plot Linear Functions} +\label{c:linearfunctions} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzLFn}: Plot linear functions} +\label{s:tzLFn} + +\subsection{\protect\cmd{\tzLFn} and \protect\cmd{\tzLFn'}} + +Knowing two coordinates or one coordinate with a slope, you can draw a linear function with the macro \icmd{\tzLFn}, \xem{without writing the explicit definition of a linear function}. + +\begin{itemize}\firmlist +\item +|\tzLFn(<coor1>)(<coor2>)| is prepared for when you know two coordinates on a line. + \begin{itemize} + \item + If you provide two points $(x_1,y_1)$ and $(x_2,y_2)$, |\tzLFnofy(x1,x2)(y1,y2)| draws the graph of $f(x)=\frac{y_2-y_1}{x_2-x_1}(x-x_1)+y_1$. + \end{itemize} + +\item +|\tzLFn(<coor1>){<slope>}| is prepared for when you know one coordinate and the slope of a line. +\item +If you specify all the three arguments |(<coor1>)(<coor2>){<slope>}|, then the slope is ignored. +\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$. +|\tzLFn(1,1){.5}[0:4]| draws a line passing through a point $(1,1)$ with a slope |.5|, over $0\leq x\leq 4$. + +|\tzLFn| accepts two mandatory arguments: |(<coor1>)| and |[<domain>]|. +\begin{itemize}\firmlist +\item The \xem{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} + +\begin{tzdef}{} +% syntax: minimum +\tzLFn(<coor1>)(<coor2>)[<domain>] +\tzLFn(<coor1>){<slope>)[<domain>] +% syntax: full +\tzLFn[<opt>]<shift coor>"<path name>" + (<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>)(){1}[<m>]{}[]<> +\end{tzdef} + + + +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>"| \xem{immediately before} the mandatory coordinate. + +\begin{tzcode}{.3} +% \tzLFn: two coordinates +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r] +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzLFn: one coordinate and slope +\begin{tikzpicture} +\tzhelplines(4,3) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFn[red]"Fx"(A){.5}[0:4]{$f(x)$}[a] +\end{tikzpicture} +\end{tzcode} + +\remark If you inadvertently try an \xem{infinite slope}, you will get an \iisw{error message}. + +\paragraph{Inverse function} The \iisw{swap version} \icmd{\tzLFn'} draws the \iisw{inverse function} of |\tzLFn|. + +\begin{tzcode}{.3} +% \tzLFn' : inverse function : intersection +\begin{tikzpicture}[scale=.8] +\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 of |\tzLFn| by specifying the option |<shift coor>| immediately before the option |"<path name>"|. (The \xem{empty} shift option |<>| is \xem{not allowed}.) +You can also extend the path of |\tzLFn| by writing \Tikz\ code in the last optional argument |<code.append>|. + +\begin{tzcode}{.3} +% \tzLFn: shift, extending path +\begin{tikzpicture}[scale=.8] +\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} + +\icmd{\tzLFnAtBegin} and \icmd{\tzLFnAtEnd} are available to extend a path of |\tzLFn| at the beginning and and the end, respectively. +Specifying the option |<code.append>| extends the path after |\tzLFnAtEnd|, if it exist. + +\begin{tzcode}{.3} +% \tzLFnAtBegin and \tzLFnAtEnd +\begin{tikzpicture}[scale=.8] +\tzhelplines*(4,4) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r] +\tzLFnAtBegin{(1,0) to [bend left] } +\tzLFnAtEnd{ arc (0:140:2) } +\tzLFn[dashed,red,->]<1,1>"Gx"(B)(C)[0:4]{$g(x)$}[r] +\end{tikzpicture} +\end{tzcode} + + + +\subsection{\protect\cmd{\tzLFnofy} and \protect\cmd{\tzLFnofy'}} + +\icmd{\tzLFnofy} draws a line as a function of |\y|. +|\tzLFnofy| works just like |\tzLFn| but for the variable $y$. +If you provide two points $(x_1,y_1)$ and $(x_2,y_2)$, |\tzLFnofy(x1,x2)(y1,y2)| draws the graph of $f(y)=\frac{x_2-x_1}{y_2-y_1}(y-y_1)+x_1$. + +Everything else is the same as |\tzLFn|. + +\begin{tzdef}{} +% syntax: minimum +\tzLFnofy(<coor1>)(<coor2>)[<domain>] +\tzLFnofy(<coor1>){<slope>)[<domain>] +% syntax: full +\tzLFnofy[<opt>]<shift coor>"<path name>" + (<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append> +% defaults + []<>""(<m>)(){1}[<m>]{}[]<> +\end{tzdef} + +\begin{tzcode}{.3} +% \tzLFnofy +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,4) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFnofy[red]"Fx"(A){.5}[0:4]{$f(y)$}[a] +\tzLFnofy[blue]"Gx"(B)(C)[.5:2.5]{$g(y)$}[a] +\tzXpoint*[fill=none]{Fx}{Gx}(E){$E$}(3pt) +\end{tikzpicture} +\end{tzcode} + +\remark If you inadvertently try an \xem{infinite slope}, you will get an \xem{error message}. + +\paragraph{Inverse function} +The \iisw{swap version} \icmd{\tzLFnofy'} draws the \iisw{inverse function} of |\tzLFnofy|. + +\begin{tzcode}{.3} +% \tzLFnofy' +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,4) +\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C); +\tzLFnofy'[red]"Fx"(A){.5}[0:4]{$f(y)$}[a] +\tzLFnofy'[blue]"Gx"(B)(C)[.5:2.5]{$g(y)$}[r] +\tzXpoint*[fill=none]{Fx}{Gx}(E){$E$}(3pt) +\end{tikzpicture} +\end{tzcode} + + +You can use \icmd{\tzLFnofyAtBegin} and \icmd{\tzLFnofyAtEnd} to extend the path of |\tzLFnofy| at the beginning and at the end. Specifying the optional argument |<code.append>| extends the path after |\tzLFnofyAtEnd| if it exists. +(See other examples of using |\tz<..>AtBegin| and |\tz<...>AtEnd|.) + + +\section{\protect\cmd{\tzdefLFn}} +\label{s:tzdefLFn} + +\icmd{\tzdefLFn} simply defines a linear function $ax+b$ and saves it to a macro. +You can use |\tzdefLFn| together with |\tzfn| to graph a linear function, \xem{without writing an explicit definition} of a linear function. +(Of course, you can directly use |\tzLFn|.) + +\begin{tzdef}{} +% syntax +\tzdefLFn{<fn csname>}(<coor1>)(<coor2>){<slope>} +% defaults +{<m>}(<m>)(){1} +\end{tzdef} + +If |(<coor2>)| is specified, |{<slope>}| is ignored. +If |(<coor2>)| is missing |<slope>| is considered as the slope of the line (by default 1). + +For example, |\tzdefLFn{\Gx}(1,1){.5}| defines as |\Gx| a linear function passing through the point $(1,2)$ with a slope |.5|. +That is, it defines a function as $f(x)=.5(x-1)+1$. +Knowing two coordinates, linear function |\Gx| passing through the two points can be defined, for example, by |\tzdefLFn{\Gx}(1,2)(3,1)|. +That is, it defines a function as $g(x)=\frac{1-2}{3-1}(x-1)+2$. + + +\begin{tztikz}{} +\tzdefLFn{\Fx}(1,2)(3,1) % works like + \def\Fx{-1/2*(\x-1)+2} +\end{tztikz} + +\remark If you inadvertently try an \xem{infinite slope}, you will get an \iisw{error message}. + + +\begin{tzcode}{.3} +% \tzdefLFn and \tzfn +\begin{tikzpicture} +\tzhelplines(4,4) +\tzaxes(4,4){$x$}{$y$} +\tzticks{1,2,3,4}{1,2,3,4} +\tzcoors*(1,1)(A){A}[-90](1,2)(B){B}(3,1)(C){C}[45]; +\tzdefLFn\Fx(A){.5} +\tzdefLFn\Gx(B)(C) +\tzfn[red]\Fx[0:4]{$f(x)$}[r] +\tzfn[blue]\Gx[0:4]{$g(x)$}[r] +\end{tikzpicture} +\end{tzcode} + +\remark The swap version |\tzfn'| simply draws the graph of the inverse function of |\tzfn|. +So |\tzfn'(A)(B)| and |\tzfn'(A){.5}| do not guarantee passing through the coordinate |(A)| or |(B)|. + +\begin{tzcode}{.3} +% \tzdefLFn and \tzfn' +\begin{tikzpicture} +\tzhelplines(4,4) +\tzaxes(4,4){$x$}{$y$} +\tzticks{1,2,3,4}{1,2,3,4} +\tzcoors*(1,1)(A){A}[-90](1,2)(B){B}(3,1)(C){C}[45]; +\tzdefLFn\Fx(A){.5} +\tzdefLFn\Gx(B)(C) +\tzfn'[red]\Fx[0:4]{$f(x)$}[r] +\tzfn'[blue]\Gx[0:4]{$g(x)$}[r] +\end{tikzpicture} +\end{tzcode} + + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzdefLFnofy}} +\label{s:tzdefLFnofy} + +\icmd{\tzdefLFnofy} defines a function of |\y|. + +\begin{tzdef}{} +% syntax +\tzdefLFnofy{<fn csname>}(<coor1>)(<coor2>){<slope>} +% defaults +{<m>}(<m>)(){1} +\end{tzdef} + +If |(<coor2>)| is specified, |{<slope>}| is ignored. +If |(<coor2>)| is missing |<slope>| is considered as the slope of the line (by default 1). + + +\begin{tztikz}{} +\tzdefLFnofy\Fy(1,1){.5} % works like + \def\Fy{.5*(\y-1)+1} +\end{tztikz} + +\begin{tztikz}{} +\tzdefLFnofy\Gy(1,2)(3,1) % works like + \def\Gy{-2*(\y-2)+1} +\end{tztikz} + + +\remark If you inadvertently try an \xem{infinite slope}, you will get an \xem{error message}. + +You can use |\tzdefLFnofy| together with |\tzFnofy| to graph a linear function of $y$. +(Of course, you can directly use |\tzLFnofy|.) + + +\begin{tzcode}{.3} +% \tzdefLFnofy and \tzLFnofy +\begin{tikzpicture} +\tzhelplines(4,4) +\tzaxes*(4,4){$x$}{$y$} +\tzticks{1,2,3,4}{1,2,3,4} +\tzcoors*(1,1)(A){A}[-90](1,2)(B){B}(3,1)(C){C}[45]; +\tzdefLFnofy\Fy(A){.5} +\tzdefLFnofy\Gy(B)(C) +\tzfnofy[red]\Fy[0:4]{$f(y)$}[r] +\tzfnofy[blue]\Gy[0:4]{$g(y)$}[a] +\end{tikzpicture} +\end{tzcode} + +\remark The swap version |\tzfnofy'| simply draws the graph of the inverse function of |\tzfnofy|. +So |\tzfnofy'(A)(B)| and |\tzfnofy'(A){.5}| do not guarantee passing through the coordinate |(A)| or |(B)|. + +\begin{tzcode}{.3} +% \tzdefLFnofy and \tzLFnofy' +\begin{tikzpicture} +\tzhelplines(4,4) +\tzaxes*(4,4){$x$}{$y$} +\tzticks{1,2,3,4}{1,2,3,4} +\tzcoors*(1,1)(A){A}[-90](1,2)(B){B}(3,1)(C){C}[45]; +\tzdefLFnofy\Fy(A){.5} +\tzdefLFnofy\Gy(B)(C) +\tzfnofy'[red]\Fy[0:4]{$f(y)$}[r] +\tzfnofy'[blue]\Gy[0:4]{$g(y)$}[r] +\end{tikzpicture} +\end{tzcode} + + + +%%================================== +\chapter{Some More Functions} +\label{c:more-fn} + +%%------------------------------------------------------------ +\section{\texttt{\bs tzpdfN(*)} and \texttt{\bs tzpdfZ}: Normal distributions} +\label{s:normaldistributions} + + +|\tzpdfN|, |\tzpdfN*| and |\tzpdfZ| are predefined functions to plot the \iisw{probability density function} (pdf) of a \iisw{normal distribution} $N(\mu,\sigma^2)$. + +\paragraph{Normal distributions} +\icmd{\tzpdfN} accepts two mandatory arguments, |{<mean>}| $\mu$ and |{<variance>}| $\sigma^2$, to define the pdf function: +\[ + \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac12\big(\frac{x-\mu}{\sigma}\big)^2} +\] + +\icmd{\tzpdfN*} uses a standard deviation $\sigma$ instead of a variance. + +With these predefined functions together with |\tzfn| you can plot the pdf of normal distributions. + +\begin{tzcode}{.3} +% \tzpdfN, \tzpdfN* +\begin{tikzpicture}[xscale=0.5,yscale=5,font=\scriptsize] +\tzhelplines[ystep=0.1](-4,0)(6,.5) +\tzaxes(-4,0)(6,.5) +\tzticks{1,...,5}{0.1,0.2,0.3,0.4} +\tzfn[blue]{\tzpdfN{0}{1.5}}[-4:4] % \tzpdfN +\tzfn[red]{\tzpdfN*{2}{sqrt(1.5)}}[-2:6] % \tzpdfN* +\end{tikzpicture} +\end{tzcode} + + + +\begin{tzcode}{.3} +% \tzpdfN, \tzpdfN* +\begin{tikzpicture}[x=0.5cm,y=5cm,font=\scriptsize] +\tzhelplines[step=.5cm](-4,0)(6,.5) +\tzaxes(-4,0)(6,.5) +\tzticks{1,2,3}{0.1,0.2,0.3,0.4} +\tzfn[blue]{\tzpdfN{0}{1.5}}[-4:4] +\tzfn[red]{\tzpdfN*{2}{sqrt(1.5)}}[-2:6] +\end{tikzpicture} +\end{tzcode} + +\remark +If |tikzpicture| is scaled when plotting the inverse function using |\tzfn'|, you may want to change the scale accordingly. + +\begin{tzcode}{.3} +% \tzpdfN and \tzfn' +\begin{tikzpicture}[x=0.5cm,y=5cm,,font=\scriptsize] +\tzhelplines[step=0.5cm](-4,-.3)(6,.5) +\tzaxes(-4,-.3)(6,.5) +% scale change +\begin{scope}[xscale={1/0.5*5},yscale={1/5*0.5}] +\tzfn'[blue]{\tzpdfN{0}{1.5}}[-4:4] +\tzfn'[red]{\tzpdfN*{2}{sqrt(1.5)}}[-2:6] +\end{scope} +\end{tikzpicture} +\end{tzcode} + +\paragraph{Standard normal distributions} +\icmd{\tzpdfZ} (with no arguments) represents the pdf of the \xem{standard normal distribution}. + +\begin{tzcode}{.3} +% \tzpdfZ: shift +\begin{tikzpicture}[x=0.5cm,y=5cm,font=\scriptsize] +\tzhelplines[step=0.5cm](-4,0)(6,.5) +\tzaxes(-4,0)(6,.5) +\tzticks{1,...,5}{0.1,0.2,0.3,0.4} +\tzfn[blue]{\tzpdfZ}[-3:3] % \tzpdfZ +\tzfn[red]<2,0>{\tzpdfZ}[-3:3] % shift +\tzfn[dashed]<3,.1>{\tzpdfZ}[-3:3] % shift +\end{tikzpicture} +\end{tzcode} + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzfnarea(*)}: Fill under the graph} + + +\subsection{\protect\cmd{\tzfnarea(*)}} + +\icmd{\tzfnarea} fills the area between the graph of a function and the x axis, with a color or pattern, on the |behind| layer by default. +With \icmd{\settzfnarealayer}, you can change the layer of |\tzfnarea|. + +|\tzfnarea| accepts two mandatory arguments: |{<fn of \x>}| and |[<domain>]|, like |\tzfn|. + +\begin{tzdef}{} +% syntax: minimum +\tzfnarea{<fn of \x>}[<domain>] +% syntax: full +\tzfnarea[<opt>]{<fn of \x>}[<domain>]{<fill opacity>}<code.append> +% defaults + []{<m>}[<m>]{.3}<> +\end{tzdef} + +\begin{tzcode}{.3} +% \tzfnarea +\begin{tikzpicture} +\tzhelplines(0,-1)(4,2) +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn[very thick]\Fx[0:3.5] +\tzfnarea[fill=red]\Fx[1:3] % +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzfnarea: layer: comparison +\begin{tikzpicture} +\tzhelplines(0,-1)(4,2) +\settzfnarealayer{main} %% +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn[very thick]\Fx[0:3.5] +\tzfnarea[fill=red]\Fx[1:3] % +\end{tikzpicture} +\end{tzcode} + + +The starred version \icmd{\tzfnarea*} fills the area with |fill=black!50| and |fill opacity=.3|, and |text opacity=1|, by default. The default values can be changed by |\settzfillcolor|, |\settzfillopacity|, and the option |{<fill opacity>}|. + +\begin{tzcode}{.3} +% \tzfnarea* +\begin{tikzpicture}[x=0.5cm,y=5cm,font=\scriptsize] +\tzhelplines[step=.5cm](-4,-.1)(6,.5) +\tzaxes(-4,-.1)(6,.5) +\tzfn[blue]{\tzpdfZ}[-3:3] +\tzfnarea*{\tzpdfZ}[-3:1] +\tzfn"AA"{\tzpdfN21}[-1:5] +\tzfnarea*[pattern=north east lines]{\tzpdfN21}[1:3] +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzfnarea*: default change and <code.append> +\begin{tikzpicture} +\settzfnarealayer{main} % +\tzhelplines(0,-1)(4,2) +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn\Fx[0:3.5] +\tzfnarea*[red]\Fx[1:3]{.1}<(2,-1) node[black]{Area}> +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzfnarea* +\begin{tikzpicture} +\tzhelplines(0,-2)(4,3) +\tzaxes(0,-2)(4,3){$x$}{$y$} +\def\Fx{.5*(\x-1)^2-1} +\tzfn\Fx[0:3.5]{$f(x)$}[a] +\tzfnarea*[red]\Fx[1:3] +\tzvXpointat{Fx}{1}(A) +\tzvXpointat{Fx}{3}(B) +\tzline[blue,thick](A)(A|-0,0) +\tzline[very thick](B)(B|-0,0) +\end{tikzpicture} +\end{tzcode} + + +\subsection{\protect\cmd{\tzfnarealine(')}} + +\icmd{\tzfnarealine} draws one or two boundary lines of |\tzfnarea| using |\tzto|, on the |behind| layer by default. The layer can be changed by \icmd{\settzfnarealayer}. +It takes two mandatory arguments: |{<path>}| and |{<x1>}|. +\begin{itemize}\firmlist +\item |\tzfnarealine{<path>}{<x1>}| draws a vertical line to the $x$ axis at |<x1>|. +\item |\tzfnarealine{<path>}{<x1>}{<x2>}| draws two vertical lines at |<x1>| and |<x2>|. +\end{itemize} + +The first option |[<opt>]| controls both lines and is overwritten by each of |[<opt1>]| (for the line at |<x1>|) and |[<opt2>]| (for the line at |<x2>|). +The line width is |very thin| by default, which can be changed by \icmd{\settzfnarealinewith}. + +You can change the length of lines by specifying |(<coor1>)| and |(<coor2>)|. + +\begin{tzdef}{} +% syntax: minimum +\tzfnarealine{<path>}{<x1>} +% syntax: minimal +\tzfnarealine{<path>}{<x1>}{<x2>} +% syntax: medium +\tzfnarealine{<path>}{<x1>}[<opt1>]{<x2>}[<opt2>] +% syntax: full +\tzfnarealine[<opt>]{<path>}{<x1>}[<opt1>](<coor1>) + {<x2>}[<opt2>](<coor2>) +% defaults: + [very thin]{<m>}{<m>}[](0,0){}[](0,0) +\end{tzdef} + + +\begin{tzcode}{.3} +% \tzfnarealine +\begin{tikzpicture}[x=0.5cm,y=5cm,font=\scriptsize] +\tzhelplines[step=.5cm](-4,-.1)(6,.5) +\tzaxes(-4,-.1)(6,.5) +\tzfn"AA"{\tzpdfN21}[-1:5] +\tzfnarea*[pattern=north east lines]{\tzpdfN21}[1:3] +\tzfnarealine[red]{AA}{1}{3} %% +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzfnarealine: one line +\begin{tikzpicture} +\tzhelplines(0,-1)(4,2) +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn\Fx[0:3.5] +\tzfnarea*[red]\Fx[1:3]{.1}<(2,-1) node[black]{Area}> +\tzfnarealine[blue]{Fx}{3} +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +% \tzfnarealine: two lines +\begin{tikzpicture} +\tzhelplines(0,-1)(4,2) +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn\Fx[0:3.5] +\tzfnarea*[red]\Fx[1:3]{.1}<(2,-1) node[black]{Area}> +\tzfnarealine[blue,thick]{Fx}{1}{3}[very thick,red] +\end{tikzpicture} +\end{tzcode} + +The \xem{swap version} \icmd{\tzfnarealine'} draws one or two horizontal lines from the point $(x_i,f(x_i))$ to the $y$ axis. +Everything else is the same as in |\tzfnarealine|. + +\begin{tzcode}{.3} +% \tzfnarealine' +\begin{tikzpicture} +\tzhelplines(0,-1)(4,2) +\settzfnarealinestyle{thick} +\tzaxes(0,-1)(4,2) +\def\Fx{.5*(\x-1)^2-1} +\tzfn\Fx[0:3.5] +\tzfnarea*[blue]\Fx[1:3]{.1}<(2,-1) node[black]{Area}> +\tzfnarealine'[->,red]{Fx}{2}{3} +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{Envelope curves} +\label{s:evelopecurves} + + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzfnmax}: Upper envelope curves} +\label{ss:tzfnmax} + +\icmd{\tzfnmax} plots the maximum of a list of functions, that is, an \xem{upper} \iisw{envelope curve}. The first mandatory argument should be a comma separated list of functions. +The second mandatory argument |[<domain>]| should be colon separated. + +The default line width of |\tzfnmax| is |thick|. + +\begin{tzdef}{} +% syntax: minimum +\tzfnmax{<fn list>}[<domain>] +% syntax: full +\tzfnmax[<opt>]<shift coor>"<path name>" + {<fn list>}[<domain>]{<text>}[<node opt>]<code.append> +% remark: + - {<fn list>} should be comma separated + - [<domain>] should be of the form [<from num:to num>] +% defaults + [thick,samples=201]<>""{<m>}[<m>]{}[]<> +\end{tzdef} + + +\begin{tzcode}{.3} +% \tzfnmax +\begin{tikzpicture} +\tzhelplines*(4,4) +\def\Fx{\x} +\def\Gx{.5*\x+.5} +\def\Hx{-.25*\x+2} +\tzfn{\Fx}[0:4] \tzfn{\Gx}[0:4] \tzfn{\Hx}[0:4] +\tzfnmax[blue]{\Fx,\Gx,\Hx}[0:4]{upper envelope}[l] +\end{tikzpicture} +\end{tzcode} + +\remark If you want sharp corners at kinked points, you may need to select an appropriate number of sample points, which is |samples=201|, by default. You can try an odd number. +\remarkafterskip + +If you want, you can shift and extend path using the option |<shift coor>| and |<code.append>|, respectively. +You can also use \icmd{\tzfnmaxAtBegin} and \icmd{\tzfnmaxAtEnd} to extend the path of |\tzfnmax| at the beginning and at the end, respectively. + +\begin{tzcode}{.3} +% shift, <code.append> +\begin{tikzpicture} +\tzhelplines*(4,5) +\def\Fx{\x} +\def\Gx{.5*\x+.5} +\def\Hx{-.25*\x+2} +\tzfn{\Fx}[0:4] \tzfn{\Gx}[0:4] \tzfn{\Hx}[0:4] +\tzfnmax[blue,thick]{\Fx,\Gx,\Hx}[0:4] +\tzfnmaxAtBegin{ (-1,0) -- } +\tzfnmax[dashed]<0,.5>{\Fx,\Gx,\Hx}[0:4] + < to[bend left] ++ (1,-1) > +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\subsection{\protect\cmd{\tzfnmin}: Lower envelope curves} +\label{ss:tzfnmin} + +\icmd{\tzfnmin} plots the minimum of a list of functions. +|\tzfnmin| works just like |\tzfnmax|, but it draws \xem{lower} a \iisw{envelope curve}. + +\begin{tzdef}{} +% syntax: minimum +\tzfnmin{<fn list>}[<domain>] +% syntax: full +\tzfnmin[<opt>]<shift coor>"<path name>" + {<fn list>}[<domain>]{<text>}[<node opt>]<code.append> +% remark: + - {<fn list>} should be comma separated + - [<domain>] should be of the form [<from num:to num>] +% defaults + [thick,samples=201]<>""{<m>}[<m>]{}[]<> +\end{tzdef} + + +\begin{tzcode}{.3} +% \tzfnmin, \tzfnmax: name path: intersection +\begin{tikzpicture} +\tzhelplines(4,6) +\def\Fx{\x} +\def\Gx{.5*(\x)^2} +\def\Hx{-.25*\x+2} +\tzfn{\Fx}[0:4]{$f(x)$}[r] +\tzfn{\Gx}[0:3]{$g(x)$}[r] +\tzfn{\Hx}[0:4]{$h(x)$}[r] +\tzfnmin[samples=2001,blue,thick]"XX" %% + {\Fx,\Gx,\Hx}[0:4]{lower evelope}[bl] +\tzvXpointat*{XX}{3} +\tzfnmax[samples=201,red,thick]"YY" %% + {\Fx,\Gx,\Hx}[0:3]{upper envelope}[bl] +\tzvXpointat*[fill=none]{YY}{2.5} %% +\end{tikzpicture} +\end{tzcode} + +\remark If you want sharp corners at kinked points, you may need to select appropriate number of sample points. Try odd number. + +To extend the path of |\tzfnmin|, you can use the option |<code.append>| or the macros \icmd{\tzfnminAtBegin} and \icmd{\tzfnminAtEnd}. + + @@ -1098,7 +2007,7 @@ For example, |\tzvfn(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvfnat{3}|. \section{\protect\cmd{\tzXpoint(*)}: Intersection points} \label{s:intersections} -\icmd{\tzXpoint} finds intersection points of two paths and saves them as coordinate names for later use. +\icmd{\tzXpoint} finds \iisw{intersection} points of two paths and saves them as coordinate names for later use. \begin{tzdef}{} % syntax: minimal @@ -1130,6 +2039,7 @@ You can label intersection points by specifying the option |{<label>}| and |[<an \end{tikzpicture} \end{tzcode} +\warning When using |\tzXpoint|, the intersection of two paths must actually exist.Otherwise, an error will occur when using coordinates. \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}). @@ -1158,7 +2068,7 @@ The default dot size is |2.4pt| and it can be changed by the last option |(<dot \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> +\tzXpoint*{bgt}{Fx}(A){A}[[draw,red] r] % <angle> or % abb \tzproj[dashed](A){$x$}{$y$} \tzXpoint*[fill=none,red]{bgt}{IC}(B){B}[0](4pt) \tzdot*[blue](B-2){B2}[[red]45](4pt) @@ -1173,7 +2083,7 @@ The default dot size is |2.4pt| and it can be changed by the last option |(<dot \subsection{\protect\cmd{\tzvXpointat(*)}} \label{ss:tzvXpointat} -\icmd{\tzvXpointat} determines vertical intersection points of a path at a specified value of $x$. +\icmd{\tzvXpointat} determines \iisw{vertical intersection} points of a path at a specified value of $x$. So it takes |{<path>}| and |{<x-val>}| as mandatory arguments. \remark @@ -1215,7 +2125,7 @@ The starred version \icmd{\tzvXpointat*} additionally prints a node dot of the s \tzvfnat[dashed]{1} \tzvXpointat{Fx}{1}(A) \tzdot(A){A}[45] -\tzvXpointat*{Fx}{3.2}{B}[-45] +\tzvXpointat*{Fx}{3.2}{B}[[red,draw]br] \end{tikzpicture} \end{tzcode} @@ -1224,7 +2134,7 @@ The starred version \icmd{\tzvXpointat*} additionally prints a node dot of the s \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. +\icmd{\tzvXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find \iisw{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|. @@ -1259,7 +2169,7 @@ The starred version \icmd{\tzvXpoint*} just adds a node dot to |\tzvXpoint|. \tzvfn[dashed](1,0) \tzvXpoint{Fx}(A)(Ax) \tzdot(Ax){Ax}[45] -\tzvXpoint*{Fx}(B){B}[-45] +\tzvXpoint*{Fx}(B){B}[[red,draw]br] % abb \end{tikzpicture} \end{tzcode} @@ -1272,7 +2182,7 @@ The starred version \icmd{\tzvXpoint*} just adds a node dot to |\tzvXpoint|. \subsection{\protect\cmd{\tzhXpointat(*)}} \label{ss:tzhXpointat} -\icmd{\tzhXpointat} determines horizontal intersection points of a path at a specified value of $y$. +\icmd{\tzhXpointat} determines \iisw{horizontal intersection} points of a path at a specified value of $y$. So it takes |{<path>}| and |{<y-val>}| as mandatory arguments. \begin{tzdef}{} @@ -1311,7 +2221,7 @@ The starred version \icmd{\tzhXpointat*} additionally prints a node dot of the s \tzdot(A){A}[0] \tzhfnat[dashed]{1.5} \tzhXpointat*{Fx}{1.5}(X){X}[45] -\tzdot*(X-2){Y}[135] +\tzdot*(X-2){Y}[[red,draw]al] % abb \end{tikzpicture} \end{tzcode} @@ -1319,7 +2229,7 @@ The starred version \icmd{\tzhXpointat*} additionally prints a node dot of the s \subsection{\protect\cmd{\tzhXpoint(*)}} \label{ss:tzhXpoint} -\icmd{\tzhXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find horizontal intersection points of a path at the $y$ value of the coordinate, ignoring the $x$ value. +\icmd{\tzhXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find \iisw{horizontal 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|. @@ -1354,7 +2264,62 @@ The starred version \icmd{\tzhXpoint*} just adds a node dot to |\tzhXpoint|. \tzdot(A){A}[0] \tzhfn[dashed](0,1.5) \tzhXpoint*{Fx}(X){X}[45] -\tzdot*(X-2){Y}[135] +\tzdot*(X-2){Y}[ [red,draw] al ] % abb +\end{tikzpicture} +\end{tzcode} + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzLFnXpoint(*)}: Intersection point of linear functions} +\label{s:tzLFnXpoint} + +Sometimes you may want to \xem{quickly} find intersection point of two linear functions \xem{without specifying path names}. + +\icmd{\tzLFnXpoint} finds the solution of two linear functions without printing anything by default. +You can name it and use it. + +\begin{tzdef}{} +% syntax: minimum +\tzLFnXpoint{<\fn>}{<\fn>} +% syntax: medium +\tzLFnXpoint{<\fn>}{<\fn>}(<coor name>){<label>}[<[<label opt>]angle>] +% syntax: full +\tzLFnXpoint[<opt>]{<\fn>}{<\fn>}(<coor name>) + {<label>}[<[<label opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt,draw=none,mimumum size=0pt]{<m>}{<m>}[0](){}[](2.4pt) +\end{tzdef} + + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzfn[yellow]{\x}[0:3] +\tzfn[yellow]{3-\x}[0:3] +\tzLFnXpoint{\x}{3-\x}(A) % invisible +\tzto+[->,bend left](A)(2,-1) +\end{tikzpicture} +\end{tzcode} + +\icmd{\tzLFnXpoint*} additionally print a filled node dot at the solution of two linear equations. + +\begin{tzdef}{} +% syntax: minimum +\tzLFnXpoint{<\fn>}{<\fn>} +% syntax: medium +\tzLFnXpoint{<\fn>}{<\fn>}(<coor name>){<label>}[<[<label opt>]angle>] +% syntax: full +\tzLFnXpoint[<opt>]{<\fn>}{<\fn>}(<coor name>) + {<label>}[<[<label opt>]angle>](<dot size>) +% defaults + [tzdot=2.4pt,fill]{<m>}{<m>}[0](){}[](2.4pt) +\end{tzdef} + +\begin{tzcode}{.3} +\begin{tikzpicture}[scale=.8] +\tzhelplines(4,3) +\tzLFnXpoint*{\x}{3-\x}(A){A}[[red,draw]90] %% +\tzline+[blue](A)(2,-1) \end{tikzpicture} \end{tzcode} @@ -1371,8 +2336,9 @@ The starred version \icmd{\tzhXpoint*} just adds a node dot to |\tzhXpoint|. \subsection{\protect\cmd{\tzsecantat}} \label{ss:tzsecantat} -\icmd{\tzsecantat} draws a line segment 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$. +\icmd{\tzsecantat} draws a line segment or a \iisw{secant} line of a curve, on the |behind| layer by default. +|\tzsecantat| accepts three mandatory arguments: +Three mandatory arguments are a path name and two values of $x$: |{<path>}|, |{<from->x}|, and |{<to-x>}|. With \icmd{\settzsecantlayer}, you can change the layer, like |\settzsecantlayer{main}|. \begin{tzdef}{} @@ -1388,7 +2354,7 @@ With \icmd{\settzsecantlayer}, you can change the layer, like |\settzsecantlayer \end{tzdef} \paragraph{Domain} -The domain should be of the form |[<from num:to num>]|. +The domain of the form |[<from num:to num>]| is optional. Without specifying the optional domain, |\tzsecantat| draws a line segment connecting two points on the (curved) path. \begin{tzcode}{.3} @@ -1403,7 +2369,7 @@ Without specifying the optional domain, |\tzsecantat| draws a line segment conne \end{tikzpicture} \end{tzcode} -You can optionally specify the |[<domain>]|. +Specifying the option |[<domain>]|, you can extend (or shorten) the line of |\tzsecantat|. \begin{tzcode}{.3} % \tzsecantat: domain @@ -1433,7 +2399,7 @@ You can move |\tzsecantat| by specifying the option |<shift coor>|. \end{tzcode} \paragraph{Naming paths} -By specifying the option |"<path name>"| you can name a path of |\tzsecantat|. +By specifying the option |"<path name>"| you can name a path of |\tzsecantat|, and use it to find intersection points. \begin{tzcode}{.3} % \tzsecantat: shift, name path (intersection) @@ -1470,7 +2436,7 @@ You can extend the path of |\tzsecantat| by writing \Tikz\ code in the last opti \subsection{\protect\cmd{\tzsecant}} \label{ss:tzsecant} -\icmd{\tzsecant} uses two \xem{coordinates instead of two values of $x$} to draw a line segment or a secant line of a curve, on the |behind| layer by default. +\icmd{\tzsecant} uses two \xem{coordinates instead of two values of $x$} to draw a line segment or a \iisw{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|. @@ -1505,7 +2471,7 @@ Without specifying the optional domain, |\tzsecant| draws a line segment connect \end{tikzpicture} \end{tzcode} -You can move the secant line and extend the path. +With the last option |<code.append>| you can extend the path of |\tzsecantat|. \begin{tzcode}{.3} % \tzsecant: shift, <code.append> @@ -1530,12 +2496,12 @@ You can move the secant line and extend the path. \subsection{\protect\cmd{\tztangentat}} \label{ss:tztangentat} -\icmd{\tztangentat} draws a tangent line to a curve at a specified value of $x$. +\icmd{\tztangentat} draws a \iisw{tangent} line to a curve at a specified value of $x$. Three mandatory arguments are a curve name, a value of $x$, and a domain: |{<path>}|, |{<x-val>}|, and |[domain]|. By default, the tangent line is drawn on the |behind| layer, which can be changed by \icmd{\settztangentlayer}, like |\settztangentlayer{main}|. \remark 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}. +So the slope of tangent line is only \xem{approximate}. \begin{tzdef}{} % syntax: minimum @@ -1553,7 +2519,7 @@ 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>]|. +The mandatory argument |[<domain>]| should be of the form |[<from num:to num>]|. \begin{tzcode}{.3} % \tztangentat @@ -1587,7 +2553,7 @@ You can move the tangent line by specifying the option |<shift coor>|. \end{tzcode} \paragraph{Naming paths} -By specifying the option |"<path name>"|, you can name the path of |\tztangentat|. +By specifying the option |"<path name>"|, you can name the path of |\tztangentat| and use it to find intersection points. \begin{tzcode}{.3} % \tztangentat: name path (intersection) @@ -1627,8 +2593,8 @@ You can extend the path of |\tztangentat| by writing \Tikz\ code in the last opt \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>}|. +Since the slope of the tangent line is \xem{approximate}, 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>)| \xem{immediately after} the mandatory argument |{<x-val>}|. Or you can change the variations by the macro \icmd{\settztangentepsilon}, like |\settztangentepsilon{|$\varepsilon_1$|}{|$\varepsilon_2$|}|. The effect remains until the end of |tikzpicture| environment unless changed again. @@ -1652,8 +2618,11 @@ like |\settztangentepsilon{|$\varepsilon_1$|}{|$\varepsilon_2$|}|. The effect re \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,<y>)| is equivalent to |\tztangentat{curve}{4}| for any |<y>|. +\icmd{\tztangent} uses a \xem{coordinate instead of a value} of $x$ to draw a \iisw{tangent} line to a curve. +|\tztangent| accepts three mandatory arguments: |{<path>}|, |(<coor>)|, and |[<domain>]|. + +The value of $y$ in |(<coor>)| is ignored. +For example, |\tztangent{curve}(4,|$y$|)| is equivalent to |\tztangentat{curve}{4}| for any $y$. \xem{Everything else is the same as in} |\tztangentat|. @@ -1672,7 +2641,6 @@ For example, |\tztangent{curve}(4,<y>)| is equivalent to |\tztangentat{curve}{4} \end{tzdef} -|\tztangent| accepts three mandatory arguments: |{<path>}|, |(<coor>)|, and |<domain>|. \begin{tzcode}{.3} % \tztangent @@ -1723,85 +2691,160 @@ You can control the interval of variations of $x$ by the option |(<epsilon1,epsi \end{tzcode} -%%================================== -\chapter{Miscellany} -\label{c:misc} %%------------------------------------------------------------ -\section{\protect\cmd{\tzbrace(')}} -\label{s:tzbrace} +\section{Slope lines and normal lines} +\label{s:slopes} + +\subsection{\protect\cmd{\tzslopeat}} +\label{ss:tzslopeat} + +\icmd{\tzslopeat} draws a slope line to a path with a specified length. +The mandatory arguments are |{<path>}|, |{<x>}|, and |{<length>}|. +The tangent point is the middle point of the slope line. + +By default, the slope lines are drawn on the |behind| layer. +You can change the layer, like \icmd{\settztslopelayer}|{main}|. + +\remark The slope is \xem{approximate} and you can manipulate the slope by changing the variation interval with the option |(<epsilon1,epsilon2>)|. The default is $(\varepsilon_1,\varepsilon_2)=(0.01,0.01)$. +You can also use +\icmd{\tzslopeepsilon}|{<epsilon1>}{<epsilon2>}| \xem{immediately after} the option |{<x-val>}|, which is valid until the end of the |tikzpicture| environment, unless changed again. -\icmd{\tzbrace} takes two coordinates as mandatory arguments to draw a \xem{calligraphic brace} connecting them. \begin{tzdef}{} % syntax: minimum -\tzbrace(<coor>)(<coor>) -% syntax: medium -\tzbrace(<coor>)(<coor>){<text>}[<node opt>] +\tzslopeat{<path>}{<x-val>}{<length>} +% syntax: minimum (for normal line) +\tzslopeat{<path>}{<x-val>}{<length>}[90] % or [-90] % syntax: full -\tzbrace[<draw opt>]{<raise>}[<decoration opt>]<shift coor> - (<coor>)(<coor>){<text>}[<node opt>] +\tzslopeat[<opt>]{<path>}{<x-val>}(<epsilon1>,<epsilon2>){<length>}[<rotate>] + {<text>}[<node opt>]<code.append> % defaults - []{5pt}[amplitude=5pt]<>(<m>)(<m>){}[] + []{<m>}{<m>}(.01,.01){<m>}[0]{}[]<> \end{tzdef} -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{tzcode}{.3} +% \tzslopeat +\begin{tikzpicture} +\tzhelplines*(5,4) +\tzcoors*(0,0)(A)(2,2)(B){B}[b](3.5,1)(C)(5,3)(D); +\tztos[thick]"AA"(A)[out=0,in=180] + (B)[out=0,in=180] + (C)[out=0,in=255] + (D); +\tzslopeat[red,thick]{AA}{1}{3cm} +\tzslopeat[blue]{AA}{2}{2cm} +\tzslopeat{AA}{4}{2cm}{$f'(4)$}[r] +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% \tzslopeat: repeated +\begin{tikzpicture} +\tzhelplines(1,1)(5,4) +\tzcoors*(0,1)(A)(2,3)(B)(4,2)(C); +\tzparabola"AA"(A)(B)(C) +\foreach \x in {1,1.5,...,3.5} + { \tzslopeat[thick,red]{AA}{\x}{2cm} } +\end{tikzpicture} +\end{tzcode} -The |amplitude| of a brace is |5pt| by default. You can control the amplitude by writing the option |amplitude=<dim>| in the second bracket option |[<decoration opt>]|. -\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 \iisw{wap version} \icmd{\tzbrace'} swaps the coordinates. -So it prints a mirror image of |\tzbrace|. -For example, |\tzbrace'(0,0)(3,1)| is equivalent to |\tzbrace(3,1)(0,0)|. + +\paragraph{Normal lines} +With the option |[<rotate>]| \xem{immediately after} the last mandatory option |{<length>}|, you can draw a \iisw{normal line} to a curve by rotating the slope lines |90|\textdegree or |-90|\textdegree. \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] +% \tzslopeat: slopes and normals +\begin{tikzpicture} +\tzhelplines*(5,4) +\tzcoors*(0,0)(A)(2,2)(B){B}[b](3.5,1)(C)(5,3)(D); +\tztos[thick]"AA"(A)[out=0,in=180] + (B)[out=0,in=180] + (C)[out=0,in=255] + (D); +\tzslopeat[red]{AA}{1}{3cm} +\tzslopeat[blue]{AA}{2}{2cm} +\tzslopeat{AA}{4}{2cm}{$f'(4)$}[r] +% normal lines: roatate: [90] or [-90] +\tzslopeat[blue]{AA}{1}{1cm}[90] +\tzslopeat[red]{AA}{2}{2cm}[90] +\tzslopeat[red]{AA}{4}{1cm}[-90]{normal}[b] \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>]|. + + + +\subsection{\protect\cmd{\tzslope}} +\label{ss:tzslope} + +\icmd{\tzslope} is the same as |\tzslopeat|, except for one thing. +|\tzslope| uses a coordinate instead of a value of $x$ to draw slope lines. +So the mandatory arguments of |\tzslope| is |{<path>}|, |(<coor>)|, and |{<length>}|. The $y$ value of |(<x,y>)| is ignored. + +\begin{tzdef}{} +% syntax +\tzslope[<opt>]{<path>}(<x,y>)(<epsilon1>,<epsilon2>){<length>}[<angle>] + {<text>}[<pos,opt>]<code.append> +% defaults + []{<m>}(<m>)(.01,.01){<m>}[0]{}[]<> +\end{tzdef} + + \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] +% \tzslope: slopes and normals +\begin{tikzpicture} +\tzhelplines*(5,4) +\tzcoors*(0,0)(A)(2,2)(B){B}[b](3.5,1)(C)(5,3)(D); +\tztos[thick]"AA"(A)[out=0,in=180] + (B)[out=0,in=180] + (C)[out=0,in=255] + (D); +\coordinate (B) at (2,2); +\tzslope[red]{AA}(1,0){3cm} +\tzgetxyval(B){\Bx}{\By} +\tzslopeat[blue]{AA}{\Bx}{2cm} +\tzslope{AA}(4,0){2cm}{$f'(4)$}[r] +% normal lines: roatate: [90] or [-90] +\tzslope[blue]{AA}(1,0){1cm}[90] +\tzslope[red]{AA}(\Bx,0){2cm}[90] +\tzslope[red]{AA}(4,0){1cm}[-90]{normal}[b] \end{tikzpicture} \end{tzcode} -You can also move a brace by specifying the option |<shift coor>| immediately before the the first mandatory coordinate. -The empty shift option |<>| is not allowed. \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] +% \tzslope: repeated +\begin{tikzpicture} +\tzhelplines(1,1)(5,4) +\tzcoors*(0,1)(A)(2,3)(B)(4,2)(C); +\tzparabola"AA"(A)(B)(C) +\foreach \x in {1,1.5,...,3.5} + { \tzslope[thick,red]{AA}(\x,0){2cm} } \end{tikzpicture} \end{tzcode} +You can add \Tikz\ code with the last option |<code.append>|. +\begin{tzcode}{.3} +% \tztangent, \tzslope: extend/shorten lines +\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); +\tzslope[red,tzextend={1cm}{2cm}]{AA}(2,0){1cm} %% +\tztangent[blue]{AA}(K4)[1:7]{tangent}[red,b] +\tzslope[->]{AA}(4,0){0.1pt}[90] + <--([turn]0:2cm) node [r] {gradient} > %% +\tzvXpoint*{AA}(K4) +\tzticksx{1,7} +\end{tikzpicture} +\end{tzcode} diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-E-v2.0.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-E-v2.0.tex new file mode 100644 index 00000000000..f3cc24f1246 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-E-v2.0.tex @@ -0,0 +1,476 @@ +%!TEX root = tzplot-doc.tex +%\begin{document} + +%%%%%===== PART: NOT YET!!! ============== +%%%%%%%%================================== +%%%%%\part{Miscellaneous Macros and Examples} +%%%%%%%%================================== +%%%%%\label{p:miscandexamples} +%%%%% +%%================================== + +%%================================== +\chapter{Miscellany} +\label{c:misc} + +%%------------------------------------------------------------ +\section{Middle arrows} +\label{s:midarrows} + +Four styles for middle arrow tips are predefined: |-->--|, |--o--|, |--x--| and |--/--|. + +\subsection{Controllable middle arrow tips: \texttt{-->--} and \protect\cmd{\settzmidarrow}} + +The middle arrow tip style \ixxw{-->--} prints a middle arrow tip of |stealth| by default. +It accepts one argument that changes the position (|0.5| by default) of a \iisw{middle arrow tip}, like |-->--=.75|. + + +\begin{tzcode}{.3} +\begin{tikzpicture} +% middle arrow tip: -->-- +\tzhelplines(4,3) +\tzline[-->--](0,3)(4,3) +\tzline[-->--=.75,blue,thick](0,2.5)(4,2.5) +\tzto[-->--,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{How to control middle arrow tips} +The default options for middle arrow tips are |-|, |thin|, |solid|, and |shorten >=0|, and |bend right=0|. The defaults can be changed by |\settzmidarrow|. + +The macro \icmd{\settzmidarrow} controls the position, style, and other options of middle arrow tips. The effect is valid until the end of the |tikzpicture| environment, unless changed again. + +\begin{tzdef}{} +% syntax: +\settzmidarrow<position>{<arrow tip style>}[<opt>] +% all arguments are optional +% defaults: + <0.5>{stealth}[-,thin,solid,shorten <=0,shorten >=0,bend right=0] +\end{tzdef} + + +\begin{tzcode}{.3} +% \settzmidarrow +\begin{tikzpicture} +\tzhelplines(4,3) +\settzmidarrow<.25>{Stealth[reversed]}[red,scale=2] % +\tzline[-->--](0,3)(4,3) +\tzline[-->--=.75,blue,thick](0,2.5)(4,2.5) +\tzto[-->--,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + + +\begin{tzcode}{.3} +% various arrow tip styles: arrows.meta +\begin{tikzpicture} +\tzhelplines(4,3) +\settzmidarrow{Circle[open]}[blue,scale=2] +\tzline[-->--](0,3)(4,3) +\tikzset{>=to} %% +\settzmidarrow{>>>}[blue,scale=2] +\tzline[-->--](0,2.5)(4,2.5) +\settzmidarrow<.25>{Rays}[blue,scale=2] +\tzline[-->--=.75,blue,thick](0,2)(4,2) +\tzto[-->--,->,red,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +You can use various styles of arrow tips. (See \Tikz\ manual on |arrows.meta| library, for more details.) + + + +\subsection{Fixed middle arrow tip styles: \texttt{--o--}, \texttt{--x--}, \texttt{--/--}} + +Three styles for middle arrow tips are predefined: \xem{circle} |--o--| , \xem{cross} |--x--| , and \xem{diagonal} |--/--| middle arrow tips. +These middle arrow tip styles are fixed and cannot be changed. +|\settzmidarrow| can only be used with |[<opt>]| to control these middle arrow tips. +The other options |<position>| and |{<arrow tip style>}| options are ignored for these styles. + +\paragraph{Circle middle arrow tips:} + +The circle middle arrow tip style \ixxw{--o--} takes one argument to change the position (|0.5| by default). + +The circle is drawn like this: + +\begin{verbatim} + \draw [<opt>] (0,0) circle (1.2pt) ; +\end{verbatim} + +|\settzmidarrow| controls the circle with |<opt>|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +% circle middle arrow tip: --o-- +\tzhelplines(4,3) +\tzline[--o--](0,3)(4,3) +\tzline[--o--=.75,blue,thick](0,2.5)(4,2.5) +\tzto[--o--,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture} +% \settzmidarrow: difference +\tzhelplines(4,3) +\settzmidarrow<.25>{Circle[open,fill=green]}[scale=2] % +\tzline[--o--,thick](0,3)(4,3) +\tzline[-->--=.5,blue,thick](0,2.5)(4,2.5) +\tzline[-->--,blue,thick](0,2)(4,2) +\settzmidarrow[scale=2,thick,fill=green] +\tzto[--o--=.25,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Cross middle arrow tips:} + +The cross middle arrow tip style \ixxw{--x--} takes one argument to change the position (|0.5| by default). + +The cross mark is drawn like this: + +\begin{verbatim} + \draw [<opt>] (2pt,2pt) to (-2pt,-2pt) ; + \draw [<opt>] (-2pt,2pt) to (2pt,-2pt) ; +\end{verbatim} + +|\settzmidarrow| controls the circle with |<opt>|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +% cross middle arrow tip: --x-- +\tzhelplines(4,3) +\tzline[--x--](0,3)(4,3) +\tzline[--x--=.75,blue,thick](0,2.5)(4,2.5) +\tzto[--x--,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture} +% \settzmidarrow: scale, tzextend +\tzhelplines(4,3) +\settzmidarrow<.25>{Rays[red]}[scale=2] % +\tzline[--x--,thick](0,3)(4,3) +\tzline[-->--=.5,blue,thick](0,2.5)(4,2.5) +\tzline[-->--,blue,thick](0,2)(4,2) +\settzmidarrow[thick,blue,tzextend={8pt}{8pt}] +\tzto[--x--=.25,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + + +\paragraph{Diagonal middle arrow tips} + +The diagonal middle arrow tip style \ixxw{--/--} takes one argument to change the position (|0.5| by default). + +The diagonal line is drawn like this: + +\begin{verbatim} + \draw [<opt>] (2pt,2pt) to (-2pt,-2pt) ; +\end{verbatim} + +|\settzmidarrow| controls the circle with |<opt>|. + +\begin{tzcode}{.3} +\begin{tikzpicture} +% diagonal middle arrow tip: --/-- +\tzhelplines(4,3) +\tzline[--/--](0,3)(4,3) +\tzline[--/--=.75,blue,thick](0,2.5)(4,2.5) +\tzto[--/--,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture} +% \settzmidarrow: rotate, tzextend +\tzhelplines(4,3) +\tzline[--/--,thick](0,3)(4,3) +\tzline[--/--=.25,blue,thick](0,2.5)(4,2.5) +\settzmidarrow[rotate=90,red,tzextend={3pt}{3pt}] +\tzline[--/--,blue,thick](0,2)(4,2) +\tzto[--/--=.75,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + +\begin{tzcode}{.3} +\begin{tikzpicture} +% \settzmidarrow: bend left +\tzhelplines(4,3) +\settzmidarrow[scale=2,rotate=45,bend left=60] +\tzline[--/--,thick](0,3)(4,3) +\tzline[--/--=.25,blue,thick](0,2.5)(4,2.5) +\settzmidarrow[rotate=90,red,tzextend={3pt}{3pt}] +\tzline[--/--,blue,thick](0,2)(4,2) +\tzto[--/--=.75,->,out=45](0,0)(4,1) +\end{tikzpicture} +\end{tzcode} + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzbrace(')}} +\label{s:tzbrace} + +\icmd{\tzbrace} takes two coordinates as mandatory arguments to draw a \xem{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 |raise| value of a brace is |5pt| by default and the value can be changed by the first curly brace optional argument |{<raise>}|. + +The |amplitude| of a brace is |5pt| by default. You can control the amplitude by writing the option |amplitude=<dim>| in the second bracket option |[<decoration opt>]|. + +\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 \iisw{swap version} \icmd{\tzbrace'} swaps the coordinates. +So it prints a mirror image of |\tzbrace|. +For example, |\tzbrace'(0,0)(3,1)| is equivalent to |\tzbrace(3,1)(0,0)|. + +\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. +The empty shift option |<>| is not allowed. + +\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} + + + + +%%------------------------------------------------------------ +\section{\protect\cmd{\tzsnake(+)}: Snake lines (Experimental)} +\label{s:tzsnake} + +\icmd{\tzsnake} connects two points with a snaked line, with many default values, using \Tikz's |to| operation. + +\begin{tztikz}{} +\tzsnake(0,1)(3,2) % works like + \draw [ decorate , decoration={ %% many defaults + snake, + segment length=5pt, % controlled by \tzsnake + amplitude=2.5pt, + pre length=5pt, + post length=5pt + } + ] (0,1) to (3,2) ; +\end{tztikz} + +\begin{tzcode}{.3} +\begin{tikzpicture} +\tzhelplines(4,3) +\tzsnake(0,1)(3,2) +\tzsnake[->,blue,bend right](1,0)(4,3) +\end{tikzpicture} +\end{tzcode} + +\begin{tzdef}{} +% syntax: minimum +\tzsnake[<opt>]{<segment length>}[<decoration opt>]<shift coor> + (<coor>){<text>}[<node opt>](<coor>){<text>}[<node opt>]<code.append> +% syntax: full +\tzsnake[<opt>]{<segment length>}[<decoration opt>]<shift coor> + (<coor>){<text>}[<node opt>] + (<coor>){<text>}[<node opt>]<code.append> +% defaults + []{5pt}[many defaults above]<>(<m>){}[](<m>){}[]<> +\end{tzdef} + +The key |segment length| is controlled by the first curly brace option and you should write down all the other keys in the second bracket option |[<decoration opt>]| to change the values. Not specifying the option |{<segment length>}|, when the first bracket option is empty, you need empty brackets |[]|, like |\tzsnake[][<decoration op>]...|. + +\begin{tzcode}{.3} +% \tzsnake: {segment length} option +\begin{tikzpicture} +\tzhelplines(4,3) +\tzsnake[blue]{3pt}[coil](0,1){spring}[a,sloped](3,2) +\tzsnake[->,bend right]{3pt} + [coil,amplitude=5pt,post length=20pt] + (1,0){coil line}[b,sloped](4,3){Up!}[draw,r] +\end{tikzpicture} +\end{tzcode} + +The plus version \icmd{\tzsnake+} uses the second mandatory coordinate as a relative coordinate to the first. Everything else is the same as in |\tzsnake|. + + +\begin{tzcode}{.3} +% \tzsnake(+): shift +\begin{tikzpicture} +\tzhelplines(4,3) +\tzsnake[->][post length=20pt](0,0)(3,0) +\tzsnake[->,red][post length=20pt]<1,1>(0,0)(3,0) %% +\tzsnake+[->,bend left,blue]{10pt}[post length=10pt] + (0,1){snake line}[a,sloped](4,2){what?}[r] +\end{tikzpicture} +\end{tzcode} + + +%%%%%%%% (under construction) +%%%%% +%%%%% +%%%%%%%------------------------------------------------------------ +%%%%%\section{\protect\cmd{\tzspy} (Experimental)} +%%%%%\label{s:tzspy} +%%%%% +%%%%% +%%%%%\begin{tzdef}{} +%%%%%% syntax: minimum +%%%%%\tzspy(<coor>)(<coor>) +%%%%%% syntax: full +%%%%%\tzbrace[<opt>]{<size>}[<maginificaltion>] +%%%%% (<on-coor>)(<in-coor>)[<node opt>]<code.append> +%%%%%% defaults +%%%%% [circle]{2cm}{5}(<m>)(<m>)[]<> +%%%%%\end{tzdef} +%%%%% +%%%%%To use |\tzspy| you need to tell \Tikz\ that a picture will be magnified, by specifying some special keys in the |tikzpicture| environment option, such as |spy using outlines|, |spy using overlays|, etc., as follows: +%%%%%\begin{verbatim} +%%%%% \begin{tikzpicture}[spy using outlines] +%%%%% <tzplot code> +%%%%% <tikz code> +%%%%% \tzspy... +%%%%% \end{tikzpicture} +%%%%%\end{verbatim} +%%%%% +%%%%%\begin{tzcode}[text above listing]{1} +%%%%%\begin{tikzpicture}[scale=.1,font=\scriptsize,spy using outlines] +%%%%%\settzdotsize{1.2pt} +%%%%%\tzaxes(-15,0)(60,60){$Q$}{$P$} +%%%%% +%%%%%\def\Dem{50-\x} +%%%%%\def\Sup{.5*\x+5} +%%%%%\def\Supa{.5*\x+6.5} +%%%%% +%%%%%\tzfn{\Dem}[0:50]{$D$} +%%%%%\tzfn{\Sup}[-10:50]{$S$}[r] +%%%%%\tzfn{\Supa}[-10:50]{$S'$} +%%%%% +%%%%%\tzXpoint*{Dem}{Sup}(eqm) +%%%%%\tzXpoint*{Dem}{Supa}(eqma) +%%%%%\tzvXpointat*{Sup}{29}(eqmb) +%%%%% +%%%%%\tzproj[densely dotted](eqm){\rlap{300}}{200} +%%%%%\tzproj[densely dotted](eqma){\llap{290}}{\raisebox{1em}{210}} +%%%%%\tzprojy[densely dotted](eqmb){\raisebox{-2em}{195}} +%%%%% +%%%%%\tzticks{-10/-100,50/500}{5/50,50/500} +%%%%% +%%%%%\tzpath*[blue](eqm)(eqma)(eqmb); +%%%%% +%%%%%\tzspy($(eqma)!.5!(eqmb)$)(100,30) +%%%%% +%%%%%%\spy [blue,draw,circle,size=5cm, magnification = 5,connect spies] +%%%%%%on ($(eqma)!.5!(eqmb)$) in node at (100,30); +%%%%%\end{tikzpicture} +%%%%%\end{tzcode} +%%%%% +%%%%% +%%%%%\begin{tzcode}[text above listing]{1} +%%%%%\begin{tikzpicture}[scale=.1,font=\scriptsize,spy using overlays] +%%%%%\settzdotsize{1.2pt} +%%%%%\tzaxes(-15,0)(60,60){$Q$}{$P$} +%%%%% +%%%%%\def\Dem{50-\x} +%%%%%\def\Sup{.5*\x+5} +%%%%%\def\Supa{.5*\x+6.5} +%%%%% +%%%%%\tzfn{\Dem}[0:50]{$D$} +%%%%%\tzfn{\Sup}[-10:50]{$S$}[r] +%%%%%\tzfn{\Supa}[-10:50]{$S'$} +%%%%% +%%%%%\tzXpoint*{Dem}{Sup}(eqm) +%%%%%\tzXpoint*{Dem}{Supa}(eqma) +%%%%%\tzvXpointat*{Sup}{29}(eqmb) +%%%%% +%%%%%\tzproj[densely dotted](eqm){\rlap{300}}{200} +%%%%%\tzproj[densely dotted](eqma){\llap{290}}{\raisebox{1em}{210}} +%%%%%\tzprojy[densely dotted](eqmb){\raisebox{-2em}{195}} +%%%%% +%%%%%\tzticks{-10/-100,50/500}{5/50,50/500} +%%%%% +%%%%%\tzpath*[blue](eqm)(eqma)(eqmb); +%%%%% +%%%%%\tzspy[connect spies]{5cm}[6]($(eqma)!.5!(eqmb)$)(100,30)[draw,fill=red,thick] +%%%%%\end{tikzpicture} +%%%%%\end{tzcode} +%%%%% + + + +%%%%%%%% (under construction) +%%%%%\section{\protect\cmd{\tzplotfile}: plotting data} +%%%%%\label{s:tzplotfile} +%%%%% +%%%%%\icmd{\tzplotfile} plots data. +%%%%% +%%%%%\begin{tcblisting}{listing only} +%%%%%% syntax +%%%%%\tzplotfile[<opt>]{<file name>}[<plot opt>] +%%%%%\end{tcblisting} +%%%%% +%%%%% +%%%%%\begin{tcblisting}{listing above text} +%%%%%\begin{tikzpicture} +%%%%%\tzplotfile{sine.data} +%%%%%\end{tikzpicture} +%%%%%\end{tcblisting} +%%%%% +%%%%%\begin{tcblisting}{listing above text} +%%%%%\begin{tikzpicture} +%%%%%\tzplotfile[blue]{sine.data}[mark=x] +%%%%%\end{tikzpicture} +%%%%%\end{tcblisting} + + + + + diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.pdf b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.pdf Binary files differindex 1c1b26fa8d2..db3e4926a4e 100644 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.pdf +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.pdf diff --git a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.tex b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.tex index 7c2394ee7ad..1a5fbb62dc3 100644 --- a/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.tex +++ b/Master/texmf-dist/doc/latex/tzplot/tzplot-doc.tex @@ -1,22 +1,33 @@ %!TEX program = arara % arara: xelatex: {shell: yes, synctex: yes} % arara: xelatex: {shell: yes, synctex: yes} -% arara: makeindex: {style: tzplot} +% arara: komkindex: {script: makeindex, style: tzplot} % arara: xelatex: {shell: yes, synctex: yes} % arara: xelatex: {shell: yes, synctex: yes} -%% 2021/03/20 v1.0.1 -\def\tmpdate{2021/03/20} -\def\tmpversion{1.0.1} +%% 2022/02/28 v2.0 +\def\tmpdate{2022/02/28} +\def\tmpversion{2.0} + +\def\printtodos{} +\def\printtmptest{} +\def\printtzplottest{} +%-------------------------------------------- +%\renewcommand\printtodos{\input{todos.tex}} +%\renewcommand\printtmptest{\input{tz-tmp-test.tex}} +%\renewcommand\printtzplottest{\input{tzplot-test.tex}} %------------------------------------------------------ \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 +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 -- Part III +tzplot-doc-C1-v\tmpversion, % connecting points -- Part III +tzplot-doc-C2-v\tmpversion, % polygons and angles -- Part III +tzplot-doc-D-v\tmpversion, % plotting graphs -- Part IV +tzplot-doc-E-v\tmpversion, % misc : final chapter : (-- Part V: not yet) +%%%tzplot-eco-v\tmpversion, % economics }} %------------------------------------------------------ @@ -24,8 +35,12 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \gdef\clearforchapter{} % no clearpage for chapter +%\usepackage{istgame} % middle arrow test +%\usepackage{tzplot-v\tmpversion} \usepackage{tzplot} +%\AtBeginDocument{\tikzset{>=to}} + % ndh \usepackage{etoolbox} \input{tzplot-oblivoirpartstyle} @@ -36,13 +51,6 @@ tzplot-doc-D-v\tmpversion, % plotting graphs %\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) @@ -71,7 +79,7 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \setlength\cftsectionindent{1.8em} \setlength\cftsectionnumwidth{2.7em} \setlength\cftsubsectionindent{4.5em} -\setlength\cftsubsectionnumwidth{3em} +\setlength\cftsubsectionnumwidth{3.5em} % 3em -> 3.5em %%% chapter style \makechapterstyle{tzdoc}{% @@ -84,6 +92,7 @@ tzplot-doc-D-v\tmpversion, % plotting graphs %\usepackage{xparse} %% oblivoir loads xparse \usepackage{tikz} +\usetikzlibrary{shapes.misc} \usepackage{makecell} @@ -91,6 +100,8 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \usepackage[normalem]{ulem} % [normalem] to correct the pdf bookmark broken characters \usepackage{idxlayout} +\usepackage{tabu,tabu-fix} + \usepackage{tcolorbox} \tcbuselibrary{minted,listings,breakable} @@ -169,9 +180,14 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \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 + \makeatletter \newcommand{\icmd}[1]{\cmdprint{#1}% - \index{\expandafter\@gobble\string#1@\string\cmdprint{\string#1}}} + \index{\expandafter\@gobble\string#1(@\string\cmdprint{\string#1}}} \makeatother \makeindex @@ -201,10 +217,39 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \def\listdivider{\leavevmode\smallskip\hrule width 1.5em\smallskip} \newcommand\remark{\bigskip\noindent \textbf{Remark: }} +\newcommand\remarkafterskip{\bigskip} \newcommand\warning{\bigskip\noindent \textbf{Warning: }} \newcommand\threeways{\textsc{Three Ways}} +\usepackage{filecontents} + +\begin{filecontents*}{sine.data} +#Curve 0, 20 points +#x y type +0.00000 0.00000 i +0.52632 0.50235 i +1.05263 0.86873 i +1.57895 0.99997 i +2.10526 0.86054 i +2.63158 0.48819 i +3.15789 -0.01630 i +3.68421 -0.51638 i +4.21053 -0.87669 i +4.73684 -0.99970 i +5.26316 -0.85212 i +5.78947 -0.47390 i +6.31579 0.03260 i +6.84211 0.53027 i +7.36842 0.88441 i +7.89474 0.99917 i +8.42105 0.84348 i +8.94737 0.45948 i +9.47368 -0.04889 i +10.00000 -0.54402 i +\end{filecontents*} + + %\parindent=0pt \title{\texttt{tzplot.sty} \\ Plot Graphs with \Tikz\ Abbreviations}\author{In-Sung Cho \\ \texttt{ischo <at> ktug.org}} @@ -213,6 +258,15 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \def\tmpclearpage{\clearpage} +\AtBeginDocument{% +\renewcommand*\contentsname{Contents} +\renewcommand*\figurename{Figure} +\renewcommand*\tablename{Table} +\renewcommand*\abstractname{Abstract} +\renewcommand*\indexname{Index} +\renewcommand*\pagerefname{\kern-4pt} +} + \AtBeginDocument{\MakeShortVerb{\|}} %%% english based document: \flushbottom @@ -226,6 +280,8 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \myincludeonly +\firmlists + %============================================================= \begin{document} @@ -235,7 +291,7 @@ tzplot-doc-D-v\tmpversion, % plotting graphs \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}. +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 have been chosen and developed with an emphasis on drawing graphs in \emph{economics}. \begin{keywords} lines, dots, curves, axes, functions, @@ -247,22 +303,202 @@ projection, ticks, intersections, tangent lines \mainmatter -\include{tzplot-doc-A-v\tmpversion} -\include{tzplot-doc-B-v\tmpversion} +\printtodos + +\printtmptest + +\printtzplottest -\include{tzplot-doc-C-v\tmpversion} -\include{tzplot-doc-D-v\tmpversion} +% Part I +\include{tzplot-doc-A-v\tmpversion} % getting ready -%\include{tzplot-eco-v\tmpversion} +% Part II +\include{tzplot-doc-B-v\tmpversion} % getting started + +% Part III +\include{tzplot-doc-C-v\tmpversion} % dots, lines, curves, angles +\include{tzplot-doc-C1-v\tmpversion} % connecting points +\include{tzplot-doc-C2-v\tmpversion} % polygons and angles + +% Part IV +\include{tzplot-doc-D-v\tmpversion} % plot functions + +% Part V (chapter now) %%% Part: not yet. +\include{tzplot-doc-E-v\tmpversion} % misc and examples + +% Not Yet! +\include{tzplot-eco-v\tmpversion} % application to economics \chapter*{Version history} \addcontentsline{toc}{chapter}{Version history} \begin{itemize} -\item v\tmpversion (\tmpdate) +%%%\item v\tmpversion (\tmpdate) +%%% \begin{itemize} +%%% \item +%%% \item +%%% \item +%%% \end{itemize} +\item v2.0 (2022/02/28) + \begin{itemize} + \item Uploaded to CTAN + \item document done + \end{itemize} +\item v1.98 (2022/02/27) + \begin{itemize} + \item added |\tzpointangle| + \item added |\tzfnarealine(')|, |\settzfnarealinestyle| + \end{itemize} +\item v1.97 (2022/02/26) + \begin{itemize} + \item corrected |\tzpdfN|: bug fix + \item redesigned |\tzfnarea| (renamed from |\tzfnArea|) + \item added |\settzfnarearlayer| + \end{itemize} +\item v1.96 (2022/02/25) + \begin{itemize} + \item modified |\tzanglemark|, |\tzrightanglemark| + \item added |\settzAAlinestyle| and |\settzRAlinestyle| + \item added |\settzAAradius|, |\settzRAsize| + \item predefined coordinates |(tzAAmid)|, |(tzRAvertext)| + \item corrected |\tzdefLFn|, |\tzdefLFnofy|, |\tzLfn|, |\tzLFnofy| + \item added |error message|: infinite slope error (for |LFn...| things) + \end{itemize} +\item v1.95 (2022/02/24) + \begin{itemize} + \item documented + \item redefined |\tzedge(+)| and |\tzedges(+)| to make them consistent with \Tikz\ way + \item added aliases: |\tzbox|, |\tzboxring|, |\tzcirclering| + \item renamed |\tzangleONE|, |\tzangleTWO|, |\tzanglresult| + \end{itemize} +%%%\item v1.94 (2022/02/22) +%%% \begin{itemize} +%%% \item added |\tzprojs(*)|, |\tzprojsx(*)|, |\tzprojsy(*)| (semicolon versions) +%%% \item added |\tznoderectangle(*)| and |\tznodebox(*)|: aliases of |\tznodeframe(*)| +%%% \item added |\tznodeoval(*)|: an alias of |\tznodeellipse(*)| +%%% \item modified |\tznode(*)|: to use full features of the \Tikz\ |node| operation with |<node.code>| +%%% \end{itemize} +%%%\item v1.93 (2022/02/19) +%%% \begin{itemize} +%%% \item added middle arrow tip styles: |-->--|, |--o--|, |--x--|, and |--/--| +%%% \item added |\settzmidarrow| to control middle arrow tips +%%% \item added libraries |arrows.meta| and |bending| +%%% \item added |error message|: when a semicolon is forgotten for semicolon versions +%%% \end{itemize} +%%%\item v1.92 (2022/02/17) +%%% \begin{itemize} +%%% \item redefined |\tzfn| and |\tzfnofy| to resolve issue with |\tz<...>AtBegin| +%%% \begin{itemize} +%%% \item used |(current subpath start)| +%%% \end{itemize} +%%% \item redefined |\tzfnmax| and |\tzfnmin| to resolve issue with |\tz<...>AtBegin| +%%% \item redefined |\tzLFn| and |\tzLFnofy| to resolve issue with |\tz<...>AtBegin| +%%% \item redefined |\tzplot| and |\tzplotcurve| to resolve issue with |\tz<...>AtBegin| +%%% \end{itemize} +%%%\item v1.91 (2022/02/15) +%%% \begin{itemize} +%%% \item added |\tznodedots(*)| and |\tznodes(*)|: semicolon versions +%%% \begin{itemize} +%%% \item modified |\tzdots| for consistency with |\tznodedots| +%%% \end{itemize} +%%% \end{itemize} +%%%\item v1.9 (2022/02/11) +%%% \begin{itemize} +%%% \item redefined |\tzparabola| to add |\tzparabolaAtBegin|, |\tzparabolaAtEnd| +%%% \item redefined |\tzbezier| to add |\tzbezierAtBegin|, |\tzbezierAtEnd| +%%% \item redefined |\tzplot|, |\tzplotcurve| to use string replacement for angles +%%% \item redefined |\tznodedot| to use string replacement for angles +%%% \item modified |\tzlinks| and |\tzpath| to make them to be (almost) equal +%%% \begin{itemize} +%%% \item |\let\tzpathstyle\tzlinkstyle| and |\let\settzpathstyle\settzlinkstyle| +%%% \end{itemize} +%%% \end{itemize} +%%%\item v1.8 (2022/02/08) +%%% \begin{itemize} +%%% \item redefined |\tzdot| and many other macros related to points, dots, and coordinates +%%% \begin{itemize} +%%% \item allows users to place labels not only by angles but also by string replacement: +%%% \item |\tzdot(s)|, |\tzcdot(s)|, |\tzcoor(s)|, |\tzcoorsquick| +%%% \item |\tzXpoint|, |\tzLFnXpoint|, |\tzhXpoint(at)|, |\tzvXpoint(at)| +%%% \end{itemize} +%%% \item modified |\tzfn| and |\tzfn'| (for functions of |\x| only) +%%% \item modified |\tzfnofy| and |\tzfnofy'| (for functions of |\y| only) +%%% \item modified |\tzdeffn|, |\tzdeffnofy|, |\tzdefLFn|, |\tzdefLFnofy| (no prime versions) +%%% \item redefined |\tzLFnofy| to add |\tzLFnofy'| +%%% \item rearraged document +%%% \end{itemize} +%%%\item v1.7 (2022/02/06) +%%% \begin{itemize} +%%% \item redefined |\tzrightanglemark| +%%% \begin{itemize} +%%% \item added |\tzrightanglemark*| to replace |\tzrightanglefill|, to be removed +%%% \item added |\tzrightanglemark'| to avoid frequent coding error +%%% \end{itemize} +%%% \item redefined |\tzanglemark| +%%% \begin{itemize} +%%% \item added |\tzanglemark*| to replace |\tzanglefill|, to be removed +%%% \item added |\tzanglemark'| to avoid frequent coding error +%%% \end{itemize} +%%% \end{itemize} +%%%\item v1.6 (2022/01/26) +%%% \begin{itemize} +%%% \item renamed |\tzmarkangle(')| to |\tzanglemark(')| +%%% \item renamed |\tzfillkangle(')| to |\tzanglefill(')| +%%% \item renamed |\tzmarkrightangle| to |\tzrightanglemark| +%%% \item renamed |\tzfillrightangle| to |\tzrightanglefill| +%%% \item redefined |\tzpath| and its friends to make |\settzpathlayer| work with them +%%% \item added |\tzlineAtBegin| and |\tzlineAtEnd| +%%% \item added |\tzlinesAtBegin| and |\tzlinesAtEnd| +%%% \item added |\tztoAtBegin| and |\tztoAtEnd| +%%% \item added |\tztosAtBegin| and |\tztosAtEnd| +%%% \item added |\tzLFnAtBegin| and |\tzLFnAtEnd| +%%% \item added |\tzLFnofyAtBegin| and |\tzLFnofyAtEnd| +%%% \item added |\tzvfn(at)AtBegin| and |\tzvfn(at)AtEnd| +%%% \item added |\tzhfn(at)AtBegin| and |\tzhfn(at)AtEnd| +%%% \end{itemize} +%%%\item v1.5 (2021/11/29) +%%% \begin{itemize} +%%% \item added |\tzfnArea| (need to be completed, and then rename to |\tzfnarea|) +%%% \begin{itemize} +%%% \item currently |no shift|, |no extension|, |no code.append| +%%% \end{itemize} +%%% \item added |\tzpdfZ| and |\tzpdfN| for normal distribution functions +%%% \end{itemize} +%%%\item v1.4 (2021/11/05) +%%% \begin{itemize} +%%% \item revived |\tzslope|, |\tzslopeat|, |\settzslopelayer|, |\tzslopeepsilon| +%%% \item revived |\tzdeffn(')|, |\tzdeffnofy(')|, |\tzdefLFn(')|, |\tzdefLFnofy| +%%% \item revived |\tzfn'|, |\tzfnofy|, |\tzLFnofy|, |\tzLFnXpoint(*)| +%%% \end{itemize} +%%%\item v1.3 (2021/04/09) +%%% \begin{itemize} +%%% \item revived |\tzlink(+)|, |\tzlinkAtBegin|, |\tzlinkAtEnd|, |\settzlinkstyle| +%%% \item revived |\tzlinks(+)|, |\tzlinksAtBegin|, |\tzlinksAtEnd| +%%% \item revived |\tzedge(+)|, |\tzedges(+)| +%%% \item revived |\tzslope|, |\tzslopeat| +%%% \item revived |\tzLFXpoint(*)| +%%% \item revived |\tzfnofy|, |\tzdeffn|, |\tzdeffnofy| +%%% \item revived |\tzLFnofy|, |\tzdefLFn|, |\tzdefLFnofy| +%%% \item revived |\tzplotfile| +%%% \end{itemize} +%%%\item v1.2 (2021/04/03) +%%% \begin{itemize} +%%% \item revived |\tzsnake|, |\tzspy| +%%% \item added |\tzmarkrightangle|, |\tzfillrightangle| +%%% \item added |\tzmarkangle(')|, |\tzfillangle(')| +%%% \item added |\settzanglelayer|, |\tzangleresult|, |\tzangleONEresult|, |\tzangleTWOresult| +%%% \item added |\tzpicangle| (considering to drop later) +%%% \item added |\tzfnmax|, |\tzfnmin|, |\tz<...>AtBegin|, |\tz<...>AtEnd| +%%% \end{itemize} +%%%\item v1.1 (2021/03/23) +%%% \begin{itemize} +%%% \item added |\tzring(*)|, |\tzellipsering(*)|, |\tzrectanglering(*)| +%%% \item added aliases: |\tzovalring(*)|, |\tzframering(*)| +%%% \end{itemize} +\item v1.0.1 (2021/03/20) uploaded to CTAN \begin{itemize} \item revised the document with typo corrections \item added the option |<code.append>| to |\tzframe|, |\tzcircle|, and |\tzellipse| @@ -281,7 +517,7 @@ projection, ticks, intersections, tangent lines \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 + \item added |text opacity=1| everywhere |fill opacity=.3| is used \end{itemize} %%%\item v0.99j (2021/02/18) %%% \begin{itemize} @@ -359,7 +595,7 @@ projection, ticks, intersections, tangent lines \chapter*{Acknowledgement} \addcontentsline{toc}{chapter}{Acknowledgement} -I am grateful to Kangsoo Kim of KTUG (Korean TeX Users Group) who has written many packages including |oblivoir.cls| for helping to implement the idea of the semicolon version with |expl3|. +Many thanks to Kangsoo Kim from KTUG (Korean TeX Users Group) who wrote many packages, including |oblivoir.cls|, for helping to implement the semicolon versions and to handle \TeX\ expansion issues using |expl3|. \chapter*{References} \addcontentsline{toc}{chapter}{Reference} @@ -368,7 +604,7 @@ I am grateful to Kangsoo Kim of KTUG (Korean TeX Users Group) who has written ma \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}. +\hpara{}Tantau, Till~(2021), ``\TikZ\ and PGF: Manual for version 3.1.9a," \url{http://sourceforge.net/projects/pgf}. \clearpage \printindex diff --git a/Master/texmf-dist/tex/latex/tzplot/tzplot.sty b/Master/texmf-dist/tex/latex/tzplot/tzplot.sty index c5a1413a142..7b574bdc25c 100644 --- a/Master/texmf-dist/tex/latex/tzplot/tzplot.sty +++ b/Master/texmf-dist/tex/latex/tzplot/tzplot.sty @@ -2,7 +2,7 @@ %% %% tzplot %% -%% (C) Copyright 2017-2021 In-Sung Cho <ischo at ktug.org> +%% (C) Copyright 2017-2022 In-Sung Cho <ischo at ktug.org> %% %% This work may be distributed and/or modified %% under the conditions of the LaTeX Project Public License, @@ -11,7 +11,7 @@ %% http://www.latex-project.org/lppl.txt. %% %% ------------------------------------------------- -\ProvidesPackage{tzplot-v1.0.1}[2021/03/20 v1.0.1 Plot Graphs with TikZ Abbreviations] +\ProvidesPackage{tzplot}[2022/02/28 v2.0 Plot Graphs with TikZ Abbreviations] % expl3,xparse: LPPL % tikz: LPPL and/or GNU GPL @@ -19,11 +19,35 @@ \RequirePackage{tikz} \usetikzlibrary{ -calc,backgrounds,positioning,intersections, -arrows,shapes,patterns, -plotmarks, % for \tzplot[mark] -decorations.pathreplacing, % for tzshowcontrols/show path construction, tzbrace +arrows, % (deprecated in tikz) +backgrounds, +calc, +decorations.pathreplacing, % for tzshowcontrols, tzbrace calligraphy, % for calligraphic brace (load after decorations.pathreplacing) +intersections, +patterns, +plotmarks, % for \tzplot[mark] +positioning, +shapes, +} + +%%(ADDED) +\usetikzlibrary{ +% for later use +%angles, % for \tzpicangle %% (Removed!!!) +arrows.meta, % (added) +bending, % (added with arrows.meta) +decorations.markings, % need for "decoration" +decorations.pathmorphing, % for \tzsnake +spy, % for \tzspy (later) +fpu, % for computation for \tzpicangle +%fit, +%quotes, +%through, +%shadings, +%shadows, +%scopes, +%graphs, } @@ -34,42 +58,40 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \pgfdeclarelayer{foreground} \pgfsetlayers{background,behind,main,above,foreground} -%% usage: \begin{pgfonlayer}{foreground} ... \end{pgfonlayer} +%% 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) +%%%%% basic defaults + +%% 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) +%% node dot (using minimum size: diameter) \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 +%% mark (using mark size: 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 +%% 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 +%% 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} @@ -77,19 +99,22 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \newcommand\tzfillcolor{\tz@initial@fill@color} -% link style +%% 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} +\let\tzpathstyle\tzlinkstyle +\let\settzpathstyle\settzlinkstyle -% tangent epsilon +%%% 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} @@ -104,28 +129,130 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \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} +%%(ADDED) +%% slope epsilon + +\def\tz@default@slope@epsilonL{.01} +\def\tz@default@slope@epsilonR{.01} +\def\tz@initial@slope@epsilonL{\tz@default@slope@epsilonL} +\def\tz@initial@slope@epsilonR{\tz@default@slope@epsilonL} +\NewDocumentCommand\settzslopeepsilon{mg} +{% + \renewcommand\tz@initial@slope@epsilonL{#1} + \IfNoValueTF {#2} + {\renewcommand\tz@initial@slope@epsilonR{#1}} + {\renewcommand\tz@initial@slope@epsilonR{#2}} +} +\newcommand\tzslopeepsilonL{\tz@initial@slope@epsilonL} +\newcommand\tzslopeepsilonR{\tz@initial@slope@epsilonR} + +\let\tzslopeatepsilonL\tzslopeepsilonL +\let\tzslopeatepsilonR\tzslopeepsilonR + -% tangent layer +%%%%% layers: defaults + +%% tzpath layer %% default: main +\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} +%% (there is No \tz-link-layer thing) + +%% tzfnArea layer %% default: main +\def\tz@default@tzfnArea@layer{behind} % fixed +\def\tz@initial@tzfnArea@layer{\tz@default@tzfnArea@layer} % changeable +\NewDocumentCommand\settzfnArealayer{m} + {\renewcommand\tz@initial@tzfnArea@layer{#1}} +\newcommand\tzfnArealayer{\tz@initial@tzfnArea@layer} + +%% tzfnarea layer %% default: main +\def\tz@default@tzfnarea@layer{behind} % fixed +\def\tz@initial@tzfnarea@layer{\tz@default@tzfnarea@layer} % changeable +\NewDocumentCommand\settzfnarealayer{m} + {\renewcommand\tz@initial@tzfnarea@layer{#1}} +\newcommand\tzfnarealayer{\tz@initial@tzfnarea@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}} +\NewDocumentCommand\settztangentlayer{m} + {\renewcommand\tz@initial@tangent@layer{#1}} \newcommand\tztangentlayer{\tz@initial@tangent@layer} + \let\tztangentatlayer\tztangentlayer +\let\settztangentatlayer\settztangentlayer -% 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}} +%% 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 +\let\settzsecantatlayer\settzsecantlayer + +%%(ADDED) +%% slope layer +\def\tz@default@slope@layer{behind} % fixed +\def\tz@initial@slope@layer{\tz@default@slope@layer} % changeable +\NewDocumentCommand\settzslopelayer{m} + {\renewcommand\tz@initial@slope@layer{#1}} +\newcommand\tzslopelayer{\tz@initial@slope@layer} + +\let\tzslopeatlayer\tzslopelayer +\let\settzslopeatlayer\settzslopelayer + +%% angle layer +\def\tz@default@angle@layer{behind} % fixed +\def\tz@initial@angle@layer{\tz@default@angle@layer} % changeable +\NewDocumentCommand\settzanglelayer{m} + {\renewcommand\tz@initial@angle@layer{#1}} +\newcommand\tzanglelayer{\tz@initial@angle@layer} + +\let\tzanglemarklayer\tzanglelayer +\let\settzanglemarklayer\settzanglelayer + + +%%%%% line style, radius, size: defaults + +%% function area (fnA) line width +\def\tz@default@fnA@linestyle{very thin} % fixed +\def\tz@initial@fnA@linestyle{\tz@default@fnA@linestyle} % changeable +\NewDocumentCommand\settzfnarealinestyle{m} + {\renewcommand\tz@initial@fnA@linestyle{#1}} +\newcommand\tzfnALstyle{\tz@initial@fnA@linestyle} + +%% angle arc (AA) line style +\def\tz@default@AA@linestyle{very thin} % fixed +\def\tz@initial@AA@linestyle{\tz@default@AA@linestyle} % changeable +\NewDocumentCommand\settzAAlinestyle{m} + {\renewcommand\tz@initial@AA@linestyle{#1}} +\newcommand\tzAAlinestyle{\tz@initial@AA@linestyle} + +\let\tzRAlinestyle\tzAAlinestyle +\let\settzRAlinestyle\settzAAlinestyle + +%% angle arc (AA) radius +\def\tz@default@AA@radius{10pt} % fixed +\def\tz@initial@AA@radius{\tz@default@AA@radius} % changeable +\NewDocumentCommand\settzAAradius{m} + {\renewcommand\tz@initial@AA@radius{#1}} +\newcommand\tzAAradius{\tz@initial@AA@radius} + +%% right angle (RA) marc size +\def\tz@default@RA@size{5pt} % fixed +\xdef\tz@initial@RA@size{\tz@default@RA@size} % changeable +\NewDocumentCommand\settzRAsize{m} + {\renewcommand\tz@initial@RA@size{#1}} +\newcommand\tzRAsize{\tz@initial@RA@size} + %%%%% TikZ alias styles @@ -157,6 +284,13 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) tzdot options/.style={tzdot=\tzdotsize,#1} } +%%%%%%% tzshowdot +%%%%%\tikzset{ +%%%%% tzshowdot/.style= +%%%%% {draw,fill,solid,thin,circle,inner sep=0pt,minimum size=\tzdotsize,#1}, +%%%%%% tzshowdot/.default=circle +%%%%%} + %% tzmark \tikzset{ tzmark/.style= @@ -227,6 +361,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } + %===================================================== %%===================================================== %%===================================================== @@ -234,6 +369,42 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%===================================================== %%===================================================== +%%% error messages: + +%% semicolon versions +\msg_new:nnn { tzplot } { semicolon-error } + { You~may~have~forgotten~a~semicolon~here~or~above! } + +%% infinite slope error: LFn related macros +\msg_new:nnn { tzplot } { infinite~slope~error } + { Perhaps~you~are~trying~an~'infinite~slope'~here~or~above! } + + +%%%% string replacement +%%%%%% to use string replacement for label positions +\cs_new:Npn \extract_posopt:w [ #1 ] #2 \q_stop % ndh +{ + \tl_set:Nn \l_label_pos_str_tl { [ \exp_not:n { #1 } ] } % \exp_not needed!!! + + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #2 } } + + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_put_right:Nn \l_label_pos_str_tl {left} } + {r} { \tl_put_right:Nn \l_label_pos_str_tl {right} } + {a} { \tl_put_right:Nn \l_label_pos_str_tl {above} } + {b} { \tl_put_right:Nn \l_label_pos_str_tl {below} } + {c} { \tl_put_right:Nn \l_label_pos_str_tl {center} } + {al} { \tl_put_right:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_put_right:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_put_right:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_put_right:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_put_right:Nn \l_label_pos_str_tl { #2 } + } +} + %%%%% help lines \NewDocumentCommand\tzhelplines{ s O{} r() d() } @@ -309,6 +480,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%%% --- end of \tzgetxyval + + + + + %%%%% Dots %%% Node Dots %%% (basic: using minimum size) @@ -318,13 +494,44 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzdot_shift_coor_bool -\NewDocumentCommand\tzdot{ s O{} d<> r() +G{} O{} D(){\tz@initial@dot@size} } +%%% \tzdot (main) +\NewDocumentCommand\tzdot + { s O{} d<> r() +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzdot_cmd_tl - \IfValueT { #7 } + \tl_if_empty:nF { #7 } { \renewcommand\tzdotsize{ #7 } } +%%%%%% to use string replacement for label positions + \IfValueTF { #6 } + { + \tl_if_in:nnTF { #6 } { [ } + { \extract_posopt:w #6 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #6 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #6 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \IfValueTF { #3 } { \tl_set:Nn \l_tzdot_shift_coor_tl { #3 } @@ -339,11 +546,13 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tl_put_right:Nx \l_tzdot_cmd_tl { - ( [ shift = { (\l_tzdot_shift_coor_tl) } ]#4 ) node + ( [ shift = { (\l_tzdot_shift_coor_tl) } ] #4 ) } } - { \tl_put_right:Nn \l_tzdot_cmd_tl { (#4) node } } + { \tl_put_right:Nn \l_tzdot_cmd_tl { (#4) } } + \tl_put_right:Nn \l_tzdot_cmd_tl { node } %% + \IfBooleanTF { #1 } { \tl_put_right:Nn \l_tzdot_cmd_tl @@ -355,7 +564,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzdot_cmd_tl { - label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #5 } } , % pos_str } \tl_put_right:Nn \l_tzdot_cmd_tl { @@ -367,6 +576,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzdot + %%% multiple dots %%% coding CAUTION! : _tzdot_ changed to _tzdots_ @@ -377,6 +587,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_new:N \l_tzdots_cmd_tl \bool_new:N \l_tzdots_shift_coor_bool +%%% \tzdots (main) \NewDocumentCommand\tzdots{ s O{} d<> } { \tl_clear:N \l_tzdots_cmd_tl @@ -413,29 +624,60 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzdots_late_opt_fn } } { - \tzdots_stop_action +% \tzdots_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzdots_sub_fn { r() +G{} O{} } +\NewDocumentCommand\tzdots_sub_fn { r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \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 ) + ( [ shift = { (\l_tzdots_shift_coor_tl) } ] #1 ) } } { \tl_put_right:Nn \l_tzdots_cmd_tl { (#1) } } + \tl_put_right:Nn \l_tzdots_cmd_tl { node } %% + \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 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } , % pos_str } \tl_put_right:No \l_tzdots_cmd_tl % expand `once' { @@ -476,12 +718,12 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \clist_new:N \l_tzCdot_opt_clist \bool_new:N \l_tzCdot_shift_coor_bool -\NewDocumentCommand\tzcdot{ s o d<> r() +G{} O{} d() } +%%% \tzcdot (main) +\NewDocumentCommand\tzcdot{ s o d<> r() +G{} >{\TrimSpaces}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 } @@ -512,8 +754,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \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 } + \clist_pop:NN \l_tzCdot_opt_input_clist \l_label_pos_str_tl + \keys_set:nV { keytzCdot } \l_label_pos_str_tl % form: { tzcdot=\l_label_pos_str_tl } \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } \clist_map_break: % non-tested list remains @@ -554,11 +796,40 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { circle ( \tzCdotradius ) } +%%%%%% to use string replacement for label positions + \IfValueTF { #6 } + { + \tl_if_in:nnTF { #6 } { [ } + { \extract_posopt:w #6 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #6 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #6 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \tl_put_right:Nx \l_tzCdot_cmd_tl { node [ inner~sep = 0pt , - label = { \exp_not:n { #6 } \c_colon_str \exp_not:n { #5 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #5 } } % pos_str ] {} } \exp_last_unbraced:No \draw \l_tzCdot_cmd_tl ; @@ -570,6 +841,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% multiple dots %%% coding CAUTION! : _tzCdot_ changes to _tzCdots + +%%% \tzcdots %%% *[<opt>]<shift> (){}[] (){}[] repeated (){}[] ; (radius) %%% repeat pattern: (coor){label}[angle] @@ -577,6 +850,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzCdots_size_call_bool \bool_new:N \l_tzCdots_shift_coor_bool +%%% \tzcdots (main) \NewDocumentCommand\tzcdots{ s o d<> } { \renewcommand\tzCdotradius{\tz@initial@Cdot@radius} @@ -609,8 +883,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \str_if_in:nnTF { ##1 } { tzcdot } { - \clist_pop:NN \l_tzCdots_opt_input_clist \l_tmpa_tl - \keys_set:nV { keytzCdot } \l_tmpa_tl + \clist_pop:NN \l_tzCdots_opt_input_clist \l_label_pos_str_tl + \keys_set:nV { keytzCdot } \l_label_pos_str_tl \exp_args:NNo \renewcommand\tzCdotradius { \key_tzCdot_radius_tl } \bool_set_true:N \l_tzCdots_size_call_bool \clist_map_break: @@ -643,12 +917,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzCdots_late_opt_fn } } { - \tzCdots_stop_action +% \tzCdots_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzCdots_sub_fn { r() +G{} O{} } +\NewDocumentCommand\tzCdots_sub_fn { r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \bool_if:NTF \l_tzCdots_shift_coor_bool {% if shift \tl_put_right:Nx \l_tzCdots_cmd_tl @@ -664,7 +967,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { node [ inner~sep = 0pt , - label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str ] {} } \tzCdots_check_token:n @@ -761,7 +1064,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%%%% Coordinates %%% \tzcoor()(){label}[pos] -\NewDocumentCommand\tzcoor{ s O{} d<> r() r() +G{} O{} D(){\tz@initial@dot@size} } +\NewDocumentCommand\tzcoor{ s O{} d<> r() r() +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzcoor_cmd_tl @@ -791,9 +1094,37 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { [ inner~sep = 0pt , } +%%%%%% to use string replacement for label positions + \IfValueTF { #7 } + { + \tl_if_in:nnTF { #7 } { [ } + { \extract_posopt:w #7 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #7 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #7 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \tl_put_right:Nx \l_tzcoor_cmd_tl { - label = { \exp_not:n { #7 } \c_colon_str \exp_not:n { #6 } } + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #6 } } % pos_str } \tl_put_right:Nn \l_tzcoor_cmd_tl { @@ -812,6 +1143,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzcoors*[opt]<radius> ()(){}[] ()(){}[] repeated ()(){}[]; %% repeat pattern: (coor)(name){label}[pos] + +%%% \tzcoors (main) \NewDocumentCommand\tzcoors{ s O{} d<> } { \tl_clear:N \l_tzcoors_cmd_tl @@ -849,12 +1182,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzcoors_late_opt_fn } } { - \tzcoors_stop_action +% \tzcoors_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzcoors_sub_fn { r() r() +G{} O{} } +\NewDocumentCommand\tzcoors_sub_fn { r() r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #4 } + { + \tl_if_in:nnTF { #4 } { [ } + { \extract_posopt:w #4 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #4 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #4 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \bool_if:NTF \l_tmpa_bool { % collect only coor info @@ -884,7 +1246,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzcoors_tzdot_cmd_tl { - label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #3 } } , % abb } \tl_put_right:No \l_tzcoors_tzdot_cmd_tl { @@ -903,7 +1265,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { (#1) coordinate } } \tl_put_right:Nx \l_tzcoors_cmd_tl - { [ label = { \exp_not:n { #4 } \c_colon_str \exp_not:n { #3 } } ] } + { [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #3 } } ] } % pos_str \tl_put_right:Nn \l_tzcoors_cmd_tl { (#2) } } @@ -931,6 +1293,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzcoors_quick_shift_coor_bool +%%% \tzcoorsquick (main) \NewDocumentCommand\tzcoorsquick { s O{} d<> } { \tl_clear:N \l_tzcoors_quick_cmd_tl @@ -968,25 +1331,70 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzcoorsquick_late_opt_fn } } { - \tzcoorsquick_stop_action +% \tzcoorsquick_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } % repetition *** -\NewDocumentCommand\tzcoorsquick_sub_fn { r() r() +g O{} } +\NewDocumentCommand\tzcoorsquick_sub_fn { r() r() +g >{\TrimSpaces}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 } + { \tl_set:Nx \l_label_pos_tl { \exp_not:n { #3 } } } + { \tl_set:Nn \l_label_pos_tl { #2 } } % automatic view + +%%%%%% to use string replacement for label positions + \IfValueTF { #4 } { + \tl_if_in:nnTF { #4 } { [ } + { \extract_posopt:w #4 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #4 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #4 } + } + } + \tl_set:Nx \l_tmpb_tl { \l_label_pos_str_tl } % pos_str + } + { + \tl_clear:N \l_label_pos_str_tl \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 } } - } +%%%%%%%%%% + +% \IfValueTF { #4 } +% { +% \tl_set:Nx \l_tmpb_tl { \l_label_pos_str_tl } % pos_str +% } +% { +% \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_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 @@ -1018,7 +1426,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tzcoors_quick_tzdot_cmd_tl { - label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } , + label = { \l_tmpb_tl \c_colon_str { \l_label_pos_tl } } , } \tl_put_right:No \l_tzcoors_quick_tzdot_cmd_tl { @@ -1038,7 +1446,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { (#1) coordinate } } \tl_put_right:Nx \l_tzcoors_quick_cmd_tl - { [ label = { \l_tmpb_tl \c_colon_str { \l_tmpa_tl } } ] } + { [ label = { \l_tmpb_tl \c_colon_str { \l_label_pos_tl } } ] } \tl_put_right:Nn \l_tzcoors_quick_cmd_tl { (#2) } } @@ -1071,9 +1479,25 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzline +\bool_new:N \g_tzline_BEGIN_cmd_bool +\bool_new:N \g_tzline_END_cmd_bool \bool_new:N \l_tzline_shift_coor_bool -%%% \tzline +%% \tzlineAtBegin +\NewDocumentCommand\tzlineAtBegin{ m } +{ + \bool_gset_true:N \g_tzline_BEGIN_cmd_bool + \tl_gset:No \g_tzline_BEGIN_cmd_tl { #1 } +} + +%% \tzlineAtEnd +\NewDocumentCommand\tzlineAtEnd{ m } +{ + \bool_gset_true:N \g_tzline_END_cmd_bool + \tl_gset:No \g_tzline_END_cmd_tl { #1 } +} + +%%% \tzline (main) \NewDocumentCommand\tzline{ s t+ o d<> d"" } { \tl_clear:N \l_tzline_cmd_tl @@ -1167,6 +1591,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nn \l_tzline_cmd_tl { node [ #7 ] { #6 } } + % add at begin/end + \bool_if:NT \g_tzline_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzline_cmd_tl { \g_tzline_BEGIN_cmd_tl } } + \bool_if:NT \g_tzline_END_cmd_bool + { \tl_put_right:Nx \l_tzline_cmd_tl { \g_tzline_END_cmd_tl } } % final action \tl_put_left:No \l_tzline_cmd_tl @@ -1178,6 +1607,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { [ \l_tzline_namepath_tl , } \exp_last_unbraced:Nf \draw \l_tzline_cmd_tl #8 ; + + \bool_gset_false:N \g_tzline_BEGIN_cmd_bool + \bool_gset_false:N \g_tzline_END_cmd_bool +% \tl_clear:N \g_tzline_BEGIN_cmd_tl +% \tl_clear:N \g_tzline_END_cmd_tl } %%% --- end of \tzline @@ -1185,8 +1619,25 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzlines +\bool_new:N \g_tzlines_BEGIN_cmd_bool +\bool_new:N \g_tzlines_END_cmd_bool \bool_new:N \l_tzlines_shift_coor_bool +%% \tzlinesAtBegin +\NewDocumentCommand\tzlinesAtBegin{ m } +{ + \bool_gset_true:N \g_tzlines_BEGIN_cmd_bool + \tl_gset:No \g_tzlines_BEGIN_cmd_tl { #1 } +} + +%% \tzlinesAtEnd +\NewDocumentCommand\tzlinesAtEnd{ m } +{ + \bool_gset_true:N \g_tzlines_END_cmd_bool + \tl_gset:No \g_tzlines_END_cmd_tl { #1 } +} + +%%% \tzlines (main) %% do not use: inner sep=0pt \NewDocumentCommand\tzlines{ s t+ O{} d<> D""{} } { @@ -1234,7 +1685,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzlines_late_opt_fn } } { - \tzlines_stop_action +% \tzlines_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1299,6 +1751,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tl_put_right:No \l_tzlines_cmd_tl { \l_tzlines_STYLE_B_tl } \tl_clear:N \l_tzlines_STYLE_tl + % add at begin/end + \bool_if:NT \g_tzlines_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlines_cmd_tl { \g_tzlines_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlines_END_cmd_bool + { \tl_put_right:Nx \l_tzlines_cmd_tl { \g_tzlines_END_cmd_tl } } % gathering options \tl_put_left:No \l_tzlines_cmd_tl { @@ -1309,6 +1766,11 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) % final action \exp_last_unbraced:Nf \draw \l_tzlines_cmd_tl \l_tzlines_code_at_end_tl ; + + \bool_gset_false:N \g_tzlines_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlines_END_cmd_bool +% \tl_clear:N \g_tzlines_BEGIN_cmd_tl +% \tl_clear:N \g_tzlines_END_cmd_tl } %%% --- end of \tzlines @@ -1318,6 +1780,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_new:N \l_tzpolygon_shift_coor_bool +%%% \tzpolygon (main) %% do not use: inner sep=0pt \NewDocumentCommand\tzpolygon{ s t+ O{} d<> D""{} } { @@ -1365,7 +1828,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzpolygon_late_opt_fn } } { - \tzpolygon_stop_action +% \tzpolygon_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1456,14 +1920,354 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzpolygon +%%(ADDED) +%%%%% Linking points + +%%% \tzlink (general version of \tzline) + +\bool_new:N \g_tzlink_BEGIN_cmd_bool +\bool_new:N \g_tzlink_END_cmd_bool +\bool_new:N \l_tzlink_shift_coor_bool + +%% \tzlinkAtBegin +\NewDocumentCommand\tzlinkAtBegin{ m } +{ + \bool_gset_true:N \g_tzlink_BEGIN_cmd_bool + \tl_gset:No \g_tzlink_BEGIN_cmd_tl { #1 } +} + +%% \tzlinkAtEnd +\NewDocumentCommand\tzlinkAtEnd{ m } +{ + \bool_gset_true:N \g_tzlink_END_cmd_bool + \tl_gset:No \g_tzlink_END_cmd_tl { #1 } +} + +%%% \tzlink (main) +\NewDocumentCommand\tzlink{ s t+ G{\tz@initial@link@style} o d<> d"" } +{ + \tl_clear:N \l_tzlink_cmd_tl + + \renewcommand\tzlinkstyle{ #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_tzlink_shift_coor_tl { #5 } + \bool_set_true:N \l_tzlink_shift_coor_bool + } + { + \tl_clear:N \l_tzlink_shift_coor_tl + \bool_set_false:N \l_tzlink_shift_coor_bool + } + + \IfValueTF { #4 } + { \tl_set:Nn \l_tzlink_opt_tl { #4 } } + { \tl_clear:N \l_tzlink_opt_tl } + + + \IfValueTF { #6 } + { \tl_set:Nn \l_tzlink_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzlink_namepath_tl } + + \tzlink_check_token:n +} + +\cs_new:Npn \tzlink_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzlink_sub_fn ( } +% \tzlink_stop_action +} + +\NewDocumentCommand\tzlink_sub_fn{ r() O{} +G{} O{} d<> r() +G{} O{} D<>{} } +{ + % determine connect line STYLE + \tl_if_empty:nTF { #2 } + { + \tl_set:Nn \l_tzlink_STYLE_A_tl { ~ \tzlinkstyle ~ } + } + { + \tl_set:Nn \l_tzlink_STYLE_A_tl { ~ #2 ~ } + } + \IfValueTF { #5 } + { + \tl_set:Nn \l_tzlink_STYLE_C_tl { #5 } % + or ++ + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzlink_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzlink_STYLE_C_tl { } } + } + % insert connect line STYLE + \bool_if:NTF \l_tzlink_shift_coor_bool + { + \tl_put_right:Nx \l_tzlink_cmd_tl + { ([ shift = { (\l_tzlink_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzlink_cmd_tl { (#1) } } + + \tl_put_right:No \l_tzlink_cmd_tl % once + { + \l_tzlink_STYLE_A_tl + } + \tl_put_right:Nn \l_tzlink_cmd_tl + { + ~ node [ above , #4 ] { #3 } % above + } + \tl_put_right:No \l_tzlink_cmd_tl % once + { + \l_tzlink_STYLE_C_tl + } + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzlink_cmd_tl { (#6) } + } + {% no ++ + \bool_if:NTF \l_tzlink_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzlink_cmd_tl + { ( [ shift = { (\l_tzlink_shift_coor_tl) } ] \exp_not:n { #6 } ) } + } + { \tl_put_right:Nn \l_tzlink_cmd_tl { (#6) } } + } + + \tl_put_right:Nn \l_tzlink_cmd_tl + { + node [ #8 ] { #7 } + } + % add at begin/end + \bool_if:NT \g_tzlink_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlink_cmd_tl { \g_tzlink_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlink_END_cmd_bool + { \tl_put_right:Nx \l_tzlink_cmd_tl { \g_tzlink_END_cmd_tl } } + + % final action + \tl_put_left:No \l_tzlink_cmd_tl + { + \l_tzlink_opt_tl ] % expand `once' needed + } + + \tl_put_left:Nx \l_tzlink_cmd_tl + { [ \l_tzlink_namepath_tl , } + + \exp_last_unbraced:Nf \draw \l_tzlink_cmd_tl #9 ; + + \bool_gset_false:N \g_tzlink_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlink_END_cmd_bool +% \tl_clear:N \g_tzlink_BEGIN_cmd_tl +% \tl_clear:N \g_tzlink_END_cmd_tl +} + +%%% --- end of \tzlink + + + + +%%%(ADDED) +%%% \tzlinks -- generalized version of \tzlines + +\bool_new:N \g_tzlinks_BEGIN_cmd_bool +\bool_new:N \g_tzlinks_END_cmd_bool +\bool_new:N \l_tzlinks_shift_coor_bool + +%% \tzlinksAtBegin +\NewDocumentCommand\tzlinksAtBegin{ m } +{ + \bool_gset_true:N \g_tzlinks_BEGIN_cmd_bool + \tl_gset:No \g_tzlinks_BEGIN_cmd_tl { #1 } +} + +%% \tzlinksAtEnd +\NewDocumentCommand\tzlinksAtEnd{ m } +{ + \bool_gset_true:N \g_tzlinks_END_cmd_bool + \tl_gset:No \g_tzlinks_END_cmd_tl { #1 } +} + +%%% \tzlinks (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tzlinks{ s t+ G{\tz@initial@link@style} O{} d<> D""{} } +{ + \tl_clear:N \l_tzlinks_cmd_tl + \tl_clear:N \l_tzlinks_STYLE_tl + + \IfValueT { #3 } + { \renewcommand\tzlinkstyle{ #3 } } + + \IfBooleanTF { #1 } % (*) 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 { #5 } + { + \tl_set:Nn \l_tzlinks_shift_coor_tl { #5 } + \bool_set_true:N \l_tzlinks_shift_coor_bool + } + { + \tl_clear:N \l_tzlinks_shift_coor_tl + \bool_set_false:N \l_tzlinks_shift_coor_bool + } + + \IfValueTF { #4 } + { \tl_set:Nx \l_tzlinks_opt_tl { #4 } } + { \tl_clear:N \l_tzlinks_opt_tl } + + \IfValueTF { #6 } + { \tl_set:Nn \l_tzlinks_namepath_tl { name~path = #6 } } + { \tl_clear:N \l_tzlinks_namepath_tl } + + \int_zero:N \l_tmpa_int + \tzlinks_check_token:n +} + +\cs_new:Npn \tzlinks_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzlinks_sub_fn #1 } +% { \tzlinks_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzlinks_sub_fn #1 } + { ; } { \tzlinks_late_opt_fn } + } + { +% \tzlinks_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzlinks_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_tzlinks_cmd_tl { \l_tzlinks_STYLE_tl } + \tl_clear:N \l_tzlinks_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzlinks_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzlinks_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzlinks_cmd_tl + { ([ shift = { (\l_tzlinks_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzlinks_cmd_tl + { ([ shift = { (\l_tzlinks_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzlinks_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_tzlinks_STYLE_A_tl { ~ \tzlinkstyle ~ } } + { \tl_set:Nn \l_tzlinks_STYLE_A_tl { #2 } } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tzlinks_STYLE_B_tl + } + { + \tl_set:Nn \l_tzlinks_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \IfValueTF { #5 } % <+ or ++ or none> (NOT USED!) + { + \tl_set:Nn \l_tzlinks_STYLE_C_tl { #5 } + } + { + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzlinks_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzlinks_STYLE_C_tl { } } + } + + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_A_tl } + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_B_tl } + \tl_put_right:No \l_tzlinks_STYLE_tl { \l_tzlinks_STYLE_C_tl } + + \tzlinks_check_token:n +} + +\NewDocumentCommand\tzlinks_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{ #1 } + \tl_set:Nn \l_tzlinks_code_at_end_tl { #2 } + \tzlinks_stop_action +} + +\NewDocumentCommand\tzlinks_stop_action {} +{ + \tl_if_empty:NF \l_tzlinks_STYLE_B_tl + { + \tl_put_right:No \l_tzlinks_cmd_tl { \l_tzlinks_STYLE_B_tl } + } + \tl_clear:N \l_tzlinks_STYLE_tl + %% add at begin/end + \bool_if:NT \g_tzlinks_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzlinks_cmd_tl { \g_tzlinks_BEGIN_cmd_tl } } + \bool_if:NT \g_tzlinks_END_cmd_bool + { \tl_put_right:Nx \l_tzlinks_cmd_tl { \g_tzlinks_END_cmd_tl } } + %% collect options + \tl_put_left:No \l_tzlinks_cmd_tl + { \l_tzlinks_opt_tl ] } % expand `once' needed + % * or not + \bool_if:NTF \l_tmpa_bool + { + \tl_put_left:Nx \l_tzlinks_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + \l_tzlinks_namepath_tl , + } + } + { + \tl_put_left:Nx \l_tzlinks_cmd_tl + { [ \l_tzlinks_namepath_tl , } + } + %% final action +% \begin{pgfonlayer}{\tzlinklayer} % default tzlinklayer = main + \exp_last_unbraced:Nf + \draw \l_tzlinks_cmd_tl \l_tzlinks_code_at_end_tl ; %% draw (\tzlinks) +% \end{pgfonlayer} + + \bool_gset_false:N \g_tzlinks_BEGIN_cmd_bool + \bool_gset_false:N \g_tzlinks_END_cmd_bool +} + +%%% --- end of \tzlinks + + %%% \tzpath %% draw=none version of \tzlinks (mainly for filling area) +\bool_new:N \g_tzfnArea_call_bool + \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 } { @@ -1478,9 +2282,9 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_gset:No \g_tzpath_END_cmd_tl { #1 } } -%%% \tzpath +%%% \tzpath (main) %% do not use: inner sep=0pt -\NewDocumentCommand\tzpath{ s t+ G{\tz@initial@path@style} O{} d<> D""{} } +\NewDocumentCommand\tzpath{ s t+ G{\tz@initial@link@style} O{} d<> D""{} } { \tl_clear:N \l_tzpath_cmd_tl \tl_clear:N \l_tzpath_STYLE_tl @@ -1529,7 +2333,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzpath_late_opt_fn } } { - \tzpath_stop_action +% \tzpath_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1552,12 +2357,12 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \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 + { ( [ 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 + { ( [ shift = { (\l_tzpath_shift_coor_tl) } ] #1 ) } % shift all coors } } { \tl_put_right:Nn \l_tzpath_cmd_tl { (#1) } } % no shift (normal) @@ -1593,6 +2398,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tzpath_check_token:n } +% \tzpath fill opacity : 0.3 (default) % differ from \tzlinks \NewDocumentCommand\tzpath_late_opt_fn { G{\tz@initial@fill@opacity} D<>{} } { \renewcommand\tzfillopacity{ #1 } @@ -1630,9 +2436,19 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { [ \l_tzpath_namepath_tl , } } %% final action - \exp_last_unbraced:Nf - \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path - + \bool_if:NTF \g_tzfnArea_call_bool + { % (ADDED) for \tzfnArealayer + \begin{pgfonlayer}{\tzfnArealayer} % default tzpathlayer = main + \exp_last_unbraced:Nf + \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path (\tzpath) + \end{pgfonlayer} + } + { % for original \tzpath + \begin{pgfonlayer}{\tzpathlayer} % default tzpathlayer = main + \exp_last_unbraced:Nf + \path \l_tzpath_cmd_tl \l_tzpath_code_at_end_tl ; %% path (\tzpath) + \end{pgfonlayer} + } \bool_gset_false:N \g_tzpath_BEGIN_cmd_bool \bool_gset_false:N \g_tzpath_END_cmd_bool } @@ -1827,7 +2643,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tztos_late_opt_fn } } { - \tztos_stop_action +% \tztos_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -1922,6 +2739,231 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tztos +%%(ADDED) +%%% \tzedge + +\bool_new:N \l_tzedge_shift_coor_bool + +%%% \tzedge (main) +\NewDocumentCommand\tzedge{ s t+ o d<> } +{ + \tl_clear:N \l_tzedge_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_tzedge_shift_coor_tl { #4 } + \bool_set_true:N \l_tzedge_shift_coor_bool + } + { + \tl_clear:N \l_tzedge_shift_coor_tl + \bool_set_false:N \l_tzedge_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzedge_opt_tl { #3 } } + { \tl_clear:N \l_tzedge_opt_tl } + + \tzedge_check_token:n +} + +\cs_new:Npn \tzedge_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzedge_sub_fn ( } +% \tzedge_stop_action +} + +\NewDocumentCommand\tzedge_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } +{ + \bool_if:NTF \l_tzedge_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzedge_cmd_tl + { ([ shift = { (\l_tzedge_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzedge_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tzedge_cmd_tl + { edge [ } + \tl_put_right:No \l_tzedge_cmd_tl + { \l_tzedge_opt_tl ] } % expand `once' needed + \tl_put_right:Nn \l_tzedge_cmd_tl + { node [ #3 ] { #2 } } + + + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzedge_cmd_tl { ++ (#4) ++ (#4) } + } + {% no ++ + \bool_if:NTF \l_tzedge_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzedge_cmd_tl + { + ([ shift = { (\l_tzedge_shift_coor_tl) } ]#4) + ([ shift = { (\l_tzedge_shift_coor_tl) } ]#4) + } + } + { \tl_put_right:Nn \l_tzedge_cmd_tl { (#4) (#4) } } + } + + \tl_if_empty:nF { #5 } + { + \tl_put_right:Nn \l_tzedge_cmd_tl + { node [ #6 ] { #5 } } + } + + % final action + \exp_last_unbraced:Nf \draw \l_tzedge_cmd_tl #7 ; +} + +%%% --- end of \tzedge + + +%%(ADDED) +%%% \tzedges -- generalized version of \tzlines + +\bool_new:N \l_tzedges_shift_coor_bool + +%%% \tzedges (main) +%% do not use: inner sep=0pt +\NewDocumentCommand\tzedges{ s t+ O{} d<> } +{ + \tl_clear:N \l_tzedges_cmd_tl + \tl_clear:N \l_tzedges_STYLE_tl + +% \IfValueT { #3 } +% { \renewcommand\tzedgestyle{ #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_tzedges_shift_coor_tl { #4 } + \bool_set_true:N \l_tzedges_shift_coor_bool + } + { + \tl_clear:N \l_tzedges_shift_coor_tl + \bool_set_false:N \l_tzedges_shift_coor_bool + } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzedges_opt_tl { #3 } } + { \tl_clear:N \l_tzedges_opt_tl } + + \int_zero:N \l_tmpa_int + \tzedges_check_token:n +} + +\cs_new:Npn \tzedges_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzedges_sub_fn #1 } +% { \tzedges_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzedges_sub_fn #1 } +% { ; } { \tzedges_late_opt_fn } + { ; } { \tzedges_stop_action } + } + { +% \tzedges_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzedges_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_tzedges_cmd_tl { \l_tzedges_STYLE_tl } + \tl_clear:N \l_tzedges_STYLE_tl + } + + % collect cmd-tl + \bool_if:NTF \l_tzedges_shift_coor_bool + {% shift-coor + \bool_if:NTF \l_tmpb_bool + {% if ++ + \int_compare:nTF { \l_tmpa_int > 1 } + { \tl_put_right:Nn \l_tzedges_cmd_tl { (#1) } } % no shift from 2nd + { + \tl_put_right:Nx \l_tzedges_cmd_tl + { ([ shift = { (\l_tzedges_shift_coor_tl) } ]#1) } % shift first + } + } + {% no ++ + \tl_put_right:Nx \l_tzedges_cmd_tl + { ([ shift = { (\l_tzedges_shift_coor_tl) } ]#1) } % shift all coors + } + } + { \tl_put_right:Nn \l_tzedges_cmd_tl { (#1) } } % no shift (normal) + + % (from the first round on) determine and save STYLE + % determine connect line STYLE + \tl_set:Nn \l_tzedges_STYLE_A_tl { edge [ #2 ] } + % save node info (for later use, at the end) + \tl_if_empty:nTF { #3 } + { + \tl_clear:N \l_tzedges_STYLE_B_tl + } + { + \tl_set:Nn \l_tzedges_STYLE_B_tl + { ~ node [ #4 ] { #3 } } + } + \bool_if:NTF \l_tmpb_bool + { \tl_set:Nn \l_tzedges_STYLE_C_tl { ++ } } + { \tl_set:Nn \l_tzedges_STYLE_C_tl { } } + + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_A_tl } + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_B_tl } + \tl_put_right:No \l_tzedges_STYLE_tl { \l_tzedges_STYLE_C_tl } + + \tzedges_check_token:n +} + +%\NewDocumentCommand\tzedges_late_opt_fn { D<>{} } +%{ +% \tl_set:Nn \l_tzedges_code_at_end_tl { #1 } +% \tzedges_stop_action +%} + +\NewDocumentCommand\tzedges_stop_action { D<>{} } +{ + % #1 works with the first coordinate + % because [edge] and [node] does not change the current point + \tl_if_empty:NF \l_tzedges_STYLE_B_tl + { + \tl_put_right:No \l_tzedges_cmd_tl { \l_tzedges_STYLE_B_tl } + } + \tl_clear:N \l_tzedges_STYLE_tl + + \tl_put_left:No \l_tzedges_cmd_tl + { [ \l_tzedges_opt_tl ] } % expand `once' needed + + % final action + \exp_last_unbraced:Nf + \draw \l_tzedges_cmd_tl #1 ; %% draw +} + +%%% --- end of \tzedges + + %%%%% Figures: circles, frames, ellipses, triangles, etc. %%% \tzcircle @@ -1929,18 +2971,18 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \NewDocumentCommand\tzcircle { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } { - \renewcommand\tzfillopacity{#7} + \renewcommand\tzfillopacity{#7} % effective only in * version \IfBooleanTF { #1 } { \IfValueTF { #3 } {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = #7 , + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) #8 ; } {% no shift (normal) - \draw [ fill = \tzfillcolor , fill~opacity = #7 , + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , name~path = #4 , #2 ] (#5) circle (#6) #8 ; @@ -1948,31 +2990,81 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } { \IfValueTF { #3 } - { \draw [ #2 ] ([shift={(#3)}]#5) circle (#6) #8 ; } - { \draw [ #2 ] (#5) circle (#6) #8 ; } + { \draw [ name~path = #4 , #2 ] ([shift={(#3)}]#5) circle (#6) #8 ; } + { \draw [ name~path = #4 , #2 ] (#5) circle (#6) #8 ; } } } +%%% \tzring + +\NewDocumentCommand\tzring + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) circle (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) circle (#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) circle (#5) + \IfValueT { #6 } { (#6) circle (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) circle (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) circle (#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) circle (#5) + \IfValueT { #6 } { (#6) circle (#7) } + #9 ; + } + } +} + +%%% --- end of \tzring + +\let\tzcirclering\tzring + + %%% \tzellipse \NewDocumentCommand\tzellipse { s O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } { - \renewcommand\tzfillopacity{#7} + \renewcommand\tzfillopacity{#7} % effective only in * version \IfBooleanTF { #1 } { \IfValueTF { #3 } {% if shift - \draw [ fill = \tzfillcolor , fill~opacity = #7 , + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , - name~path = #4 , #2 ] ([shift={(#3)}]#5) ellipse (#6) - #8 ; + name~path = #4 , #2 ] + ([shift={(#3)}]#5) ellipse (#6) + #8 ; } {% no shift (normal) - \draw [ fill = \tzfillcolor , fill~opacity = #7 , + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , - name~path = #4 , #2 ] (#5) ellipse (#6) - #8 ; + name~path = #4 , #2 ] + (#5) ellipse (#6) + #8 ; } } { @@ -1987,12 +3079,60 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \let\tzoval\tzellipse +%%% \tzellipsering + +\NewDocumentCommand\tzellipsering + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) ellipse (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) ellipse (#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) ellipse (#5) + \IfValueT { #6 } { (#6) ellipse (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) ellipse (#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) ellipse (#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) ellipse (#5) + \IfValueT { #6 } { (#6) ellipse (#7) } + #9 ; + } + } +} + +%%% --- end of \tzellipsering + +\let\tzovalring\tzellipsering + + %%% \tzframe \NewDocumentCommand\tzframe { s t+ O{} d<> D""{} r() r() G{\tz@initial@fill@opacity} D<>{} } { - \renewcommand\tzfillopacity{#8} + \renewcommand\tzfillopacity{#8} % effective only in * version \IfBooleanTF { #1 } { \IfBooleanTF { #2 } @@ -2060,12 +3200,171 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzframe \let\tzrectangle\tzframe +\let\tzbox\tzframe + + + +%%% \tzrectanglering + +\NewDocumentCommand\tzrectanglering + { s O{} d<> r() r() d() d() G{\tz@initial@fill@opacity} D<>{} } +{ + \renewcommand\tzfillopacity{#8} % effective only in * version + \IfBooleanTF { #1 } + { + \IfValueTF { #3 } + {% if shift + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + ([shift={(#3)}]#4) rectangle ([shift={(#3)}]#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) rectangle ([shift={(#3)}]#7) } + #9 ; + } + {% no shift (normal) + \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , + even~odd~rule , #2 ] + (#4) rectangle (#5) + \IfValueT { #6 } { (#6) rectangle (#7) } + #9 ; + } + } + { + \IfValueTF { #3 } + { + \draw [ even~odd~rule , #2 ] + ([shift={(#3)}]#4) rectangle ([shift={(#3)}]#5) + \IfValueT { #6 } { ([shift={(#3)}]#6) rectangle ([shift={(#3)}]#7) } + #9 ; + } + { + \draw [ even~odd~rule , #2 ] + (#4) rectangle (#5) + \IfValueT { #6 } { (#6) rectangle (#7) } + #9 ; + } + } +} + +%%% --- end of \tzrectanglering + +\let\tzframering\tzrectanglering +\let\tzboxring\tzrectanglering + + + +%%%%%%%(ADDED) -- to be removed +%%%%%%%% \tzdiamond +%%%%% +%%%%%\NewDocumentCommand\tzdiamond +%%%%% { 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 = \tzfillopacity , +%%%%% text~opacity = 1 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (#6-|0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift (normal) +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , #2 ] +%%%%% ($ (#5) + (#6|-0,0) $) +%%%%% -- ($ (#5) + (#6-|0,0) $) +%%%%% -- ($ (#5) - (#6|-0,0) $) +%%%%% -- ($ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ #2 ] +%%%%% ([shift={(#3)}]$ (#5) + (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (#6-|0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift (normal) +%%%%% \draw [ #2 ] +%%%%% ($ (#5) + (#6|-0,0) $) +%%%%% -- ($ (#5) + (#6-|0,0) $) +%%%%% -- ($ (#5) - (#6|-0,0) $) +%%%%% -- ($ (#5) - (#6-|0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%%} +%%%%% +%%%%% +%%%%%%%(ADDED) -- to be removed +%%%%%%%% \tztriangle +%%%%% +%%%%%\NewDocumentCommand\tztriangle +%%%%% { 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 = \tzfillopacity , +%%%%% text~opacity = 1 , name~path = #4 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + .5*(#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (0,0|-#6) $) +%%%%% -- ([shift={(#3)}]$ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift +%%%%% \draw [ fill = \tzfillcolor , fill~opacity = \tzfillopacity , +%%%%% text~opacity = 1 , name~path = #4 , #2 ] +%%%%% ($ (#5) + .5*(#6|-0,0) $) +%%%%% -- ($ (#5) + (0,0|-#6) $) +%%%%% -- ($ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%% { +%%%%% \IfValueTF { #3 } +%%%%% {% if shift +%%%%% \draw [ name~path = #4 , #2 ] +%%%%% ([shift={(#3)}]$ (#5) + .5*(#6|-0,0) $) +%%%%% -- ([shift={(#3)}]$ (#5) + (0,0|-#6) $) +%%%%% -- ([shift={(#3)}]$ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% {% no shift +%%%%% \draw [ name~path = #4 , #2 ] +%%%%% ($ (#5) + .5*(#6|-0,0) $) +%%%%% -- ($ (#5) + (0,0|-#6) $) +%%%%% -- ($ (#5) - .5*(#6|-0,0) $) -- cycle; +%%%%% } +%%%%% } +%%%%%} %%% \tzparabola +\bool_new:N \g_tzparabola_BEGIN_cmd_bool +\bool_new:N \g_tzparabola_END_cmd_bool \bool_new:N \l_tzparabola_shift_coor_bool +%% \tzparabolaAtBegin +\NewDocumentCommand\tzparabolaAtBegin{ m } +{ + \bool_gset_true:N \g_tzparabola_BEGIN_cmd_bool + \tl_gset:No \g_tzparabola_BEGIN_cmd_tl { #1 } +} + +%% \tzparabolaAtEnd +\NewDocumentCommand\tzparabolaAtEnd{ m } +{ + \bool_gset_true:N \g_tzparabola_END_cmd_bool + \tl_gset:No \g_tzparabola_END_cmd_tl { #1 } +} + +%% \tzparabola (main) \NewDocumentCommand\tzparabola { s t+ O{} d<> D""{} } { @@ -2183,13 +3482,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } + \tl_put_right:Nn \l_tzparabola_cmd_tl + { node [ #5 ] { #4 } } + % add at begin/end + \bool_if:NT \g_tzparabola_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzparabola_cmd_tl { \g_tzparabola_BEGIN_cmd_tl } } + \bool_if:NT \g_tzparabola_END_cmd_bool + { \tl_put_right:Nx \l_tzparabola_cmd_tl { \g_tzparabola_END_cmd_tl } } + + % final action \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 ; + \draw \l_tzparabola_cmd_tl #7 ; + + \bool_gset_false:N \g_tzparabola_BEGIN_cmd_bool + \bool_gset_false:N \g_tzparabola_END_cmd_bool +% \tl_clear:N \g_tzparabola_BEGIN_cmd_tl +% \tl_clear:N \g_tzparabola_END_cmd_tl } %%% -- end of \tzparabola @@ -2197,8 +3510,25 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzbezier +\bool_new:N \g_tzbezier_BEGIN_cmd_bool +\bool_new:N \g_tzbezier_END_cmd_bool \bool_new:N \l_tzbezier_shift_coor_bool +%% \tzbezierAtBegin +\NewDocumentCommand\tzbezierAtBegin{ m } +{ + \bool_gset_true:N \g_tzbezier_BEGIN_cmd_bool + \tl_gset:No \g_tzbezier_BEGIN_cmd_tl { #1 } +} + +%% \tzbezierAtEnd +\NewDocumentCommand\tzbezierAtEnd{ m } +{ + \bool_gset_true:N \g_tzbezier_END_cmd_bool + \tl_gset:No \g_tzbezier_END_cmd_tl { #1 } +} + +%% \tzbezier (main) \NewDocumentCommand\tzbezier{ s t+ O{} d<> D""{tzplot~path} } { \tl_clear:N \l_tzbezier_cmd_tl @@ -2324,17 +3654,31 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } + \tl_put_right:Nn \l_tzbezier_cmd_tl + { node [ #6 ] { #5 } } + % add at begin/end + \bool_if:NT \g_tzbezier_BEGIN_cmd_bool + { \tl_put_left:Nx \l_tzbezier_cmd_tl { \g_tzbezier_BEGIN_cmd_tl } } + \bool_if:NT \g_tzbezier_END_cmd_bool + { \tl_put_right:Nx \l_tzbezier_cmd_tl { \g_tzbezier_END_cmd_tl } } + + % final action \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 ; + + \exp_last_unbraced:Nf \draw \l_tzbezier_cmd_tl #7 ; + + \bool_gset_false:N \g_tzbezier_BEGIN_cmd_bool + \bool_gset_false:N \g_tzbezier_END_cmd_bool +% \tl_clear:N \g_tzbezier_BEGIN_cmd_tl +% \tl_clear:N \g_tzbezier_END_cmd_tl } %%% -- end of \tzbezier -%%% \tzarc +%%% \tzarc (main) \use:x{ \NewDocumentCommand \exp_not:N \tzarc @@ -2369,14 +3713,14 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { arc ( \tzarcAngleA \c_colon_str - \IfBooleanTF {#2} + \IfBooleanTF { #2 } {\tzarcAngleB - 360} {\tzarcAngleB} \c_colon_str \tzarcRadius ) } { - arc ( \IfBooleanTF {#2} + arc ( \IfBooleanTF { #2 } {\tzarcAngleA - 360} {\tzarcAngleA} \c_colon_str @@ -2412,8 +3756,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzarc - -%%% \tzarcfrom % (works like tikz original) +%%% \tzarcfrom (main) +%% (works like tikz original) \use:x{ \NewDocumentCommand \exp_not:N \tzarcfrom @@ -2492,7 +3836,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzarcfrom -%%% \tzarcsfrom % (works like tikz original) +%%% \tzarcsfrom (main) +%% (works like tikz original) \tl_new:N \l_tzarcsfrom_code_at_end_tl @@ -2531,7 +3876,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzarcsfrom_late_opt_fn } } { - \tzarcsfrom_stop_action +% \tzarcsfrom_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } @@ -2597,8 +3943,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzarcsfrom - -%%% \tzwedge +%%% \tzwedge (main) \use:x{ \NewDocumentCommand \exp_not:N \tzwedge @@ -2692,23 +4037,471 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzwedge -%%%%% plot of Tikz +%%%%% Angles + + +%%% \tzp + +\NewDocumentCommand\tzpointangle{ r() r() m } +{ + \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}% + {\pgfpointanchor{#2}{center}} + \edef#3{\pgfmathresult} +% \tl_set:cx { #3 } { \pgfmathresult } +} + + + +%%% \tzanglemark (main) + +\NewDocumentCommand\tzanglemark{ s t' o } +{ + \tl_clear:N \l_tzanglemark_cmd_tl + + \IfBooleanTF { #1 } + { \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 { #3 } + { \tl_set:Nn \l_tzanglemark_opt_tl { #3 } } + { \tl_clear:N \l_tzanglemark_opt_tl } + + \tzanglemark_check_token:n +} + +\cs_new:Npn \tzanglemark_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzanglemark_sub_fn ( } +} + +\NewDocumentCommand\tzanglemark_sub_fn + { r() r() r() +G{} O{} + D(){\tz@initial@AA@radius} G{\tz@initial@fill@opacity} + } + +{ + \renewcommand\tzfillopacity{#7} + \renewcommand\tzAAradius{#6} + + \path (#1) coordinate (tzAng-A) + (#2) coordinate (tzAng-B) + (#3) coordinate (tzAng-C); + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-A}{center}} + \edef\tzangleONE{\pgfmathresult} + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-C}{center}} + \edef\tzangleTWO{\pgfmathresult} + + \fp_set:Nn \l_tmpa_fp { \tzangleONE } + \fp_set:Nn \l_tmpb_fp { \tzangleTWO } + + \bool_if:NTF \l_tmpb_bool + { + \edef\tzangleresult{\fp_eval:n { 360 - abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + { + \edef\tzangleresult{\fp_eval:n { abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + +% % test +% \node (0,0) [align=left,right] {\tzangleresult \\ \halfangle}; + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:No \l_tzanglemark_cmd_tl + { + [ \tzAAlinestyle , draw = none , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + } + } + { + \tl_put_right:No \l_tzanglemark_cmd_tl + { + [ \tzAAlinestyle , + } + } + + \tl_put_right:No \l_tzanglemark_cmd_tl + { \l_tzanglemark_opt_tl ] } + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { (#2) -- ++ (\tzangleONE \c_colon_str #6) } + } + { + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { (#2) ++ (\tzangleONE \c_colon_str #6) } + } + + \tl_put_right:Nx \l_tzanglemark_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzangleONE + \c_colon_str + \bool_if:NTF \l_tmpb_bool + { \tzangleTWO - 360 } + { \tzangleTWO } + \c_colon_str + \tzAAradius ) node (tzAAmid) [midway] {} + } + { + arc ( \bool_if:NTF \l_tmpb_bool + { \tzangleONE -360 } + { \tzangleONE } + \c_colon_str + \tzangleTWO + \c_colon_str + \tzAAradius ) node (tzAAmid) [midway] {} + } + } + + \begin{pgfonlayer}{\tzanglelayer} + \bool_if:NTF \l_tmpa_bool + { + \exp_last_unbraced:Nf + \draw \l_tzanglemark_cmd_tl -- cycle ; %% -- cycle + } + { + \exp_last_unbraced:Nf + \draw \l_tzanglemark_cmd_tl ; + } + \end{pgfonlayer} + + \path (#2) -- (tzAAmid.center) node [ pos = 1.5, #5 ] { #4 } ; +} + +%%% --- end of \tzanglemark + + +%%% \tzanglefill (obsolete: to be removed) + +\NewDocumentCommand\tzanglefill{ s t' o } +{ + \tl_clear:N \l_tzanglefill_cmd_tl + + \IfBooleanTF { #1 } + { \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 { #3 } + { \tl_set:Nn \l_tzanglefill_opt_tl { #3 } } + { \tl_clear:N \l_tzanglefill_opt_tl } + + \tzanglefill_check_token:n +} + +\cs_new:Npn \tzanglefill_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzanglefill_sub_fn ( } +} + +\NewDocumentCommand\tzanglefill_sub_fn + { r() r() r() +G{} O{} D(){10pt} G{\tz@initial@fill@opacity} } + +{ + \renewcommand\tzfillopacity{#7} + + \path (#1) coordinate (tzAng-A) + (#2) coordinate (tzAng-B) + (#3) coordinate (tzAng-C); + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-A}{center}} + \edef\tzangleONE{\pgfmathresult} + \pgfmathanglebetweenpoints{\pgfpointanchor{tzAng-B}{center}}% + {\pgfpointanchor{tzAng-C}{center}} + \edef\tzangleTWO{\pgfmathresult} + + \fp_set:Nn \l_tmpa_fp { \tzangleONE } + \fp_set:Nn \l_tmpb_fp { \tzangleTWO } + + \bool_if:NTF \l_tmpb_bool + { + \edef\tzangleresult{\fp_eval:n { 360 - abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + { + \edef\tzangleresult{\fp_eval:n { abs(\l_tmpb_fp - \l_tmpa_fp) } } + } + +% % test +% \node (0,0) [align=left,right] {\tzangleresult}; + + \bool_if:NTF \l_tmpa_bool %%% (* NOT USED!) + { + \tl_put_right:No \l_tzanglefill_cmd_tl + { + [ \tzAAlinestyle , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + } + } + { + \tl_put_right:No \l_tzanglefill_cmd_tl + { + [ \tzAAlinestyle , fill = \tzfillcolor , + fill~opacity = \tzfillopacity , text~opacity = 1 , + } + } + + \tl_put_right:No \l_tzanglefill_cmd_tl + { \l_tzanglefill_opt_tl ] } + + \tl_put_right:Nx \l_tzanglefill_cmd_tl + { (#2) -- ++ (\tzangleONE \c_colon_str #6) } + + \tl_put_right:Nx \l_tzanglefill_cmd_tl + { + \fp_compare:nTF { \l_tmpa_fp < \l_tmpb_fp } + { + arc ( \tzangleONE + \c_colon_str + \bool_if:NTF \l_tmpb_bool + { \tzangleTWO - 360 } + { \tzangleTWO } + \c_colon_str + #6 ) node (tzAAmid) [midway] {} + } + { + arc ( \bool_if:NTF \l_tmpb_bool + { \tzangleONE -360 } + { \tzangleONE } + \c_colon_str + \tzangleTWO + \c_colon_str + #6 ) node (tzAAmid) [midway] {} + } + } + + \begin{pgfonlayer}{\tzanglelayer} + \exp_last_unbraced:Nf + \path \l_tzanglefill_cmd_tl -- cycle ; %% -- cycle + \end{pgfonlayer} + \path (#2) -- (tzAAmid.center) node [ pos = 1.5, #5 ] { #4 } ; +} + +%%% --- end of \tzanglefill + + + + +%%%(ADDED) +%%% \tzrightanglemark (main) + +\NewDocumentCommand\tzrightanglemark{ s t' o } +{ + \tl_clear:N \l_tzrightanglemark_cmd_tl + \tl_clear:N \l_tzrightanglemark_fill_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfBooleanTF { #2 } % NOT USED (just to avoid frequent coding error) + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + + \IfValueTF { #3 } + { \tl_set:Nn \l_tzrightanglemark_opt_tl { #3 } } + { \tl_clear:N \l_tzrightanglemark_opt_tl } + + \tzrightanglemark_check_token:n +} + +\cs_new:Npn \tzrightanglemark_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzrightanglemark_sub_fn ( } +} + +\NewDocumentCommand\tzrightanglemark_sub_fn + { r() r() r() +G{} O{} D(){\tz@initial@RA@size} G{\tz@initial@fill@opacity} } + +{ + \renewcommand\tzfillopacity{#7} + \renewcommand\tzRAsize{#6} + + \coordinate (tzRAOne) at ($(#2)!\tzRAsize!(#1)$) ; + \coordinate (tzRAThree) at ($(#2)!\tzRAsize!(#3)$) ; + \coordinate (tzRAvertex) at ($(tzRAThree) + (tzRAOne) - (#2)$) ; + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { + [ \tzAAlinestyle , draw = none , + fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , + } + } + { + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { + [ \tzAAlinestyle , + } + } + + \tl_put_right:No \l_tzrightanglemark_cmd_tl + { \l_tzrightanglemark_opt_tl ] } + + \begin{pgfonlayer}{\tzanglelayer} + \bool_if:NTF \l_tmpa_bool + { + \exp_last_unbraced:Nf + \draw \l_tzrightanglemark_cmd_tl + (#2) -- (tzRAOne) -- (tzRAvertex) -- (tzRAThree) -- cycle ; + } + { + \exp_last_unbraced:Nf + \draw \l_tzrightanglemark_cmd_tl + (tzRAOne) -- (tzRAvertex) -- (tzRAThree) ; + } + \end{pgfonlayer} + \path (#2) -- (tzRAvertex) node [ pos = 2 , #5 ] { #4 } ; +} + +%%% --- end of \tzrightanglemark + + +%%% \tzrightanglefill (obsolete: to be removed) + +\NewDocumentCommand\tzrightanglefill{ s t' o } +{ + \tl_clear:N \l_tzrightanglefill_cmd_tl + + \IfBooleanTF { #1 } + { \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 { #3 } + { \tl_set:Nn \l_tzrightanglefill_opt_tl { #3 } } + { \tl_clear:N \l_tzrightanglefill_opt_tl } + + \tzrightanglefill_check_token:n +} + +\cs_new:Npn \tzrightanglefill_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzrightanglefill_sub_fn ( } +} + +\NewDocumentCommand\tzrightanglefill_sub_fn + { r() r() r() +G{} O{} D(){5pt} G{\tz@initial@fill@opacity} } + +{ + \renewcommand\tzfillopacity{#7} + + \coordinate (tzRAOne) at ($(#2)!#6!(#1)$) ; + \coordinate (tzRAThree) at ($(#2)!#6!(#3)$) ; + \coordinate (tzRAvertex) at ($(tzRAThree) + (tzRAOne) - (#2)$) ; + + \tl_put_right:Nn \l_tzrightanglefill_cmd_tl + { + [ very~thin , + } + + \tl_put_right:Nn \l_tzrightanglefill_cmd_tl + { + fill = \tzfillcolor , fill~opacity = \tzfillopacity , text~opacity = 1 , + } + + \tl_put_right:No \l_tzrightanglefill_cmd_tl + { \l_tzrightanglefill_opt_tl ] } + + \begin{pgfonlayer}{\tzanglelayer} + \exp_last_unbraced:Nf + \fill \l_tzrightanglefill_cmd_tl + (#2) -- (tzRAOne) -- (tzRAvertex) -- (tzRAThree) -- cycle ; + \end{pgfonlayer} + \path (#2) -- (tzRAvertex) node [ pos = 2 , #5 ] { #4 } ; +} + +%%% --- end of \tzrightanglefill + + + +%%%(ADDED) +%%% \tzpicangle (to be removed) +\NewDocumentCommand\tzpicangle + { t' O{} O{} r() r() r() G{} O{1.5} D(){10pt} } +{ + \IfBooleanTF #1 + { + \begin{pgfonlayer}{background} + \path [ #3 ] (#4) coordinate (tzangleA) -- + (#5) coordinate (tzangleB) -- + (#6) coordinate (tzangleC) + pic [ draw , "#7" , angle~radius=#9 , angle~eccentricity = #8 , #2 ] + { angle = tzangleC -- tzangleB -- tzangleA } ; + % C to A (counter clockwise) + \end{pgfonlayer} + } + { + \begin{pgfonlayer}{background} + \path [ #3 ] (#4) coordinate (tzangleA) -- + (#5) coordinate (tzangleB) -- + (#6) coordinate (tzangleC) + pic [ draw , "#7" , angle~radius=#9 , angle~eccentricity = #8 , #2 ] + { angle = tzangleA -- tzangleB -- tzangleC } ; + % A to C (clockwise) + \end{pgfonlayer} + } +} + +%%% --- end of \tzpicangle + + + +%%%%% plot coordinates (of TikZ) + %%% \tzplot \bool_new:N \l_tzplot_shift_coor_bool +\bool_new:N \g_tzplot_BEGIN_cmd_bool +\bool_new:N \g_tzplot_END_cmd_bool + +%% \tzplotAtBegin +\NewDocumentCommand\tzplotAtBegin{ m } +{ + \bool_gset_true:N \g_tzplot_BEGIN_cmd_bool + \tl_gset:No \g_tzplot_BEGIN_cmd_tl { #1 } +} + +%% \tzplotAtEnd +\NewDocumentCommand\tzplotAtEnd{ m } +{ + \bool_gset_true:N \g_tzplot_END_cmd_bool + \tl_gset:No \g_tzplot_END_cmd_tl { #1 } +} +%%% \tzplot (main) \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 + \tl_clear:N \l_tzplot_opt_tl % [opt] + \tl_clear:N \l_tzplot_TEMP_opt_tl % for path only: [opt,mark=none] + \tl_clear:N \l_tzplot_plot_coordinates_tl % plot coordinates + \tl_clear:N \l_tzplot_coors_tl % {(coor-1)(coor-2)...(coor-n)} + \tl_clear:N \l_tzplot_code_at_end_tl % <code.append> + \tl_clear:N \l_tzplot_nodes_tl \renewcommand\tzmarksize{\tz@initial@mark@size} - \tl_put_right:Nn \l_tzplot_opt_cmd_tl + \tl_put_right:Nn \l_tzplot_opt_tl { [ name~path = #6 , @@ -2717,12 +4510,23 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) tzmark = \tzmarksize , } - \IfBooleanT { #1 } + %% closing options + % if AtBegin_true, USE mark=none (for path only) + \bool_if:NT \g_tzplot_BEGIN_cmd_bool + { + \tl_set_eq:NN \l_tzplot_TEMP_opt_tl \l_tzplot_opt_tl + \tl_put_right:Nn \l_tzplot_TEMP_opt_tl { mark = none ] } + } + % (normal) + \IfBooleanTF { #1 } { - \tl_put_right:Nn \l_tzplot_opt_cmd_tl - { mark = * , draw = none , } + \tl_put_right:Nn \l_tzplot_opt_tl + { mark = * , draw = none , #2 ] } + } + { + \tl_put_right:Nn \l_tzplot_opt_tl + { #2 ] } } - \IfValueTF { #5 } { \tl_set:Nn \l_tzplot_shift_coor_tl { #5 } @@ -2733,12 +4537,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_set_false:N \l_tzplot_shift_coor_bool } - \tl_put_right:Nn \l_tzplot_opt_cmd_tl - { - #2 - ] - plot [ #4 ] coordinates - } + \tl_put_right:Nn \l_tzplot_plot_coordinates_tl + { plot [ #4 ] coordinates } \tzplot_check_token:n } @@ -2753,34 +4553,63 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzplot_late_opt_fn } } { - \tzplot_stop_action +% \tzplot_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzplot_sub_fn{ r() +G{} O{} } +\NewDocumentCommand\tzplot_sub_fn{ r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% % 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:Nx \l_tzplot_coors_tl + { ( [ shift = { (\l_tzplot_shift_coor_tl) } ] \exp_not:n { #1 } ) } } { - \tl_put_right:Nn \l_tzplot_coors_cmd_tl { (#1) } + \tl_put_right:Nn \l_tzplot_coors_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:Nx \l_tzplot_nodes_tl + { ( [ shift = { (\l_tzplot_shift_coor_tl) } ] \exp_not:n { #1 } ) } } { - \tl_put_right:Nn \l_tzplot_nodes_cmd_tl { (#1) } + \tl_put_right:Nn \l_tzplot_nodes_tl { (#1) } } - \tl_put_right:Nx \l_tzplot_nodes_cmd_tl + \tl_put_right:Nx \l_tzplot_nodes_tl { node - [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str ] {} } \tzplot_check_token:n @@ -2798,14 +4627,80 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \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 - ; + %% final action cases: + \bool_if:NTF \g_tzplot_BEGIN_cmd_bool + { %% if AtBegin_true + % define (tzCPSS) by path (WITH \l_tzplot_TEMP_opt_tl ) + \exp_last_unbraced:Nf + \path + \l_tzplot_TEMP_opt_tl + \l_tzplot_plot_coordinates_tl + { \l_tzplot_coors_tl } + ; + \path (current~subpath~start) coordinate (tzCSPS) ; + % all together (important) + \tl_put_right:No \l_tmpa_tl { \g_tzplot_BEGIN_cmd_tl } + \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } + \tl_put_right:No \l_tmpa_tl { \l_tzplot_plot_coordinates_tl } % important + \bool_if:NTF \g_tzplot_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplot_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplot_coors_tl } + \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; + } + { %% if AtEnd_false + % plot AtBegin and (coors) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplot_coors_tl } +% \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; + + } + } + { %% if AtBegin_false + \bool_if:NTF \g_tzplot_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplot_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl + \l_tzplot_plot_coordinates_tl + { \l_tzplot_coors_tl } + \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl + \l_tzplot_nodes_tl + ; + } + { %% if AtEnd_false + % normal + \exp_last_unbraced:Nf + \draw + \l_tzplot_opt_tl % [opt] + \l_tzplot_plot_coordinates_tl % plot coordinates + { \l_tzplot_coors_tl } % { (coor-1)(coor-2)...(coor-n) } +% \g_tzplot_END_cmd_tl % AtEnd + \l_tzplot_code_at_end_tl % <code.append> + \l_tzplot_nodes_tl % (coor-i) node [opt] {text}, all i + ; + } + } + + \bool_gset_false:N \g_tzplot_BEGIN_cmd_bool + \bool_gset_false:N \g_tzplot_END_cmd_bool } %%% --- end of \tzplot @@ -2814,18 +4709,37 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzplotcurve \bool_new:N \l_tzplotcurve_shift_coor_bool +\bool_new:N \g_tzplotcurve_BEGIN_cmd_bool +\bool_new:N \g_tzplotcurve_END_cmd_bool + +%% \tzplotcurveAtBegin +\NewDocumentCommand\tzplotcurveAtBegin{ m } +{ + \bool_gset_true:N \g_tzplotcurve_BEGIN_cmd_bool + \tl_gset:No \g_tzplotcurve_BEGIN_cmd_tl { #1 } +} + +%% \tzplotcurveAtEnd +\NewDocumentCommand\tzplotcurveAtEnd{ m } +{ + \bool_gset_true:N \g_tzplotcurve_END_cmd_bool + \tl_gset:No \g_tzplotcurve_END_cmd_tl { #1 } +} + +%%% \tzplotcurve (main) \NewDocumentCommand\tzplotcurve{ s O{} G{1} O{} d<> D""{} } { - \IfBooleanT { #1 } {}{} % NOT USED! + \tl_clear:N \l_tzplotcurve_opt_tl % [opt] + \tl_clear:N \l_tzplotcurve_TEMP_opt_tl % for path only: [opt,mark=none] + \tl_clear:N \l_tzplotcurve_plot_coordinates_tl % plot coordinates + \tl_clear:N \l_tzplotcurve_coors_tl % {(coor-1)(coor-2)...(coor-n)} + \tl_clear:N \l_tzplotcurve_code_at_end_tl % <code.append> + \tl_clear:N \l_tzplotcurve_nodes_tl - \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 + \renewcommand\tzmarksize{\tz@initial@mark@size} - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl + \tl_put_right:Nn \l_tzplotcurve_opt_tl { [ name~path = #6 , tension = #3 , @@ -2833,10 +4747,20 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) tzmark = \tzmarksize , } - \IfBooleanT { #1 } + %% closing options + % if AtBegin_true, USE mark=none (for path only) + \bool_if:NT \g_tzplotcurve_BEGIN_cmd_bool + { + \tl_set_eq:NN \l_tzplotcurve_TEMP_opt_tl \l_tzplotcurve_opt_tl + \tl_put_right:Nn \l_tzplotcurve_TEMP_opt_tl { mark = none ] } + } + % (normal) + \IfBooleanTF { #1 } { - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl - { mark = * , } + \tl_put_right:Nn \l_tzplotcurve_opt_tl { mark = * , #2 ] } + } + { + \tl_put_right:Nn \l_tzplotcurve_opt_tl { #2 ] } } \IfValueTF { #5 } @@ -2849,12 +4773,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \bool_set_false:N \l_tzplotcurve_shift_coor_bool } - \tl_put_right:Nn \l_tzplotcurve_opt_cmd_tl - { - #2 - ] - plot [ #4 ] coordinates - } + \tl_put_right:Nn \l_tzplotcurve_plot_coordinates_tl + { plot [ #4 ] coordinates } \tzplotcurve_check_token:n } @@ -2869,33 +4789,62 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { ; } { \tzplotcurve_late_opt_fn } } { - \tzplotcurve_stop_action +% \tzplotcurve_stop_action + \msg_error:nn { tzplot } { semicolon-error } } } -\NewDocumentCommand\tzplotcurve_sub_fn{ r() +G{} O{} } +\NewDocumentCommand\tzplotcurve_sub_fn{ r() +G{} >{\TrimSpaces}o } { +%%%%%% to use string replacement for label positions + \IfValueTF { #3 } + { + \tl_if_in:nnTF { #3 } { [ } + { \extract_posopt:w #3 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #3 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #3 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% % 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:Nx \l_tzplotcurve_coors_tl + { ( [ shift = { (\l_tzplotcurve_shift_coor_tl) } ] \exp_not:n { #1 } ) } } { - \tl_put_right:Nn \l_tzplotcurve_coors_cmd_tl { (#1) } + \tl_put_right:Nn \l_tzplotcurve_coors_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:Nx \l_tzplotcurve_nodes_tl + { ( [ shift = { (\l_tzplotcurve_shift_coor_tl) } ] \exp_not:n { #1 } ) } } { - \tl_put_right:Nn \l_tzplotcurve_nodes_cmd_tl { (#1) } + \tl_put_right:Nn \l_tzplotcurve_nodes_tl { (#1) } } - \tl_put_right:Nx \l_tzplotcurve_nodes_cmd_tl + \tl_put_right:Nx \l_tzplotcurve_nodes_tl { node - [ label = { \exp_not:n { #3 } \c_colon_str \exp_not:n { #2 } } + [ label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #2 } } % pos_str ] {} } \tzplotcurve_check_token:n @@ -2913,19 +4862,155 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \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 - ; + %% final action cases: + \bool_if:NTF \g_tzplotcurve_BEGIN_cmd_bool + { %% if AtBegin_true + % define (tzCPSS) by path (WITH \l_tzplotcurve_TEMP_opt_tl ) + \exp_last_unbraced:Nf + \path + \l_tzplotcurve_TEMP_opt_tl + \l_tzplotcurve_plot_coordinates_tl + { \l_tzplotcurve_coors_tl } + ; + \path (current~subpath~start) coordinate (tzCSPS) ; + % all together (important) + \tl_put_right:No \l_tmpa_tl { \g_tzplotcurve_BEGIN_cmd_tl } + \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } + \tl_put_right:No \l_tmpa_tl { \l_tzplotcurve_plot_coordinates_tl } % important + \bool_if:NTF \g_tzplotcurve_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplotcurve_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplotcurve_coors_tl } + \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + } + { %% if AtEnd_false + % plot AtBegin and (coors) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tmpa_tl % AtBegin + plot coordinates + { \l_tzplotcurve_coors_tl } +% \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + + } + } + { %% if AtBegin_false + \bool_if:NTF \g_tzplotcurve_END_cmd_bool + { %% if AtEnd_true + % append AtBegin, AtEnd + % plot AtBegin, (coors), and AtEnd (WITH \l_tzplotcurve_opt_tl) + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl + \l_tzplotcurve_plot_coordinates_tl + { \l_tzplotcurve_coors_tl } + \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl + \l_tzplotcurve_nodes_tl + ; + } + { %% if AtEnd_false + % normal + \exp_last_unbraced:Nf + \draw + \l_tzplotcurve_opt_tl % [opt] + \l_tzplotcurve_plot_coordinates_tl % plot coordinates + { \l_tzplotcurve_coors_tl } % { (coor-1)(coor-2)...(coor-n) } +% \g_tzplotcurve_END_cmd_tl % AtEnd + \l_tzplotcurve_code_at_end_tl % <code.append> + \l_tzplotcurve_nodes_tl % (coor-i) node [opt] {text}, all i + ; + } + } + + \bool_gset_false:N \g_tzplotcurve_BEGIN_cmd_bool + \bool_gset_false:N \g_tzplotcurve_END_cmd_bool } %%% --- end of \tzplotcurve +%%(ADDED) +%%% \tzplotfile +\NewDocumentCommand\tzplotfile{ O{} m O{} } +{ + \draw [ #1 ] plot [ smooth , #3 ] file { #2 } ; +} + +%%% --- end of \tzplotfile + + +%%%%% Plot functions + +%%% \tzdeffn +\NewDocumentCommand\tzdeffn{ m m } +{ + \tl_set:cn { #1 } { #2 } +} +%% USAGE: \tzdeffn{Fx}{2*\x+1} + +%%% \tzdeffnofy +\NewDocumentCommand\tzdeffnofy{ m m } +{ + \tl_set:cn { #1 } { #2 } +} +%% just a reminder of using \y instead of \x +%% USAGE: \tzdeffn'{Gy}{2*\y+1} + + +%%% \tzdefLFn +\NewDocumentCommand\tzdefLFn{ m r() d() G{1} } +{ + \IfNoValueTF { #3 } + { + \tzgetxyval(#2){\tzdefLFnXvalS}{\tzdefLFnYvalS} + \def#1{#4*(\x-\tzdefLFnXvalS)+\tzdefLFnYvalS} + } + { + \tzgetxyval(#2){\tzdefLFnXval}{\tzdefLFnYval} + \tzgetxyval(#3){\tzdefLFnXXval}{\tzdefLFnYYval} + \fp_compare:nT { \tzdefLFnXXval - \tzdefLFnXval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzdefLFnSlope{% + (\tzdefLFnYYval-\tzdefLFnYval)/(\tzdefLFnXXval-\tzdefLFnXval) + } + \def#1{\tzdefLFnSlope*(\x-\tzdefLFnXval)+\tzdefLFnYval} + } +} + +%%% \tzdefLFnofy +\NewDocumentCommand\tzdefLFnofy{ m r() d() G{1} } +{ % linear function of \y + \IfNoValueTF { #3 } + { + \tzgetxyval(#2){\tzdefLFnofyXvalS}{\tzdefLFnofyYvalS} + \def#1{#4*(\y-\tzdefLFnofyYvalS)+\tzdefLFnofyXvalS} + } + { + \tzgetxyval(#2){\tzdefLFnofyXval}{\tzdefLFnofyYval} + \tzgetxyval(#3){\tzdefLFnofyXXval}{\tzdefLFnofyYYval} + \fp_compare:nT { \tzdefLFnofyYYval - \tzdefLFnofyYval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzdefLFnofySlope{% + (\tzdefLFnofyXXval-\tzdefLFnofyXval)/(\tzdefLFnofyYYval-\tzdefLFnofyYval) + } + \def#1{\tzdefLFnofySlope*(\y-\tzdefLFnofyYval)+\tzdefLFnofyXval} + } +} + + + %%% \tzLFn -- plot Linear Function (LF) \bool_new:N \g_tzLFn_BEGIN_cmd_bool @@ -2945,12 +5030,14 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_gset:No \g_tzLFn_END_cmd_tl { #1 } } -%%% \tzLFn +%%% \tzLFn (main) %% \tzLFn : variable = \x (default) -%% \tzLFn': variable = \y \NewDocumentCommand \tzLFn { t' o D<>{0,0} d"" } { + \tl_clear:N \l_tzLFn_opt_tl + \tl_clear:N \l_tzLFn_path_tl + \tl_clear:N \l_tzLFn_TEMP_cmd_tl \tl_clear:N \l_tzLFn_cmd_tl \IfBooleanTF { #1 } @@ -2965,8 +5052,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tl_clear:N \l_tzLFn_shift_tl } \IfValueTF { #2 } - { \tl_set:Nn \l_tzLFn_opt_tl { #2 } } - { \tl_clear:N \l_tzLFn_opt_tl } + { \tl_set:Nn \l_tzLFn_user_opt_tl { #2 } } + { \tl_clear:N \l_tzLFn_user_opt_tl } \IfValueTF { #4 } { \tl_set:Nn \l_tzLFn_namepath_tl { name~path = #4 } } @@ -2990,57 +5077,65 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) { \tzLFn_domain_process #4 - \tl_put_right:Nx \l_tzLFn_cmd_tl + \tl_put_right:Nx \l_tzLFn_opt_tl { [ +% samples = 201 , \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 } } , +% variable = \exp_not:n { \x } , \l_tzLFn_shift_tl , } - \tl_put_right:No \l_tzLFn_cmd_tl + \tl_put_right:No \l_tzLFn_opt_tl { - \l_tzLFn_opt_tl + \l_tzLFn_user_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} + % define LF: (X,Y)(XX,YY){slope num: dY/dX} \IfNoValueTF { #2 } { - \bool_if:NTF \l_tmpa_bool - { \def\tzLFnDEF{#3*(\y-\tzLFBval)+\tzLFAval} } - { \def\tzLFnDEF{#3*(\x-\tzLFAval)+\tzLFBval} } + \tzgetxyval(#1){\tzLFnXvalS}{\tzLFnYvalS} + \def\tzLFnDEF{#3*(\x-\tzLFnXvalS)+\tzLFnYvalS} } { - \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} - } + \tzgetxyval(#1){\tzLFnXval}{\tzLFnYval} + \tzgetxyval(#2){\tzLFnXXval}{\tzLFnYYval} + \fp_compare:nT { \tzLFnXXval - \tzLFnXval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzLFSlope{(\tzLFnYYval-\tzLFnYval)/(\tzLFnXXval-\tzLFnXval)} + \def\tzLFnDEF{\tzLFSlope*(\x-\tzLFnXval)+\tzLFnYval} } \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_path_tl + { plot ( { \tzLFnDEF } , \x ) } % \x should not be expanded } { - \tl_put_right:Nn \l_tzLFn_cmd_tl + \tl_put_right:Nn \l_tzLFn_path_tl { plot ( \x , { \tzLFnDEF } ) } % \x should not be expanded } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzLFn_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzLFn_TEMP_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_TEMP_cmd_tl { \l_tzLFn_path_tl } + \exp_last_unbraced:Nf \path \l_tzLFn_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzLFn_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_path_tl } + } + { + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_opt_tl } + \tl_put_right:No \l_tzLFn_cmd_tl { \l_tzLFn_path_tl } + } \bool_if:NT \g_tzLFn_END_cmd_bool - { \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_END_cmd_tl } } + { + \tl_put_right:No \l_tzLFn_cmd_tl { \g_tzLFn_END_cmd_tl } % append + } \tl_put_right:Nn \l_tzLFn_cmd_tl { node [ #6 ] { #5 } } % final action @@ -3059,7 +5154,155 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzLFn -%% \tzfn (variable=\x -- default) + +%%% \tzLFnofy +%% variable = \y + +\bool_new:N \g_tzLFnofy_BEGIN_cmd_bool +\bool_new:N \g_tzLFnofy_END_cmd_bool + +%% \tzLFnofyAtBegin +\NewDocumentCommand\tzLFnofyAtBegin{ m } +{ + \bool_gset_true:N \g_tzLFnofy_BEGIN_cmd_bool + \tl_gset:No \g_tzLFnofy_BEGIN_cmd_tl { #1 } +} + +%% \tzLFnofyAtEnd +\NewDocumentCommand\tzLFnofyAtEnd{ m } +{ + \bool_gset_true:N \g_tzLFnofy_END_cmd_bool + \tl_gset:No \g_tzLFnofy_END_cmd_tl { #1 } +} + +%%% \tzLFnofy (main) +%% \tzLFnofy : variable = \y +\NewDocumentCommand \tzLFnofy { t' o D<>{0,0} d"" } +{ + \tl_clear:N \l_tzLFnofy_opt_tl + \tl_clear:N \l_tzLFnofy_path_tl + \tl_clear:N \l_tzLFnofy_TEMP_cmd_tl + \tl_clear:N \l_tzLFnofy_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tzLFnofy_shift_tl + { shift = { (#3) } } + } + { \tl_clear:N \l_tzLFnofy_shift_tl } + + \IfValueTF { #2 } + { \tl_set:Nn \l_tzLFnofy_user_opt_tl { #2 } } + { \tl_clear:N \l_tzLFnofy_user_opt_tl } + + \IfValueTF { #4 } + { \tl_set:Nn \l_tzLFnofy_namepath_tl { name~path = #4 } } + { \tl_clear:N \l_tzLFnofy_namepath_tl } + + \tzLFnofy_check_token:n +} + +\cs_new:Npn \tzLFnofy_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzLFnofy_sub_fn ( } +} + +\use:x{ + \NewDocumentCommand \exp_not:N \tzLFnofy_sub_fn + { r() d() G{1} + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] + G{} O{} D<>{} + } +} +{ + \tzLFnofy_domain_process #4 + + \tl_put_right:Nx \l_tzLFnofy_opt_tl + { + [ +% samples = 201 , + \l_tzLFnofy_namepath_tl , + domain = \tzLFnofyFromVal \c_colon_str \tzLFnofyToVal , %%% [here?] + variable = \exp_not:n { \y } , + \l_tzLFnofy_shift_tl , + } + \tl_put_right:No \l_tzLFnofy_opt_tl + { + \l_tzLFnofy_user_opt_tl + ] + } + + % define LFofy: (X,Y)(XX,YY){slope num: dX/dY} + \IfNoValueTF { #2 } + { + \tzgetxyval(#1){\tzLFnofyXvalS}{\tzLFnofyYvalS} + \def\tzLFnofyDEF{#3*(\y-\tzLFnofyYvalS)+\tzLFnofyXvalS} + } + { + \tzgetxyval(#1){\tzLFnofyXval}{\tzLFnofyYval} + \tzgetxyval(#2){\tzLFnofyXXval}{\tzLFnofyYYval} + \fp_compare:nT { \tzLFnofyYYval - \tzLFnofyYval = 0 } + { \msg_error:nn { tzplot } { infinite~slope~error } } + \edef\tzLFofySlope + { + (\tzLFnofyXXval-\tzLFnofyXval)/(\tzLFnofyYYval-\tzLFnofyYval) + } + \def\tzLFnofyDEF{\tzLFofySlope*(\y-\tzLFnofyYval)+\tzLFnofyXval} + } + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:Nn \l_tzLFnofy_path_tl + { plot ( \y , { \tzLFnofyDEF } ) } % \y should not be expanded + } + { + \tl_put_right:Nn \l_tzLFnofy_path_tl + { plot ( { \tzLFnofyDEF } , \y ) } % \y should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzLFnofy_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzLFnofy_TEMP_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_TEMP_cmd_tl { \l_tzLFnofy_path_tl } + \exp_last_unbraced:Nf \path \l_tzLFnofy_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_cmd_tl { \g_tzLFnofy_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzLFnofy_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_path_tl } + } + { + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_opt_tl } + \tl_put_right:No \l_tzLFnofy_cmd_tl { \l_tzLFnofy_path_tl } + } + \bool_if:NT \g_tzLFnofy_END_cmd_bool + { + \tl_put_right:No \l_tzLFnofy_cmd_tl { \g_tzLFnofy_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzLFnofy_cmd_tl + { node [ #6 ] { #5 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzLFnofy_cmd_tl #7 ; + + \bool_gset_false:N \g_tzLFnofy_BEGIN_cmd_bool + \bool_gset_false:N \g_tzLFnofy_END_cmd_bool +} + +\NewDocumentCommand\tzLFnofy_domain_process{ m m } +{ + \def\tzLFnofyFromVal{#1} + \def\tzLFnofyToVal{#2} +} + +%%% --- end of \tzLFnofy + + +%%% \tzfn +%%(variable=\x -- default) \bool_new:N \g_tzfn_BEGIN_cmd_bool \bool_new:N \g_tzfn_END_cmd_bool @@ -3078,8 +5321,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_gset:No \g_tzfn_END_cmd_tl { #1 } } -%% \tzfn (variable=\x) -%% \tzfn' (variable=\y) -- equivalent to \tzfnofy +%%% \tzfn (main) +%%(variable =\x) \use:x{ \NewDocumentCommand \exp_not:N \tzfn { t' O{} D<>{0,0} D""{} m @@ -3087,6 +5330,9 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } { + \tl_clear:N \l_tzfn_opt_tl + \tl_clear:N \l_tzfn_path_tl + \tl_clear:N \l_tzfn_TEMP_cmd_tl \tl_clear:N \l_tzfn_cmd_tl \IfBooleanTF { #1 } @@ -3095,35 +5341,50 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \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 + \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } + \tl_set:No \l_tzfn_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfn_opt_tl { [ + samples = 201 , 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 } } , +% 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:No \l_tzfn_path_tl + { plot ( { #5 } , \exp_not:n { \x } ) } % \x should not be expanded } { - \tl_put_right:Nn \l_tzfn_cmd_tl - { plot ( \x , { #5 } ) } % \x should not be expanded + \tl_put_right:No \l_tzfn_path_tl + { plot ( \exp_not:n { \x } , { #5 } ) } % \x should not be expanded } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfn_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfn_TEMP_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_TEMP_cmd_tl { \l_tzfn_path_tl } + \exp_last_unbraced:Nf \path \l_tzfn_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfn_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_path_tl } + } + { + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_opt_tl } + \tl_put_right:No \l_tzfn_cmd_tl { \l_tzfn_path_tl } + } \bool_if:NT \g_tzfn_END_cmd_bool - { \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_END_cmd_tl } } + { + \tl_put_right:No \l_tzfn_cmd_tl { \g_tzfn_END_cmd_tl } % append + } \tl_put_right:Nn \l_tzfn_cmd_tl { node [ #8 ] { #7 } } % final action @@ -3142,7 +5403,457 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzfn -%% \tzvfnat +%%% \tzfnofy +%% (variable = \y) + +\bool_new:N \g_tzfnofy_BEGIN_cmd_bool +\bool_new:N \g_tzfnofy_END_cmd_bool + +%% \tzfnofyAtBegin +\NewDocumentCommand\tzfnofyAtBegin{ m } +{ + \bool_gset_true:N \g_tzfnofy_BEGIN_cmd_bool + \tl_gset:No \g_tzfnofy_BEGIN_cmd_tl { #1 } +} + +%% \tzfnofyAtEnd +\NewDocumentCommand\tzfnofyAtEnd{ m } +{ + \bool_gset_true:N \g_tzfnofy_END_cmd_bool + \tl_gset:No \g_tzfnofy_END_cmd_tl { #1 } +} + +%%% \tzfnofy (main) +%% (variable=\y) +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnofy + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzfnofy_opt_tl + \tl_clear:N \l_tzfnofy_path_tl + \tl_clear:N \l_tzfnofy_TEMP_cmd_tl + \tl_clear:N \l_tzfnofy_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzfnofy_domain_process #6 + + \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } + \tl_set:No \l_tzfnofy_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfnofy_opt_tl + { + [ + samples = 201 , + name~path = + \tl_if_empty:nTF { #4 } { \l_tzfnofy_pathname_tl } { #4 } , + domain = \tzfnofyFromVal \c_colon_str \tzfnofyToVal , + shift = { (#3) } , + variable = \exp_not:n { \y } , + \exp_not:n { #2 } + ] + } + + \bool_if:NTF \l_tmpa_bool + { + \tl_put_right:Nn \l_tzfnofy_path_tl + { plot ( \y , { #5 } ) } % \y should not be expanded + } + { + \tl_put_right:Nn \l_tzfnofy_path_tl + { plot ( { #5 } , \y ) } % \y should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnofy_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfnofy_TEMP_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_TEMP_cmd_tl { \l_tzfnofy_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnofy_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_cmd_tl { \g_tzfnofy_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnofy_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_path_tl } + } + { + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_opt_tl } + \tl_put_right:No \l_tzfnofy_cmd_tl { \l_tzfnofy_path_tl } + } + \bool_if:NT \g_tzfnofy_END_cmd_bool + { + \tl_put_right:No \l_tzfnofy_cmd_tl { \g_tzfnofy_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnofy_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfnofy_cmd_tl #9 ; + + \bool_gset_false:N \g_tzfnofy_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnofy_END_cmd_bool +} + +\NewDocumentCommand\tzfnofy_domain_process{ m m } +{ + \def\tzfnofyFromVal{#1} + \def\tzfnofyToVal{#2} +} + +%%% --- end of \tzfnofy + + +%%% \tzfnmax +%% (variable=\x -- default) + +\bool_new:N \g_tzfnmax_BEGIN_cmd_bool +\bool_new:N \g_tzfnmax_END_cmd_bool + +%% \tzfnmaxAtBegin +\NewDocumentCommand\tzfnmaxAtBegin{ m } +{ + \bool_gset_true:N \g_tzfnmax_BEGIN_cmd_bool + \tl_gset:No \g_tzfnmax_BEGIN_cmd_tl { #1 } +} + +%% \tzfnmaxAtEnd +\NewDocumentCommand\tzfnmaxAtEnd{ m } +{ + \bool_gset_true:N \g_tzfnmax_END_cmd_bool + \tl_gset:No \g_tzfnmax_END_cmd_tl { #1 } +} + + +%%% \tzfnmax (main) +%% (variable=\x) +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnmax + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzfnmax_opt_tl + \tl_clear:N \l_tzfnmax_path_tl + \tl_clear:N \l_tzfnmax_TEMP_cmd_tl + \tl_clear:N \l_tzfnmax_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzfnmax_domain_process #6 + + \tl_put_right:Nx \l_tzfnmax_opt_tl + { + [ + thick , samples = 201 , + name~path = #4 , + domain = \tzfnmaxFromVal \c_colon_str \tzfnmaxToVal , + shift = { (#3) } , +% varialbe = \exp_not:n { \x } , + \exp_not:n { #2 } + ] + } + + \bool_if:NTF { \l_tmpa_bool } + { + \tl_put_right:Nn \l_tzfnmax_path_tl + { plot ( { max(#5) } , \x ) } % \x should not be expanded + } + { + \tl_put_right:Nn \l_tzfnmax_path_tl + { plot ( \x , { max(#5) } ) } % \x should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnmax_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfnmax_TEMP_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_TEMP_cmd_tl { \l_tzfnmax_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnmax_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_cmd_tl { \g_tzfnmax_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnmax_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_path_tl } + } + { + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_opt_tl } + \tl_put_right:No \l_tzfnmax_cmd_tl { \l_tzfnmax_path_tl } + } + \bool_if:NT \g_tzfnmax_END_cmd_bool + { + \tl_put_right:No \l_tzfnmax_cmd_tl { \g_tzfnmax_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnmax_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfnmax_cmd_tl #9 ; + + \bool_gset_false:N \g_tzfnmax_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnmax_END_cmd_bool +} + +\NewDocumentCommand\tzfnmax_domain_process{ m m } +{ + \def\tzfnmaxFromVal{#1} + \def\tzfnmaxToVal{#2} +} + +%%% --- end of \tzfnmax + + + +%%% \tzfnmin +%% (variable=\x -- default) + +\bool_new:N \g_tzfnmin_BEGIN_cmd_bool +\bool_new:N \g_tzfnmin_END_cmd_bool + +%% \tzfnminAtBegin +\NewDocumentCommand\tzfnminAtBegin{ m } +{ + \bool_gset_true:N \g_tzfnmin_BEGIN_cmd_bool + \tl_gset:No \g_tzfnmin_BEGIN_cmd_tl { #1 } +} + +%% \tzfnminAtEnd +\NewDocumentCommand\tzfnminAtEnd{ m } +{ + \bool_gset_true:N \g_tzfnmin_END_cmd_bool + \tl_gset:No \g_tzfnmin_END_cmd_tl { #1 } +} + + + +%%% \tzfnmin (main) +%% (variable=\x) +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnmin + { t' O{} D<>{0,0} D""{} m + >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] +G{} O{} D<>{} + } +} +{ + \tl_clear:N \l_tzfnmin_opt_tl + \tl_clear:N \l_tzfnmin_path_tl + \tl_clear:N \l_tzfnmin_TEMP_cmd_tl + \tl_clear:N \l_tzfnmin_cmd_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzfnmin_domain_process #6 + +% \tl_set:No \l_label_pos_tl { \tl_to_str:n { #5 } } +% \tl_set:No \l_tzfnmin_pathname_tl { \tl_tail:N \l_label_pos_tl } + \tl_put_right:Nx \l_tzfnmin_opt_tl + { + [ + thick , samples = 201 , + name~path = #4 , +% \tl_if_empty:nTF { #4 } { } { #4 } , + domain = \tzfnminFromVal \c_colon_str \tzfnminToVal , + shift = { (#3) } , +% variable = \exp_not:n { \x } , + \exp_not:n { #2 } + ] + } + + \bool_if:NTF { \l_tmpa_bool } + { + \tl_put_right:Nn \l_tzfnmin_path_tl + { plot ( { min(#5) } , \x ) } % \x should not be expanded + } + { + \tl_put_right:Nn \l_tzfnmin_path_tl + { plot ( \x , { min(#5) } ) } % \x should not be expanded + } + % to resolve AtBegin issue with "plot" operation + \bool_if:NTF \g_tzfnmin_BEGIN_cmd_bool + { + \tl_put_right:No \l_tzfnmin_TEMP_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_TEMP_cmd_tl { \l_tzfnmin_path_tl } + \exp_last_unbraced:Nf \path \l_tzfnmin_TEMP_cmd_tl ; + \path (current~subpath~start) coordinate (tzCSPS) ; + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_cmd_tl { \g_tzfnmin_BEGIN_cmd_tl } % insert + \tl_put_right:Nn \l_tzfnmin_cmd_tl { (tzCSPS) -- } % + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_path_tl } + } + { + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_opt_tl } + \tl_put_right:No \l_tzfnmin_cmd_tl { \l_tzfnmin_path_tl } + } + \bool_if:NT \g_tzfnmin_END_cmd_bool + { + \tl_put_right:No \l_tzfnmin_cmd_tl { \g_tzfnmin_END_cmd_tl } % append + } + \tl_put_right:Nn \l_tzfnmin_cmd_tl + { node [ #8 ] { #7 } } + % final action + \exp_last_unbraced:Nf \draw \l_tzfnmin_cmd_tl #9 ; + + \bool_gset_false:N \g_tzfnmin_BEGIN_cmd_bool + \bool_gset_false:N \g_tzfnmin_END_cmd_bool +} + +\NewDocumentCommand\tzfnmin_domain_process{ m m } +{ + \def\tzfnminFromVal{#1} + \def\tzfnminToVal{#2} +} + +%%% --- end of \tzfnmin + + +%%% pdf + +%% normal distribution + +\NewExpandableDocumentCommand\tzpdfN{ s m m } +{ + \IfBooleanTF { #1 } + { % standard deviation + 1/(#3*sqrt(2*pi))*exp( -1/2*( (\exp_not:n{\x}-#2)^2 / (#3)^2 ) ) + } + { % variance (default) + 1/(sqrt(#3)*sqrt(2*pi))*exp(-1/2*((\exp_not:n{\x}-#2)^2/(sqrt(#3))^2)) + } +} + + +%% standard normal distribution + +\NewExpandableDocumentCommand\tzpdfZ{ } +{ +% \IfBooleanTF { #1 } {}{} % NOT USED! (to avoid coding error) + 1/sqrt(2*pi)*exp( -1/2*( \exp_not:n{\x} )^2 ) +} + + + +%%% \tzfnarea +%% no shift, no name path + +\use:x{ + \NewDocumentCommand \exp_not:N \tzfnarea + { s O{} m >{ \SplitArgument {1} { \tl_to_str:n {:} } } r[] G{.3} D<>{} } +} +{ + \tl_clear:N \l_tzfnarea_cmd_tl + + \tl_if_empty:nTF { #5 } + { \renewcommand\tzfillopacity{\tz@initial@fill@opacity} } + { \renewcommand\tzfillopacity{#5} } + + \tzfnarea_domain_process #4 + + % collect fill options + \IfBooleanTF { #1 } + { + \tl_put_right:Nx \l_tzfnarea_cmd_tl + { + [ fill=\tzfillcolor , fill~opacity = \tzfillopacity , + text~opacity = 1 , \exp_not:n { #2 } ] + } + } + { + \tl_put_right:Nn \l_tzfnarea_cmd_tl + { [ #2 ] } + } + + + \tl_put_right:Nx \l_tzfnarea_cmd_tl + { + (\tzfnareaFromVal,0) -- plot + [ samples = 201 , + domain = \tzfnareaFromVal \c_colon_str \tzfnareaToVal , +% variable = \exp_not:n { \x } , + ] + } + \tl_put_right:No \l_tzfnarea_cmd_tl + { + ( \exp_not:n { \x } , { #3 } ) -- (\tzfnareaToVal,0) + } + + % final action + \begin{pgfonlayer}{ \tzfnarealayer } % default = behind + \exp_last_unbraced:Nf + \path \l_tzfnarea_cmd_tl #6 ; + \end{pgfonlayer} +} + +\NewDocumentCommand\tzfnarea_domain_process{ m m } +{ + \def\tzfnareaFromVal{#1} + \def\tzfnareaToVal{#2} +} + +%%% --- end of \tzfnarea + + +\NewDocumentCommand\tzfnarealine{ t' O{} m m O{} D(){0,0} g O{} D(){0,0} } +{ + \tzvXpointat{#3}{#4}(tzfnAL) + + \IfBooleanTF { #1 } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAL) (tzfnAL -| #6) + \end{pgfonlayer} + } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAL) (tzfnAL |- #6) + \end{pgfonlayer} + } + + \IfValueT { #7 } + { + \tzvXpointat{#3}{#7}(tzfnAR) + + \IfBooleanTF { #1 } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAR) (tzfnAR -| #9) + \end{pgfonlayer} + } + { + \begin{pgfonlayer}{\tzfnarealayer} + \tzto [ \tzfnALstyle , #2 , #8 ] (tzfnAR) (tzfnAR|-#9) + \end{pgfonlayer} + } + } +} + + + + +%%% \tzvfnat +%% -- vertical line at x + +\bool_new:N \g_tzvfnat_BEGIN_cmd_bool +\bool_new:N \g_tzvfnat_END_cmd_bool + +%% \tzvfnatAtBegin +\NewDocumentCommand\tzvfnatAtBegin{ m } +{ + \bool_gset_true:N \g_tzvfnat_BEGIN_cmd_bool + \tl_gset:No \g_tzvfnat_BEGIN_cmd_tl { #1 } +} + +%% \tzvfnatAtEnd +\NewDocumentCommand\tzvfnatAtEnd{ m } +{ + \bool_gset_true:N \g_tzvfnat_END_cmd_bool + \tl_gset:No \g_tzvfnat_END_cmd_tl { #1 } +} + +%% \tzvfnat (main) \use:x{ \NewDocumentCommand \exp_not:N \tzvfnat { O{} D<>{0,0} D""{} m @@ -3157,12 +5868,14 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzvfnat_cmd_tl { [ +% samples = 201 , name~path = #3 , shift = { (#2) } , -% samples = 200 , \exp_not:n { #1 } ] } + \bool_if:NT \g_tzvfnat_BEGIN_cmd_bool + { \tl_put_right:No \l_tzvfnat_cmd_tl { \g_tzvfnat_BEGIN_cmd_tl } } \IfValueTF { #5 } { \tl_put_right:Nn \l_tzvfnat_cmd_tl @@ -3175,10 +5888,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) -- (#4,0 |- current~bounding~box.north) } } + \bool_if:NT \g_tzvfnat_END_cmd_bool + { \tl_put_right:No \l_tzvfnat_cmd_tl { \g_tzvfnat_END_cmd_tl } } \tl_put_right:Nn \l_tzvfnat_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzvfnat_cmd_tl #8 ; + + \bool_gset_false:N \g_tzvfnat_BEGIN_cmd_bool + \bool_gset_false:N \g_tzvfnat_END_cmd_bool } \NewDocumentCommand\tzvfnat_domain_process{ m m } @@ -3190,10 +5908,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzvfnat -%%% \tzvfn (On) -- vertical line through (x,y) +%%% \tzvfn (On) +%% -- vertical line through (x,y) + +\bool_new:N \g_tzvfn_BEGIN_cmd_bool +\bool_new:N \g_tzvfn_END_cmd_bool + +%% \tzvfnAtBegin +\NewDocumentCommand\tzvfnAtBegin{ m } +{ + \bool_gset_true:N \g_tzvfn_BEGIN_cmd_bool + \tl_gset:No \g_tzvfn_BEGIN_cmd_tl { #1 } +} +%% \tzvfnAtEnd +\NewDocumentCommand\tzvfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzvfn_END_cmd_bool + \tl_gset:No \g_tzvfn_END_cmd_tl { #1 } +} -%%% \tzvfn +%%% \tzvfn (main) \use:x{ \NewDocumentCommand \exp_not:N \tzvfn { O{} d<> D""{} r() @@ -3212,6 +5947,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzvfn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzvfn_cmd_tl { \g_tzvfn_BEGIN_cmd_tl } } \IfValueTF { #5 } { \IfValueTF { #2 } @@ -3243,10 +5980,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } } + \bool_if:NT \g_tzvfn_END_cmd_bool + { \tl_put_right:No \l_tzvfn_cmd_tl { \g_tzvfn_END_cmd_tl } } \tl_put_right:Nn \l_tzvfn_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzvfn_cmd_tl #8 ; + + \bool_gset_false:N \g_tzvfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzvfn_END_cmd_bool } \NewDocumentCommand\tzvfn_domain_process{ m m } @@ -3258,7 +6000,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzvfn -%% \tzhfnat +%%% \tzhfnat +%% -- horizontal line at y + +\bool_new:N \g_tzhfnat_BEGIN_cmd_bool +\bool_new:N \g_tzhfnat_END_cmd_bool + +%% \tzhfnatAtBegin +\NewDocumentCommand\tzhfnatAtBegin{ m } +{ + \bool_gset_true:N \g_tzhfnat_BEGIN_cmd_bool + \tl_gset:No \g_tzhfnat_BEGIN_cmd_tl { #1 } +} + +%% \tzhfnatAtEnd +\NewDocumentCommand\tzhfnatAtEnd{ m } +{ + \bool_gset_true:N \g_tzhfnat_END_cmd_bool + \tl_gset:No \g_tzhfnat_END_cmd_tl { #1 } +} + +%% \tzhfnat (main) \use:x{ \NewDocumentCommand \exp_not:N \tzhfnat { O{} D<>{0,0} D""{} m @@ -3279,6 +6041,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzhfnat_BEGIN_cmd_bool + { \tl_put_right:No \l_tzhfnat_cmd_tl { \g_tzhfnat_BEGIN_cmd_tl } } \IfValueTF { #5 } { \tl_put_right:Nn \l_tzhfnat_cmd_tl @@ -3291,10 +6055,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) -- (0,#4 -| current~bounding~box.east) } } + \bool_if:NT \g_tzhfnat_END_cmd_bool + { \tl_put_right:No \l_tzhfnat_cmd_tl { \g_tzhfnat_END_cmd_tl } } \tl_put_right:Nn \l_tzhfnat_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzhfnat_cmd_tl #8 ; + + \bool_gset_false:N \g_tzhfnat_BEGIN_cmd_bool + \bool_gset_false:N \g_tzhfnat_END_cmd_bool } \NewDocumentCommand\tzhfnat_domain_process{ m m } @@ -3306,9 +6075,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzhfnat -%%% \tzhfn (On) -- horizontal line through (x,y) +%%% \tzhfn (On) +%% -- horizontal line through (x,y) + +\bool_new:N \g_tzhfn_BEGIN_cmd_bool +\bool_new:N \g_tzhfn_END_cmd_bool -%% \tzhfn +%% \tzhfnAtBegin +\NewDocumentCommand\tzhfnAtBegin{ m } +{ + \bool_gset_true:N \g_tzhfn_BEGIN_cmd_bool + \tl_gset:No \g_tzhfn_BEGIN_cmd_tl { #1 } +} + +%% \tzhfnAtEnd +\NewDocumentCommand\tzhfnAtEnd{ m } +{ + \bool_gset_true:N \g_tzhfn_END_cmd_bool + \tl_gset:No \g_tzhfn_END_cmd_tl { #1 } +} + +%% \tzhfn (main) \use:x{ \NewDocumentCommand \exp_not:N \tzhfn { O{} d<> D""{} r() @@ -3328,6 +6115,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \exp_not:n { #1 } ] } + \bool_if:NT \g_tzhfn_BEGIN_cmd_bool + { \tl_put_right:No \l_tzhfn_cmd_tl { \g_tzhfn_BEGIN_cmd_tl } } \IfValueTF { #5 } { \IfValueTF { #2 } @@ -3363,10 +6152,15 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } } + \bool_if:NT \g_tzhfn_END_cmd_bool + { \tl_put_right:No \l_tzhfn_cmd_tl { \g_tzhfn_END_cmd_tl } } \tl_put_right:Nn \l_tzhfn_cmd_tl { node [ #7 ] { #6 } } % final action \exp_last_unbraced:Nf \draw \l_tzhfn_cmd_tl #8 ; + + \bool_gset_false:N \g_tzhfn_BEGIN_cmd_bool + \bool_gset_false:N \g_tzhfn_END_cmd_bool } \NewDocumentCommand\tzhfn_domain_process{ m m } @@ -3382,9 +6176,37 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzXpoint -- intersection point of two paths \NewDocumentCommand\tzXpoint - { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } + { s O{} m m D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzXpoint_cmd_tl +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% \path [ name~intersections = { of = #3 ~ and ~ #4 , name = #5 } ] ; \tl_put_right:Nn \l_tzXpoint_cmd_tl { @@ -3396,7 +6218,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzXpoint_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } \tl_put_right:Nn \l_tzXpoint_cmd_tl @@ -3411,15 +6233,119 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzXpoint +%%% \tzLFnXpoint : linear Xpoint +\NewDocumentCommand\tzLFnXpoint + { s O{} m m o D(){} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } +{ + \tl_clear:N \l_tzLFnXpoint_cmd_tl + +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + + \IfValueTF { #5 } + { + \def\x{#5} + \path (\x,{#3}) coordinate (tzLFnXA-1) (\x,{#4}) coordinate (tzLFnXB-1); + \def\x{\fp_eval:n {1.01*#5+.1}} + \path (\x,{#3}) coordinate (tzLFnXA-2) (\x,{#4}) coordinate (tzLFnXB-2); + } + { + \def\x{0} + \path (\x,{#3}) coordinate (tzLFnXA-1) (\x,{#4}) coordinate (tzLFnXB-1); + \def\x{.1} + \path (\x,{#3}) coordinate (tzLFnXA-2) (\x,{#4}) coordinate (tzLFnXB-2); + } + + \tl_put_right:Nn \l_tzLFnXpoint_cmd_tl + { + (intersection~of~tzLFnXA-1--tzLFnXA-2 ~and~ tzLFnXB-1--tzLFnXB-2) + coordinate (#6) + \IfBooleanTF {#1} + { node [ tzdot , fill , minimum~size = #9 , } + { node [ tzdot , draw = none , minimum~size = 0pt , } + } + + \tl_put_right:Nx \l_tzLFnXpoint_cmd_tl + { + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str + } + + \tl_put_right:Nn \l_tzLFnXpoint_cmd_tl + { + #2 + ] {} + } + + \exp_last_unbraced:Nf \draw \l_tzLFnXpoint_cmd_tl ; +} + +%%% --- end of \tzLFnXpoint + + %%% \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} } + { s O{} m m D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzvXpointat_cmd_tl \tzvfnat[draw=none]"tzvXpoint-At" {#4} % depends on (current bounding box) +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \path [ name~intersections = { of = tzvXpoint-At ~and~ #3 , name = #5 } ] ; \tl_put_right:Nn \l_tzvXpointat_cmd_tl @@ -3432,7 +6358,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzvXpointat_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } \tl_put_right:Nn \l_tzvXpointat_cmd_tl @@ -3452,12 +6378,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% -- 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} } + { s O{} m r() D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzvXpoint_cmd_tl \tzvfn[draw=none]"tzvXpoint-On"(#4) % depends on (current bounding box) +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \path [ name~intersections = { of = tzvXpoint-On ~and~ #3 , name = #5 } ] ; \tl_put_right:Nn \l_tzvXpoint_cmd_tl { @@ -3469,7 +6424,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzvXpoint_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } \tl_put_right:Nn \l_tzvXpoint_cmd_tl @@ -3488,12 +6443,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \tzhXpointat -- horizontal intersection point at y \NewDocumentCommand\tzhXpointat - { s O{} m m D(){intersection} O{1} +G{} O{} D(){\tz@initial@dot@size} } + { s O{} m m D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzhXpointat_cmd_tl \tzhfnat[draw=none]"tzhXpoint-At"{#4} % depends on (current bounding box) +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \path [ name~intersections = { of = tzhXpoint-At ~and~ #3 , name = #5 } ] ; \tl_put_right:Nn \l_tzhXpointat_cmd_tl { @@ -3505,7 +6489,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzhXpointat_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } \tl_put_right:Nn \l_tzhXpointat_cmd_tl @@ -3523,12 +6507,41 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \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} } + { s O{} m r() D(){intersection} O{1} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tzhXpoint_cmd_tl \tzhfn[draw=none]"tzhXpoint-On"(#4) % depends on (current bounding box) +%%%%%% to use string replacement for label positions + \IfValueTF { #8 } + { + \tl_if_in:nnTF { #8 } { [ } + { \extract_posopt:w #8 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #8 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #8 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \path [ name~intersections = { of = tzhXpoint-On ~and~ #3 , name = #5 } ] ; \tl_put_right:Nn \l_tzhXpoint_cmd_tl @@ -3541,7 +6554,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \tl_put_right:Nx \l_tzhXpoint_cmd_tl { - label = { \exp_not:n { #8 } \c_colon_str \exp_not:n { #7 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #7 } } , % pos_str } \tl_put_right:Nn \l_tzhXpoint_cmd_tl @@ -3585,6 +6598,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } } + %%% \tzaxesL -- simpler version of \tzaxes \NewDocumentCommand\tzaxesL{ t' O{} d<> r() r() +G{} O{} +G{} O{} } @@ -3634,6 +6648,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% -- end of \tzaxesL + %%% \tzaxisx \NewDocumentCommand\tzaxisx{ s O{} D<>{0} m m G{} O{} } @@ -3642,6 +6657,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) ( #4 , #3 ) -- ( #5 , #3 ) node [ right , #7 ] { #6 } ; } + %%% \tzaxisy \NewDocumentCommand\tzaxisy{ s O{} D<>{0} m m G{} O{} } @@ -3734,7 +6750,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzticks -%%% \tztikcsx -- ticks and labels along the x axis +%%% \tztikcsx (main) +%% -- ticks and labels along the x axis \use:x{ \NewDocumentCommand \exp_not:N \tzticksx @@ -3784,7 +6801,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzticksx -%%% \tztikcsy -- ticks and labels along with the y axis +%%% \tztikcsy (main) +%% -- ticks and labels along with the y axis \use:x{ \NewDocumentCommand \exp_not:N \tzticksy @@ -3849,10 +6867,77 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) text~depth = .25ex , below , #6 ] { #5 } -- (#4) -- (tzProj |- #4) - node [ left , #8 ] {#7} ; + node [ left , #8 ] { #7 } ; \IfBooleanT {#1} { \tzdot*(#4)(#9) } } +%%% \tzprojs : semicolon version + +%\bool_new:N \l_tzprojs_shift_coor_bool + +%%% \tzprojs (main) +\NewDocumentCommand\tzprojs { s O{} d<> } +{ + \tl_clear:N \l_tzprojs_cmd_tl +% \tl_clear:N \l_tzprojs_opt_tl + \tl_clear:N \l_tzprojs_coors_tl + + \IfValueTF { #3 } + { \coordinate (tzProjs) at (#3) ; } + { \coordinate (tzProjs) at (0,0) ; } + + \tl_put_right:Nn \l_tzprojs_cmd_tl { [ dotted , #2 ] } + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzprojs_check_token:n +} + +\cs_new:Npn \tzprojs_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzprojs_sub_fn #1 } +% { \tzprojs_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzprojs_sub_fn #1 } + { ; } { \tzprojs_stop_action } + } + { + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzprojs_sub_fn { r() G{} O{} G{} O{} } +{ + % collect only coordinates (to print dots) + \tl_put_right:Nn \l_tzprojs_coors_tl { (#1) } + % collect cmd_tl (for all inputs) + \tl_put_right:Nn \l_tzprojs_cmd_tl + { + (#1 |- tzProjs) + node [ text~height = 1.25ex , + text~depth = .25ex , + below , #3 ] { #2 } + -- (#1) -- (tzProjs |- #1) + node [ left , #5 ] { #4 } + } + + \tzprojs_check_token:n +} + +\NewDocumentCommand\tzprojs_stop_action { D(){\tz@initial@dot@size} } +{ + % final action + \exp_last_unbraced:Nf \draw \l_tzprojs_cmd_tl ; + \bool_if:NT \l_tmpa_bool + { \exp_last_unbraced:NNf \tzdots* \l_tzprojs_coors_tl ; (#1) } +} +%%% --- end of \tzprojs + + %%% \tzprojx \NewDocumentCommand\tzprojx @@ -3883,35 +6968,276 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) \IfBooleanT { #1 } { \tzdot*(#4)(#7) } } +%%% \tzprojsx : semicolon version + +%\bool_new:N \l_tzprojsx_shift_coor_bool + +%%% \tzprojsx (main) +\NewDocumentCommand\tzprojsx { s O{} d<> } +{ + \tl_clear:N \l_tzprojsx_cmd_tl +% \tl_clear:N \l_tzprojsx_opt_tl + \tl_clear:N \l_tzprojsx_coors_tl + + \IfValueTF { #3 } + { \coordinate (tzProjsx) at (#3) ; } + { \coordinate (tzProjsx) at (0,0) ; } + + \tl_put_right:Nn \l_tzprojsx_cmd_tl { [ dotted , #2 ] } + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzprojsx_check_token:n +} + +\cs_new:Npn \tzprojsx_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzprojsx_sub_fn #1 } +% { \tzprojsx_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzprojsx_sub_fn #1 } + { ; } { \tzprojsx_stop_action } + } + { + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzprojsx_sub_fn { r() G{} O{} } +{ + % collect only coordinates (to print dots) + \tl_put_right:Nn \l_tzprojsx_coors_tl { (#1) } + % collect cmd_tl (for all inputs) + \tl_put_right:Nn \l_tzprojsx_cmd_tl + { + (#1) -- (#1 |- tzProjsx) + node [ text~height = 1.25ex , + text~depth = .25ex , + below , #3 ] { #2 } + } + + \tzprojsx_check_token:n +} + +\NewDocumentCommand\tzprojsx_stop_action { D(){\tz@initial@dot@size} } +{ + % final action + \exp_last_unbraced:Nf \draw \l_tzprojsx_cmd_tl ; + \bool_if:NT \l_tmpa_bool + { \exp_last_unbraced:NNf \tzdots* \l_tzprojsx_coors_tl ; (#1) } +} +%%% --- end of \tzprojsx + + +%%% \tzprojsy : semicolon version + +%\bool_new:N \l_tzprojsy_shift_coor_bool + +%%% \tzprojsy (main) +\NewDocumentCommand\tzprojsy { s O{} d<> } +{ + \tl_clear:N \l_tzprojsy_cmd_tl +% \tl_clear:N \l_tzprojsy_opt_tl + \tl_clear:N \l_tzprojsy_coors_tl + + \IfValueTF { #3 } + { \coordinate (tzProjsy) at (#3) ; } + { \coordinate (tzProjsy) at (0,0) ; } + + \tl_put_right:Nn \l_tzprojsy_cmd_tl { [ dotted , #2 ] } + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tzprojsy_check_token:n +} + +\cs_new:Npn \tzprojsy_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tzprojsy_sub_fn #1 } +% { \tzprojsy_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tzprojsy_sub_fn #1 } + { ; } { \tzprojsy_stop_action } + } + { + \msg_error:nn { tzplot } { semicolon-error } + } +} + +\NewDocumentCommand\tzprojsy_sub_fn { r() G{} O{} } +{ + % collect only coordinates (to print dots) + \tl_put_right:Nn \l_tzprojsy_coors_tl { (#1) } + % collect cmd_tl (for all inputs) + \tl_put_right:Nn \l_tzprojsy_cmd_tl + { + (#1) -- (#1 -| tzProjsy) + node [ left , #3 ] { #2 } + } + + \tzprojsy_check_token:n +} + +\NewDocumentCommand\tzprojsy_stop_action { D(){\tz@initial@dot@size} } +{ + % final action + \exp_last_unbraced:Nf \draw \l_tzprojsy_cmd_tl ; + \bool_if:NT \l_tmpa_bool + { \exp_last_unbraced:NNf \tzdots* \l_tzprojsy_coors_tl ; (#1) } +} +%%% --- end of \tzprojsy + %%%%% Nodes %%% \tznode -- putting texts (and labels as option) -\NewDocumentCommand\tznode{ s O{} d<> r() D(){tzNodeName} +G{} O{} } +\NewDocumentCommand\tznode{ s O{} d<> r() D(){tzNodeName} +m O{} D<>{} } { \IfBooleanTF { #1 } { \IfValueTF { #3 } - { \node [ draw , #2 ] (#5) at ([shift={(#3)}]#4) [ #7 ] { #6 } ; } - { \node [ draw , #2 ] (#5) at (#4) [ #7 ] { #6 } ; } + { \node #8 [ draw , #2 ] (#5) at ([shift={(#3)}]#4) [ #7 ] { #6 } ; } + { \node #8 [ 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 } ; } + { \node #8 [ #2 ] (#5) at ([shift={(#3)}]#4) [ #7 ] { #6 } ; } + { \node #8 [ #2 ] (#5) at (#4) [ #7 ] { #6 } ; } } } +%%% --- end of \tznode + + +%%% \tznodes +%%% repeat pattern: (coor)(nodename){label}[pos] + +%\tl_new:N \l_tznodes_opt_tl +%\tl_new:N \l_tznodes_cmd_tl +\bool_new:N \l_tznodes_shift_coor_bool + +%%% \tznodes (main) +\NewDocumentCommand\tznodes{ s O{} d<> } +{ + \tl_clear:N \l_tznodes_cmd_tl + + \IfBooleanTF { #1 } + { + \tl_set:Nn \l_tznodes_cmd_tl { [ every~node/.style = { draw , #2 } ] } + } + { + \tl_set:Nn \l_tznodes_cmd_tl { [ every~node/.style = { #2 } ] } + } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tznodes_shift_coor_tl { #3 } + \bool_set_true:N \l_tznodes_shift_coor_bool + } + { + \tl_clear:N \l_tznodes_shift_coor_tl + \bool_set_false:N \l_tznodes_shift_coor_bool + } + \tznodes_check_token:n +} + +\cs_new:Npn \tznodes_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tznodes_sub_fn #1 } +% { \tznodes_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tznodes_sub_fn #1 } + { ; } { \tznodes_late_opt_fn } + } + { +% \tznodes_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + + +\NewDocumentCommand\tznodes_sub_fn { r() r() +G{} O{} } +{ + \bool_if:NTF \l_tznodes_shift_coor_bool + { + \tl_put_right:Nx \l_tznodes_cmd_tl + {% if shift + ( [ shift = { (\l_tznodes_shift_coor_tl) } ] #1 ) + } + } + { \tl_put_right:Nn \l_tznodes_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tznodes_cmd_tl { node (#2) } %% node (name) + \tl_put_right:Nn \l_tznodes_cmd_tl + { [ #4 ] { #3 } } + \tznodes_check_token:n +} + +\NewDocumentCommand\tznodes_late_opt_fn { D<>{} } +{ + % #1 does nothing (kept for consistency with \tznodedots) + \tznodes_stop_action +} + + +\NewDocumentCommand\tznodes_stop_action {} +{ + \exp_last_unbraced:Nf \path \l_tznodes_cmd_tl ; +} + +%%% --- end of \tznodes + + + +%%% \tznodedot (main) -%%% \tznodedot \NewDocumentCommand\tznodedot - { s O{} d<> r() D(){tzNodeName} +G{} O{} D(){\tz@initial@dot@size} } + { s O{} d<> r() D(){tzNodeName} +G{} >{\TrimSpaces}o D(){\tz@initial@dot@size} } { \tl_clear:N \l_tznodedot_cmd_tl \renewcommand\tzdotsize{ #8 } +%%%%%% to use string replacement for label positions + \IfValueTF { #7 } + { + \tl_if_in:nnTF { #7 } { [ } + { \extract_posopt:w #7 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #7 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #7 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + \IfValueTF { #3 } {% if shift \tl_put_right:Nn \l_tznodedot_cmd_tl @@ -3930,7 +7256,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) } \tl_put_right:Nx \l_tznodedot_cmd_tl { - label = { \exp_not:n { #7 } \c_colon_str \exp_not:n { #6 } } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #6 } } , % str_opt } \tl_put_right:Nn \l_tznodedot_cmd_tl { @@ -3942,6 +7268,131 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tznodedot +%%% \tznodedots +%%% repeat pattern: (coor)(nodename){label}[pos] + +\tl_new:N \l_tznodedots_opt_tl +\tl_new:N \l_tznodedots_cmd_tl +\bool_new:N \l_tznodedots_shift_coor_bool + +%%% \tznodedots (main) +\NewDocumentCommand\tznodedots{ s O{} d<> } +{ + \tl_clear:N \l_tznodedots_cmd_tl + + \IfBooleanTF { #1 } + { \tl_set:Nn \l_tznodedots_STYLE_fill_tl { fill } } + { \tl_set:Nn \l_tznodedots_STYLE_fill_tl { fill = none } } + + \tl_if_empty:nTF { #2 } + { \tl_set:Nn \l_tznodedots_opt_tl { tzdot } } + { \tl_set:Nn \l_tznodedots_opt_tl { tzdot , #2 } } + + \IfValueTF { #3 } + { + \tl_set:Nn \l_tznodedots_shift_coor_tl { #3 } + \bool_set_true:N \l_tznodedots_shift_coor_bool + } + { + \tl_clear:N \l_tznodedots_shift_coor_tl + \bool_set_false:N \l_tznodedots_shift_coor_bool + } + + \tznodedots_check_token:n +} + +\cs_new:Npn \tznodedots_check_token:n #1 +{ +% \token_if_eq_charcode:NNTF #1 ( +% { \tznodedots_sub_fn #1 } +% { \tznodedots_stop_action } + \str_case:nnF { #1 } + { + { ( } { \tznodedots_sub_fn #1 } + { ; } { \tznodedots_late_opt_fn } + } + { +% \tznodedots_stop_action + \msg_error:nn { tzplot } { semicolon-error } + } +} + + +\NewDocumentCommand\tznodedots_sub_fn { r() r() +G{} >{\TrimSpaces}o } +{ +%%%%%% to use string replacement for label positions + \IfValueTF { #4 } + { + \tl_if_in:nnTF { #4 } { [ } + { \extract_posopt:w #4 \q_stop } % ndh + { + \tl_set:Nx \l_label_pos_str_trimmed_tl { \tl_trim_spaces:n { #4 } } + \str_case_e:nnF { \l_label_pos_str_trimmed_tl } + { + {l} { \tl_set:Nn \l_label_pos_str_tl {left} } + {r} { \tl_set:Nn \l_label_pos_str_tl {right} } + {a} { \tl_set:Nn \l_label_pos_str_tl {above} } + {b} { \tl_set:Nn \l_label_pos_str_tl {below} } + {c} { \tl_set:Nn \l_label_pos_str_tl {center} } + {al} { \tl_set:Nn \l_label_pos_str_tl {above~left} } + {ar} { \tl_set:Nn \l_label_pos_str_tl {above~right} } + {bl} { \tl_set:Nn \l_label_pos_str_tl {below~left} } + {br} { \tl_set:Nn \l_label_pos_str_tl {below~right} } + } + { + \tl_set:Nn \l_label_pos_str_tl { #4 } + } + } + } + { + \tl_clear:N \l_label_pos_str_tl + } +%%%%%%%%%% + + \bool_if:NTF \l_tznodedots_shift_coor_bool + { + \tl_put_right:Nx \l_tznodedots_cmd_tl + {% if shift + ( [ shift = { (\l_tznodedots_shift_coor_tl) } ] #1 ) + } + } + { \tl_put_right:Nn \l_tznodedots_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tznodedots_cmd_tl { node (#2) } %% node (name) + + \tl_put_right:Nx \l_tznodedots_cmd_tl + { + [ + \l_tznodedots_STYLE_fill_tl , + minimum~size = \exp_not:n { \tzdotsize } , + label = { \l_label_pos_str_tl \c_colon_str \exp_not:n { #3 } } , % pos_str + } + \tl_put_right:No \l_tznodedots_cmd_tl % expand `once' + { + \l_tznodedots_opt_tl + ] {} + } + \tznodedots_check_token:n +} + +\NewDocumentCommand\tznodedots_late_opt_fn { D(){\tz@initial@dot@size} } +{ + \renewcommand\tzdotsize{ #1 } + + \tznodedots_stop_action +} + + +\NewDocumentCommand\tznodedots_stop_action {} +{ + \exp_last_unbraced:Nf \path \l_tznodedots_cmd_tl ; +} + +%%% --- end of \tznodedots + + + + %%% \tznodeframe @@ -4030,7 +7481,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %% secant line -%%% \tzsecantat +%%% \tzsecantat (main) \use:x{ \NewDocumentCommand \exp_not:N \tzsecantat @@ -4129,7 +7580,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tzsecantat -%%% \tzsecant +%%% \tzsecant (main) \use:x{ \NewDocumentCommand \exp_not:N \tzsecant @@ -4256,15 +7707,224 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% \gdef\TANCurve{<#m>}\gdef\TANWhere{<#n>} -%%%%% Tangent lines +%%%%% Slope lines +%% No <shift coor> +%% No <shift coor> +%% No <shift coor> -%%% ref. \settztangentepsilon +%%% \tzslopeat +%% -- slope line at x -\bool_new:N \l_tztangentat_bbox_bool +\bool_new:N \l_tzslopeat_bbox_bool + +%%% \tzslopeat (main) +\NewDocumentCommand\tzslopeat + { O{} m m + >{ \SplitArgument { 1 } { , } } d() + m O{0} +G{} O{} D<>{} + } +{ + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #2 } && + \str_if_eq_p:ee { \TANWhere } { #3 } + } + { \bool_set_true:N \l_tzslopeat_bbox_bool } + { \bool_set_false:N \l_tzslopeat_bbox_bool } + + % for local change of epsilon_1, epsilon_2 + \IfValueT { #4 } + { + \tzslopeat_epsilon_process #4 + \renewcommand\tzslopeepsilonL{\tzslopeatEpsilonOne} + \renewcommand\tzslopeepsilonR{\tzslopeatEpsilonTwo} + } + + % getting ready + \coordinate (LXcoor) at ($(#3,0)-(\tzslopeepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#3,0)+(\tzslopeepsilonR,0)$) ; + + \bool_if:NTF \l_tzslopeat_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 ] (#3,0 |- bbxBottom) -- (#3,0 |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ 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_label_pos_tl + { + (RRpoint) -- (TANp-1) -- + ([turn]#6 \c_colon_str #5/2 ) coordinate (final-LL) + } + \tl_set:Nx \l_tmpb_tl + { + (LLpoint) -- (TANp-1) -- + ([turn]#6 \c_colon_str #5/2 ) coordinate (final-RR) + } + + \exp_last_unbraced:Nf \path \l_label_pos_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tl_set:Nn \l_tzslopeat_cmd_tl + { + [ #1 ] (final-LL) -- (final-RR) + } + + \gdef\TANCurve{#2}\gdef\TANWhere{#3} + + \begin{pgfonlayer}{\tzslopelayer} + \exp_last_unbraced:Nf \draw \l_tzslopeat_cmd_tl node [ #8 ] { #7 } #9 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzslopeat_cmd_tl ; +} + +\NewDocumentCommand\tzslopeat_epsilon_process{ m m } +{ + \def\tzslopeatEpsilonOne{#1} + \def\tzslopeatEpsilonTwo{#2} +} + +%%% --- end of \tzslopeat + + +%%% \tzslope (On) -- slope line at (x,y) + +\bool_new:N \l_tzslope_bbox_bool + +%%% \tzslope (main) +\NewDocumentCommand\tzslope + { O{} m r() + >{ \SplitArgument { 1 } { , } } d() + m O{0} +G{} O{} D<>{} + } +{ + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #2 } && + \str_if_eq_p:ee { \TANWhere } { #3 } + } + { \bool_set_true:N \l_tzslope_bbox_bool } + { \bool_set_false:N \l_tzslope_bbox_bool } + + % for local change of epsilon_1, epsilon_2 + \IfValueT { #4 } + { + \tzslope_epsilon_process #4 + \renewcommand\tzslopeepsilonL{\tzslopeEpsilonOne} + \renewcommand\tzslopeepsilonR{\tzslopeEpsilonTwo} + } + + % getting ready + \coordinate (LXcoor) at ($(#3)-(\tzslopeepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#3)+(\tzslopeepsilonR,0)$) ; + + \bool_if:NTF \l_tzslope_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 ] (#3,0 |- bbxBottom) -- (#3,0 |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #2 ~ 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_label_pos_tl + { + (RRpoint) -- (TANp-1) -- + ([turn]#6 \c_colon_str #5/2 ) coordinate (final-LL) + } + \tl_set:Nx \l_tmpb_tl + { + (LLpoint) -- (TANp-1) -- + ([turn]#6 \c_colon_str #5/2 ) coordinate (final-RR) + } + + \exp_last_unbraced:Nf \path \l_label_pos_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tl_set:Nn \l_tzslope_cmd_tl + { + [ #1 ] (final-LL) -- (final-RR) + } + + \gdef\TANCurve{#2}\gdef\TANWhere{#3} + + \begin{pgfonlayer}{\tzslopelayer} + \exp_last_unbraced:Nf \draw \l_tzslope_cmd_tl node [ #8 ] { #7 } #9 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzslope_cmd_tl ; +} + +\NewDocumentCommand\tzslope_epsilon_process{ m m } +{ + \def\tzslopeEpsilonOne{#1} + \def\tzslopeEpsilonTwo{#2} +} + +%%% --- end of \tzslope + + + +%%%%% Tangent lines %%% \tztangentat -- tangent to a path at x +%%% ref. \settztangentepsilon %%% [<opt>]<shift coor>"<path name>"{<path>}{<x>}(<epsilon1>,<epsilon2>)[<from>:<to>]{<text>}[<pos,opt>]<code.append> +\bool_new:N \l_tztangentat_bbox_bool + +%%% \tztangentat (main) \use:x{ \NewDocumentCommand \exp_not:N \tztangentat { s O{} d<> D""{} m m @@ -4333,7 +7993,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move % determine final extended points - \tl_set:Nx \l_tmpa_tl + \tl_set:Nx \l_label_pos_tl { (RRpoint) -- (TANp-1) -- ([turn]0 \c_colon_str ~ -\tztangentatFromVal) coordinate (final-LL) @@ -4344,7 +8004,7 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) ([turn]0 \c_colon_str ~ \tztangentatToVal) coordinate (final-RR) } - \exp_last_unbraced:Nf \path \l_tmpa_tl ; + \exp_last_unbraced:Nf \path \l_label_pos_tl ; \exp_last_unbraced:Nf \path \l_tmpb_tl ; \tzgetxyval(LLpoint){\tzTANLLX}{\tzTANLLY} @@ -4414,11 +8074,12 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- 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> +\bool_new:N \l_tztangent_bbox_bool + +%%% \tztangent (main) \use:x{ \NewDocumentCommand \exp_not:N \tztangent { s O{} d<> D""{} m r() @@ -4487,14 +8148,14 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move % determine final extended points - \tl_set:Nx \l_tmpa_tl + \tl_set:Nx \l_label_pos_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_label_pos_tl ; \exp_last_unbraced:Nf \path \l_tmpb_tl ; \tzgetxyval(LLpoint){\tzTANLLX}{\tzTANLLY} @@ -4564,6 +8225,8 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% --- end of \tztangent + + %%%%% \tzbrace %%% \tzbrace'[<opt>]{<raise>}[<brace opt>] @@ -4596,6 +8259,232 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %%% -- end of \tzbrace +%%%(ADDED) +%%% \tzsnake + +\bool_new:N \l_tzsnake_shift_coor_bool + +%%% \tzsnake (main) +\NewDocumentCommand\tzsnake{ s t+ o G{5pt} O{} d<> } +{ + \tl_clear:N \l_tzsnake_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 { #3 } + { \tl_set:Nn \l_tzsnake_opt_tl { #3 } } + { \tl_clear:N \l_tzsnake_opt_tl } + + \tl_set:Nn \l_tzsnake_segment_length_tl { #4 } + + \tl_set:Nn \l_tzsnake_snake_opt_tl { #5 } + + \IfValueTF { #6 } + { + \tl_set:Nn \l_tzsnake_shift_coor_tl { #6 } + \bool_set_true:N \l_tzsnake_shift_coor_bool + } + { + \tl_clear:N \l_tzsnake_shift_coor_tl + \bool_set_false:N \l_tzsnake_shift_coor_bool + } + + \tzsnake_check_token:n +} + +\cs_new:Npn \tzsnake_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzsnake_sub_fn ( } +% \tzsnake_stop_action +} + +\NewDocumentCommand\tzsnake_sub_fn{ r() +G{} O{} r() +G{} O{} D<>{} } +{ + + \bool_if:NTF \l_tzsnake_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzsnake_cmd_tl + { ([ shift = { (\l_tzsnake_shift_coor_tl) } ]#1) } + } + { \tl_put_right:Nn \l_tzsnake_cmd_tl { (#1) } } + + \tl_put_right:Nn \l_tzsnake_cmd_tl + { to ~node [ #3 ] { #2 } } + + \bool_if:NTF \l_tmpb_bool + {% if ++ + \tl_put_right:Nn \l_tzsnake_cmd_tl { ++ (#4) } + } + {% no ++ + \bool_if:NTF \l_tzsnake_shift_coor_bool + {% if shift + \tl_put_right:Nx \l_tzsnake_cmd_tl + { ([ shift = { (\l_tzsnake_shift_coor_tl) } ]#4) } + } + { \tl_put_right:Nn \l_tzsnake_cmd_tl { (#4) } } + } + + \tl_put_right:Nn \l_tzsnake_cmd_tl + { node [ #6 ] { #5 } } + + % final action + \tl_put_left:No \l_tzsnake_cmd_tl + { + \l_tzsnake_opt_tl ] % expand `once' needed + } + + \tl_put_left:Nx \l_tzsnake_cmd_tl + { + [ decorate , + decoration = + { snake , + pre~length = 5pt , post~length = 5pt , + amplitude = 2.5pt , + segment~length = \l_tzsnake_segment_length_tl , + \l_tzsnake_snake_opt_tl + } , + } + + \exp_last_unbraced:Nf \draw \l_tzsnake_cmd_tl #7 ; +} + +%%% --- end of \tzsnake + + +%%%(ADDED) +%%% \tzspy + +\NewDocumentCommand\tzspy{ s O{} G{2cm} O{5} r() r() O{} D<>{} } +{ + \IfBooleanTF { #1 } {}{} % (NOT USED!!!) + \spy [ circle , size = #3 , magnification = #4 , #2 ] + on (#5) in~node at (#6) [ #7 ] #8 ; +} + +%%% --- end of \tzspy + + + +%%%%% Arrows (copy from istgame.sty and modified) + + +%%%%% middle arrows + +%%% mid arrow styles +%% \tz@default... used + +%% defaults +\def\tz@default@midarrow@pos { .5 } % istgame: .55 +\def\tz@midarrow@pos { \tz@default@midarrow@pos } +\def\tz@default@midarrow@opt { } % istgame: black +\def\tz@midarrow@opt { \tz@default@midarrow@opt } +\def\tz@default@midarrow@shape { > } +\def\tz@midarrow@shape { \tz@default@midarrow@shape } +\newcommand*\tzmidarrowpos { \tz@midarrow@pos } +\newcommand*\tzmidarrowopt { \tz@midarrow@opt } +\newcommand*\tzmidarrowshape { \tz@midarrow@shape } + + +%% \settzmidarrow +%% to toss values to arrow tip styles +\NewDocumentCommand \settzmidarrow +{ + D<>{ \tz@default@midarrow@pos } + G{ \tz@default@midarrow@shape } + O{ \tz@default@midarrow@opt } +} +{ + \renewcommand*\tz@midarrow@pos { #1 } + \renewcommand*\tz@midarrow@shape { #2 } + \renewcommand*\tzmidarrowopt + { - , thin , solid , shorten~> = 0 , shorten~< = 0 , bend~right = 0 , #3 } +} + +%% initial set for defaults +\AtBeginDocument{\settzmidarrow} + +%% -->-- : position controllable by \settzmidarrow<pos> +\tikzset +{ -->-- /.style = + { + decoration = + { + markings , + mark = at~position~ #1 ~with~ + { \exp_last_unbraced:NNV \arrow [ \tzmidarrowopt ] { \tzmidarrowshape } } + } , + postaction = {decorate} + } , + -->-- /.default = \tz@midarrow@pos +} + + +\tikzset +{ --o-- /.style = + { + decoration = + { + markings , + mark = at~position~ #1 ~with~ + { +% \exp_last_unbraced:NNo \arrow [ \tzmidarrowopt ] { o } + \exp_last_unbraced:NNf + \draw [ \tzmidarrowopt ] (0,0) circle (1.2pt) ; + } + } , + postaction = {decorate} + } , + --o-- /.default = .5 % istgame: .55 +} + +\tikzset +{ --x-- /.style = + { + decoration = + { + markings , + mark + = at~position~ #1 ~with~ + { % use the option tzextend{2pt}{2pt} to change lenghts + \exp_last_unbraced:NNo + \draw [ \tzmidarrowopt ] (2pt,2pt) to (-2pt,-2pt) ; + \exp_last_unbraced:NNo + \draw [ \tzmidarrowopt ] (-2pt,2pt) to (2pt,-2pt) ; + } + } , + postaction = {decorate} + } , + --x-- /.default = .5 +} + +\tikzset +{ --/-- /.style = + { + decoration = + { + markings , + mark + = at~position~ #1 ~with~ + { % use the option tzextend{2pt}{2pt} to change lenghts + \exp_last_unbraced:NNo + \draw [ \tzmidarrowopt ] (2pt,2pt) to (-2pt,-2pt) ; +% \exp_last_unbraced:NNo +% \draw [ \tzmidarrowopt ] (-2pt,2pt) to (2pt,-2pt) ; + } + } , + postaction = {decorate} + } , + --/-- /.default = .5 +} + + %===================================================== %===================================================== \ExplSyntaxOff @@ -4603,5 +8492,27 @@ calligraphy, % for calligraphic brace (load after decorations.pathreplacing) %===================================================== +%%% mixed NE + +% tzEu +\NewDocumentCommand\TzEu{D(){LFname}O{}mmD<>{\tmpB}O{right}G{}} +{ +\def\tmpEu{(#3-#4)*\x+#4} +\def\tmpB{#3} %??? +\draw [name path=#1,#2] (0,#4) node [left] {#4} plot [domain=0:1] (\x,{\tmpEu}) node [right] {#5} node [#6] {#7}; +} + +% tzEu +%\NewDocumentCommand\TzEu{D(){LFname}O{}mmD<>{\tmpB}O{right}G{}} +\NewDocumentCommand\TzEU { O{} D""{} m m D[.{0} D.]{1} D<>{\tmpB} O{right} G{} } +{ +\def\tmpEU{(#3-#4)*\x+#4} +\def\tmpB{#3} %??? +%\draw [name path=#1,#2] (0,#4) node [left] {#4} plot [domain=0:1] (\x,{\tmpEu}) node [right] {#5} node [#6] {#7}; +\Tzfn [#1]"#2"{\tmpEU}[{#5}..{#6}] +\path (0,#4) node [left] {#4} plot [domain=0:1] (\x,{\tmpEU}) node [right] {#7} node [#8] {#9}; +} + + \endinput |