Debian Codegraph @

texmf-dist/doc/latex/tzplot/tzplot-doc-C-v2.2.tex

raw
1 %!TEX root = tzplot-doc.tex
2 %\begin{document}
3
4 %%%==========================
5 \part{Points, Lines, Curves, and Angles}
6 %%%==========================
7 \label{p:linesandcurves}
8
9
10 %%==================================
11 \chapter{Getting Ready}
12 \label{c:gettingready}
13
14 %%------------------------------------------------------------
15 \section{Styles: \texttt{tzdotted}, \texttt{tzdashed}, \texttt{tzhelplines}}
16 \label{s:styles:tzhelplines}
17
18 The styles \ixttw{tzdotted}, \ixttw{tzdashed}, and \ixttw{tzhelplines} are defined as follows:
19
20 \begin{tzsty}
21 % styles: tzdotted, tzdashed, tzhelplines
22 \tikzset{%
23 tzdotted/.style={line cap=round,dash pattern=on 0pt off 1cm/(#1)},
24 tzdotted/.default=10
25 }
26 \tikzset{%
27 tzdashed/.style={dashed=none,dash pattern=on 5mm/(#1) off 5mm/(#1)},
28 tzdashed/.default=10
29 }
30 \tikzset{%
31 tzhelplines/.style={help lines,-,tzdotted}
32 }
33 \end{tzsty}
34
35 The styles |tzdotted| and |tzdashed| print 10 dots and 10 dashes per 1cm, respectively, by default.
36 The style |tzhelplines| uses |tzdotted| by default.
37
38
39 %%------------------------------------------------------------
40 \section{\protect\cmd{\tzhelplines}, \protect\cmd{\tzhelplines*}}
41 \label{s:tzhelplines}
42
43 \icmd{\tzhelplines} draws |grid| from the first coordinate to the second coordinate.
44 If only one coordinate is specified, then the first coordinate is regarded as |(0,0)|.
45
46 The starred version \icmd{\tzhelplines*} uses the grid as a \iisw{bounding box}.
47
48 \begin{tzdef}
49 % syntax: minimum
50 \tzhelplines(<coor>)
51 % syntax: full
52 \tzhelplines[<opt>](<coor1>)(<coor2>)
53 % defaults
54 [help lines,tzdotted=10](<m>)()
55 % (<m>): mandatory argument
56 \end{tzdef}
57
58 Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument.
59
60 \begin{tztikz}
61 \tzhelplines(4,3) % works similarly to:
62 \draw [help lines] (0,0) grid (4,3);
63
64 \tzhelplines(1,1)(4,3) % works similarly to:
65 \draw [help lines] (1,1) grid (4,3);
66 \end{tztikz}
67
68
69 By default, |\tzhelplines| prints |grid| with |10| dots per |1cm|.
70 |\tzhelplines| with the option value |[tzdotted=<n>]| prints |<n>| dots per |1cm|.
71 (That is, the default value is |tzdotted=10|.)
72
73 \begin{tzcode}{.3}
74 % \tzhelplines
75 \begin{tikzpicture}
76 \tzhelplines(2,2)
77 \draw [help lines] (3,0) grid (5,2);
78 \end{tikzpicture}
79 \end{tzcode}
80
81
82 \begin{tzcode}{.3}
83 % tzdotted: (default: 10 dots per 1cm)
84 \begin{tikzpicture}
85 \tzhelplines[thick](1,2) % 10 dots
86 \tzhelplines[thick,tzdotted=20](2,0)(3,2) % 20 dots
87 \tzhelplines[thick,tzdotted=5](4,0)(5,2) % 5 dots
88 \end{tikzpicture}
89 \end{tzcode}
90
91 With the option value, |[tzdotted=<n>/<d>]|, |\tzhelplines| prints |<n>| dots per |<d>cm|.
92
93 Similarly for |tzdashed|.
94
95 \begin{tzcode}{.3}
96 % tzdotted, tzdashed
97 \begin{tikzpicture}
98 \tzhelplines[thick,tzdashed](4,2)
99 \tzhelplines[thick,step=.5](4,2)
100 \end{tikzpicture}
101 \end{tzcode}
102
103 \begin{tzcode}{.3}
104 % scaled: 7 dots per .7cm (10 dots per hard 1cm)
105 \begin{tikzpicture}[scale=.7]
106 \tzhelplines[tzdashed](4,3)
107 \tzhelplines[step=.5](4,3)
108 \end{tikzpicture}
109 \end{tzcode}
110
111 \begin{tzcode}{.3}
112 % scaled: 10/.7 means 10 dots per .7cm
113 \begin{tikzpicture}[scale=.7]
114 \tzhelplines[tzdashed=10/.7](4,3) %%
115 \tzhelplines[step=.5,tzdotted=10/.7](4,3) %%
116 \end{tikzpicture}
117 \end{tzcode}
118
119
120 %%------------------------------------------------------------
121 \section{\protect\cmd{\tzbbox}: A bounding box}
122 \label{s:tzbbox}
123
124 \icmd{\tzbbox} sets a bounding box.
125
126 \begin{tzdef}
127 % syntax
128 \tzbbox(<coor1>)(<coor2>)
129 % defaults
130 (0,0)(<m>)
131 % <m>: mandatory
132 \end{tzdef}
133
134 \begin{tztikz}
135 \tzbbox(-1,-1)(4,3) % is an abbreviation of:
136 \path [ use as bounding box ] (-1,-1) rectangle (4,3);
137 \end{tztikz}
138
139 If only one coordinate is specified, the first coordinate is regarded as |(0,0)|.
140
141 %%==================================
142 \chapter{Dots}
143 \label{c:dots}
144
145 %%------------------------------------------------------------
146 \section{\protect\cmd{\tzcdot(*)}: A small circle}
147 \label{s:tzcdot}
148
149 A dot is usually expressed by a small circle.
150 \icmd{\tzcdot} prints a circle dot \tikz \tzcdot(0,0);.
151
152 The starred version \icmd{\tzcdot*} prints a filled circle dot \tikz \tzcdot*(0,0);.
153 The \xem{radius} of the circle is |1.2pt|, by default.
154
155 \begin{tzdef}
156 % syntax: minimum
157 \tzcdot(<coor>)
158 % syntax: medium
159 \tzcdot*(<coor>){<label>}[<angle>](<radius>)
160 % syntax: full
161 \tzcdot*[<opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<radius>)
162 % defaults
163 *[ solid,thin,tzcdot=1.2pt ]<>(<m>){}[](1.2pt)
164 % tzcdot is a predefined key (in this package).
165 % <m>: mandatory
166 \end{tzdef}
167
168 Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument. All others are optional arguments.
169
170 \paragraph{How to change the size}
171 There are \textsc{Three Ways} to change the \xem{radius} of a circle dot drawn by |\tzcdot|.
172
173 \begin{enumerate}
174 \item The simplest way is to use the \xem{last parenthesis option}, like |\tzcdot(0,0)(3pt)|.
175
176 \begin{tztikz}
177 \tzcdot(0,0) % is an abbreviation of:
178 \draw (0,0) circle (1.2pt); % default radius=1.2pt
179 \end{tztikz}
180
181 \begin{tztikz}
182 \tzcdot*(0,0)(3pt) % is an abbreviation of:
183 \draw [fill] (0,0) circle (3pt);
184 \end{tztikz}
185
186 \item
187 You can use the key-value option |[tzcdot=<dim>]|, like |\tzcdot[tzcdot=3pt](0,0)|, to change the \xem{radius} of a circle dot. The |tzcdot| key is defined in the package.
188 If both the |tzcdot| key-value and the last parenthesis option are used, the former wins.
189
190 \begin{tztikz}
191 \tzcdot*(1,1) % works like:
192 \draw [fill] (1,1) circle [radius=1.2pt]; % default radius=1.2pt
193 \end{tztikz}
194
195 \begin{tztikz}
196 \tzcdot*[tzcdot=3pt] % works like:
197 \draw [fill] (0,0) circle [radius=3pt];
198 \end{tztikz}
199
200 \begin{tzcode}{.3}
201 % \tzcdot(*)
202 \begin{tikzpicture}
203 \tzhelplines(4,2)
204 \tzcdot(0,0) \tzcdot[tzcdot=4pt](1,1)
205 \tzcdot*(2,1)(2pt) \tzcdot*(3,0)(3pt)
206 \end{tikzpicture}
207 \end{tzcode}
208
209 \item
210 Another way to change the radius is to use a macro, like |\settzcdotradius{3pt}|.
211 It is effective within the |tizpicture| environment unless changed by \icmd{\settzcdotradius} again.
212
213 \begin{tzcode}{.3}
214 % \settzcdotradius
215 \begin{tikzpicture}
216 \tzhelplines(4,2)
217 \settzcdotradius{4pt}
218 \tzcdot(0,0) \tzcdot(1,1)
219 \tzcdot*(2,1)(2pt) \tzcdot*(3,0)
220 \end{tikzpicture}
221 \end{tzcode}
222
223 \end{enumerate}
224
225
226 \paragraph{How to label}
227 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>]|.
228
229 \begin{tztikz}
230 \tzcdot(0,0){A} % is an abbreviation of:
231 \draw (0,0) circle (1.2pt) node [label={:A}] {};
232
233 \tzcdot(0,0)(2pt){A}[[blue]0] % is an abbreviation of:
234 \draw (0,0) circle (2pt) node [label={[blue]0:A}] {};
235 \end{tztikz}
236
237 \begin{tzcode}{.3}
238 % \tzcdot: labels
239 \begin{tikzpicture}
240 \tzhelplines(4,3)
241 \tzcdot(0,0){A} % default position: 90 or above
242 \tzcdot[tzcdot=4pt](1,1){B}[0]
243 \tzcdot*(2,1){C}[45](2pt)
244 \tzcdot*(3,0){D}[-90](3pt)
245 \tzcdot(4,3){E}[-90](6pt)
246 \end{tikzpicture}
247 \end{tzcode}
248
249 In \Tikz, the distance from the coordinate center to a label does not depend on the size of circle dots.
250
251 \paragraph{How to change colors}
252 With the first optional argument |[<opt>]|, you can change the color of a dot.
253 You can also change the color of a label, as shown in the following example.
254
255 \begin{tzcode}{.3}
256 % \tzcdot(*): color, fill
257 \begin{tikzpicture}
258 \draw [help lines] (0,0) grid (4,3);
259 \tzcdot(0,0){A}
260 \tzcdot*[red](1,0){\textbf{B}}[45]
261 \tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt)
262 \tzcdot[tzcdot=2*7pt](3,2){big}[center]
263 \tzcdot*[fill=red,text=blue](4,3){D}(2*3pt)
264 \end{tikzpicture}
265 \end{tzcode}
266
267
268 \paragraph{Shift}
269 Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The \xem{empty} shift option |<>| is \xem{not allowed}.
270
271 \begin{tzcode}{.3}
272 % \tzcdot: shift
273 \begin{tikzpicture}
274 \draw [help lines] (0,0) grid (4,3);
275 \tzcdot(0,0){A}
276 \tzcdot*[red]<0,2>(1,0){\textbf{B}}[45] % shift
277 \tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt)
278 \tzcdot[tzcdot=2*7pt]<1,-1>(3,2){big}[center] % shift
279 \tzcdot*[fill=red,text=blue](4,3){D}(2*3pt)
280 \end{tikzpicture}
281 \end{tzcode}
282
283 \begin{tzcode}{.3}
284 % \tzcdot: repeated
285 \begin{tikzpicture}
286 \tzhelplines(4,2)
287 \foreach \x in {0,...,4}
288 { \foreach \A in {2,4,6,8}
289 { \tzcdot[blue] (\x,0)(\A pt) } }
290 \foreach \x in {0,...,4}
291 { \foreach \A in {2,4,6,8}
292 { \tzcdot[red]<1,1>(\x,0)(\A pt) } } % shift
293 \end{tikzpicture}
294 \end{tzcode}
295
296
297 %%------------------------------------------------------------
298 \section{\protect\cmd{\tzcdots(*)}: Multiple circle dots}
299 \label{s:tzcdots}
300
301 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.
302 You need to indicate when the iteration of an arbitrary number of coordinates ends, by typing a \xem{semicolon} |;|.
303 Let us call this kind of macro a \iisw{semicolon version} macro.
304
305 \remark
306 \begin{itemize}
307 \item DO NOT FORGET to enter `|;|' at the end of iteration.
308 \item Without the semicolon |;|, an error occurs with the the \iisw{error message}:
309 \begin{verbatim}
310 ! Package tzplot Error: You may have forgotten a semicolon here or above!
311 \end{verbatim}
312 \end{itemize}
313
314
315 The starred version \icmd{\tzcdots*} prints multiple filled dots.
316
317 \begin{tzdef}
318 % syntax: minimum
319 \tzcdots*(<coor>)(<coor>)..repeated..(<coor>) ;
320 % syntax: full
321 \tzcdots*[<opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>]
322 ..repeated.. (){}[] ; (<dot radius>)
323 % defaults
324 *[tzcdot=1.2pt]<>(<m>){}[]..repeated..(){}[] ; (1.2pt)
325 \end{tzdef}
326
327 \begin{tzcode}{.3}
328 % \tzcdots(*)
329 \begin{tikzpicture}
330 \tzhelplines(4,3)
331 \tzcdots(0,0)(1,1)(2,1)(3,2)(4,0);
332 \tzcdots*(0,3)(1,2)(2,2)(3,3)(4,3); % semicolon
333 \end{tikzpicture}
334 \end{tzcode}
335
336 \paragraph{How to label}
337
338 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>|.
339
340 \begin{tzcode}{.3}
341 % \tzcdots: label
342 \begin{tikzpicture}
343 \tzhelplines(4,3)
344 \tzcdots(0,0){A}
345 (1,1)
346 (2,1){C}[0]
347 (3,2){D}[-90]
348 (4,0){E}[[red,draw]45];
349 \tzcdots*(0,3)(1,2){B}[-135](2,2){C}[45](3,3)(4,3);
350 \end{tikzpicture}
351 \end{tzcode}
352
353 \paragraph{How to change the size of dots}
354
355 There are \textsc{Three Ways} of changing the \xem{radius} of dots.
356 \begin{enumerate}
357 \item The simplest way is to use the \xem{last} parenthesis optional argument, \xem{after the semicolon}.
358 \item Another way is to use the \ixxw{tzcdot} key, like |\tzcdots[tzcdot=3pt]...|.
359 If both options are used the key-value option wins.
360 \item You can also use the macro \icmd{\settzcdotradius}.
361 The effect remains within the |tikzpicture| environment unless it is changed again.
362 \end{enumerate}
363
364 \begin{tzcode}{.3}
365 % \tzcdots: size (radius)
366 \begin{tikzpicture}
367 \tzhelplines(4,3)
368 \settzcdotradius{3pt}
369 \tzcdots(0,0)(1,0){3pt};
370 \tzcdots*(1,1)(2,1){1pt};(1pt) % simplest
371 \tzcdots[tzcdot=5pt](2,2)(3,2){5pt};
372 \tzcdots*(3,3)(4,3){3pt};
373 \end{tikzpicture}
374 \end{tzcode}
375
376
377
378 \paragraph{How to change colors}
379
380 With the first optional argument |[<opt>]|, you can change the color of dots.
381 You can also change the color of all labels at once using the first optional argument,
382 like |\tzcdots[text=red]...| as shown in the following example.
383
384 \begin{tzcode}{.3}
385 % \tzcdots: color
386 \begin{tikzpicture}
387 \tzhelplines(4,3)
388 \settzcdotradius{3pt}
389 \tzcdots*[red]
390 (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
391 \tzcdots*[thick,blue,fill=green,text=red]
392 (1,2){A}(2,2){Ben}[[blue]-90](3,2){C}(4,2){D};(4pt)
393 \tzcdots*[blue]
394 (1,3){A}(2,3){B}(3,3){C}(4,3){D};
395 \end{tikzpicture}
396 \end{tzcode}
397
398 \paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate.
399
400 \begin{tzcode}{.3}
401 % \tzcdots: shift
402 \begin{tikzpicture}
403 \tzhelplines(4,3)
404 \tzcdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
405 \tzcdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
406 \end{tikzpicture}
407 \end{tzcode}
408
409
410 %%------------------------------------------------------------
411 \section{\protect\cmd{\tzdot(*)}: A single node dot}
412 \label{s:tzdot}
413
414 The macro \icmd{\tzdot} prints a small circle node \tikz \tzdot(0,0);, as a dot, with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default.
415
416 The starred version \icmd{\tzdot*} prints a filled dot \tikz \tzdot*(0,0);.
417
418 \begin{tzdef}
419 % syntax: minimum
420 \tzdot(coor)
421 % syntax: medium
422 \tzdot*(<coor>){<label>}[<angle>](<dot size>)
423 % syntax: full
424 \tzdot*[<node opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<dot size>)
425 % defaults
426 *[ tzdot=2.4pt ]<>(<m>){}[](2.4pt)
427 % the style tzdot is predefined
428 % (<m>): mandatory
429 \end{tzdef}
430
431 |\tzdot(*)| accepts one mandatory argument, denoted by |(|\ixxw{<m>}|)|. All others are optional.
432
433 The style \ixxw{tzdot} is predefined in this package as follows:
434
435 \begin{tzsty}
436 % style: tzdot
437 \tikzset{
438 tzdot/.style={draw,circle,solid,thin,inner sep=0pt,minimum size=#1},
439 tzdot/.default=2.4pt
440 }
441 \end{tzsty}
442
443
444 \subsection{{\normalfont\scshape Three Ways} to change the size of node dots}
445 \label{ss:threeways}
446
447 There are \iscw{Three Ways} to change the \xem{diameter} (or |minimum size|) of a node dot drawn by |\tzdot(*)|.
448
449 \begin{enumerate}
450 \item Use the predefined style |tzdot| in the first optional agrument, like |\tzdot[tzdot=5pt](0,0)|, which gives the same result as |\tzdot[minimum size=5pt](0,0)|.
451
452 \begin{tztikz}
453 \tzdot(0,0) % works like:
454 \path (0,0) node [tzdot=2.4pt] {}; % default size
455 % or equivalently
456 \node [tzdot,minimum size=2.4pt] at (0,0) {};
457 \end{tztikz}
458
459 \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)|.
460 If both options are used, the \ixxw{tzdot} (or |minimum size|) option overwrites the last parenthesis option.
461
462 \begin{tzcode}{.3}
463 % \tzdot(*)
464 \begin{tikzpicture}
465 \tzhelplines(4,2)
466 \tzdot(0,0) \tzdot[tzdot=8pt](1,1)
467 \tzdot*(2,1)(4pt) \tzdot*(3,0)(6pt)
468 \end{tikzpicture}
469 \end{tzcode}
470
471 \item You can use the macro \icmd{\settzdotsize} to change the size (or diameter) of all node dots drawn by |\tzdot*|. It is effective within the |tikzpicture| environment unless changed again.
472
473 \begin{tzcode}{.3}
474 % \settzdotsize
475 \begin{tikzpicture}
476 \tzhelplines(4,2)
477 \settzdotsize{8pt}
478 \tzdot(0,0) \tzdot(1,1)
479 \tzdot*(2,1)(4pt) \tzdot*(3,0)
480 \end{tikzpicture}
481 \end{tzcode}
482
483 \end{enumerate}
484
485 \subsection{How to label}
486 \label{ss:tzdot:label}
487
488 You can add a label to a specified coordinate by specifying the optional argument |{<label>}| immediately after the coordinate |(<coor>)|.
489 You can also change the label position by the option |[<angle>]| or |[<[label opt]angle>]| following |{<label>}|.
490
491 \begin{tztikz}
492 \tzdot(0,0){A}(3pt) % works like:
493 \path (0,0) node [tzdot=3pt,label={:A}] {};
494
495 \tzdot*(0,0){A}[[red]0](3pt) % works like:
496 \path (0,0) node [fill,tzdot=3pt,label={[red]0:A}] {};
497 \end{tztikz}
498
499
500 \begin{tzcode}{.3}
501 % \tzdot: labels
502 \begin{tikzpicture}
503 \tzhelplines(4,3)
504 \tzdot(0,0){A}
505 \tzdot(1,1){B}[0](8pt)
506 \tzdot*(2,1){C}[45](4pt)
507 \tzdot*(3,0){D}[-90](6pt)
508 \tzdot(4,3){E}[[red,draw]br](12pt) % string replacement
509 \end{tikzpicture}
510 \end{tzcode}
511
512 \paragraph{String replacement}
513 (See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement}.)
514 \begin{itemize}\firmlist
515 \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.
516 \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.
517 \item So |[[blue,draw]-45]|, |[[blue,draw]below right]|, and |[[blue,draw]br]| give the same result.
518 \end{itemize}
519
520 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.
521
522
523 \subsection{How to change colors and shapes}
524 \label{ss:tzdot:color}
525
526 With the first optional argument |[<node opt>]|, you can change of the color or shape of dots.
527 You can also change the label color using |[<label opt>]| as shown in the following example.
528
529 \remark
530 \begin{itemize}\firmlist
531 \item |[<node opt>]| is for options of \xem{main nodes}, |[<label opt>]| is for options of \xem{label nodes}.
532 \item |[<label opt>]| is used in the form of |[<[<label opt>]angle>]|.
533 \end{itemize}
534
535 \begin{tzcode}{.3}
536 % \tzdot: color
537 \begin{tikzpicture}
538 \draw [help lines] (0,0) grid (4,3);
539 \tzdot(0,0){A}
540 \tzdot*[red](1,0){\textbf{B}}[45]
541 \tzdot*[red,fill=green](2,1){green}[[blue]0](2*10pt)
542 \tzdot[tzdot=4*7pt](3,2){big}[center]
543 \tzdot*[fill=red](4,3){D}(4*3pt)
544 \end{tikzpicture}
545 \end{tzcode}
546
547
548 \begin{tzcode}{.3}
549 % \tzdot: shape
550 \begin{tikzpicture}
551 \draw [help lines] (0,0) grid (4,3);
552 \tzdot[regular polygon](0,0){A}(10pt)
553 \tzdot*[red](1,0){\textbf{B}}[45]
554 \tzdot*[red,green,rectangle](2,1){green}[0](2*10pt)
555 \tzdot[tzdot=4*7pt](3,2){big}[center]
556 \tzdot*[fill=red,star](4,3){D}(4*3pt)
557 \end{tikzpicture}
558 \end{tzcode}
559
560
561
562 \subsection{How to move: \texttt{shift}}
563 \label{ss:tzdot:shift}
564
565 Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed.
566
567 \begin{tzcode}{.3}
568 % \tzdot: shift
569 \begin{tikzpicture}
570 \draw [help lines] (0,0) grid (4,3);
571 \tzdot[regular polygon](0,0){A}(10pt)
572 \tzdot*[red]<0,2>(1,0){\textbf{B}-shifted}[45] % shift
573 \tzdot*[red,green,rectangle](2,1){green}[0](2*10pt)
574 \tzdot[tzdot=4*7pt]<1,-1>(3,2){big}[center] % shift
575 \tzdot*[fill=red,star](4,3){D}(4*3pt)
576 \end{tikzpicture}
577 \end{tzcode}
578
579
580 \begin{tzcode}{.3}
581 % \tzdot: repeated
582 \begin{tikzpicture}
583 \tzhelplines(4,2)
584 \foreach \x in {0,...,4}
585 { \foreach \A in {1,2,3,4}
586 { \tzdot[blue] (\x,0)(2*\A mm) } }
587 \foreach \x in {0,...,4}
588 { \foreach \A in {1,2,3,4}
589 { \tzdot[green]<1,1>(\x,0)(2*\A mm) } } % shift
590 \end{tikzpicture}
591 \end{tzcode}
592
593
594 \subsection{Comparison: \protect\cmd{\tzdot} and \protect\cmd{\tzcdot}}
595 \label{ss:tzdot:comparison}
596
597 The most important difference between |\tzcdot| and |\tzdot| is that |\tzcdot| is affected by \Tikz's scaling factor, but |\tzdot| is not.
598 This is critical when |xscale| is not equal to |yscale|.
599
600 \begin{tzcode}{.3}
601 \begin{tikzpicture}[xscale=1.6,yscale=.8]
602 \tzhelplines(3,3)
603 \tzcdot(0,0)(3pt) % dostorted
604 \tzdot(1,0)(6pt)
605 \tzcdots*(1,1)(2,1)(3,1);(2pt) % distorted
606 \tzdots*(1,2)(2,2)(3,2);(4pt)
607 \end{tikzpicture}
608 \end{tzcode}
609
610 The following table further shows the differences between them.
611 %Everything else is the same for end-users.
612
613 \begin{tzcode}{.3}[listing only,colback=green!10!white]
614 % concept % single % multi % size control % [key=default size]
615 node [circle] \tzdot \tzdots \settzdotsize [tzdot=2.4pt] % diameter
616 circle \tzcdot \tzcdots \settzcdotradius [tzcdot=1.2pt] % radius
617 \end{tzcode}
618
619 \remark
620 \begin{itemize}\firmlist
621 \item In \Tikz, a `node' is `not' affected by `scaling' unless the \Tikz\ option |transform shape| is used together.
622 |\tzdot| is also useful for labelling a large dot.
623 \begin{itemize}
624 \item In |\tzdot|, |<label>| is a label in a \iisw{label node} for a node dot (as a \iisw{main node}).
625 So if a main node dot gets larger or smaller, its label moves accordingly.
626 (Unlike, the labels with |\tzcdot| or |\tzcdots|.)
627 \item The position of |<label>| in |\tzcdot| does not depend on the size of dots.
628 \end{itemize}
629 \item The package |tzplot| takes |\tzdot| as a \xem{standard dot}, not |\tzcdot|.
630 So, you can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of any standard dots.
631 \end{itemize}
632
633
634 %%------------------------------------------------------------
635 \section{\protect\cmd{\tzdots(*)}: Multiple node dots}
636 \label{s:tzdots}
637
638 \icmd{\tzdots} takes an arbitrary number of coordinates as arguments to print multiple circle node dots with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default.
639
640 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}."
641
642 \remark
643 \begin{itemize}\firmlist
644 \item DO NOT FORGET to enter `|;|' at the end of iteration.
645 \item Without the semicolon |;|, an error occurs with the error message:
646 \begin{verbatim}
647 ! Package tzplot Error: You may have forgotten a semicolon here or above!
648 \end{verbatim}
649 \end{itemize}
650
651 The starred version \icmd{\tzdots*} prints multiple filled node dots.
652
653 \begin{tzdef}
654 % syntax: minimum
655 \tzdots*(<coor>)(<coor>)..repeated..(<coor>) ;
656 % syntax: full
657 \tzdots*[<node opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>]
658 ..repeated.. (){}[] ; (<dot size>)
659 % defaults
660 *[tzdot=2.4pt]<> (<m>){}[] ..repeated.. (){}[] ; (2.4pt)
661 \end{tzdef}
662
663 \begin{tzcode}{.3}
664 % \tzdots(*)
665 \begin{tikzpicture}
666 \tzhelplines(4,3)
667 \tzdots(0,0)(1,1)(2,1)(3,2)(4,0);
668 \tzdots*(0,3)(1,2)(2,2)(3,3)(4,3); % semicolon
669 \end{tikzpicture}
670 \end{tzcode}
671
672 \paragraph{How to label}
673
674 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.
675 (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}
676
677 \begin{tzcode}{.3}
678 % \tzdots: label
679 \begin{tikzpicture}
680 \tzhelplines(4,3)
681 \tzdots(0,0){A}
682 (1,1)
683 (2,1){C}[0]
684 (3,2){D}[b] % string replacement
685 (4,0){E};
686 \tzdots*(0,3)(1,2){B}(2,2){C}[45](3,3)(4,3);
687 \end{tikzpicture}
688 \end{tzcode}
689
690
691
692 \paragraph{How to change the size of dots}
693
694 There are \threeways\ of changing the \xem{diameter} of node dots, as discussed in Section \ref{ss:threeways} on page \pageref{ss:threeways}.
695
696 \begin{enumerate}
697 \item The simplest way is to use the \xem{last} parenthesis optional argument, \xem{after the semicolon}.
698 \item Another way is to use the style \ixxw{tzdot}, like |\tzdots[tzdot=3pt]...|.
699 If both options are used the |tzdot| option style wins.
700 \item You can also use the macro \icmd{\settzdotsize}.
701 The effect remains within the |tikzpicture| environment unless it is changed again.
702 \end{enumerate}
703
704 \begin{tzcode}{.3}
705 % \tzdots: size (diameter)
706 \begin{tikzpicture}
707 \tzhelplines(4,3)
708 \settzdotsize{3mm}
709 \tzdots(0,0)(1,0){3mm};
710 \tzdots*(1,1)(2,1){2mm};(2mm) % simplest
711 \tzdots[tzdot=4mm](2,2)(3,2){4mm};
712 \tzdots*(3,3)(4,3){3mm};
713 \end{tikzpicture}
714 \end{tzcode}
715
716
717
718 \paragraph{How to change colors}
719
720 With the first optional argument |[<node opt>]| you can change the color of node dots.
721 You can also change the color of each label by |[<label opt>]|.
722
723 \begin{tzcode}{.3}
724 % \tzdots: color
725 \begin{tikzpicture}[->]
726 \tzhelplines(4,3)
727 \settzdotsize{6pt}
728 \tzdots*[red]
729 (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
730 \tzdots*[thick,blue,fill=green]
731 (1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt)
732 \tzdots*[blue]
733 (1,3){A}(2,3){B}(3,3){C}(4,3){D};
734 \end{tikzpicture}
735 \end{tzcode}
736
737 \remark
738 \begin{itemize}
739 \item |[<node opt>]| is the option of a \iisw{main node} and |[<label opt>]| is the option of a \iisw{label node}.
740 \item |[<label opt>]| is used in the form of |[<[<label opt>]angle>]|, like |[[red]90]|.
741 \item You can control all labels together using |every label/.style| as in the following examples:
742 \end{itemize}
743
744 \begin{tzcode}{.3}
745 % \tzdots: every label/.style
746 \begin{tikzpicture}
747 \tzhelplines(4,3)
748 \settzdotsize{6pt}
749 \tzdots*[red]
750 (0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
751 \tzdots*[thick,blue,fill=green]
752 (1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt)
753 \tikzset{every label/.style={draw,text=red}} %%
754 \tzdots*[blue]
755 (1,3){A}(2,3){B}(3,3){C}(4,3){D}[0];
756 \end{tikzpicture}
757 \end{tzcode}
758
759
760 \begin{tzcode}{.3}
761 % every label/.style
762 \begin{tikzpicture}[every label/.style={draw,text=red}]
763 \tzhelplines(4,3)
764 \tzdots*
765 (0,0){Ace}[[font=\LARGE\ttfamily]-90]
766 (2,1){\textbf{Bob}}[[blue]135]
767 (3,2){$C_1$\\$N_o$}[[align=center]0];
768 \end{tikzpicture}
769 \end{tzcode}
770
771
772 \paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate.
773 The \xem{empty} shift option |<>| is \xem{not allowed}.
774
775 \begin{tzcode}{.3}
776 % \tzdots: shift
777 \begin{tikzpicture}
778 \tzhelplines(4,3)
779 \tzdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
780 \tikzset{every label/.style={red}}
781 \tzdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
782 \end{tikzpicture}
783 \end{tzcode}
784
785
786
787 %%==================================
788 \chapter{Coordinates}
789 \label{c:coordinates}
790
791 %%------------------------------------------------------------
792 \section{\protect\cmd{\tzcoor} and \protect\cmd{\tzcoor*}}
793 \label{s:tzcoor}
794
795 \subsection{\protect\cmd{\tzcoor}}
796 \label{ss:tzcoor}
797
798 For example, \icmd{\tzcoor}|(0,0)(A)| means that the coordinate |(0,0)| is named |(A)|.
799
800 \begin{tztikz}
801 \tzcoor(0,0)(A) % is an abbreviation of:
802 \path (0,0) coordinate (A);
803 % or
804 \coordinate (A) at (0,0);
805 \end{tztikz}
806
807 \begin{tzdef}
808 % syntax: minimum
809 \tzcoor(<coor>)(<name>)
810 % syntax: medium
811 \tzcoor(<coor>)(<name>){<label>}[<angle>]
812 % syntax: full
813 \tzcoor<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
814 % defaults
815 <>(<m>)(<m>){}[]
816 \end{tzdef}
817
818 Here, |<m>| stands for `mandatory.' |\tzcoor| takes two mandatory arguments in parenthesis.
819
820 \paragraph{How to label}
821 You can put a label to a coordinate by specifying the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|.
822
823 \begin{tztikz}
824 \tzcoor(0,0)(A){$A$}[0] % works like:
825 \path (0,0) coordinate [label={0:$A$}] (A);
826 \end{tztikz}
827
828 \begin{tzcode}{.3}
829 % \tzcoor
830 \begin{tikzpicture}
831 \tzhelplines(4,3)
832 \tzcoor(0,0)(A){$A_1$} % TikZ default: 90 or above
833 \tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0]
834 \draw (A) -- (B);
835 \end{tikzpicture}
836 \end{tzcode}
837
838 \paragraph{Shift}
839 You can move the coordinate by specifying the optional argument |<shift coor>| before |(<coor>)|.
840 The \xem{empty} shift option |<>| is \xem{not allowed}.
841
842 \begin{tzcode}{.3}
843 % \tzcoor: shift
844 \begin{tikzpicture}
845 \tzhelplines(4,3)
846 \tzcoor<0,1>(0,0)(A){$A_1$} %%
847 \tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0]
848 \tzline(A)(B)
849 \end{tikzpicture}
850 \end{tzcode}
851
852
853 \subsection{\protect\cmd{\tzcoor*}}
854 \label{ss:tzcoor*}
855
856 The starred version \icmd{\tzcoor*} works like |\tzcoor| with one exception. It prints a `node dot' of the size |2.4pt|, by default, at a specified coordinate.
857
858 \begin{tzdef}
859 % syntax: minimum
860 \tzcoor*(<coor>)(<coor name>)
861 % syntax: medium
862 \tzcoor*(<coor>)(<coor name>){<label>}[<angle>]
863 % syntax: full
864 \tzcoor*[<dot opt>]<shift coor>
865 (<coor>)(<name>){<label>}[[<label opt>]<angle>](<dot size>)
866 % defaults
867 *[]<>(<m>)(<m>){}[](2.4pt)
868 \end{tzdef}
869
870
871 \begin{tztikz}
872 \tzcoor*(0,0)(A) % works like:
873 \path (0,0) coordinate (A);
874 \tzdot*(0,0)
875 \end{tztikz}
876
877 \begin{tztikz}
878 \tzcoor(0,0)(A){$A$}[right] % works like:
879 \path (0,0) coordinate (A);
880 \tzdot*(0,0){$A$}[right]
881 \end{tztikz}
882
883 \begin{tzcode}{.3}
884 % \tzcoor*
885 \begin{tikzpicture}
886 \tzhelplines(4,3)
887 \tzcoor*(0,0)(A){$A_1$} % TikZ default: 90 or above
888 \tzcoor*(30:3cm)(B){$B_2$}[[draw,blue]0]
889 \draw (A) -- (B);
890 \end{tikzpicture}
891 \end{tzcode}
892
893 \paragraph{Changing the color and size of a dot}
894
895 You can change the color of a dot by specifying |[<dot opt>]|, which is, in fact, \Tikz's |node| option.
896 To change the size of dots, you can apply the \threeways\ (see Subsection \ref{ss:threeways} on page \pageref{ss:threeways}).
897
898 \begin{tzcode}{.3}
899 % \tzcoor*: color, size
900 \begin{tikzpicture}
901 \tzhelplines(4,3)
902 \tzcoor(1,1)(A){A}
903 \tzcoor*(2,1)(B){B}[0]
904 \tzcoor*[red](1,2)(C){C}[[blue,draw]l] % abb
905 \tzcoor*[fill=none,tzdot=5pt](3,2)(D){D}[45]
906 \tzcoor*[blue,thick,fill=green](4,0)(E){E}[180](6pt)
907 \end{tikzpicture}
908 \end{tzcode}
909
910 \paragraph{Shift} The optional argument |<shift coor>| works just like in |\tzcoor|.
911 The \xem{empty} shift option |<>| is \xem{not allowed}.
912
913 \begin{tzcode}{.3}
914 % \tzcoor*: shift
915 \begin{tikzpicture}
916 \tzhelplines(4,3)
917 \tzcoor*<0,1>(0,0)(A){$A_1$} %%
918 \tzcoor*(2,1)(B){$B_2$\\end point}[[align=left,red]0]
919 \tzline(A)(B)
920 \end{tikzpicture}
921 \end{tzcode}
922
923 %%------------------------------------------------------------
924 \section{\protect\cmd{\tzcoors} and \protect\cmd{\tzcoors*}: Semicolon versions}
925 \label{s:tzcoors}
926
927 \subsection{\protect\cmd{\tzcoors}}
928 \label{ss:tzcoors}
929
930 The macro \icmd{\tzcoors} takes an \xem{arbitrary number of pairs} of coordinates and their names as arguments.
931 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)|.
932
933 \begin{tzdef}
934 % syntax: minimum
935 \tzcoors(<coor>)(<name>..repeated..(<coor>)(<name>) ;
936 % syntax: full
937 \tzcoors <shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
938 ..repeated.. ()(){}[] ;
939 % defaults
940 <> (<m>)(<m>){}[] ..repeated.. ()(){}[] ;
941 \end{tzdef}
942
943 This is a \xem{semicolon version} macro. The quadruple |(<coor>)(<name>){<label>}[<angle>]| is the whole repeating pattern.
944 It is required to type a \xem{semicolon} `|;|' to indicate when the coordinate repetition ends.
945
946
947 \begin{tztikz}
948 \tzcoors (0,0)(A) (1,1)(B) (2,1)(C) (3,0)(D) ; % works like:
949 \path (0,0) coordinate (A)
950 (1,1) coordinate (B)
951 (2,1) coordinate (C)
952 (3,0) coordinate (D);
953 \end{tztikz}
954
955 \begin{tztikz}
956 \tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C}[0] (3,0)(D){D}[90]; % works like:
957 \path (0,0) coordinate (A)
958 (1,1) coordinate (B)
959 (2,1) coordinate [label={0:C}] (C)
960 (3,0) coordinate [label={90:D}] (D);
961 \end{tztikz}
962
963 You can add a label to each specified coordinate by adding the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|.
964
965 \begin{tzcode}{.3}
966 % \tzcoors
967 \begin{tikzpicture}
968 \tzcoors (0,0)(A){Ace}[[font=\LARGE\ttfamily]-90]
969 (2,1)(B){\textbf{Bob}}[[blue]135]
970 (3,2)(C){$C_1$\\$N_o$}[[align=center]0];
971 \draw (A) -- (B) -- (C);
972 \end{tikzpicture}
973 \end{tzcode}
974
975 By the option |<shift coor>|, all specified coordinates are shifted.
976 The \xem{empty} shift option |<>| is \xem{not allowed}.
977
978 \begin{tzcode}{.3}
979 % \tzcoors
980 \begin{tikzpicture}
981 \tzhelplines(4,3)
982 \tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D);
983 \tzlines(A)(B)(C)(D);
984 % shift
985 \tzcoors <1,1> (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D);
986 \tzlines[dashed](A)(B)(C)(D);
987 \end{tikzpicture}
988 \end{tzcode}
989
990
991 \subsection{\protect\cmd{\tzcoors*}}
992 \label{ss:tzcoors*}
993
994 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.
995
996 The full repeating pattern is |(<coor>)(<name>){<label>}[<angle>]|.
997 It is required to type a \xem{semicolon} `|;|' to indicate when the iteration of coordinates ends.
998
999 \begin{tzdef}
1000 % syntax: minimum
1001 \tzcoors*(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
1002 % syntax: full
1003 \tzcoors*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
1004 ..repeated.. ()(){}[] ; (<dot size>)
1005 % defaults
1006 *[]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt)
1007 \end{tzdef}
1008
1009 You can label each dot by specifying the optional arguments |{<label>}| and |[<angle>]| after the pair |(<coor>)(<name>)|.
1010
1011 \begin{tzcode}{.3}
1012 % \tzcoors*
1013 \begin{tikzpicture}
1014 \tzhelplines(4,3)
1015 \tzcoors*(0,0)(A)
1016 (1,1)(B){B}
1017 (2,1)(C)
1018 (3,3)(D){D}[0] ; % semicolon
1019 \end{tikzpicture}
1020 \end{tzcode}
1021
1022 You can change the dot color by |[<dot opt>]| and the label color by |[<label opt>]|.
1023 You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the dot size. The simplest way of changing the dot size is to specify the \xem{last} (even after the semicolon) parenthesis option |(<dot size>)|.
1024
1025 \begin{tzcode}{.3}
1026 % \tzcoors*
1027 \begin{tikzpicture}
1028 \tzhelplines(4,3)
1029 \tzcoors*[red](0,0)(A)
1030 (1,1)(B){B}
1031 (2,1)(C)
1032 (3,3)(D){D}[[blue]0] ; (6pt)
1033 \end{tikzpicture}
1034 \end{tzcode}
1035
1036 By specifying the optional argument |<shift coor>| immediately before the first coordinate, you can move all specified coordinates.
1037 The \xem{empty} shift option |<>| is \xem{not allowed}.
1038
1039 \begin{tzcode}{.3}
1040 % \tzcoors*: shift
1041 \begin{tikzpicture}
1042 \tzhelplines(4,3)
1043 \settzdotsize{6pt}
1044 \tzcoors*[red] (0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D);
1045 \settzdotsize{4pt}
1046 \tzcoors*[blue]<.5,0>(0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D);
1047 \end{tikzpicture}
1048 \end{tzcode}
1049
1050
1051 %%------------------------------------------------------------
1052 \section{\protect\cmd{\tzcoorsquick} and \protect\cmd{\tzcoorsquick*}: Semicolon versions}
1053 \label{s:tzcoorsquick}
1054
1055 \subsection{\protect\cmd{\tzcoorsquick}}
1056 \label{ss:tzcoorsquick}
1057
1058 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.
1059
1060 \begin{tzdef}
1061 % syntax: minimum
1062 \tzcoorsquick(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
1063 % syntax: full
1064 \tzcoorsquick<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
1065 ..repeated.. ()(){}[] ;
1066 % defaults
1067 <> (<m>)(<m>){}[center] ..repeated.. ()(){}[] ;
1068 \end{tzdef}
1069
1070 \begin{tzcode}{.3}
1071 % \tzcoorsquick
1072 \begin{tikzpicture}
1073 \tzhelplines(4,3)
1074 \tzcoorsquick(0,0)(A)
1075 (1,1)(Ben)
1076 (2,1)(Cate)
1077 (3,2)(Daniel); % semicolon
1078 \end{tikzpicture}
1079 \end{tzcode}
1080
1081 A label can be suppressed by the empty braces |{}|.
1082 You can move the coordinates by specifying |<shift coor>| immediately before the first coordinate. The \xem{empty} option |<>| is \xem{not allowed}.
1083
1084 \begin{tzcode}{.3}
1085 % \tzcoorsquick: shift, color
1086 \begin{tikzpicture}
1087 \tzhelplines(4,3)
1088 \tzcoorsquick
1089 (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
1090 \tikzset{every label/.style={blue}}
1091 \tzcoorsquick <0,1>
1092 (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
1093 \end{tikzpicture}
1094 \end{tzcode}
1095
1096
1097 \subsection{\protect\cmd{\tzcoorsquick*}}
1098 \label{ss:tzcoorsquick*}
1099
1100 The starred version \icmd{\tzcoorsquick*} prints node dots on the coordinates and displays the names |above| (or |90| degree from) the dots, by default.
1101
1102 \begin{tzdef}
1103 % syntax: minimum
1104 \tzcoorsquick*(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
1105 % syntax: full
1106 \tzcoorsquick*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
1107 ..repeated.. ()(){}[] ; (<dot size>)
1108 % defaults
1109 *[ tzdot=1.2pt ]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt)
1110 \end{tzdef}
1111
1112 \begin{tzcode}{.3}
1113 % \tzcoorsquick*
1114 \begin{tikzpicture}
1115 \tzhelplines(4,3)
1116 \tzcoorsquick*(0,0)(A) (1,1)(Ben)
1117 (2,1)(Cate) (3,2)(Daniel);
1118 \end{tikzpicture}
1119 \end{tzcode}
1120
1121 A label can be suppressed by the empty braces |{}|.
1122 You can change the dot size using the \threeways\ (on page \pageref{ss:threeways}).
1123 You can shift the coordinate by specifying |<shift coor>| immediately before the first coordinate. The \xem{empty} shift option |<>| is \xem{not allowed}.
1124
1125 \begin{tzcode}{.3}
1126 % \tzcoorsquick*: size, color, shift
1127 \begin{tikzpicture}
1128 \tzhelplines(4,3)
1129 \tzcoorsquick*
1130 (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
1131 \tikzset{every label/.style={blue}}
1132 \tzcoorsquick*[blue]<0,1>
1133 (0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);(6pt)
1134 \end{tikzpicture}
1135 \end{tzcode}
1136
1137 \remark
1138 The first optional argument |[<dot opt>]| of |\tzcoorsquick*| is for only dots.
1139 You can use the \Tikz\ option |every label/.style={...}| to control all the labels together.
1140 You can also control each labels using |[<label opt>]| for each coordinate.
1141
1142 \begin{tzcode}{.3}
1143 % \tzcoorsquick*: every label/.style
1144 \begin{tikzpicture}
1145 \tzhelplines(4,3)
1146 \tikzset{every label/.style={draw,red}} %%
1147 \tzcoorsquick*[fill=none,blue,very thick]
1148 (0,0)(A)(1,1)(B-1)(2,1)(C)(3,3)(D)[[blue]-45];(8pt)
1149 \end{tikzpicture}
1150 \end{tzcode}
1151
1152
1153 %%------------------------------------------------------------
1154 \section{\protect\cmd{\tzgetxyval}}
1155 \label{s:tzgetxyval}
1156
1157 \icmd{\tzgetxyval} extracts the values of x-coordinate and the y-coordinate \xem{in the unit of centimeter} from a specified coordinate and saves the values in the user-defined macros, so that you can use them later.
1158 For example, |\tzgetxyval(3,2){\xval}{\yval}| results in |\xval=3| and |\yval=2|.
1159
1160 \begin{tzdef}
1161 % syntax
1162 \tzgetxyval(<coor>){<\macroXval>}{<\macroYval>}
1163 % default
1164 (<m>){<m>}{<m>}
1165 \end{tzdef}
1166
1167 \begin{tzcode}{.3}
1168 \begin{tikzpicture}
1169 \tzhelplines(4,3)
1170 \tzfn"dem"{3-(3/4)*\x}[0:4]
1171 \tzfn"sup"{\x}[0:4]
1172 % intersection point: (E)
1173 \tzXpoint*{dem}{sup}(E)(5pt)
1174 % extract x/y-coordinate from (E)
1175 \tzgetxyval(E){\Ex}{\Ey}
1176 \tzdots*(\Ex,\Ey){E}(\Ex+1,\Ey){F}(\Ex,\Ey+1){G};
1177 \tzdot(E)(10pt)
1178 \tznodeframe(2,0){x\;=\;\Ex\,cm\\ y\;=\;\Ey\,cm}
1179 [font=\ttfamily\scriptsize,align=left]
1180 \end{tikzpicture}
1181 \end{tzcode}
1182
1183 %%------------------------------------------------------------
1184 \section{\protect\cmd{\tzcoortangenttocircle(*)}}
1185 \label{s:tzcoor-tangenttocircle}
1186
1187 \icmd{\tzcoortangenttocircle} definds the \iisw{tangent} \xem{coordinates} to a \xem{node circle} from a point.
1188 This works together with |\tznodecircle|.
1189
1190 The starred version \icmd{\tzcoortangenttocircle*} prints dots (by |\tzdot*|) at the tangent coordinates.
1191
1192 See Section \ref{s:tzcoortangenttocircle} on page \pageref{s:tzcoortangenttocircle} for more details.
1193
1194 %%==================================
1195 \chapter{Plot Coordinates: \protect\cmd{\tzplot}: Semicolon Versions}
1196 \label{c:plotcoordinates}
1197
1198 %%------------------------------------------------------------
1199 \section{\protect\cmd{\tzplot} and \protect\cmd{\tzplot*}: Syntax}
1200 \label{s:tzplot}
1201
1202 \icmd{\tzplot} takes an \xem{arbitrary number of coordinates} as arguments. Internally, |\tzplot| uses the |plot coordinates| operation of \TikZ.
1203
1204 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.
1205
1206 The macro |\tzplot| draws connected line segments that link specified coordinates.
1207
1208 \begin{tzdef}
1209 % syntax: minimum
1210 \tzplot(<coor>)(<coor>)..repeated..(<coor>) ;
1211 % syntax: medium
1212 \tzplot(<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>] ;
1213 % syntax:full
1214 \tzplot[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>"
1215 (<coor>){<label>}[<[label opt]angle>]
1216 ..repeated..
1217 (){}[] ; (<mark size>) <code.append>
1218 % defaults
1219 [tzmark=2pt]{0}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <>
1220 - [<plot opt>] is [smooth] by default
1221 - It can be changed to [smooth cycle]
1222 \end{tzdef}
1223
1224 The starred version |\tzplot*| prints dot marks at specified coordinates, without drawing line segments connecting the coordinates, by default.
1225
1226 |\tzplot*| is equivalent to |\tzplot[draw=none,mark=*]|.
1227 The style \ixxw{tzmark} is defined as follows:
1228
1229 \begin{tzsty}
1230 % style: tzmark
1231 \tikzset{
1232 tzmark/.style=
1233 {mark options={solid,thin},mark size=#1},
1234 tzmark/.default=\tzmarksize
1235 }
1236 \end{tzsty}
1237
1238 \icmd{\tzmarksize} is the \xem{radius} of a |mark| and the default is |2pt| as in \Tikz.
1239 The value of |\tzmarksize| can be changed by the macro \icmd{\settzmarksize}, like |\settzmarksize{3pt}|.
1240
1241
1242
1243
1244 %%------------------------------------------------------------
1245 \section{\protect\cmd{\tzplot*}: Dots and marks}
1246 \label{s:tzplot-dots}
1247
1248 The starred version |\tzplot*| prints \Tikz\ marks (|*| by default) at specified coordinates.
1249 You can change the mark color and mark style using the first bracket optional argument.
1250
1251 \begin{tztikz}
1252 \tzplot*(0,0)(1,2)(2,2)(3,3); % works like:
1253 \draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) } ;
1254 \end{tztikz}
1255
1256
1257 \begin{tzcode}{.3}
1258 % \tzplot*
1259 \begin{tikzpicture}[scale=.8]
1260 \tzhelplines(4,3)
1261 \tzplot*(0,0)(1,1)(2,1)(3,3);
1262 \tzplot*[mark=o](0,3)(1,3)(2,2)(3,1) ; % semicolon
1263 \tzplot*[red](0,2)(1,2)(2,0)(3,2);
1264 \end{tikzpicture}
1265 \end{tzcode}
1266
1267 \paragraph{Labels, marks, and mark size}
1268 You can also add labels to specified coordinates with the optional arguments |{<label>}| and |[<angle>]| immediately after each |(<coor>)|.
1269
1270 \begin{tztikz}
1271 \tzplot*(0,0){A}[90](1,2)(2,2)(3,3){D}[0]; % works like:
1272 \draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) }
1273 (0,0) node [label={90:A}] {}
1274 (3,3) node [label={0:D}] {} ;
1275 \end{tztikz}
1276
1277 There are \textsc{Three Ways} to change the mark size.
1278
1279 \begin{enumerate}
1280 \item The simplest way is to use the parenthesis optional argument |(<mark size>)|, \xem{immediately after the semicolon}.
1281 \item You can use the style |tzmark|, like |tzmark=3pt|.
1282 \item You can also use the macro |\settzmarksize|, which is effective until the end of |tikzpicture| environment.
1283 \end{enumerate}
1284
1285 \begin{tzcode}{.3}
1286 % \tzplot*: label, size
1287 \begin{tikzpicture}[scale=.8]
1288 \tzhelplines(4,3)
1289 \tzplot*(0,0){A}[-135](1,1)(2,1)(3,3){D}[[blue]0];(1mm)
1290 \tzplot*[mark=o,tzmark=6pt](0,3)(1,3)(2,2)(3,1);
1291 \settzmarksize{4pt}
1292 \tzplot*[red](0,2){A}(1,2){B}(2,0){C}[[blue]0](3,2){D};
1293 \end{tikzpicture}
1294 \end{tzcode}
1295
1296 \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.)
1297
1298 \begin{tzcode}{.3}
1299 % \tzplot*: label: strings instead of angles
1300 \begin{tikzpicture}[scale=.8]
1301 \tzhelplines(4,3)
1302 \tzplot*(0,0){A}[bl](1,1)(2,1)(3,3){D}[[blue]r];(1mm)
1303 \tzplot*[mark=o,tzmark=6pt](0,3)(1,3)(2,2)(3,1);
1304 \settzmarksize{4pt}
1305 \tzplot*[red](0,2){A}(1,2){B}(2,0){C}[[blue]r](3,2){D};
1306 \end{tikzpicture}
1307 \end{tzcode}
1308
1309 With |\tzplot*|, you can draw line segments by giving the \Tikz's option |draw| in the first bracket optional argument, like |\tzplot*[draw]|.
1310
1311 \begin{tzcode}{.3}
1312 % \tzplot*: line, more marks, size
1313 \begin{tikzpicture}[scale=1]
1314 \tzhelplines(4,3)
1315 \settzmarksize{3pt}
1316 \tzplot*[draw,mark=x]
1317 (0,0)(1,1)(2,1)(3,3);
1318 \tzplot*[blue,mark=diamond*]
1319 (0,3)(1,3)(2,2)(3,1);(10pt)
1320 \tzplot*[draw,dashed,red,mark=heart]
1321 (0,2)(1,2)(2,0)(3,2);
1322 \end{tikzpicture}
1323 \end{tzcode}
1324
1325 \remark In \Tikz, the |mark| shapes are affected by |scale|, |xscale|, and |yscale|.
1326
1327 \begin{tzcode}{.3}
1328 % \tzplot*: marks: distorted
1329 \begin{tikzpicture}[yscale=.5]
1330 \tzhelplines(4,3)
1331 \settzmarksize{3pt}
1332 \tzplot*[draw,mark=x]
1333 (0,0)(1,1)(2,1)(3,3);
1334 \tzplot*[blue,mark=diamond*]
1335 (0,3)(1,3)(2,2)(3,1);(10pt)
1336 \tzplot*[draw,dashed,red,mark=heart]
1337 (0,2)(1,2)(2,0)(3,2);
1338 \end{tikzpicture}
1339 \end{tzcode}
1340
1341 \paragraph{Shift}
1342 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).
1343 The \xem{empty} shift option |<>| is \xem{not allowed}.
1344
1345
1346 \begin{tzcode}{.3}
1347 % \tzplot*: shift
1348 \begin{tikzpicture}
1349 \tzhelplines(4,3)
1350 \tzcoors(1,3)(A)(2,3)(B)(3,3)(C)(4,3)(D);
1351 \tzplot*[draw] (A){A}(B)(C)(D){D}[0];
1352 \tzplot*[draw,red]<-1,-1>(A){A}(B)(C)(D){D}[0];
1353 \tzplot*[draw,blue]<0,-3>(A){A}(B)(C)(D){D}[0];
1354 \end{tikzpicture}
1355 \end{tzcode}
1356
1357 \paragraph{Extending path}
1358 You can use |<code.append>| as the last optional argument after a semicolon.
1359
1360 \begin{tzcode}{.3}
1361 \begin{tikzpicture}
1362 \tzhelplines(4,3)
1363 \tzplot*[draw](0,0)(1,1)(2,2){C}(3,2){D};
1364 < arc (-90:0:1cm) node [a] {ends here!}>
1365 \end{tikzpicture}
1366 \end{tzcode}
1367
1368 \icmd{\tzplotAtBegin} and \icmd{\tzplotAtEnd} are also available.
1369 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|.
1370
1371 \begin{tzcode}{.3}
1372 \begin{tikzpicture}
1373 \tzhelplines(4,3)
1374 \tzplotAtBegin{(0,2) to [bend right]} % ERROR!!!
1375 \tzplotAtEnd{arc (90:0:1cm) node [b] {here?}}
1376 \tzplot*[draw,blue](0,0)(1,1)(2,2){C}(3,2){D};
1377 <arc (-90:0:1cm) node [r] {ends here!}>
1378 \tzplot*[draw,red]<.5,1>(0,0)(1,1)(2,2){C}(3,2){D};
1379 <arc (-90:0:1cm) node [r] {ends here!}>
1380 \end{tikzpicture}
1381 \end{tzcode}
1382
1383
1384 %%------------------------------------------------------------
1385 \section{\protect\cmd{\tzplot}: Lines}
1386 \label{s:tzplot-lines}
1387
1388 |\tzplot| draws connected line segments connecting specified coordinates.
1389 (By default, |tension=0|.)
1390
1391
1392 \begin{tztikz}
1393 \tzplot(0,0)(1,2)(2,2)(3,3); % works like:
1394 \draw [tension=0] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
1395 \end{tztikz}
1396
1397 |\tzplot*| is equivalent to |\tzplot[draw=none,mark=*]|.
1398
1399
1400 \paragraph{Options: draw, mark, mark options, etc.}
1401 You can use the optional argument |[<opt>]| to change the style of lines and marks.
1402
1403 \begin{tzcode}{.3}
1404 % \tzplot: line
1405 \begin{tikzpicture}[scale=.8]
1406 \tzhelplines(4,3)
1407 \tzplot (0,0)(1,1)(2,1)(3,3);
1408 \tzplot[dashed,mark=o](0,3)(1,3)(2,2)(3,1);
1409 \tzplot[red,mark=ball,mark options={ball color=purple}]
1410 (0,1)(1,2)(2,0)(3,2);
1411 \end{tikzpicture}
1412 \end{tzcode}
1413
1414 To close the path of |\tzplot| you can use the option |smooth cycle| in the first bracket optional argument |[<opt>]| or in the second bracket optional argument |[<plot opt>]|.
1415
1416 \begin{tzcode}{.3}
1417 % \tzplot: smooth cycle
1418 \begin{tikzpicture}[scale=.8]
1419 \tzhelplines(4,3)
1420 \tzplot (0,0)(1,1)(2,1)(3,3);
1421 \tzplot[dashed,mark=o,smooth cycle]
1422 (0,3)(1,3)(2,2)(3,1);
1423 \tzplot[red,mark=*,mark options={blue}]
1424 [smooth cycle] %% default tension=0
1425 (0,1)(1,2)(2,0)(3,2);
1426 \end{tikzpicture}
1427 \end{tzcode}
1428
1429
1430
1431 \paragraph{Labels} You can label specified coordinates with the options |{<label>}| and |[<angle>]| immediately after each |(<coor>)|.
1432
1433 \begin{tzcode}{.3}
1434 % \tzplot: label
1435 \begin{tikzpicture}[scale=.8]
1436 \tzhelplines(4,3)
1437 \tzplot(0,0){A}(1,1){B}[-90](2,1)(3,3){Da}[[draw]0];
1438 \tzplot[mark=o](0,3)(1,3){B}(2,2)(3,1){Db}[0];
1439 \tzplot[red,mark=*,draw=blue]
1440 (0,1)(1,2){B}(2,0)(3,2){Dc}[[blue]0];
1441 \end{tikzpicture}
1442 \end{tzcode}
1443
1444 \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).
1445 The \xem{empty} shift option |<>| is \xem{not allowed}.
1446
1447 \begin{tzcode}{.3}
1448 % \tzplot: shift
1449 \begin{tikzpicture}[scale=.8]
1450 \tzhelplines(4,3)
1451 \tzcoors(0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D);
1452 \tzplot <1,0>(A)(B)(C)(D){Da}[0];
1453 \tzplot[mark=o] <1,0>(0,3)(1,3)(2,2)(3,1){Db}[0];
1454 \tzplot*[draw,red]<1,0>(0,1)(1,2)(2,0)(3,2){Dc}[0];
1455 \end{tikzpicture}
1456 \end{tzcode}
1457
1458 \paragraph{\texttt{name path} for intersections}
1459
1460 To find the intersection points of two lines, you may want to name the paths first, like |[name path=<path name>]| in \Tikz. With |\tzplot|, you can do it by specifying the quote optional argument |"<path name>"| immediately before the first coordinate.
1461
1462 \begin{tzcode}{.3}
1463 % \tzplot: "path name"
1464 \begin{tikzpicture}[scale=.8]
1465 \tzhelplines(4,3)
1466 \tzplot[name path=Da] (0,0)(1,1)(2,1)(3,3){Da}[0];
1467 \tzplot[mark=o] "Db"(0,3)(1,3)(2,2)(3,1){Db}[0];
1468 \tzplot*[draw,red]"Dc"(0,1)(1,2)(2,0)(3,2){Dc}[0];
1469 % intersection points
1470 \tzXpoint*[gray]{Da}{Db}
1471 \tzXpoint*[blue]{Da}{Dc}
1472 \end{tikzpicture}
1473 \end{tzcode}
1474
1475 \paragraph{Extending the path}
1476 In order to \xem{extend a path}, formed by |\tzplot|, \xem{from the last coordinate}, you can write \Tikz\ code in the very last optional argument |<code.append>|, \xem{after the semicolon}.
1477
1478 \begin{tzcode}{.3}
1479 % \tzplot: "path name"
1480 \begin{tikzpicture}[scale=.8]
1481 \tzhelplines(6,4)
1482 \tzplot(0,0)(1,1)(2,1)(3,3){Da}[0];< -- (6,4) >
1483 \tzplot[mark=o](0,3)(1,3)(2,2)(3,1){Db}[0];(4pt)
1484 \tzplot[mark=ball,red](0,1)(1,2)(2,0)(3,2){Dc}[0];
1485 (5pt)< to [bend left] ++(2,-2) node {ends here!} >
1486 \end{tikzpicture}
1487 \end{tzcode}
1488
1489 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|.
1490
1491
1492 %%------------------------------------------------------------
1493 \section{\protect\cmd{\tzplot}: Curves}
1494 \label{s:tzplot:curves}
1495
1496 With |\tzplot|, the default value of |tension| is |0|.
1497 You can draw a curve with |\tzplot|, by specifying the optional argument |{<tension>}| before the coordinates or between the first and second bracket options (if they exist).
1498
1499 \begin{tztikz}
1500 \tzplot[blue,smooth cycle]{1}(0,0)(1,2)(2,2)(3,3); % works like:
1501 \draw [blue,tension=1] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
1502 \end{tztikz}
1503
1504 \begin{tzcode}{.3}
1505 \begin{tikzpicture}[scale=.8]
1506 \tzhelplines(4,3)
1507 \tzplot[tension=1](0,0)(1,1)(2,1)(3,3);
1508 \tzplot[mark=o] (0,3)(1,3)(2,2)(3,1); % tension=0
1509 \tzplot*[draw,red,smooth cycle]{1} % tension=1
1510 (0,1)(1,2)(2,0)(3,2);
1511 \end{tikzpicture}
1512 \end{tzcode}
1513
1514 To plot curves, the macro |\tzplotcurve| is provided.
1515 Basically, |\tzplotcurve| is the |tension=1| version of |\tzplot|.
1516 (See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve}.)
1517
1518
1519 %%------------------------------------------------------------
1520 \section{\protect\cmd{\tzplot}: Bars and combs}
1521 \label{s:tzplot-bars}
1522
1523 With |\tzplot|, you can draw bars or combs, using the \Tikz\ options |ybar|, |xbar|, |ycomb|, and |xcomb|.
1524
1525 \begin{tzcode}{.3}
1526 \begin{tikzpicture}[scale=.8]
1527 \tzhelplines(4,3)
1528 \tzplot*[draw](0,0)(1,1)(2,1)(3,3);
1529 \tzplot[ybar](0,3)(1,3)(2,2)(3,1);
1530 \tzplot[dashed,red,mark=heart](0,1)(1,2)(2,0)(3,2);
1531 \end{tikzpicture}
1532 \end{tzcode}
1533
1534 \begin{tzcode}{.3}
1535 \begin{tikzpicture}[scale=.8]
1536 \tzhelplines(4,3)
1537 \tzplot[xbar](.5,2.5)(1,3)(2,2)(3,1);
1538 \tzplot[xbar,bar width=2mm,fill,red!50]
1539 (1,2.5)(1.5,2)(2,0)(3,1.5);(3pt)
1540 \end{tikzpicture}
1541 \end{tzcode}
1542
1543
1544 \begin{tzcode}{.3}
1545 \begin{tikzpicture}[yscale=1.5]
1546 \tzhelplines(0,-1)(4,1)
1547 \tzplot[ycomb,mark=*,very thick,blue]
1548 (.5,.1)(1,.3)(1.5,.4)(2,.5)
1549 (4,-.1)(3.5,-.3)(3,-.4)(2.5,-.5);
1550 \end{tikzpicture}
1551 \end{tzcode}
1552
1553 \begin{tzcode}{.3}
1554 \begin{tikzpicture}[scale=.8]
1555 \tzhelplines(4,3)
1556 \tzplot[xcomb,mark=*,very thick]
1557 (1,2.5)(1.5,2)(2,0)(3,1.5);
1558 \end{tikzpicture}
1559 \end{tzcode}
1560
1561 \remark
1562 \begin{itemize}
1563 \item
1564 Do not use |<shift coor>| for plotting bars or combs to avoid getting unexpected results. It gives you wrong bars because |<shift coor>| moves coordinates but not bars.
1565
1566 %\item Use the option |shift={(coor)}| to move bars.
1567 %\begin{tzcode}{.3}
1568 %% shift : shift={(1,1)}
1569 %\begin{tikzpicture}[scale=1]
1570 %\tzhelplines(4,3)
1571 %\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3);
1572 %\tzplot[ybar,shift={(1,1)}](0,3)(1,3)(2,2)(3,1); %%
1573 %\tzplot[red,mark=heart]<1,1>(0,2)(1,2)(2,0)(3,2);
1574 %\end{tikzpicture}
1575 %\end{tzcode}
1576
1577 \item
1578 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.
1579
1580 %\begin{tzcode}{.3}
1581 %% \tzplot(*)
1582 %% shift : mixed coor : shift={(1,1)} : chaos
1583 %\begin{tikzpicture}[scale=1]
1584 %\tzhelplines(4,3)
1585 %\tzcoors(0,3)(A)(1,3)(B)(2,2)(C)(3,1)(D);
1586 %\tzcoors(0,2)(a)(1,2)(b)(2,0)(c)(3,2)(d);
1587 %\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3);
1588 %\tzplot[ybar,shift={(1,1)}](A)(1,3)(C)(D); %%
1589 %\tzplot[dashed,red,mark=heart]<1,1>(a)(1,2)(c)(d);
1590 %\end{tikzpicture}
1591 %\end{tzcode}
1592
1593 \end{itemize}
1594
1595
1596
1597 %%-----------------------------------
1598 %%------------------------------------------------------------
1599 \section{\protect\cmd{\tzplotcurve(*)}}
1600 \label{s:tzplotcurve}
1601
1602 \icmd{\tzplotcurve} draws a curve connecting specified coordinates with |tension=1|, by default. Basically, it is equivalent to |\tzplot| with |[tension=1]|.
1603
1604 The starred version \icmd{\tzplotcurve*} draws a curve and displays marks |*|, by default.
1605 Basically, this is equivalent to |\tzplot*[draw,tension=1]|.
1606
1607 \begin{tzdef}
1608 % syntax: minimum
1609 \tzplotcurve(<coor>)(<coor>)..repeated..(<coor>) ;
1610 % syntax: full
1611 \tzplotcurve*[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>"
1612 (<coor>){<label>}[<[label opt]angle>]
1613 ..repeated..
1614 (){}[] ; (<mark size>) <code.append>
1615 % defaults
1616 *[tzmark=2pt]{1}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <>
1617 \end{tzdef}
1618
1619 \begin{tztikz}
1620 \tzplotcurve(0,0)(1,2)(2,2)(3,3); % works like:
1621 \draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
1622 \end{tztikz}
1623
1624 \begin{tztikz}
1625 \tzplotcurve[blue,smooth cycle]{2}(0,0)(1,2)(2,2)(3,3); % works like:
1626 \draw [blue,tension=2] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
1627 \end{tztikz}
1628
1629 Since |\tzplotcurve| is a \xem{semicolon version}, you need to enter a semicolon to indicate when the coordinate iteration ends.
1630 In repeating coordinates, each mandatory coordinate can have a label.
1631 So the whole repeating pattern is the triple |(<coor>){<text>}[<pos>]|.
1632 For example, |(A){here}[above]| represents |(A) node [above] {here}| in \Tikz.
1633
1634 \paragraph{Options: lines, labels, colors, smooth cycle}
1635 Use the first bracket option to control the colors of lines or labels.
1636
1637 \begin{tztikz}
1638 \tzplotcurve(0,0)(1,2)(2,2){A}[below](3,3){B}[right]; % works like:
1639 \draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) }
1640 (2,2) node [below] {A}
1641 (3,3) node [right] {B} ;
1642 \end{tztikz}
1643
1644 You can change the color of all labels together by adding |[text=<color>]| to the first bracket option list.
1645
1646 \begin{tzcode}{.3}
1647 % \tzplotcurve(*)
1648 \begin{tikzpicture}
1649 \tzhelplines(4,3)
1650 \tzplotcurve*[red,text=blue]
1651 (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];
1652 \tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1);
1653 \end{tikzpicture}
1654 \end{tzcode}
1655
1656 The simplest way to change the mark size is to specify |(<mark size>)| immediately after the semicolon |;|.
1657 To close the path of |\tzplotcurve|, you can use the \Tikz\ option |smooth cycle| in the first bracket option or in the second bracket option.
1658
1659 \begin{tzcode}{.3}
1660 % \tzplotcurve(*): smooth cycle, mark size
1661 \begin{tikzpicture}
1662 \tzhelplines(4,3)
1663 \tzplotcurve*[red,text=blue][smooth cycle]
1664 (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %%
1665 \tzplotcurve*[smooth cycle](1,.5)(2,3)(3,2)(2,1)(3,1);
1666 \end{tikzpicture}
1667 \end{tzcode}
1668
1669 \begin{tzcode}{.3}
1670 % abridges strings: label position
1671 \begin{tikzpicture}
1672 \tzhelplines(4,3)
1673 \tzplotcurve*[red,text=blue][smooth cycle]
1674 (0,0)(1,2){B}[[red]l](2,2)(3,3)(4,1){E}[[draw]r];(3pt)
1675 \tzplotcurve*[smooth cycle](1,.5)(2,3)(3,2)(2,1)(3,1);
1676 \end{tikzpicture}
1677 \end{tzcode}
1678
1679 \paragraph{Tension}
1680 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.
1681
1682 \begin{tzcode}{.3}
1683 % \tzplotcurve: tension
1684 \begin{tikzpicture}
1685 \tzhelplines(4,3)
1686 \tzcoor(.5,.5)(A)
1687 \tzplotcurve[blue]{2}(1,3)(A)(4,0);
1688 \tzplotcurve[thick](1,3)(A)(4,0); % default: tension=1
1689 \tzplotcurve[red]{.5}(1,3)(A)(4,0);
1690 \tzplotcurve[dashed]{0}(1,3)(A)(4,0);
1691 \end{tikzpicture}
1692 \end{tzcode}
1693
1694
1695 \paragraph{Shift} Use the optional argument |<shift coor>| before the first coordinate (to be precise, immediately before |"<path name>"|, if it exists).
1696 The empty shift option |<>| is not allowed.
1697
1698 \begin{tzcode}{.3}
1699 % \tzplotcurve(*): shift
1700 \begin{tikzpicture}
1701 \tzhelplines(4,3)
1702 \tzcoors(0,0)(A)(1,2)(B)(2,2)(C)(3,3)(D)(4,1)(E);
1703 \tzplotcurve*[red,text=blue,smooth cycle]
1704 <0,1>(A)(B){B}(C)(D)(E){E}[0];(3pt) %%
1705 \tzplotcurve*[smooth cycle]
1706 (1,.5)(2,3)(3,2)(2,1)(3,1);
1707 \end{tikzpicture}
1708 \end{tzcode}
1709
1710
1711 \paragraph{Extending the path} In order to extend the path created by |\tzplotcurve(*)| from the last coordinate, you can directly write \Tikz\ code in the very last optional argument |<code.append>|, after the semicolon.
1712
1713 \begin{tzcode}{.3}
1714 % \tzplotcurve(*): <code.append>
1715 \begin{tikzpicture}
1716 \tzhelplines(4,3)
1717 \tzplotcurve*[red,text=blue,thick]
1718 (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[-45];(3pt)
1719 < arc (-90:90:1cm) node [above] {up} > %%
1720 \tzplotcurve[dashed]
1721 (1,.5)(2,3)(3,2)(2,1)(3,1);
1722 < -- ++(-1,-1) node [below] {down} > %%
1723 \end{tikzpicture}
1724 \end{tzcode}
1725
1726 You can also use |<--cycle>| to \xem{close} the path \xem{with a straight line} from the last coordinate to the first coordinate.
1727
1728 \begin{tzcode}{.3}
1729 % \tzplotcurve(*): <--cycle>
1730 \begin{tikzpicture}
1731 \tzhelplines(4,3)
1732 \tzplotcurve*[red,text=blue]
1733 (0,0)(1,2)(2,2)(3,3)(4,1){A}[right] ; (3pt)<--cycle>
1734 \tzplotcurve
1735 (1,.5)(2,3)(3,2)(2,1)(3,1) ; <--cycle>
1736 \end{tikzpicture}
1737 \end{tzcode}
1738
1739 You can also use \icmd{\tzplotcurveAtBegin} and \icmd{\tzplotcurveAtEnd} to extend the path of |\tzplotcurve| at the beginning and at the end, respectively.
1740 Specifying |<code.append>| extends the path after |\tzplotcurveAtEnd|.
1741
1742 \begin{tzcode}{.3}
1743 % \tzplotcurve(*)
1744 \begin{tikzpicture}
1745 \tzhelplines(4,3)
1746 \tzplotcurve*[red,text=blue]
1747 (0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];
1748 \tzplotcurveAtBegin{(0,2) |-} % ERROR!!!
1749 \tzplotcurveAtEnd{arc (180:270:1cm) node {End!}}
1750 \tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1);
1751 \end{tikzpicture}
1752 \end{tzcode}
1753
1754 \paragraph{\texttt{name path} for intersection points}
1755 You can name the path of |\tzplotcurve| by specifying the option |"<path name>"| immediately before the first coordinate.
1756
1757 \begin{tzcode}{.3}
1758 % \tzplotcurve(*): name path
1759 \begin{tikzpicture}
1760 \tzhelplines(4,3)
1761 \tzplotcurve[blue]
1762 "IC"(.5,3)(1.5,1.2)(4,.5){$u$}[0];
1763 \tzplot[draw=red]
1764 "bgt"(0,3)(4,0){budget}[-90];
1765 % intersection points
1766 \tzXpoint{IC}{bgt}(K)
1767 \tzdots*(K){$A_1$}[30](K-2){$A_2$};
1768 \end{tikzpicture}
1769 \end{tzcode}
1770
1771
1772 %%==================================
1773 \chapter{Nodes}
1774 \label{c:nodes}
1775
1776 %%------------------------------------------------------------
1777 \section{\protect\cmd{\tznode} and \protect\cmd{\tznode*}}
1778 \label{s:tznode}
1779
1780 The macro \icmd{\tznode} allows you to put \xem{text} at a specified \xem{coordinate}. |\tznode| expects two mandatory arguments: |(<coor>)| and |{<text>}|.
1781 You can also \xem{optionally} name a node so that you can refer to the \iisw{node coordinate} later.
1782
1783 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|.
1784
1785 \begin{tzdef}
1786 % syntax: minimal
1787 \tznode(<coor>){<text>}
1788 % syntax: full
1789 \tznode[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]<node.code>
1790 % defaults: two mandatory arguments
1791 []<>(<m>)(){<m>}[]<>
1792 \end{tzdef}
1793
1794 \begin{tztikz}
1795 \tznode(0,0){text} % works like:
1796 \path (0,0) node {text};
1797 % or
1798 \node at (0,0) {text};
1799 \end{tztikz}
1800
1801 \begin{tztikz}
1802 \tznode[draw] (0,0)(A){text}[above right] % works like:
1803 \node [draw] (A) at (0,0) [above right] {text};
1804 \end{tztikz}
1805
1806 |\tznode*| prints the perimeter of a node, which is a |rectangle| by default.
1807
1808 \begin{tzdef}
1809 % syntax: minimal
1810 \tznode*(<coor>){<text>}
1811 % syntax: full
1812 \tznode*[<opt>]<shift coor>(<coor>)(<name>){<text>}[<node opt>]<node.code>
1813 % defaults
1814 *[draw]<>(<m>)(){}[]<>
1815 \end{tzdef}
1816
1817 \begin{tztikz}
1818 \tznode* (0,0)(A){text}[above right] % works like:
1819 \node [draw] (A) at (0,0) [above right] {text};
1820 \end{tztikz}
1821
1822 \paragraph{Putting text} You can use \Tikz\ options in the first bracket optional argument |[<opt>]| or the second bracket option |[<node opt>]| to put text with different colors, fonts, and so on.
1823
1824 \begin{tzcode}{.3}
1825 % \tznode(*)
1826 \begin{tikzpicture}
1827 \tzhelplines(4,3)
1828 \tznode(1,1){text}
1829 \tznode(2,2){another\\text}[align=left]
1830 \tznode*(3,1){\textbf{text}}
1831 \tznode*[blue](3,0){\scshape Text}[r] % right
1832 \tznode*(4,2){another\\text}[align=center,font=\itshape]
1833 \end{tikzpicture}
1834 \end{tzcode}
1835
1836 \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}.)
1837
1838 \begin{quote}
1839 \remark
1840 \begin{itemize}\firmlist
1841 \item A \iisw{label node} is placed by angles or the corresponding positioning words.
1842 \item A \iisw{main node} is placed by the placement words or their aliases.
1843 \item You cannot use angles to place main nodes.
1844 \end{itemize}
1845 \end{quote}
1846
1847
1848 \begin{tzcode}{.3}
1849 % \tznode(*): main node, label node
1850 \begin{tikzpicture}
1851 \tzhelplines(4,3)
1852 \tzdot*(1,1)
1853 \tznode*(1,1){A}[ar]
1854 \tznode*[red](1,1){B}[b]
1855 \tznode(1,1){C}[l]
1856 \tznode*[inner sep=0pt,text=blue,scale=2]
1857 (3,2){Text}[label=180:Left,pin=45:Above Right]
1858 \tznode*[inner sep=0pt,text=red,scale=2]
1859 (3,2){Text}[b=2cm] %% below=2cm
1860 \end{tikzpicture}
1861 \end{tzcode}
1862
1863 \paragraph{Naming nodes}
1864 You can name a node at a specified coordinate |(<coor>)| by specifying |(<name>)| immediately after the coordinate. You can use the node name as a \iisw{node coordinate}.
1865
1866 \begin{tzcode}{.3}
1867 % \tznode(*): name nodes
1868 \begin{tikzpicture}
1869 \tzhelplines(4,3)
1870 \tznode*(1,1)(A){A}
1871 \tznode*[fill=blue,text=yellow](2,3)(B){B}
1872 \tznode*[circle,text=red](4,1)(C){C}
1873 \tzline[->](A)(B)
1874 \tzto[->,bend left,dashed](B)(C)
1875 \end{tikzpicture}
1876 \end{tzcode}
1877
1878 \paragraph{Shift}
1879 You can move the coordinates by specifying the option |<shift coor>| immediately before the coordinate |(<coor>)|.
1880 The empty shift option |<>| is not allowed.
1881
1882 \begin{tzcode}{.3}
1883 % \tznode(*): shift
1884 \begin{tikzpicture}
1885 \tzhelplines(4,3)
1886 \tznode*<-1,0>(1,1)(A){A}
1887 \tznode*[fill=blue,text=yellow]<1,-1>(2,3)(B){B}
1888 \tznode*[circle,text=red]<-2,-1>(4,1)(C){C}
1889 \tzline[->](A)(B)
1890 \tzto[->,bend left,dashed](B)(C)
1891 \end{tikzpicture}
1892 \end{tzcode}
1893
1894
1895 \paragraph{Repetition: \texttt{foreach}}
1896 The \xem{last} optional argument |<node.code>| can be used to iterate over to place multiple nodes.
1897
1898 \begin{tzcode}{.3}
1899 % \tznode(*): foreach, shift
1900 \begin{tikzpicture}
1901 \tzhelplines(4,3)
1902 \tznode(\x,0){\x}
1903 < foreach \x in {1,2,3} >
1904 \tznode*<1,2>(\x,0){\x}[circle,blue,fill=yellow]
1905 < foreach \x in {1,2,3} >
1906 \end{tikzpicture}
1907 \end{tzcode}
1908
1909 \begin{tztikz}
1910 \tznode(\x,0){\x}<foreach \x in {1,2,3}> % works like
1911 \node foreach \x in {1,2,3} at (\x,0) {\x};
1912 \end{tztikz}
1913
1914 \begin{tzcode}{.3}
1915 % \tznode: foreach
1916 \begin{tikzpicture}
1917 \tzhelplines(4,3)
1918 \tznode(\x,\y){$P_{\x\y}$}
1919 < foreach \x in {1,2,3,4}
1920 foreach \y in {1,2,3} >
1921 \end{tikzpicture}
1922 \end{tzcode}
1923
1924
1925 %%------------------------------------------------------------
1926 \section{\protect\cmd{\tznodes} and \protect\cmd{\tznodes*}: Semicolon versions}
1927 \label{s:tznodes}
1928
1929 \icmd{\tznodes} accepts any number of \xem{mandatory} pairs of coordinates and their names to defined node coordinates at specified coordinates.
1930
1931 \begin{tzdef}
1932 % syntax: minimum
1933 \tznodes(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ;
1934 % syntax: medimum
1935 \tznodes(<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ;
1936 % syntax: full
1937 \tznodes[<every node opt>]<shift coor>
1938 (<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ;
1939 % defaults
1940 [] <> (<m>)(<m>){}[]..repeated..()(){}[] ;
1941 *[draw]<> (<m>)(<m>){}[]..repeated..()(){}[] ;
1942 \end{tzdef}
1943
1944 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.
1945 Since this is a semicolon version, it is required to type a semicolon |;| to indicate when the repetition ends.
1946 |\tznodes| works similarly to |\tzcoors|, but the former uses main nodes and the latter uses label nodes.
1947
1948 The starred version \icmd{\tznodes*} is equivalent to |\tznodes[draw]|. That is, all node perimeters are drawn.
1949
1950 \begin{tzcode}{.3}
1951 % \tznodes
1952 \begin{tikzpicture}
1953 \tzhelplines(4,3)
1954 \tznodes(0,0)(A){A}
1955 (1,1)(B){B}
1956 (2,1)(C){C}[r]
1957 (3,2)(D){D}[b]
1958 (4,0)(E){E}; % semicolon
1959 \tzlines(A)(B)(C)(D)(E);
1960 \end{tikzpicture}
1961 \end{tzcode}
1962
1963
1964 \begin{tzdef}
1965 % syntax: minimum
1966 \tznodes(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ;
1967 % syntax: medimum
1968 \tznodes(<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ;
1969 % syntax: full
1970 \tznodes[<every node opt>]<shift coor>
1971 (<coor>)(<node name>){<text>}[<node opt>]..repeated..()(){}[] ;
1972 % defaults
1973 [] <> (<m>)(<m>){}[]..repeated..()(){}[] ;
1974 *[draw]<> (<m>)(<m>){}[]..repeated..()(){}[] ;
1975 \end{tzdef}
1976
1977
1978
1979 \begin{tzcode}{.3}
1980 % \tznodes*: retangle nodes (default)
1981 \begin{tikzpicture}
1982 \tzhelplines(4,3)
1983 \tznodes*(0,0)(A){A}
1984 (1,1)(B){B}
1985 (2,1)(C){C}[r]
1986 (3,2)(D){D}[b]
1987 (4,0)(E){E}; % semincolon
1988 \tzlines(A)(B)(C)(D)(E);
1989 \end{tikzpicture}
1990 \end{tzcode}
1991
1992
1993 \begin{tzcode}{.3}
1994 % \tznodes*: ellipse nodes
1995 \begin{tikzpicture}
1996 \tzhelplines*(5,4)
1997 \tznodes*[ellipse,fill=yellow,text=blue]
1998 (0,0)(A){Ann}
1999 (1,1)(B){Bryn}
2000 (2,0)(C){C}[r]
2001 (3,2)(D){Donald}[b,font=\scshape]
2002 (4,0)(E){End!}[rectangle,fill=green];
2003 \tzlines(A)(B)(C)(D)(E);
2004 \end{tikzpicture}
2005 \end{tzcode}
2006
2007
2008 \begin{tzcode}{.3}
2009 % \tznodes: shift
2010 \begin{tikzpicture}
2011 \tzhelplines*(5,4)
2012 \tznodes*[ellipse,fill=yellow,text=blue]
2013 <1,1>(0,0)(A){Ann}
2014 (1,1)(B){Bryn}
2015 (2,0)(C){C}[r]
2016 (3,2)(D){Donald}[b,font=\scshape]
2017 (4,0)(E){End!}[rectangle,fill=green];
2018 \tzlines(A)(B)(C)(D)(E);
2019 \end{tikzpicture}
2020 \end{tzcode}
2021
2022
2023
2024 %%------------------------------------------------------------
2025 \section{\protect\cmd{\tznodedot(*)}}
2026 \label{s:tznodedot}
2027
2028 \icmd{\tznodedot} names a node and prints a circle node dot (of the size |2.4pt|, by default).
2029 |\tznodedot| is basically the same as |\tzdot|, except for one thing.
2030 |\tznodedot| names a node.
2031
2032 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.
2033
2034 \begin{tzdef}
2035 % syntax: medium
2036 \tznodedot(<coor>)(<node name>){<label>}[<angle>]
2037 % syntax: full
2038 \tznodedot*[<opt>]<shift coor>
2039 (<coor>)(<node name>){<label>}[<[label opt]angle>] (<dot size>)
2040 % defaults
2041 [tzdot] <>(<m>)(){}[](2.4pt)
2042 *[tzdot,fill]<>(<m>)(){}[](2.4pt)
2043 \end{tzdef}
2044
2045 Since |\tznodedot(*)| prints a node dot, its |<label>| is placed by |<angle>|.
2046
2047 \begin{tztikz}
2048 \tznodedot*(1,1)(A){Ace}[180] % works like:
2049 \path (1,1) node (A) [tzdot,fill,label={180:Ace}] {} ;
2050 \end{tztikz}
2051
2052 \begin{tzcode}{.3}
2053 % \tznodedot(*): label, color
2054 \begin{tikzpicture}
2055 \tzhelplines(4,3)
2056 \tznodedot(0,0)
2057 \tznodedot(1,1)(A){A}[180]
2058 \tznodedot*(2,3)(B){\textbf{B}}
2059 \tznodedot[rectangle](4,1)(C){C}[[red]0]
2060 \tzline[->](A)(B)
2061 \tzto[->,bend left,dashed](B)(C)
2062 \end{tikzpicture}
2063 \end{tzcode}
2064
2065 You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of node dots.
2066 The simplest way is to use the last parenthesis option |(<dot size>)|.
2067
2068 \begin{tzcode}{.3}
2069 % \tznodedot(*): size
2070 \begin{tikzpicture}
2071 \tzhelplines(4,3)
2072 \settzdotsize{5pt} %%
2073 \tznodedot(1,1)(A){A}[180]
2074 \tznodedot*(2,3)(B){B}
2075 \tznodedot[rectangle](4,1)(C){C}[0](10pt) %%
2076 \tzline[->](A)(B)
2077 \tzto[->,bend left,dashed](B)(C)
2078 \end{tikzpicture}
2079 \end{tzcode}
2080
2081
2082 You can move the coordinates of dots by specifying the |<shift coor>| option immediately before the coordinate.
2083 The empty shift option |<>| is not allowed.
2084
2085 \begin{tzcode}{.3}
2086 % \tznodedot(*): shift
2087 \begin{tikzpicture}
2088 \tzhelplines(4,3)
2089 \settzdotsize{5pt}
2090 \tznodedot(1,1)(A){A}[180]
2091 \tznodedot*(2,3)(B){B}
2092 \tznodedot[rectangle]<-1,-1>(4,1)(C){C}[0](10pt) %%
2093 \tzline[->](A)(B)
2094 \tzto[->,bend left,dashed](B)(C)
2095 \end{tikzpicture}
2096 \end{tzcode}
2097
2098 You can use the abridges strings instead of angles. (See also Section \ref{ss:string-replacement} on page \pageref{ss:string-replacement}.)
2099
2100 \begin{tzcode}{.3}
2101 % abridged strings: label position
2102 \begin{tikzpicture}
2103 \tzhelplines(4,3)
2104 \settzdotsize{5pt}
2105 \tznodedot(1,1)(A){A}[[draw,blue]l]
2106 \tznodedot*(2,3)(B){B}
2107 \tznodedot[rectangle]<-1,-1>(4,1)(C){C}[br](10pt) %%
2108 \tzline[->](A)(B)
2109 \tzto[->,bend left,dashed](B)(C)
2110 \end{tikzpicture}
2111 \end{tzcode}
2112
2113
2114
2115
2116 %%------------------------------------------------------------
2117 \section{\protect\cmd{\tznodedots(*)}: Semicolon versions}
2118 \label{s:tznodedots}
2119
2120 \icmd{\tznodedots} accepts any number of \xem{mandatory} pairs of coordinates and their names to print multiple node circle dots at specified coordinates.
2121 It works just like |\tzdots|, for one exception. It names multiple node coordinates.
2122 Everything else is the same as in |\tzdots|.
2123
2124 The starred version \icmd{\tznodedots*} prints filled node circle dots.
2125
2126 \begin{tzdef}
2127 % syntax: minimum
2128 \tznodedots(<coor>)(<node name>)..repeated..(<coor>)(<node name>) ;
2129 % syntax: full
2130 \tznodedots[<dot opt>]<shift coor>
2131 (<coor>)(<node name>){<label>}[<[label opt]angle>]
2132 ..repeated.. ()(){}[] ; (<dot size>)
2133 % defaults
2134 [tzdot=2.4pt] <> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt)
2135 *[tzdot=2.4pt,fill]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt)
2136 \end{tzdef}
2137
2138
2139
2140 \begin{tzcode}{.3}
2141 % \tznodedots: label
2142 \begin{tikzpicture}
2143 \tzhelplines(4,3)
2144 \tznodedots(0,0)(A){A}
2145 (1,1)(B)
2146 (2,1)(C){C}[0]
2147 (3,2)(D){D}[-90]
2148 (4,0)(E){E} ; % semicolon
2149 \tzlines[red](A)(B)(C)(D)(E);
2150 \tznodedots*
2151 (0,3)(A)(1,2)(B){B}(2,2)(C){C}[45](3,3)(D)(4,3)(E);
2152 \tzlines(A)(B)(C)(D)(E);
2153 \end{tikzpicture}
2154 \end{tzcode}
2155
2156
2157
2158 The simple first bracket option of |\tznodedots(*)| controls dots rather than labels.
2159 If you want to control all the labels, you can use \Tikz's |every label| style as follows:
2160
2161 \begin{tzcode}{.3}
2162 % every label/.style
2163 \begin{tikzpicture}
2164 \tzhelplines(4,3)
2165 \begin{scope}[every label/.style={draw,text=red}]
2166 \tznodedots*[green]
2167 (0,0)(Ace){Ace}[[font=\LARGE\ttfamily]-90]
2168 (2,1)(Bob){\textbf{Bob}}[[blue]135]
2169 (3,2)(Cate){$C_1$\\$N_o$}[[align=center]0]
2170 (4,0)(D){Done!};(5pt)
2171 \end{scope}
2172 \end{tikzpicture}
2173 \end{tzcode}
2174
2175
2176
2177 \remark Comparison of connecting nodes and coordinates:
2178
2179
2180 \begin{tzcode}{.3}
2181 % connecting \tznodedots
2182 \begin{tikzpicture}
2183 \tzhelplines(4,3)
2184 \tznodedots(0,0)(A){A}
2185 (1,1)(B)
2186 (2,1)(C){C}[[red]-90]
2187 (3,2)(D){D}[[draw,blue]a]
2188 (4,0)(E){E}; (6pt)
2189 \tzlines[thick](A)(B)(C)(D)(E); % connects nodes
2190 \end{tikzpicture}
2191 \end{tzcode}
2192
2193 While the previous example shows that |\tzlines| connects nodes,
2194 the following example shows that |\tzlines| connects coordinates.
2195
2196
2197 \begin{tzcode}{.3}
2198 % connecting \tzcoors
2199 \begin{tikzpicture}
2200 \tzhelplines(4,3)
2201 \tzcoors*[fill=none](0,0)(A){A}
2202 (1,1)(B)
2203 (2,1)(C){C}[[red]-90]
2204 (3,2)(D){D}[[draw,blue]a]
2205 (4,0)(E){E}; (6pt)
2206 \tzlines[thick](A)(B)(C)(D)(E); % connects coordinates
2207 \end{tikzpicture}
2208 \end{tzcode}
2209
2210
2211
2212
2213 %%------------------------------------------------------------
2214 \section{\protect\cmd{\tznodeframe} and \protect\cmd{\tznodeframe*}}
2215 \label{s:tznodeframe}
2216
2217 \icmd{\tznodeframe} draws and \xem{optionally} names a rectangle node with (black, by default) text in it.
2218
2219 %\icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|.
2220
2221 \begin{tzdef}
2222 % syntax:
2223 \tznodeframe[<opt>](<coor>)(<node name>){<text>}[<node opt>]
2224 % defaults
2225 [draw]<>(<m>)(){}[text=black]
2226 \end{tzdef}
2227
2228 \begin{tztikz}
2229 \tznodeframe(2,1)(A){Here}[a] % works like
2230 \node [draw,rectangle] (A) at (2,1) [above] {Here} ;
2231 \end{tztikz}
2232
2233
2234 \begin{tzcode}{.3}
2235 % \tznodeframe
2236 \begin{tikzpicture}
2237 \tzhelplines(4,3)
2238 \tznodeframe(0,0)(A)
2239 \tznodeframe(4,2)(B)[circle]
2240 \tzline[blue,thick](A)(B)
2241 \tznodeframe[scale=1.5](2,1){Node frame}
2242 [label=180:Left, pin=-45:pin]
2243 \end{tikzpicture}
2244 \end{tzcode}
2245
2246 \begin{tzcode}{.3}
2247 % \tznodeframe: fill (opacity=1)
2248 \begin{tikzpicture}
2249 \tzhelplines(4,3)
2250 \tznodeframe(0,3)
2251 \tznodeframe(0,0)(A)
2252 \tznodeframe(4,2)(B)[circle]
2253 \tzline[blue,thick](A)(B)
2254 \tznodeframe[fill=green,scale=1.5](2,1){Node frame}
2255 [label=180:Left, pin=-45:pin]
2256 \end{tikzpicture}
2257 \end{tzcode}
2258
2259 The starred version |\tznodeframe*| fills the rectangle with color (|black!50| by default) with |fill opacity=.3| and |text opacity=1|, by default.
2260
2261 %\icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|.
2262
2263 \begin{tzdef}
2264 % syntax:
2265 \tznodeframe*[<opt>]<shift coor>
2266 (<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>}
2267 % defaults
2268 *[fill=black!50,fill opacity=.3,text opacity=1] <>
2269 (<m>)(){}[draw=black,text=black]{.3}
2270 \end{tzdef}
2271
2272 \remark
2273 |\tznodeframe| works very similar to |\tznode|, but their `starred versions' work differently.
2274 While |\tznode*| draws the perimeter of a node, |\tznodeframe*| fills a node with color.
2275
2276 \begin{tzcode}{.3}
2277 % \tznodeframe*: opacity=.3 (by default)
2278 \begin{tikzpicture}
2279 \tzhelplines(4,3)
2280 \tznodeframe(0,0)(A)
2281 \tznodeframe(4,2)(B)[circle]
2282 \tzline[blue,thick](A)(B)
2283 \tznodeframe*[green,scale=1.5](2,1){Node frame}
2284 [label=180:Left, pin=-45:pin]
2285 \end{tikzpicture}
2286 \end{tzcode}
2287
2288 \icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|.
2289 \icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|.
2290
2291
2292 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.
2293 (The \xem{empty} shift option |<>| is \xem{not allowed}.)
2294
2295
2296 \begin{tzcode}{.3}
2297 % \tznodeframe(*): opacity, shift
2298 \begin{tikzpicture}
2299 \tzhelplines[solid](4,3)
2300 \tznodebox(0,0)
2301 \tznoderectangle*(1,2)(A){A}{.1} % opacity
2302 \tznodeframe[fill=yellow](2,2)(B){B}
2303 \tznodeframe*[red](3,2)(C){Cat}
2304 \tznodebox[fill=green]<-1,-2>(4,2)(D){Dog} % shift
2305 \tzto[->,bend left=45](A.north)(C.90)
2306 \tzto[->,bend right=45,dashed](B.-135)(D.west)
2307 \end{tikzpicture}
2308 \end{tzcode}
2309
2310 \remark
2311 In addition to using the option |{<fill opacity>}|, you can use a macro to change the default value.
2312 \begin{itemize}
2313 \item The default fill opacity can be changed by the macro \icmd{\settzfillopacity}.
2314 \item
2315 The default fill color is |black!50|. You can use the macro \icmd{\settzfillcolor} to change the default fill color.
2316 \item With |\tznodeframe|, you can change the color of the perimeter and text with the second bracket option |[<node opt>]|.
2317 \end{itemize}
2318
2319
2320 %%------------------------------------------------------------
2321 \section{\protect\cmd{\tznodecircle} and \protect\cmd{\tznodecircle*}}
2322 \label{s:tznodecircle}
2323
2324 \icmd{\tznodecircle} works just like |\tznodeframe|, but draws a circle node with the option |outer sep=0pt|.
2325
2326 \begin{tzdef}
2327 % syntax
2328 \tznodecircle[<opt>]<shift coor>"<path name>"(<coor>)(<node name>)
2329 {<text>}[<node opt>](<node size>)
2330 % defaults
2331 [draw,circle,outer sep=0pt]<>""(<m>)(){}[text=black]
2332 % defualts: if (<minimum size>) is given
2333 [draw,circle,inner sep=0pt,outer sep=0pt]<>""(<m>)(){}[text=black]()
2334 \end{tzdef}
2335
2336 \icmd{\tznodecircle*} works like |\tznodeframe*|, but draws a circle node with the option |outer sep=0pt|.
2337
2338 \begin{tzdef}
2339 % syntax
2340 \tznodecircle*[<opt>]<shift coor>"<path name>"(<coor>)(<node name>)
2341 {<text>}[<node opt>](<node size>){<fill opacity>}
2342 % defaults
2343 *[circle,fill=black!50,fill opacity=.3,text opacity=1,outer sep=0pt]
2344 <>""(<m>)(){}[draw=black,text=black]{.3}
2345 % defaults: if (<minimum size>) is given
2346 *[circle,fill=black!50,fill opacity=.3,text opacity=1,inner sep=0pt,outer sep=0pt]
2347 <>""(<m>)(){}[draw=black,text=black](){.3}
2348 \end{tzdef}
2349
2350 \begin{tzcode}{.3}
2351 % \tznodecircle
2352 \begin{tikzpicture}
2353 \tzhelplines(4,3)
2354 \tznodecircle(0,0)(A)
2355 \tznodecircle(4,2)(B)[circle]
2356 \tzline[red,thick](A)(B)
2357 \tznodecircle[blue,scale=1.5](2,1){Node frame}
2358 [label=180:Left, pin=-45:pin]
2359 \end{tikzpicture}
2360 \end{tzcode}
2361
2362 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.
2363 The \xem{empty} shift coordinate option |<>| is \xem{not allowed}.
2364
2365 \begin{tzcode}{.3}
2366 % opacity, shift
2367 \begin{tikzpicture}
2368 \tzhelplines[solid](4,3)
2369 \tznodecircle(0,0)
2370 \tznodecircle*(1,2)(A){A}{.1} % opacity
2371 \tznodecircle[fill=yellow](2,2)(B){B}
2372 \tznodecircle*[red](3,2)(C){Cat}
2373 \tznodecircle[fill=green]<-1,-2>(4,2)(D){Dog} % shift
2374 \tzto[->,bend left=45](A.north)(C.90)
2375 \tzto[->,bend right=45,dashed](B.-135)(D.west)
2376 \end{tikzpicture}
2377 \end{tzcode}
2378
2379 When the option |(<minimum size)| is given, the \TikZ\ option |inner sep=0pt| is added.
2380
2381 \begin{tzcode}{.3}
2382 % \tznodecircle: (minimum size)
2383 \begin{tikzpicture}
2384 \tzhelplines(4,3)
2385 \tznodecircle(2,1)(K1)(2cm)
2386 \tznodecircle*[blue](1,1)(K2)(1cm)
2387 \tznodecircle*[red](3,2)(K3)(10pt)
2388 \end{tikzpicture}
2389 \end{tzcode}
2390
2391 With the option |"<path name>"|, you can easily find intersection points on the circle.
2392
2393 \begin{tzcode}{.3}
2394 % \tznodecircle*: "name path"
2395 \begin{tikzpicture}
2396 \tzhelplines(4,3)
2397 \tznodecircle*[green]"AA"(2,1)(K)(2cm)
2398 \tzline"BB"(0,3)(4,0)
2399 \tzXpoint{AA}{BB}(X)
2400 \tzdots*(X-1)(X-2);
2401 \end{tikzpicture}
2402 \end{tzcode}
2403
2404 %%------------------------------------------------------------
2405 \section{\protect\cmd{\tzcoortangenttocircle(*)}}
2406 \label{s:tzcoortangenttocircle}
2407
2408 \icmd{\tzcoortangenttocircle} finds the \iisw{tangent} \xem{coordinates} to a \xem{node circle} from a point.
2409 This works together with |\tznodecircle| (with the default option |[outer sep=0pt]|).
2410
2411 \begin{tzdef}
2412 % syntax: minimum
2413 \tzcoortangenttocircle(<node>)(<point>)(<coor name1>)
2414 % syntax: medium
2415 \tzcoortangenttocircle(<node>)(<point>)(<coor name1>)(<coor name2>)
2416 % syntax: medium
2417 \tzcoortangenttocircle[<dot opt>](<node>)(<point>)
2418 (<coor name1>){<text1>}[<node opt>]
2419 (<coor name2>){<text2>}[<node opt>]
2420 % defaults
2421 *[](<m>)(<m>)(<m>){}[](){}[]
2422 \end{tzdef}
2423
2424 \begin{tztikz}
2425 \tzcoortangenttocircle(A)(B)(X) % works like:
2426 \path (tangent cs:node=A,point={(B)},solution=1) coordinate (X) ;
2427 \path (tangent cs:node=A,point={(B)},solution=2) coordinate (X-2) ;
2428 \tzcoortangenttocircle(A)(B)(X)(Y) % works like:
2429 \path (tangent cs:node=A,point={(B)},solution=1) coordinate (X) ;
2430 \path (tangent cs:node=A,point={(B)},solution=2) coordinate (Y) ;
2431 \end{tztikz}
2432
2433 When the solution 1 is named |(X)|, you can use |(X-1)| instead, and the solution 2 is named |(X-2)| automatically.
2434 Even when the solution 1 is named |(X)| and the solution 2 is named |(Y)|, you can still use |(X-2)| instead of |(Y)|.
2435
2436 The starred version \icmd{\tzcoortangenttocircle*} prints dots (by |\tzdot*|) at the tangent coordinates. To change the dot size you can use the option \ixxw{tzdot} or the macro \icmd{\settzdotsize}. (For more details, see Section \ref{ss:threeways} on page \pageref{ss:threeways}.)
2437
2438 \begin{tzcode}{.3}
2439 % \tzcoortangenttocircle* with \tznodecircle
2440 \begin{tikzpicture}
2441 \tzhelplines(4,3)
2442 \tznodecircle(1,1)(K)(2cm) %%
2443 \tzcoor*(4,3)(A){A}[0]
2444 \tzcoortangenttocircle*(K)(A)(X) %%
2445 \tzline[red, tzextend={0pt}{1cm}](A)(X-1) % (X)=(X-1)
2446 \tzline[blue,tzextend={0pt}{1cm}](A)(X-2)
2447 \tznode(X-2){\texttt{X-2}}[br]
2448 \end{tikzpicture}
2449 \end{tzcode}
2450
2451 \begin{tzcode}{.3}
2452 % \tzcoortangenttocircle
2453 \begin{tikzpicture}
2454 \tzhelplines(4,3)
2455 \tznodecircle(1,1)(KK)(2cm)
2456 \tzcoor*(4,3)(A){A}[0]
2457 \tzcoortangenttocircle(KK)(A)(X){X}[90](Y){Y}[-45]
2458 \tzline[red, tzextend={0pt}{1cm}](A)(X)
2459 \tzline[blue,tzextend={0pt}{1cm}](A)(Y)
2460 \tzpath*[red](A)(X)(KK.center);
2461 \tzpath*[blue](A)(Y)(KK.center);
2462 \tzrightanglemark(A)(X)(KK.center)
2463 \tzrightanglemark(A)(Y)(KK.center)
2464 \end{tikzpicture}
2465 \end{tzcode}
2466
2467 \begin{tzcode}{.3}
2468 % outer common tangent
2469 \begin{tikzpicture}
2470 \tzhelplines*(5,5)
2471 \def\rA{.5}
2472 \def\rB{1.5}
2473 \tznodecircle(1,1)(A){A}(2*\rA cm)
2474 \tznodecircle(3,3)(B){B}(2*\rB cm)
2475 \tzcoor($(A.center)!{\rA/(\rA-\rB)}!(B.center)$)(X)
2476 \tzdot*(X){X}[br]
2477 \tzcoortangenttocircle*(A)(X)(tanA) %%
2478 \tzcoortangenttocircle*(B)(X)(tanB) %%
2479 \tzline[->,red, tzextend={0pt}{2cm}](X)(tanB)
2480 \tzline[->,blue,tzextend={0pt}{2cm}](X)(tanB-2)
2481 \end{tikzpicture}
2482 \end{tzcode}
2483
2484 \begin{tzcode}{.3}
2485 % inner common tangent
2486 \begin{tikzpicture}
2487 \tzhelplines*(5,5)
2488 \def\rA{.5}
2489 \def\rB{1}
2490 \tznodecircle(1,1)(A){A}(2*\rA cm)
2491 \tznodecircle(3,3)(B){B}(2*\rB cm)
2492 \tzcoor($(A.center)!{\rA/(\rA+\rB)}!(B.center)$)(X)
2493 \tzdot*(X){X}[al]
2494 \tzcoortangenttocircle*(A)(X)(tanA) %%
2495 \tzcoortangenttocircle*(B)(X)(tanB) %%
2496 \tzline[->,red, tzextend={1cm}{2cm}](tanA)(tanB)
2497 \tzline[->,blue,tzextend={1cm}{2cm}](tanA-2)(tanB-2)
2498 \end{tikzpicture}
2499 \end{tzcode}
2500
2501 %%------------------------------------------------------------
2502 \section{\protect\cmd{\tznodeellipse} and \protect\cmd{\tznodeellipse*}}
2503 \label{s:tznodeellipse}
2504
2505 \icmd{\tznodeellipse} works just like |\tznodeframe| but with an ellipse node.
2506
2507 \begin{tzdef}
2508 % syntax:
2509 \tznodeellipse[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]
2510 % defaults
2511 [ellipse]<>(<m>)(){}[text=black]
2512 \end{tzdef}
2513
2514 The starred version \icmd{\tznodeellipse*} works just like |\tznodeframe*| but with an ellipse node.
2515
2516 \begin{tzdef}
2517 % syntax:
2518 \tznodeellipse*[<opt>]<shift coor>
2519 (<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>}
2520 % defaults
2521 *[ellipse,fill=black!50,fill opacity=.3,text opacity=1] <>
2522 (<m>)(){}[draw=black,text=black]{.3}
2523 \end{tzdef}
2524
2525
2526 \begin{tzcode}{.3}
2527 % \tznodeellipse
2528 \begin{tikzpicture}
2529 \tzhelplines(4,3)
2530 \tznodeellipse(0,3)
2531 \tznodeellipse(0,0)(A)
2532 \tznodeellipse(4,2)(B)[circle]
2533 \tzline[blue,thick](A)(B)
2534 \tznodeellipse[scale=1.5](2,1){Node frame}
2535 [label=180:Left, pin=-45:pin]
2536 \end{tikzpicture}
2537 \end{tzcode}
2538
2539 \icmd{\tznodeoval} and \icmd{\tznodeoval*} are aliases of |\tznodeellipse| and |\tznodeellipse*|, respectively.
2540
2541 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.
2542 The \xem{empty} shift option |<>| is \xem{not allowed}.
2543
2544 \begin{tzcode}{.3}
2545 % opacity, shift
2546 \begin{tikzpicture}
2547 \tzhelplines[solid](4,3)
2548 \tznodeellipse(0,0)
2549 \tznodeoval*(1,2)(A){A}{.1} % opacity
2550 \tznodeoval[fill=yellow](2,2)(B){B}
2551 \tznodeellipse*[red](3,2)(C){Cat}
2552 \tznodeellipse[fill=green]<-1,-2>(4,2)(D){Dog} % shift
2553 \tzto[->,bend left=45](A.north)(C.90)
2554 \tzto[->,bend right=45,dashed](B.-135)(D.west)
2555 \end{tikzpicture}
2556 \end{tzcode}
2557
2558
2559 %%==================================
2560 \chapter{Lines}
2561 \label{c:lines}
2562
2563 %%------------------------------------------------------------
2564 \section{\protect\cmd{\tzline}: Connecting two points}
2565 \label{s:tzline}
2566
2567 \icmd{\tzline} connects two points with a straight line.
2568
2569 \begin{tzdef}
2570 % syntax: miminum
2571 \tzline(<coor1>)(<coor2>)
2572 % syntax: medium
2573 \tzline[<opt>](<coor1>){<text1>}[<node opt1>]
2574 (<coor2>){<text2>}[<node opt2>]
2575 % syntax: full
2576 \tzline[<opt>]<shift coor>"<path name>"
2577 (<coor1>){<text1>}[<node opt1>]
2578 (<coor2>){<text2>}[<node opt2>]<code.append>
2579 % defaults
2580 []<>""(<m>){}[above](<m>){}[]<>
2581 \end{tzdef}
2582
2583
2584 \begin{tztikz}
2585 \tzline(0,1)(2,1) % works like:
2586 \draw (0,1) -- (2,1);
2587 \end{tztikz}
2588
2589
2590 \subsection{Line styles}
2591 \label{ss:tzline:linestyles}
2592
2593 You can use the first optional argument |[<opt>]| to control the line styles.
2594
2595 \begin{tztikz}
2596 \tzline[blue](0,1)(2,1) % works like:
2597 \draw [blue] (0,1) -- (2,1);
2598 \end{tztikz}
2599
2600 \begin{tzcode}{.3}
2601 % \tzline
2602 \begin{tikzpicture}
2603 \tzhelplines(4,3)
2604 \tzline[blue,->](0,0)(3,3)
2605 \tzline[<->](0,2)(3,0)
2606 \tzline[dashed](1,2)(4,0)
2607 \tzdots*(1,2)(4,0);
2608 \end{tikzpicture}
2609 \end{tzcode}
2610
2611 \subsection{Adding text}
2612 \label{ss:tzline:addingtext}
2613
2614 You can add text by specifying the optional arguments |{<text>}| and |[<node opt>]|.
2615
2616 \paragraph{Text next to the line}
2617 With the options |{<text1>}[<node opt1>]| \xem{in-between} two coordinates, you can add text next to the line, with the option |[above,midway]| by default.
2618
2619 \begin{tztikz}
2620 \tzline[blue](0,1){my line}[sloped](2,1) % works like:
2621 \draw [blue] (0,1) -- node [above,sloped] {my line} (2,1) ;
2622 \end{tztikz}
2623
2624 \begin{tzcode}{.3}
2625 % \tzline: text next to line
2626 \begin{tikzpicture}
2627 \tzhelplines(4,3)
2628 \tzline(0,0){Above}(4,0) % default [above]
2629 \tzline[blue](0,1){Near end}[b,near end](4,1) % below
2630 \tzline[->](0,2){Sloped}[sloped](3,3) % default [above]
2631 \end{tikzpicture}
2632 \end{tzcode}
2633
2634 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}.)
2635
2636
2637 \paragraph{Text at or around the last coordinate}
2638
2639 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.
2640
2641 \begin{tztikz}
2642 \tzline[blue](0,1)(2,1){my line}[r] % works like:
2643 \draw [blue] (0,1) -- (2,1) node [right] {my line};
2644 \end{tztikz}
2645
2646
2647 \begin{tzcode}{.3}
2648 % \tzline
2649 \begin{tikzpicture}
2650 \tzhelplines(4,3)
2651 \tzline[blue,->](0,0)(3,3){\textbf{line A}}[r]
2652 \tzline[<->](0,2)(3,0){line B}[red,draw=blue,b=1mm]
2653 \tzline[dashed](1,2){dashed}[sloped](4,0){line C}[ar]
2654 \tzdots*(1,2)(4,0);
2655 \end{tikzpicture}
2656 \end{tzcode}
2657
2658 %\subsection{Relative coordinates: \texttt{+} or \texttt{++}}
2659 %\label{ss:tzline:relative}
2660 %
2661 %You can make the second coordinate relative to the first.
2662 %You can even select `|+| relative' or `|++| relative' by specifying the option |<+>| or |<++>| immediately before the second coordinate.
2663 %
2664 %\begin{tztikz}
2665 %\tzline+(0,0)<+>(2,1) % works like:
2666 % \draw (1,1) -- + (2,1);
2667 %\end{tztikz}
2668 %
2669 %\begin{tzcode}{.3}
2670 %% \tzline
2671 %\begin{tikzpicture}
2672 %\tzhelplines(4,3)
2673 %\tzline[blue,->](0,0) (3,3) {A}[r]
2674 %\tzline[<->] (0,2){b} <+>(3,-2){B}[r]
2675 %\tzline[dashed] (1,2){c}<++>(3,-2){C}[r]
2676 %\tzdots*(1,2)(4,0);
2677 %\end{tikzpicture}
2678 %\end{tzcode}
2679 %
2680 %Notice that, with |\tzline|, |<+>| and |<++>| make no difference.
2681 %But with the macro |\tzlines| it is not the case.
2682 %
2683 %\remark
2684 %Notice that using |<+>| and |<++>| makes no difference in |\tzline|.
2685 %But it is not the case with the macro |\tzlines| that connects multiple coordinates.
2686
2687 \subsection{Moving lines: \texttt{shift}}
2688 \label{ss:tzline:shift}
2689
2690 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).
2691 The empty shift coor |<>| is not allowed.
2692
2693 \begin{tzcode}{.3}
2694 % \tzline: shift
2695 \begin{tikzpicture}
2696 \tzhelplines(4,3)
2697 \tzline[blue,->] (0,0)(3,3){A}[r]
2698 \tzline[blue] <1,0>(0,0)(3,3){A}[r]
2699 \tzline[dashed] (1,2)(4,0){C}[r]
2700 \tzline[dashed]<-.5,-.5>(1,2)(4,0){C}[r]
2701 \tzdots*(1,2)(4,0);
2702 \end{tikzpicture}
2703 \end{tzcode}
2704
2705
2706
2707 \subsection{Extending paths}
2708 \label{ss:tzline:extendingpath}
2709
2710 You can extend the path of |\tzline| from the last coordinate, by writing \Tikz\ code in the last optional argument |<code.append>|.
2711
2712 \begin{tzcode}{.3}
2713 % \tzline: shift
2714 \begin{tikzpicture}
2715 \tzhelplines(4,3)
2716 \tzline[blue,->](0,0)(3,3)<arc(0:-60:1cm)>
2717 \tzline[dashed,->](1,2)(4,0)
2718 <to[bend left] ++(-4,1) node [a] {ends here!}>
2719 \end{tikzpicture}
2720 \end{tzcode}
2721
2722 You can also use \icmd{\tzlineAtBegin} and \icmd{\tzlineAtEnd} to extend a path of |\tzline| at the beginning and at end, respectively.
2723 Specifying |<code.append>| extends the path after |\tzlineAtEnd|.
2724
2725 \begin{tzcode}{.3}
2726 % \tzline: shift
2727 \begin{tikzpicture}
2728 \tzhelplines(4,3)
2729 \tzline[blue,->](0,0)(3,3)<arc(0:-60:1cm)>
2730 \tzlineAtBegin{(2,3) -|}
2731 \tzlineAtEnd{ arc (-90:90:.5) node [a] {here?} }
2732 \tzline[dashed,->](1,2)(4,0)
2733 < to[bend left] ++(-4,1) node [a] {ends here!} >
2734 \end{tikzpicture}
2735 \end{tzcode}
2736
2737 \subsection{Naming paths: Intersection points}
2738 \label{ss:tzline:namepath}
2739
2740 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>]|.
2741 You can use this name of path to find intersection points.
2742
2743 \begin{tzcode}{.3}
2744 % \tzline+: name path
2745 \begin{tikzpicture}
2746 \tzhelplines(4,3)
2747 \tzline[blue,->] "dem" (0,0)(3,3){demand}[r]
2748 \tzline[dashed,->]"supp"(1,2)(4,0){supply}[ar]
2749 % intersection point
2750 \tzXpoint*{dem}{supp}
2751 \end{tikzpicture}
2752 \end{tzcode}
2753
2754
2755 %%------------------------------------------------------------
2756 \section{\protect\cmd{\tzline+}: Relative coordinates}
2757 \label{s:tzline+}
2758
2759 The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| relative (with |++|) to the first coordinate |(<coor1>)|.
2760 %That is, |\tzline+(A)(B)| is equivalent to |\tzline(A)<++>(B)|.
2761
2762 \xem{Everything else is the same as in} |\tzline|.
2763
2764 \begin{tzdef}
2765 % syntax: full
2766 \tzline+[<opt>]<shift coor>"<path name>"
2767 (<coor1>){<text1>}[<node opt1>]
2768 (<coor2>){<text2>}[<node opt2>]<code.append>
2769 % defaults
2770 +[]<>""(<m>){}[above](<m>){}[]<>
2771 \end{tzdef}
2772
2773
2774 \begin{tztikz}
2775 \tzline+(0,1)(2,1) % works like:
2776 \draw (0,1) -- ++ (2,1);
2777 \end{tztikz}
2778
2779 \begin{tztikz}
2780 \tzline+[dashed]"AA"(0,1){A}[red](2,1){B}[right,blue] % works like:
2781 \draw [dashed,name path=AA]
2782 (0,1) -- node [red] {A} ++ (2,1) node [right,blue] {B};
2783 \end{tztikz}
2784
2785
2786 \begin{tzcode}{.3}
2787 % \tzline+
2788 \begin{tikzpicture}
2789 \tzhelplines(4,3)
2790 \tzline+[blue,->](0,1)(3,2) {A}[r]
2791 \tzline+[<->] (0,2){b}(3,-2){B}[r]
2792 \tzline+[dashed]<1,0>(0,2){b}(3,-2){B}[r]
2793 \end{tikzpicture}
2794 \end{tzcode}
2795
2796
2797 \begin{tzcode}{.3}
2798 % \tzline+: name path
2799 \begin{tikzpicture}
2800 \tzhelplines(4,3)
2801 \tzline+[blue,->] "dem" (0,0)(3,3){demand}[r]
2802 \tzlineAtBegin{(0,1) to [bend left] }
2803 \tzline+[dashed,->]"supp"(1,2)(3,-2){supply}[ar]
2804 % intersection point
2805 \tzXpoint*{dem}{supp}
2806 \end{tikzpicture}
2807 \end{tzcode}
2808
2809
2810 %%------------------------------------------------------------
2811 \section{Styles: \texttt{tzshorten} and \texttt{tzextend}}
2812 \label{s:tzshorten}
2813
2814 The styles \ixxw{tzshorten} and \ixxw{tzextend} are defined as follows:
2815
2816 \begin{tzsty}
2817 % tzshorten
2818 \tikzset{%
2819 tzshorten/.style 2 args ={shorten <=#1, shorten >=#2},
2820 tzshoretn/.default={2pt}{2pt}
2821 }
2822
2823 % tzextend (negative tzshorten)
2824 \tikzset{%
2825 tzextend/.style 2 args ={shorten <=-#1, shorten >=-#2},
2826 tzextend/.default={2pt}{2pt}
2827 }
2828 \end{tzsty}
2829
2830 For example, |[tzshorten={2mm}{1mm}]| is equivalent to |[shorten <=2mm,shorten >=1mm]| in \Tikz. Simple |[tzshorten]| means |[tzshorten={2pt}{2pt}]| by default.
2831
2832 The style |tzextend| is a negative |tzshorten|. For example, |tzextend{2mm}{1mm}| is equivalent to |tzshorten{-2mm}{-1mm}|.
2833
2834
2835 \begin{tzcode}{.3}
2836 % tzshorten, tzextend
2837 \begin{tikzpicture}
2838 \tzhelplines(4,3)
2839 \tzdots(0,0)(3,0); \tzline(0,0)(3,0)
2840 \tzdots(0,1)(3,1);
2841 \tzline[->,thick,blue,tzshorten={2mm}{1mm}](0,1)(3,1)
2842 \tzdots(1,2)(3,2);
2843 \tzline[<->,thick,red,tzextend={1cm}{1cm}](1,2)(3,2)
2844 \end{tikzpicture}
2845 \end{tzcode}
2846
2847
2848 %%------------------------------------------------------------
2849 \section{\protect\cmd{\tzlines}: Connecting multiple points: Semicolon version}
2850 \label{s:tzlines}
2851
2852 \icmd{\tzlines} connects two or more points with connected line segments.
2853 Since |\tzlines| takes an arbitrary number of coordinates as arguments, it is a \xem{semicolon version}. So, you need to enter a semicolon `|;|' to indicate when the coordinate iteration ends.
2854
2855 \begin{tzdef}
2856 % syntax: minimum
2857 \tzlines(<coor>)(<coor>)..repeated..(<coor>) ;
2858 % syntax: medium
2859 \tzlines(<coor>){<text>}[<node opt>]..repeatd..(<coor>){<text>}[<node opt>] ;
2860 % syntax: full
2861 \tzlines[<opt>]<shift coor>"<path name>"
2862 (<coor>){<text>}[<node opt>]
2863 ..repeated.. (){}[] ; <code.append>
2864 % defaults
2865 []<>"" (<m>){}[] ..repeated.. (){}[] ; <>
2866 \end{tzdef}
2867
2868
2869 \begin{tztikz}
2870 \tzlines(1,1)(2,2)(3,1)(4,3); % works like:
2871 \draw (1,1) -- (2,2) -- (3,1) -- (4,3);
2872 \end{tztikz}
2873
2874 The whole repeating pattern in |\tzlines| is the triple |(<coor>){<text>}[<node opt>]|.
2875 %Any |<+ or ++>| after the last coordinate, if any, is ignored.
2876
2877 \begin{tztikz}
2878 \tzlines(1,1)(2,2)(3,1){C}(4,3){D}[r]; % works like:
2879 \draw (1,1) -- (2,2) -- (3,1) -- node {C} (4,3) node [right] {D};
2880 \end{tztikz}
2881
2882 \paragraph{Line styles}
2883 Use the first optional argument |[<opt>]| to control the style of the connected line drawn by |\tzlines|.
2884
2885 \begin{tzcode}{.3}
2886 % \tzlines: line style
2887 \begin{tikzpicture}
2888 \tzhelplines(4,3)
2889 \tzlines[blue,<->](0,1)(1,2)(3,1)(4,3); % semicolon
2890 \tzlines[dashed](0,0)(1,1)(2,1)(3,0);
2891 \end{tikzpicture}
2892 \end{tzcode}
2893
2894 \paragraph{Adding text}
2895
2896 You can add text in the |midway|, by default, of each line segment by specifying the options |{<text>}| and |[<node opt>]| immediately after each coordinate (except the last one).
2897 The options |{<text>}| and |[<node opt>]| after the last coordinate put |<text>| at or around the last coordinate.
2898
2899
2900 \begin{tzcode}{.3}
2901 % \tzlines: adding text
2902 \begin{tikzpicture}
2903 \tzhelplines(4,3)
2904 \tzlines[red,thick,<->,text=blue]
2905 (0,1){Up}
2906 (1,2){Down}[a,sloped]
2907 (3,1){Up}
2908 (4,3){line A} ;
2909 \tzlines[dashed](0,0)(1,1)(2,1)(3,0){line B}[r];
2910 \end{tikzpicture}
2911 \end{tzcode}
2912
2913 %\paragraph{Relative coordinates: \texttt{+} and \texttt{++}}
2914 %
2915 %You can make the coordinates (from the second coordinate) relative to the previous one by specifying the option |<+>| and |<++>| immediately before the coordinates.
2916 %(In \Tikz, only |<++>| refreshes the \xem{current point} to new one.)
2917 %
2918 %\begin{tzcode}{.3}
2919 %% \tzlines
2920 %\begin{tikzpicture}
2921 %\tzhelplines(4,3)
2922 %\tzlines[red,thick,<->,text=blue]
2923 % (0,1){Up}
2924 % <+>(1,1){Down}[a,sloped] % current point: (0,1)
2925 % <++>(3,0){Up} % new current point: (3,1)
2926 % <++>(1,2){line A} ;
2927 %\tzlines[dashed](0,0)(1,1)(2,1)<++>(1,-1){line B}[r];
2928 %\end{tikzpicture}
2929 %\end{tzcode}
2930
2931 \paragraph{Shift}
2932 You can move the connected line by specifying |<shift coor>| before the first coordinate or immediately before the option |"<path name>"| if it exists.
2933 (The empty shift option |<>| is not allowed.)
2934
2935 \begin{tzcode}{.3}
2936 % \tzlines: shift
2937 \begin{tikzpicture}
2938 \tzhelplines(4,3)
2939 \tzlines[red,thick,<->,text=blue]
2940 <0,-1>(0,1)
2941 (1,2)
2942 (3,1)
2943 (4,3){shifted\\line A}[align=left,ar] ;
2944 \tzlines[dashed]<1,0>(0,0)(1,1)(2,1)(3,0){line B}[r] ;
2945 \end{tikzpicture}
2946 \end{tzcode}
2947
2948
2949 \paragraph{Naming paths}
2950 You can name the path of |\tzlines| by specifying the option |"<path name>"| immediately before the first coordinate.
2951
2952 \begin{tzcode}{.3}
2953 % \tzlines: shift, intersection
2954 \begin{tikzpicture}
2955 \tzhelplines(4,3)
2956 \tzlines[red,thick,<->,text=blue]
2957 <0,-1>"AA"(0,1)
2958 (1,2)(3,1)(4,3){shifted\\line A}[align=left,ar] ;
2959 \tzlines[dashed]
2960 <1,0>"BB"(0,0)(1,1)(2,1)(3,0){line B}[r] ;
2961 % intersection points
2962 \tzXpoint*{AA}{BB}(X){X1}[-90] % [<angle>] for point
2963 \tzdot(X-2){X2}[0] % [<angle>] for dot
2964 \end{tikzpicture}
2965 \end{tzcode}
2966
2967
2968
2969 \paragraph{Extending paths}
2970 You can extend the path of |\tzlines| by writing \Tikz\ code in the \xem{last} (even \xem{after the semicolon}) optional argument |<code.append>|.
2971
2972 \begin{tzcode}{.3}
2973 % \tzlines: <code.append>
2974 \begin{tikzpicture}
2975 \tzhelplines(4,3)
2976 \tzlines[red,thick,<->,text=blue]
2977 (0,1){Up}
2978 (1,2){Down}[a,sloped]
2979 (3,1){Up}
2980 (4,3) ;
2981 <arc(0:90:1cm)>
2982 \tzlines[dashed]
2983 (0,0)(1,1)(2,1)(3,0) ;
2984 <to[bend right] ++(2,2) node{Here!}>
2985 \end{tikzpicture}
2986 \end{tzcode}
2987
2988 You can close the path with a straight line by |<--cycle>|.
2989
2990 \begin{tzcode}{.3}
2991 % \tzlines: closed path
2992 \begin{tikzpicture}
2993 \tzhelplines(4,3)
2994 \tzlines[red,thick,<->,text=blue]
2995 (0,1){Up}
2996 (1,2){Down}[a,sloped]
2997 (3,1){Up}
2998 (4,3){line A} ; <--cycle>
2999 \tzlines[dashed]
3000 (0,0)(1,1)(2,1)(3,0){line B}[r] ; <--cycle>
3001 \end{tikzpicture}
3002 \end{tzcode}
3003
3004 You can also use \icmd{\tzlinesAtBegin} and \icmd{\tzlinesAtEnd} to extend a path of |\tzlines| at the beginning and at the end, respectively.
3005 Specifying |<code.append>| extends the path after |\tzlinesAtEnd|, if it exists.
3006
3007 \begin{tzcode}{.3}
3008 % \tzlines: extending paths
3009 \begin{tikzpicture}
3010 \tzhelplines(4,3)
3011 \tzlinesAtBegin{(1,3) to [bend right]}
3012 \tzlinesAtEnd{arc(0:90:1cm)}
3013 \tzlines[red,thick,<->,text=blue]
3014 (0,1){Up}
3015 (1,2){Down}[a,sloped]
3016 (3,1){Up}
3017 (4,3) ;
3018 \tzlinesAtEnd{to[bend right] ++(2,2) node{Here!}}
3019 \tzlines[dashed]
3020 (0,0)(1,1)(2,1)(3,0){not here}[b];
3021 < -| ++(-1,-1) node [draw,b] {Ends here!!} >
3022 \end{tikzpicture}
3023 \end{tzcode}
3024
3025
3026 %%------------------------------------------------------------
3027 \section{\protect\cmd{\tzlines+}: Relative coordinates: Semicolon version}
3028 \label{s:tzlines+}
3029
3030 The \iisw{plus version} \icmd{\tzlines+} connects two or more points with connected line segments, but each coordinate (except the first one) is \xem{relative} to the previous coordinate.
3031 %For example, |\tzline+(A)(B)(C)(D);| is equivalent to |\tzline(A)<++>(B)<++>(C)<++>(D);|.
3032
3033 \xem{Everything else is the same as in} |\tzlines|.
3034 It is also required to enter a \xem{semicolon} to indicate when the coordinate iteration ends.
3035
3036
3037 \begin{tzdef}
3038 % syntax: minimum
3039 \tzlines+ (<coor>)(<coor>) ..repeat.. (<coor>) ;
3040 % syntax: full
3041 \tzlines+[<opt>]<shift coor>"<path name>"
3042 (<coor>){<text>}[<node opt>]
3043 ..repeated.. (){}[] ; <code.append>
3044 % defaults
3045 []<>"" (<m>){}[] ..repeated.. (){}[] ; <>
3046 \end{tzdef}
3047
3048
3049 \begin{tztikz}
3050 \tzlines+(0,1)(1,1)(2,-1)(1,2); % works like:
3051 \draw (0,1) -- ++(1,1) -- ++(2,-1) -- ++(1,2);
3052 \end{tztikz}
3053
3054
3055 \begin{tztikz}
3056 \tzlines+[dashed]"AA"(0,1){A}(1,1){B}(2,-1){C}(1,2){D}[right]; % works like:
3057 \draw [dashed,name path=AA]
3058 (0,1) -- node {A} ++(1,1)
3059 -- node {B} ++(2,-1)
3060 -- node {C} ++(1,2) node [right] {D} ;
3061 \end{tztikz}
3062
3063
3064 \begin{tzcode}{.3}
3065 % \tzlines+
3066 \begin{tikzpicture}
3067 \tzhelplines(4,3)
3068 \tzlines+[red,thick,<->,text=blue]
3069 (0,1){Up}
3070 (1,1){Down}[a,sloped]
3071 (2,-1){Up}
3072 (1,2){line A} ;
3073 \tzlines+[dashed,auto,text=red]
3074 (0,0){A}
3075 (1,1){B}
3076 (1,0){C}
3077 (1,-1){line B}[blue,draw,r] ;
3078 \end{tikzpicture}
3079 \end{tzcode}
3080
3081
3082
3083 \begin{tzcode}{.3}
3084 % \tzlines+: shift
3085 \begin{tikzpicture}
3086 \tzhelplines*(4,3)
3087 \tzlines+[red,thick,<->,text=blue]
3088 <1,1> (0,1){Up}
3089 (1,1){Down}[a,sloped]
3090 (2,-1){Up}
3091 (1,2){line A} ;
3092 \tzcoors(0,0)(A)(1,1)(B)(1,0)(C)(1,-1)(D);
3093 \tzlines+[dashed,auto,text=red]
3094 <-1,.5> (A){A}
3095 (B){B}
3096 (C){C}
3097 (D){line B}[blue,draw,r] ;
3098 \end{tikzpicture}
3099 \end{tzcode}
3100
3101