summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tzplot/tzplot-doc-D-v1.0.tex
blob: 3f76a7cb3ed79bb18fe452e3379bb2501d472d16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
%!TEX root = tzplot-doc.tex
%\begin{document}

%%%==========================
\part{Plotting Graphs}
%%%==========================
\label{p:plotting}


%%==================================
\chapter{Axes}
\label{c:axes}

%%------------------------------------------------------------
\section{Draw axes}
\label{s:tzaxes}

\subsection{\protect\cmd{\tzaxes}}
\label{ss:tzaxes}

Basically, \cmd{\tzaxes}|(<x1,y1>)(<x2,y2>)| draws the $x$ axis from |<x1>| to |<x2>| and the $y$ axis from |<y1>| to |<y2>|.
The coordinate |(<x1,y1>)| represents the origin and |(<x2,y2>)| represents the opposite corner of the rectangle.

|\tzaxes| takes only one coordinate |(<x2,y2>)| as a mandatory argument, in which case |(<x1,y1>)| is considered as |(0,0)|.

\begin{tzdef}{}
% syntax: minimal
\tzaxes(<x2,y2>){<x-axis name>}{<y-axis name>}
% syntax: full
\tzaxes[<opt>]<x-shift,y-shift>(<x1,y1>)(<x2,y2>)
        {<x-axis label>}[<node opt>]{<y-axis name>}[<node opt>]
% defaults
  [->]<0,0>(0,0)(<m>){}[right]{}[above]
% arguments
  [#1]: line style, arrow type (for x-axis & y-axis)
  <#2>: axes shift coor    %% axes intersect at (#2)
  (#3): (x1,y1)            %% origin: if omitted, regarded as (0,0)
  (#4): (x2,y2)            %% opposite corner: mandatory
  {#5}: x-axis name      
  [#6]: x-axis name option %% node option
  {#7}: y-axis name      
  [#8]: y-axis name option %% node option
\end{tzdef}

Here, |(|\ixxw{<m>}|)| stands for a mandatory argument.

\begin{tzcode}{.3}
% tzaxes
\begin{tikzpicture}[scale=.7]
\tzhelplines(3,3)
\tzaxes(3,3){$x$}{$y$}
\end{tikzpicture}
\end{tzcode}

\paragraph{Shift}
By default, the $x$ and $y$ axes intersect at $(0,0)$.
Specifying the option |<x-shift,y-shift>| moves the axes to intersect at $(\text{\ttfamily<x-shift,y-shift>})$.


\begin{tzcode}{.3}
% \tzaxes: shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(-1,-1)(7,7)
\tzshoworigin*
\tzaxes[thick,blue]<1,2>(7,7){$x$}{$y$}
\tzaxes[-,dashed](7,7){$X$}[below]{$Y$}[left]
\tzaxes<6,1>(6,1)(3,6){$a$}[left]{$b$}
\end{tikzpicture}
\end{tzcode}


\subsection{\protect\cmd{\tzaxes*}}
\label{ss:tzaxes*}

The starred version \icmd{\tzaxes*} sets the current state to a \iisw{bounding box} when |\tzaxes| is executed. It is recommended for you to use |\tzaxes*| as the first graphics command in |tikzpicture| environment or before any larger graphics.

\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.5]
\tzaxes*(8,5){$x$}{$f(x)$} % bounding box
\tzhelplines(-2,-1)(10,8)
\tzto[out=90,in=-135,dashed](-2,8)(12,-2)
\tzbezier[blue](-1,-1)(3,-2)(7,12)(10,10)
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{\protect\cmd{\tzaxisx} and \protect\cmd{\tzaxisy}}
\label{s:tzaxisx}

\icmd{\tzaxisx} draws only the $x$ axis.

\begin{tzdef}{}
% syntax
\tzaxisx[<opt>]<y-shift>{<from>}{<to>}{<x-axis name>}[<node opt>]
% defaults
  [->]<0>{<m>}{<m>}{}[right]
% arguments:
  [#1]: line style, arrow type (for x-axis)
  <#2>: y-shift of x-axis
  {#3}: x-axis starts from %% mandatory
  {#4}: x-axis runs to     %% mandatory
  {#5}: x-axis name      
  [#6]: x-axis name option %% node option
\end{tzdef}

\icmd{\tzaxisy} draws only the $y$ axis.

\begin{tzdef}{}
% syntax
\tzaxisy[<opt>]<x-shift>{<from>}{<to>}{<y-axis name>}[<node opt>]
% defaults
  [->]<0>{<m>}{<m>}{}[above]
% arguments:
  [#1]: line style, arrow type (for y-axis)
  <#2>: x-shift of y axis
  {#3}: y-axis starts from %% mandatory
  {#4}: y-axis runs to     %% mandatory
  {#5}: y-axis name      
  [#6]: y-axis name option %% node option
\end{tzdef}



\begin{tzcode}{.3}
% \tzaxisx, \tzaxisy
\begin{tikzpicture}[scale=.5]
\tzshoworigin
\tzhelplines(5,5)
\tzaxisx[blue]{-1}{5}{$xx$}
\tzaxisy[red] {-1}{5}{$yy$}[green]
\end{tikzpicture}
\end{tzcode}



\begin{tzcode}{.3}
% \tzaxisx, \tzaxisy: shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(7,7)
\tzshoworigin
\tzaxisx{-1}{7}{$xx$}[near end,below]
\tzaxisy{-1}{7}{$yy$}[midway,sloped,auto]
\tzaxisx[-,dashed,red]<2>{-1}{7}{$xx'$}[blue]
\tzaxisy[-,dashed,blue]<3>{-1}{7}{$yy'$}
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{Display the origin}
\label{s:tzshoworigin}

\subsection{\protect\cmd{\tzshoworigin}}
\label{ss:tzshoworigin}


\icmd{\tzshoworigin} prints `0' (approximately) at the bottom left of the origin |(0,0)|, by default.

\begin{tzdef}{}
% syntax
\tzshoworigin<shift coor>(<origin>){<text>}[<node opt>]
% default
  <>(0,0)<>{0}[below left,text height=1.25ex,text depth=.25ex]
\end{tzdef}

All arguments of |\tzshoworigin| are optional.

\begin{tzcode}{.3}
% \tzshoworigin
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,5)
\tzshoworigin
\tzaxes(8,5)
\end{tikzpicture}
\end{tzcode}

You can change the text by specifying the curly brace option |{<text>}|, like, for example, |\tzshoworigin{$O$}|.
You can also change the coordinate of origin by the option |(<origin>)|.
Specifying the option |<shift coor>| also moves the origin.


\begin{tzcode}{.3}
% \tzshoworigin
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-1)(8,6)
\tzshoworigin{$O_1$}
\tzaxes(8,6){$x$}{$y$}
\tzshoworigin<2,1>{$O_2$}[red]
\tzaxes[dashed]<2,1>(8,6)
\end{tikzpicture}
\end{tzcode}


\subsection{\protect\cmd{\tzshoworigin*}}
\label{ss:tzshoworigin*}


\icmd{\tzshoworigin*} prints a node dot at the origin with no text by default.
Internally the dot is processed by |\tzdot*|. All arguments are optional.

\begin{tzdef}{}
% syntax
\tzshoworigin*[<dot opt>]<shift coor>(<origin>){<text>}[<node opt>](<dotsize>)
% default
 *[]<>(0,0)<>{}[below left,text height=1.25ex,text depth=.25ex](2.4pt)
\end{tzdef}

\begin{tzcode}{.3}
% \tzshoworigin*
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-1)(6,4)
\tzshoworigin*
\tzaxes(-2,-1)(6,4)
\end{tikzpicture}
\end{tzcode}

You can add text with the option |{<text>}|.
The default size of the dot is |2.4pt|, and it can be changed it with the last option |(<dot size)|. You can change the dot style using the first optional argument |[<dot opt>]|.
You can also move the dot by specifying the option |<shift coor>|.

\begin{tzcode}{.3}
% \tzshoworigin*
\begin{tikzpicture}[scale=.5]
\tzhelplines(-1,-1)(7,7)
\tzshoworigin*[blue]{$o_1$}[red](5pt)
\tzaxes(-1,-1)(7,7){$x$}{$y$}
\tzaxes<6,4>(6,4)(1,1){$x'$}[left]{$y'$}[below]
\tzshoworigin*[fill=none]<6,4>{$O'$}[blue,ar](3pt)
\end{tikzpicture}
\end{tzcode}

\remark
For |\tzshoworigin*|, text for the origin and the dot are placed independently. In other words, the position of node text does not depend on the size of a node dot.
(In fact, the node text for the origin should look good with the `ticks', so it was not designed as a |label| for the node dot. This also means that the origin text cannot be positioned by an |<angle>|.)


\begin{tzcode}{.3}
% \tzshoworigin* (with ticks)
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,1)(6,5)
\tzshoworigin*{0}(5pt)
\tzaxes(-2,-1)(6,5){$x$}{$y$}
\tzticks{1,...,5}{1,...,4}
\end{tikzpicture}
\end{tzcode}



%%------------------------------------------------------------
\section{\protect\cmd{\tzaxesL(')}: L-type axes}
\label{s:tzaxesL}

\icmd{\tzaxesL} is similar to |\tzaxes|, but it draws only the `L' type axes with |(<x1,y1>)| as the origin and |(<x2,y2>)| as the opposite corner of the rectangle. 
Those two coordinates are mandatory.

\begin{tzdef}{}
% syntax
\tzaxesL[<opt>]<shift coor>(<x1,y1>)(<x2,y2>)
        {<x-axis name>}[<node opt>]{<y-axis name>}[<node opt>]
% defaults
  []<>(<m>)(<m>){}[right]{}[above]
% arguments:
  [#1]: line style, arrow type
  <#2>: shift coordinate
  (#3): (x1,y1)            %% mandatory
  (#4): (x2,y2)            %% mandatory
  {#5}: x-axis name
  [#6]: x-axis name option %% node option
  {#7}: y-axis name
  [#8]: y-axis name option %% node option
\end{tzdef}

The swap version \icmd{\tzaxesL'} swaps |(x1,y1)| and |(x2,y2)| from |\tzaxesL|.
That is, |\tzaxesL'(A)(B)| is equivalent to |\tzaxesL(B)(A)|.

\begin{tzcode}{.3}
% \tzaxesL, \tzaxesL'
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,7)
\tzshoworigin
\tzaxes(8,7){$x$}{$y$}
\tzaxesL[red,thick](2,2)(6,5){$a$}{$b$}
\tzaxesL'[blue,dashed,->](2,2)(6,5){$c$}{$d$}
\tzaxesL'[->](7,1)(4,7){m}[draw,r]{n}[draw,circle]
\end{tikzpicture}
\end{tzcode}

The option |<shift coor>| moves the whole L-type axes.

\begin{tzcode}{.3}
% \tzaxesL, \tzaxesL': shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,7)
\tzshoworigin
\tzaxes(8,7){$x$}{$y$}
\tzaxesL[red,thick](2,2)(6,5){$a$}{$b$}
\tzaxesL[red,thick]<.5,.5>(2,2)(6,5){$a'$}{$b'$}
\tzaxesL'[blue,dashed,->](2,2)(6,5){$c$}{$d$}
\tzaxesL'[blue,dashed,->]<-1,-1>(2,2)(6,5){$c'$}{$d'$}
\end{tikzpicture}
\end{tzcode}



%%==================================
\chapter{Ticks}
\label{c:ticks}


%%------------------------------------------------------------
\section{\protect\cmd{\tzticks}: Tick labels}
\label{s:tzticks}

By default, \icmd{\tzticks} prints tick labels and draw zero length tick marks, i.e. from |(0pt)| to |(0pt)|.

\begin{tzdef}{}
% syntax: minimal
\tzticks{<x-ticks pos>}{<y-ticks pos>}
% syntax: medium
\tzticks(<x-from:x-to>){<x-ticks pos/labels>}[<node opt>]
        (<y-from:y-to>){<y-ticks pos/labels>}[<node opt>]
% syntax: full
\tzticks[<opt>]<x-shift,y-shift>
        (<x-from:x-to>){<x-ticks pos/labels>}[<node opt>]
        (<y-from:y-to>){<y-ticks pos/labels>}[<node opt>]
% defaults
  []<0,0>(0pt:0pt){<m>}[text height=1.25ex,text depth=.25ex,below](0pt:0pt){}[left]
\end{tzdef}

\paragraph{Tick labels}
Internally, |\tzticks| uses \Tikz's |foreach| operation.
So you need to provide comma separated lists to print tick labels.
If only one comma separated is used, it is for $x$ tick labels.

\begin{tzcode}{.3}
% \tzticks
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzaxes(-1,-1)(10,10)
\tzticks[blue]{1,...,8}{2,...,7}
\end{tikzpicture}
\end{tzcode}

You change the numbered labels to a different format slashes and other text, as follows: |<number>/<other text>|.

\begin{tzcode}{.3}
% \tzticks: tick labels
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzaxes(-1,-1)(10,10)
\tzticks{1/$x_1$,2,5/$x_2$,8/$x_3$}[blue]
        {2/$\sqrt{x}$,3/y,4/m,5,7/$k$}[red]
\end{tikzpicture}
\end{tzcode}

\paragraph{Tick marks}
To prints tick marks you need to specify |(<x-from:x-to>)| for $x$ ticks and/or |(<y-from:y-to>)| for $y$ ticks. (The default is |(0pt:0pt)|.)

\begin{tzcode}{.3}
% \tzticks: tick marks
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzticks[draw=red,thick]
        (-5pt:10pt){1,...,7,8/$\alpha$}
        (0pt:3cm){2,...,6,7/$\beta$}
\end{tikzpicture}
\end{tzcode}


\paragraph{Shift}
The position of tick labels does not depend on the length of the tick marks.
To change the position, use the option |<x-shift,y-shift>|, where |<x-shift>| is for |y-ticks| and |<y-shift>| is for |x-ticks|.

\begin{tzcode}{.3}
% \tzticks: shift
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzaxes[dashed]<4,2>(-1,-1)(10,10)
\tzticks[draw=red]<4,2>
        (-5pt:10pt){5,...,8}
        (0pt:3cm){3,...,7}
\end{tikzpicture}
\end{tzcode}





%%------------------------------------------------------------
\section{\protect\cmd{\tzticks*}: Tick marks}
\label{s:tzticks*}

The starred version \icmd{\tzticks*} always ignores all tick labels and draws tick marks from |0pt| to |3pt|, by default.

\begin{tzdef}{}
% syntax: minimal
\tzticks*{<x-ticks pos>}{<y-ticks pos>}
% syntax: medium
\tzticks*(<x-from:x-to>){<x-ticks pos>}(<y-from:y-to>){<y-ticks pos>}
% syntax: full
\tzticks*[<opt>]<x-shift,y-shift>
         (<x-from:x-to>){<x-ticks pos/labels>}(<y-from:y-to>){<y-ticks pos/labels>}
% defaults
  []<0,0>(0pt:3pt){<m>}(0pt:3pt){}
% starred(*) version always ignores tick labels
\end{tzdef}

\begin{tzcode}{.3}
% \tzticks*
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzticks*[draw=red,thick]
          {1,...,7,8/$\alpha$} % label ignored
 (0pt:3cm){2,...,6,7/$\beta$}  % label ignored
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.5}
% \tzticks*
\begin{tikzpicture}[scale=.5]
\tzhelplines(10,8)
\tzaxes(-1,-1)(10,8)
\tzticks*{0,0.2,...,8}
         {0,0.2,...,7} % default
\tzticks*(0pt:10pt){1,...,8}
         (0pt:10pt){1,...,7}
\tzticks{1,...,8}{2,...,7}
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{\protect\cmd{\tzticksx(*)} and \protect\cmd{\tzticksy(*)}}
\label{s:tzticksx}

You can handle $x$ ticks and $y$ ticks independently.

\paragraph{X ticks}

\icmd{\tzticksx} only prints x-tick labels but not tick marks, by default.
To prints tick marks you need to specify |(<x-from>:<x-to>)|.

\begin{tzdef}{}
% syntax 
\tzticksx[<opt>]<y-shift>(<from>:<to>){<x-tick pos/labels>}[<node opt>]
% defaults
  []<>(0pt:0pt){<m>}[text height=1.25ex,text depth=.25ex,below]
\end{tzdef}


\icmd{\tzticksx*} only prints x-tick marks from |0pt| to |3pt|, by default, suppressing tick labels.

\begin{tzdef}{}
% syntax:
\tzticksx*[<opt>]<y-shift>(<from>:<to>){<xtick pos>}
% defaults
 *[]<>(0pt:3pt){<m>}
% starred(*) version always suppresses tick labels
\end{tzdef}


\paragraph{Y ticks}

\icmd{\tzticksy} only prints y-tick labels but not tick marks, by default.
To prints tick marks you need to specify |(<x-from>:<x-to>)|.

\icmd{\tzticksy*} only prints y-ticks from |0pt| to |3pt| by default, suppressing tick labels.

\begin{tzdef}{}
% syntax: 
\tzticksy[<opt>]<x-shift>(<from:to>){<y-ticks pos/labels>}[<node opt>]
% defaults
  []<>(0pt:0pt){<m>}[]
\end{tzdef}

\begin{tzdef}{}
% syntax
\tzticksy*[<opt>]<x-shift>(from:to){<yticks pos>}
% defaults
  []<>(0pt:0pt){<m>}
% starred(*) version suppresses tick labels
\end{tzdef}


\begin{tzcode}{.3}
% \tztickx(*), \tzticky(*)
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzticksx [draw=red,thick]
          (-5pt:1cm){1,...,7,8/$\alpha$}
\tzticksy*[draw=blue,thick]
          (0pt:3cm){2,...,6,7/$\beta$} % labels ignored
\end{tikzpicture}
\end{tzcode}

\paragraph{Shift}
The options |<y-shift>| and |<x-shift>| move x-ticks and y-ticks, respectively.

\begin{tzcode}{.3}
% \tztickx(*), \tzticky(*): shift
\begin{tikzpicture}[scale=.4,font=\scriptsize]
\tzhelplines(10,10)
\tzshoworigin
\tzaxes(-1,-1)(10,10)
\tzaxes[dashed]<2,1>(-1,-1)(10,10)
\tzticksx*[draw=red,thick]
  <1>(-5pt:10pt){1,...,7,8/$\alpha$} % labels ignored
\tzticksy [draw=blue,thick]
  <2>(0pt:3cm){2,...,6,7/$\beta$}
\end{tikzpicture}
\end{tzcode}




%%==================================
\chapter{Projections}
\label{c:projections}

%%------------------------------------------------------------
\section{\protect\cmd{\tzproj(*)}}
\label{s:tzproj}

\icmd{\tzproj} accepts a mandatory coordinate and draws perpendicular lines onto each axis from the coordinate. The lines are |dotted|, by default.

\begin{tzdef}{}
% syntax: minimum
  \tzproj(<coor>)
% syntax: medium
  \tzproj*(<coor>){<x-text>}[<node opt>]{<y-text>}[<node opt>]
% syntax: 
  \tzproj*[<opt>]<x-shift,y-shift>(<coor>)
         {<x-text>}[<node opt>]{<y-text>}[<node opt>](<dot size>)
% defaults
 *[]<0,0>(<m>){}[text height=1.25ex,text depth=.25ex,below]{}[left](2.4pt)
\end{tzdef}

\icmd{\tzproj*} additionally prints a black node dot of the size |2.4pt|, by default.

\paragraph{Dot size}
You can only control the size of by |(<dot size>)| or by the \threeways\ on page \pageref{ss:threeways}.
If you want to control |fill| or |color|, use |\tzdot*|.

\begin{tzcode}{.3}
%\tzproj(*)
\begin{tikzpicture}[scale=.5]
\tzaxes(8,6)
\tzproj[dashed,blue](2,3)
\tzcoors(30:7)(A)(50:6)(B);
\tzproj*(A)
\tzproj*[dashed,text=blue](B)(5pt)
\end{tikzpicture}
\end{tzcode}

\paragraph{Adding text}
You can also add text around the projection point on each axis by the option |{<text>}|.
The position and color of the text is controlled by the option |[<node option>]|.
The default position is (approximately) |[below]| for the x axis and |[left]| for the y axis.


\begin{tzcode}{.3}
% \tzproj(*): adding text
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(8,6)
\tzproj[dashed,blue](2,3){$x$}{$y$}
\tzcoors(30:7)(A)(50:6)(B);
\tzproj*[text=blue](A){$a_1$}{$a_2$}
\tzproj*[dashed](B){$x^*$}[green]{$y^*$}[red]
\end{tikzpicture}
\end{tzcode}

\paragraph{Projection shift}
Specifying the option |<x-shift,y-shift>| moves the projection point and text on each axis.

\begin{tzcode}{.3}
% \tzproj(*): projection shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(8,6)
\tzproj[dashed,blue](2,3){$x$}{$y$}
\tzcoors(30:7)(A)(50:6)(B);
\tzaxes[blue]<3,1>(8,6)
\tzproj*[dashed,text=blue]<3,1>(A){$a_1$}{$a_2$}
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{\protect\cmd{\tzprojx(*)} and \protect\cmd{\tzprojy(*)}}
\label{s:tzprojx}

\icmd{\tzprojx} draw a dotted line, which is perpendicular to the x axis.

\icmd{\tzprojx*} additionally prints a black node dot of the size |2.4pt|, by default.


\begin{tzdef}{}
% syntax: 
  \tzprojx[<opt>]<x-shift,y-shift>(<coor>){<x-text>}[<node opt>](<dot size>)
% defaults
  []<0>(<m>){}[text height=1.25ex,text depth=.25ex,below](2.4pt)
\end{tzdef}


\icmd{\tzprojy} draws a dotted line, which is perpendicular to the y axis.

\icmd{\tzprojy*} additionally prints a black node dot of the size |2.4pt|, by default.

\begin{tzdef}{}
% syntax: 
  \tzprojy[<opt>]<x-shift,y-shift>(<coor>){<y-text>}[<node opt>](<dot size>)
% defaults
  []<0>(<m>){}[left](2.4pt)
\end{tzdef}


You can only control the size of by |(<dot size>)|.
If you want to control |fill| or |color|, use |\tzdot*|.
You can also add text around the projection point on each axis by specifying the option |{<x-text>}| or |{<y-text>}| followed by the option |[<node option>]|.

\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.5,font=\scriptsize]
\tzhelplines(-1,-2)(6,6)
\tzshoworigin
\tzaxes(-1,-1)(6,6)
\tzproj*[dashed](4,5){4}{5}(3pt)
\tzprojx*[green,thick,solid](3,4){$x=3$}[blue]
\tzprojy*[thick](5,2){2}(5pt)
\end{tikzpicture}
\end{tzcode}

Specifying the option |<x-shift,y-shift>| with |\tzprojx(*)| and |\tzprojy(*)| moves the projection point and text accordingly.

\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.5,font=\scriptsize]
\tzhelplines(-1,-2)(6,6)
\tzshoworigin
\tzaxes(-1,-1)(6,6)
\tzaxes[blue]<2,1>(-1,-1)(6,6)
\tzprojx*[green,thick,solid]<2,1>(3,4){$x=3$}[blue]
\tzprojy*[thick]<2,1>(5,2){2}(5pt)
\end{tikzpicture}
\end{tzcode}




%%==================================
\chapter{Plot Functions}
\label{c:functions}


%%------------------------------------------------------------
\section{\protect\cmd{\tzfn}: Plot functions}
\label{s:tzfn}

\subsection{Syntax}
\label{ss:tzfn}

\icmd{\tzfn} plots a function of |\x|.

\begin{tzdef}{}
% syntax: minimum
\tzfn{<fn of \x>}[<domain>]
% syntax: medium
\tzfn{<fn of \x>}[<domain>]{<text>}[<pos>]
% syntax
\tzfn[<opt>]<shift coor>"<path name>"
     {<fn of \x>}[<domain>]{<text>}[<node opt>]<code.append>
% [<domain>] should be of the form [<from num:to num>]
% defaults
  [samples=200]<>""{<m>}[<m>]{}[]<>
\end{tzdef}

|\tzfn| takes two mandatory arguments: |{<fn of \x>}| and |[<domain>]|.
The domain should be of the form |[<from num:to num>]|, like |[1:5]|.

\begin{tztikz}{}
\tzfn{2*\x+1}[1:5] % works like:
  \draw [samples=200,domain=1:5] plot (\x,{2*\x+1});
\end{tztikz}


\subsection{Define and name functions}

To use |\tzfn| you need to express a function as a function of |\x|.
You can add text (as a function name) at the end of the graph,
by specifying |{<text>}| and |[<node opt>]| immediately after the domain.

\begin{tzcode}{.3}
% \tzfn
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,8)
\tzaxes(8,8)
\def\Dx{7-2/3*\x}
\tzfn{\Dx}[0:7]{$D$}[r]
\tzfn{1+\x}[0:7]{$S$}[blue,r]
\end{tikzpicture}
\end{tzcode}

You can also use the predefined functions of \Tikz such as |sin|, |cos|, |ln|, |log10|, |log2|, |exp|, |sqrt|, and so on. (See \Tikz\ manual.)

\begin{tzcode}{.3}
% \tzfn
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-2)(8,6)
\tzaxes*(-2,-2)(8,6)
\def\Fx{sin(\x r)+3}
\def\Gx{exp(\x)}
\def\Hx{ln(\x)}
\tzfn\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r]
\tzfn[blue]\Gx[-2:2]{$e^x$}[red,r]
\tzfn[dashed]\Hx[.2:7]{$\ln\,x$}[r]
\end{tikzpicture}
\end{tzcode}

\subsection{Name paths: \texttt{name path}}

You can name the path of |\tzfn| by specifying the option |"<path name>"| immediately before the mandatory argument |{<fn of \x>}|. You can use the path name to find intersection points.

\begin{tztikz}{}
\tzfn"mypath"\Fx[1:5] % works like:
  \draw [samples=200,,domain=1:5,name path=mypath] plot (\x,{\Fx}};
\end{tztikz}

\begin{tzcode}{.3}
% \tzfn: name path: intersection point
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,8)
\tzaxes(8,8)
\def\Dx{7-2/3*\x}
\def\Sx{1+\x}
\tzfn"Dx"\Dx[0:7]{$D$}[r]
\tzfn"Sx"\Sx[0:7]{$S$}[blue,r]
\tzXpoint*{Dx}{Sx}(E){E}
\end{tikzpicture}
\end{tzcode}

\remark
Suppose that the mandatory argument |<fn of \x>| is represented by a macro name only, say |\Fx|. Then
\begin{itemize}
\item The name |Fx| (without the backslash) of the macro can be used as |<path name>|, unless you specify another name. 
\item That is, |\tzfn\Fx| is equivalent to |\tzfn"Fx"\Fx|.
(You don't need to type the same thing twice.)
\begin{tztikz}{}
\tzfn\Fx[1:5] % works like:
  \draw [samples=200,domain=1:5,name path=Fx] plot (\x,{\Fx});
\end{tztikz}
\end{itemize}

\subsection{Move graphs: \texttt{shift}}

You can move the graph of |\tzfn| by specifying the option |<shift coor>| before the mandatory argument |{<fn of \x>}| or  immediately after the option |"<path name">|, if any.

\begin{tzcode}{.3}
% \tzfn: shift
\begin{tikzpicture}[scale=.6]
\tzhelplines(8,8)
\def\Dx{7-2/3*\x}
\def\Sx{1+\x}
\tzfn        \Dx[0:7]{$D$}[right] % name path = Dx
\tzfn"supply"\Sx[0:7]{$S$}[right] % name path = supply
\tzXpoint*{Dx}{supply}(E){$E$}
\tzfn[dashed]<1,1>"demandA"\Dx[0:7]{$D'$}[right]
\tzfn[dashed]<1,-1>"supplyA"\Sx[0:7]{$S'$}[right]
\tzXpoint*{demandA}{supplyA}(E1){$E'$}
\end{tikzpicture}
\end{tzcode}


\subsection{Extend paths: \texttt{<code.append>}, \protect\cmd{\tzfnAtBegin}, \protect\cmd{\tzfnAtEnd}}
\label{ss:tzfn:atbegin}

\paragraph{\texttt{<code.append>}}
You can extend the path created by |\tzfn| from the end of the graph, by writing \Tikz\ code in the \xem{last optional argument} |<code.append>|. Internally it add the \Tikz\ code after the text node |{<text>}| and |[<node opt>]|.

\begin{tzcode}{.3}
% \tzfn: <code.append>
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-2)(8,6)
\tzaxes*(-2,-2)(8,6)
\def\Fx{sin(\x r)+3}
\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r]
        < to [bend right] ++(2,-2) node [b] {End!} >
\end{tikzpicture}
\end{tzcode}

\paragraph{\texttt{\bs tzfnAtEnd}}
You can also extend the path with \icmd{\tzfnAtEnd}.
Internally it adds \Tikz\ code immediately before the options |{<text>}| and |[<node opt>]|. But you have to use |\tzfnAtEnd| (immediately) \xem{before each} |\tzfn|.

\begin{tzcode}{.3}
% \tzfnAtEnd
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-2)(8,6)
\tzaxes*(-2,-2)(8,6)
\def\Fx{sin(\x r)+3}
\tzfnAtEnd{to [bend right] ++(2,-2) node [b] {End!}}
\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r]
%        < to [bend right] ++(2,-2) node [b] {End!} >
\end{tikzpicture}
\end{tzcode}


\paragraph{\texttt{\bs tzfnAtBegin}}
You can use \icmd{\tzfnAtBegin} (immediately) \xem{before each} |\tzfn| to insert \Tikz\ code before the path of |\tzfn|.

\begin{tzcode}{.3}
% \tzfnAtBegin
\begin{tikzpicture}[scale=.5]
\tzhelplines(-2,-2)(8,6)
\tzaxes*(-2,-2)(8,6)
\def\Fx{sin(\x r)+3}
\tzfnAtBegin{ (0,0) -- }
\tzfn[->]\Fx[-2:2*pi]{$\sin\,x+3$}[blue,r]
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{\protect\cmd{\tzLFn}: Plot linear functions}
\label{s:tzLFn}


\icmd{\tzLFn} draws a linear function: $y=ax+b$.

\begin{itemize}
\item
When you know two coordinates on a line,
|\tzLfn(<coor1>)(<coor2>)| draws the line.
\item
When you know one coordinate and the slope of a line,
|\tzLfn(<coor1>){<slope>}| draws the line.
\item
If you specify all the three arguments |(<coor1>)(<coor2>){<slope>}|, then the slope is ignored.
\end{itemize}

\begin{tzdef}{}
% syntax
\tzLFn[<opt>]<shift coor>"<path name>"
      (<coor1>)(<coor2>){<slope>}[<domain>]{<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>)(){1}[<m>]{}[]<>
\end{tzdef}

|\tzLFn| accepts two mandatory arguments: |(<coor1>)| and |<domain>|.
\begin{itemize}
\item The domain should be of the form |[<from num:to num>]|.
\item If just one coordinate is specified without a slope, the slope is regarded as |1|, by default.
\end{itemize}

For example, |\tzLFn(1,1)(2,3)[0:4]| draws a line passing through two points: $(1,1)$ and $(2,3)$, over $0\leq x\leq 4$.
|\tzdefLFn\Gx(1,1){.5}[0:4]| draws a line passing through a point $(1,1)$ with the slope |.5|, over $0\leq x\leq 4$.

You can add text at the end of the line of |\tzLFn| by the options |{<text>}| and |[<node opt>]|. You can also name the path of |\tzLFn| by specifying the option |"<path name>"| immediately before the mandatory coordinate.

\begin{tzcode}{.3}
% \tzLFn
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C);
\tzLFn[red]"Fx"(A){.5}[0:4]{$f(x)$}[a]
\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r]
\tzXpoint*[fill=none]{Fx}{Gx}(E){$E$}(3pt)
\end{tikzpicture}
\end{tzcode}

You can move the line by specifying the option |<shift coor>| immediately before |"<path name">|.
You can also expand the path of |\tzLFn| by writing \Tikz\ code in the last optional argument |<code.append>|.

\begin{tzcode}{.3}
% \tzLFn: shift, expanding path
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors*(1,1)(A)(1,2)(B)(3,1)(C);
\tzLFn[blue]"Gx"(B)(C)[0:4]{$g(x)$}[r]
\tzLFn[dashed,red,->]<1,1>"Gx"(B)(C)[0:4]{$g(x)$}[r]
      < arc (0:140:2) node [below] {End!} >
\end{tikzpicture}
\end{tzcode}


%%------------------------------------------------------------
\section{Horizontal lines}
\label{s:tzhfn}

\subsection{\protect\cmd{\tzvfnat}}
\label{ss:tzhfnat}

\icmd{\tzhfnat} draws a horizontal line at a specified value of $y$.


\begin{tzdef}{}
% syntax: minimal
\tzhfnat{<y-val>}[<domain>]
% syntax: full
  \tzhfnat[<opt>]<shift coor>"<path name>"{<y-val>}[<domain>]{<text>}[<pos>]<code.append>
% defaults
  []<>""{<m>}[left:right (of current bonding box)]{}[]<>
\end{tzdef}

|\tzhfnat| accepts only one mandatory argument |{<y-val>}|.
The domain is optional and should be of the form |[<from num:to num>]|.
The default domain is from left to right of the \ixxw{current bounding box}.

\remark Internally, the default domain of |\tzhfn| depends on \ixxw{current bounding box}.
\begin{itemize}
\item Each |\tzhfnat| may draw a line with a (slightly) different length.
\item If an appropriate |current bounding box| is not formed before |\tzhfnat| is executed, you will probably get an unexpected result.
\item In that case, you can fix a |bounding box| in the beginning of the |tikzpicture| environment using macros such as \icmd{\tzbbox}, \icmd{\tzhelplines*}, \icmd{\tzaxes*}, or \Tikz's \icmd{\useasboundingbox}.
\end{itemize}


\begin{tzcode}{.3}
% \tzhfnat
\begin{tikzpicture}
\tzhelplines(4,3)
\tzhfnat[blue,thick]{0}
\tzhfnat[red,thick]{1}[1:3]{line A}[r]
\tzhfnat[blue]{2}{line B}[r]
\tzhfnat[red]{3}[0:3]{line C}[draw=blue,red,r]
\end{tikzpicture}
\end{tzcode}

You can name the path of |\tzhfnat| by the option |"<path name>"|.
You can move the line by the option |<shift coor>|.
You can also expand the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|.

\begin{tzcode}{.3}
% \tzhfnat: shift
\begin{tikzpicture}
\tzhelplines*(4,4) % bonding box
\tzfn"XX"{\x}[0:4]
\tzhfnat[blue,thick]{0}
\tzhfnat[red,thick]<-.5,.5>"AA"{1}[1:3]{line A'}[r]
\tzXpoint*{AA}{XX}
\tzhfnat[blue,->]{2}{line B}[r]
        < arc (0:120:1.5) node [b,draw] {End!} >
\end{tikzpicture}
\end{tzcode}



\subsection{\protect\cmd{\tzhfn}}
\label{ss:tzhfn}

\icmd{\tzhfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $y$ value of the coordinate.
For example, |\tzhfn(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhfnat{3}|.

\xem{Everything else is the same as in} |\tzhfnat|.

\begin{tzdef}{}
% syntax: minimal
\tzhfn(<coor>)[<domain>]
% syntax: full
  \tzhfn[<opt>]<shift coor>"<path name>"(<coor>)[<domain>]{<text>}[<pos>]<code.append>
% defaults
  []<>""{<m>}[left to right of current bonding box]{}[]<>
\end{tzdef}

\begin{tzcode}{.3}
% \tzhfn: shift
\begin{tikzpicture}
\tzhelplines*(4,4) % bonding box
\tzcoors(0,1)(A)(0,2)(B);
\tzfn"XX"{\x}[0:4]
\tzhfn[blue,thick](5,0) % x=5 ignored
\tzhfn[red,thick]<-.5,.5>"AA"(A)[1:3]{line A'}[r]
\tzXpoint*{AA}{XX}
\tzhfn[blue,->](B){line B}[r]
        < arc (0:120:1.5) node [b,draw] {End!} >
\end{tikzpicture}
\end{tzcode}






%%------------------------------------------------------------
\section{Vertical lines}
\label{s:tzvfn}

\subsection{\protect\cmd{\tzvfnat}}
\label{ss:tzvfnat}

\icmd{\tzvfnat} draws a vertical line at a specified value of $x$.


\begin{tzdef}{}
% syntax: minimal
\tzvfnat{<x-val>}[<domain>]
% syntax: full
  \tzvfnat[<opt>]<shift coor>"<path name>"{<x-val>}[<domain>]{<text>}[<pos>]<code.append>
% defaults
  []<>""{<m>}[bottom:top (of current bonding box)]{}[]<>
\end{tzdef}

|\tzvfnat| accepts only one mandatory argument |{<x-val>}|.
The domain is optional and should be of the form |[<from num:to num>]|.
The default domain is from bottom to top of the \ixxw{current bounding box}.


\begin{tzcode}{.3}
% \tzvfnat
\begin{tikzpicture}
\tzhelplines(4,4)
\tzvfnat[blue,thick]{0}
\tzvfnat[red,thick]{1}[1:3]{line A}[a]
\tzvfnat[blue]{2}{line B}[a]
\tzvfnat[red]{3}[0:3]{line C}[draw=blue,red,a]
\end{tikzpicture}
\end{tzcode}

You can name the path of |\tzvfnat| by the option |"<path name>"|.
You can move the line by the option |<shift coor>|.
You can also expand the path from the end of the line by writing \Tikz\ code in the last optional argument |<code.append>|.

\begin{tzcode}{.3}
% \tzvfnat: shift
\begin{tikzpicture}
\tzhelplines*(4,4) % bonding box
\tzfn"XX"{\x}[0:4]
\tzvfnat[blue,thick]{0}
\tzvfnat[red,thick]<.5,-.5>"AA"{1}[1:3]{line A'}[a]
\tzXpoint*{AA}{XX}
\tzvfnat[blue,->]{2}{line B}[a]
        < arc (90:-30:1.5) node [b,draw] {End!} >
\end{tikzpicture}
\end{tzcode}



\subsection{\protect\cmd{\tzvfn}}
\label{ss:tzvfn}

\icmd{\tzvfn} accepts a coordinate as a mandatory argument and draws a horizontal line at the $x$ value of the coordinate.
For example, |\tzvfn(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvfnat{3}|.

\xem{Everything else is the same as in} |\tzvfnat|.

\begin{tzdef}{}
% syntax: minimal
\tzvfn(<coor>)[<domain>]
% syntax: full
\tzvfn[<opt>]<shift coor>"<path name>"(<coor>)[<domain>]{<text>}[<pos>]<code.append>
% defaults
  []<>""{<m>}[bottom:top (of current bonding box)]{}[]<>
\end{tzdef}

\begin{tzcode}{.3}
% \tzvfn: shift
\begin{tikzpicture}
\tzhelplines*(4,4) % bonding box
\tzcoors(1,0)(A)(2,0)(B);
\tzfn"XX"{\x}[0:4]
\tzvfn[blue,thick](0,5) % y=5 ignored
\tzvfn[red,thick]<.5,-.5>"AA"(A)[1:3]{line A'}[a]
\tzXpoint*{AA}{XX}
\tzvfn[blue,->](B){line B}[a]
        < arc (90:-30:1.5) node [b,draw] {End!} >
\end{tikzpicture}
\end{tzcode}





%%==================================
\chapter{Intersections}
\label{c:intersections}

%%------------------------------------------------------------
\section{\protect\cmd{\tzXpoint(*)}: Intersection points}
\label{s:intersections}

\icmd{\tzXpoint} finds intersection points of two paths and save them as coordinate names for later use.

\begin{tzdef}{}
% syntax: minimal
\tzXpoint{<path>}{<path>}(<coor name>)
% syntax: medium
\tzXpoint{<path>}{<path>}(<coor name>){<label>}[<angle>]
% syntax: full
\tzXpoint[<opt>]{<path>}{<path>}(<coor name>)[<nth>]{<label>}[<[<label opt>]angle>]
% defaults
  []{<m>}{<m>}()[1]{}[]
\end{tzdef}

For example, |\tzXpoint{path1}{path2}(A)| determines an intersection of the two paths and names the point |(A)| or |(A-1)|. (By default the name is |(intersection)| as in \Tikz.)
If there are two or more intersection points, they are named as follows: |(A)=(A-1)|, |(A-2)|, |(A-3)|, etc.

You can determine which intersection point is named by specifying the option |[<nth>]|. If you select the second intersection point to be named |(A)| out of multiple intersections, they are named as follows: |(A-1)|, |(A)=(A-2)|, |(A-3)|, |(A4)|, etc.
You can label intersection points by specifying the option |{<label>}| and |[<angle>]|.


\begin{tzcode}{.3}
% \tzXpoint
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,8)
\tzaxes(8,8)
\tzto[red,bend right]"AA"(1,8)(8,1)
\tzto[blue,bend right]"BB"(0,2)(8,6)
\tzXpoint{AA}{BB}(A)
\tzdot*(A)
\end{tikzpicture}
\end{tzcode}


\paragraph{\icmd{\tzXpoint*}} The starred version |\tzXpoint*| simply adds a node dot to |\tzXpoint|.
The default dot size is |2.4pt| and it can be changed by the last option |(<dot size>)| or the \threeways\ (on page \pageref{ss:threeways}).

\begin{tzdef}{}
% syntax: minimum
\tzXpoint*{<path>}{<path>}
% syntax: medium
\tzXpoint*{<path>}{<path>}(<coor name>){<label>}[<angle>]
% syntax:
\tzXpoint*[<opt>]{<path>}{<path>}
          (<coor name>)[<nth>]{<label>}[<[<label opt>]angle>](<dotsize>)
% defaults
  [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt)
\end{tzdef}



\begin{tzcode}{.3}
% \tzXpoint*
\begin{tikzpicture}[scale=.5]
\tzhelplines(10,10)
\tzaxes(10,10)
\def\bgt{8-\x}
\def\Fx{\x}
\def\IC{7/\x}
\tzfn\bgt[0:8]               % name path=bgt
\tzfn\Fx[0:8]{ray}[red,ar]   % name path=Fx
\tzfn"IC"\IC[.8:8]{$u$}[r]   % name path=IC
\tzXpoint*{bgt}{Fx}(A){A}[0] % <angle>
\tzproj[dashed](A){$x$}{$y$}
\tzXpoint*[fill=none,red]{bgt}{IC}(B){B}[0](4pt)
\tzdot*[blue](B-2){B2}[[red]45](4pt)
\end{tikzpicture}
\end{tzcode}




%%------------------------------------------------------------
\section{Vertical intersection points}
\label{s:tzvXpointat}

\subsection{\protect\cmd{\tzvXpointat(*)}}
\label{ss:tzvXpointat}

\icmd{\tzvXpointat} determines vertical intersection points of a path at a specified value of $x$.
So it takes |{<path>}| and |{<x-val>}| as mandatory arguments.

\remark 
Internally, |\tzvXpointat| depends on |current bounding box|, which generally does not cause a problem because it is used after paths to be intersected is drawn.
In case of any problem of no intersection point, you can use |\tzbbox| or |\tzaxes*| or \Tikz's |\useasboundingbox| to fix a bounding box.

\begin{tzdef}{}
% syntax: minimal
\tzvXpointat{<path>}{<x-val>}(<coor name>)
% syntax: medium
\tzvXpointat{<path>}{<x-val>}(<coor name>){<label>}[<angle>]
% syntax: full
\tzvXpointat[<opt>]{<path>}{<x-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>]
% defaults
  []{<m>}{<m>}()[1]{}[]
\end{tzdef}

\xem{Everything else is the same as in} |\tzXpointat|.


The starred version \icmd{\tzvXpointat*} additionally prints a node dot of the size |2.4pt|, by default, at the (first) intersection point.

\begin{tzdef}{}
% syntax: minimum
\tzvXpointat*{<path>}{<x-val>}
% syntax: medium
\tzvXpointat*{<path>}{<x-val>}(<coor name>){<label>}[<angle>]
% syntax: full
\tzvXpointat*[<opt>]{<path>}{<x-val>}
             (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>)
% defaults
  [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt)
\end{tzdef}

\begin{tzcode}{.3}
% \tzvXpointat(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\def\Fx{.5*(\x-2)^2}
\tzfn\Fx[0:4] % name path=Fx
\tzvfnat[dashed]{1}
\tzvXpointat{Fx}{1}(A)
\tzdot(A){A}[45]
\tzvXpointat*{Fx}{3.2}{B}[-45]
\end{tikzpicture}
\end{tzcode}

%%------------------------------------------------------------
\subsection{\protect\cmd{\tzvXpoint(*)}}
\label{ss:tzvXpoint}

\icmd{\tzvXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find vertical intersection points of a path at the $x$ value of the coordinate, ignoring the $y$ value.
For example, |\tzvXpoint{mypath}(3,<y>)|, ignoring |<y>|, is equivalent to |\tzvXpointat{mypath}{3}|.

\xem{Everything else is the same as in} |\tzvXpointat|.

\begin{tzdef}{}
% syntax
\tzvXpoint[<opt>]{<path>}{<coor>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>]
% defaults
  []{<m>}(<m>)[1]{}[]()
\end{tzdef}

The starred version \icmd{\tzvXpoint*} just adds a node dot to |\tzvXpoint|.

\begin{tzdef}{}
% syntax
\tzvXpoint*[<opt>]{<path>}(<coor>)
           (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>)
% defaults
  [tzdot=2.4pt]{<m>}(<m>)()[1]{}[](2.4pt)
\end{tzdef}

|\tzvXpoint*| prints, at the first intersection point, a node dot of the size 2.4pt by default.

\begin{tzcode}{.3}
% \tzvXpoint(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\def\Fx{.5*(\x-2)^2}
\tzfn\Fx[0:4] % name path=Fx
\tzcoors(1,0)(A)(3.2,0)(B);
\tzvfn[dashed](1,0)
\tzvXpoint{Fx}(A)(Ax)
\tzdot(Ax){Ax}[45]
\tzvXpoint*{Fx}(B){B}[-45]
\end{tikzpicture}
\end{tzcode}








%%------------------------------------------------------------
\section{Horizontal intersection points}
\label{s:tzhXpointat}

\subsection{\protect\cmd{\tzhXpointat(*)}}
\label{ss:tzhXpointat}

\icmd{\tzhXpointat} determines vertical intersection points of a path at a specified value of $y$.
So it takes |{<path>}| and |{<y-val>}| as mandatory arguments.

\begin{tzdef}{}
% syntax: minimal
\tzhXpointat{<path>}{<y-val>}(<coor name>)
% syntax: medium
\tzhXpointat{<path>}{<y-val>}(<coor name>){<label>}[<angle>]
% syntax: full
\tzhXpointat[<opt>]{<path>}{<y-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>]
% defaults
  []{<m>}{<m>}()[1]{}[]
\end{tzdef}

\xem{Everything else is the same as in} |\tzXpoint|.


The starred version \icmd{\tzhXpoint*} additionally prints a node dot of the size 2.4pt by default at the intersection point.

\begin{tzdef}{}
% syntax: minimum
\tzhXpointat*{<path>}{<y-val>}
% syntax: medium
\tzhXpointat*{<path>}{<y-val>}(<coor name>){<label>}[<angle>]
% syntax: full
\tzhXpointat*[<opt>]{<path>}{<y-val>}
             (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>)
% defaults
  [tzdot=2.4pt]{<m>}{<m>}()[1]{}[](2.4pt)
\end{tzdef}

\begin{tzcode}{.3}
% \tzhXpointat(*)
\begin{tikzpicture}
\tzhelplines*(4,3)
\def\Fx{.5*(\x-2)^2}
\tzfn\Fx[0:4] % name path=Fx
\tzhXpointat{Fx}{1}(A)
\tzdot(A){A}[0]
\tzhfnat[dashed]{1.5}
\tzhXpointat*{Fx}{1.5}(X){X}[45]
\tzdot*(X-2){Y}[135]
\end{tikzpicture}
\end{tzcode}

%%------------------------------------------------------------
\subsection{\protect\cmd{\tzhXpoint(*)}}
\label{ss:tzhXpoint}

\icmd{\tzhXpoint} accepts |{<path>}| and |(<coor>)| as mandatory arguments to find vertical intersection points of a path at the $y$ value of the coordinate, ignoring the $x$ value.
For example, |\tzhXpoint{mypath}(<x>,3)|, ignoring |<x>|, is equivalent to |\tzhXpointat{mypath}{3}|.

\xem{Everything else is the same as in} |\tzhXpointat|.

\begin{tzdef}{}
% syntax
\tzhXpointat[<opt>]{<path>}{<y-val>}(<coor name>)[<n>]{<label>}[<[<opt>]angle>]
% defaults
  []{<m>}{<m>}()[1]{}[]()
\end{tzdef}

The starred version \icmd{\tzhXpoint*} just adds a node dot to |\tzhXpoint|.

\begin{tzdef}{}
% syntax
\tzhXpoint*[<opt>]{<path>}(<coor>)
           (<coor name>)[<n>]{<label>}[<[<opt>]angle>](<dot size>)
% defaults
  [tzdot=2.4pt]{<m>}(<m>)()[1]{}[](2.4pt)
\end{tzdef}

|\tzhXpoint*| prints, at the first intersection point, a node dot of the size |2.4pt|, by default.

\begin{tzcode}{.3}
% \tzhXpoint(*)
\begin{tikzpicture}
\tzhelplines*(4,3)
\def\Fx{.5*(\x-2)^2}
\tzfn\Fx[0:4] % name path=Fx
\tzcoors(0,1)(A)(0,1.5)(B);
\tzhXpoint{Fx}(A)(A)
\tzdot(A){A}[0]
\tzhfn[dashed](0,1.5)
\tzhXpoint*{Fx}(X){X}[45]
\tzdot*(X-2){Y}[135]
\end{tikzpicture}
\end{tzcode}





%%==================================
\chapter{Secant and Tangent Lines}
\label{c:tangent}

%%------------------------------------------------------------
\section{Secant lines}
\label{s:secant}

\subsection{\protect\cmd{\tzsecantat}}
\label{ss:tzsecantat}

\icmd{\tzsecantat} draws a chord or a secant line of a curve, on the |behind| layer by default.
You need to specify a path name and two values of $x$.
With \icmd{\settzsecantlayer}, you can change the layer, like |\settzsecantlayer{main}|.

\begin{tzdef}{}
% syntax: minium
\tzsecantat{<path>}{<from-x>}{<to-x>}
% syntax: medium
\tzsecantat{<path>}{<from-x>}{<to-x>}[<domain>]{<text>}[<node opt>]
% syntax: full
\tzsecantat[<opt>]<shift coor>"path name"
           {<path>}{<from-x>}{<to-x>}[<domain>]{<text>}[<node opt>]<code.append>
% defaults
  []<>""{<m>}{<m>}{<m>}[]{}[]<>
\end{tzdef}

\paragraph{Domain}
The domain should be of the form |[<from num:to num>]|.
Without specifying the optional domain, |\tzsecantat| draws a chord.

\begin{tzcode}{.3}
% \tzsecantat
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5)
\tzsecantat[thick,red]{curve}{1}{3}
\tzsecantat[thick,red]{curve}{1}{4}
\tzsecantat[thick,red]{curve}{1}{7}
\end{tikzpicture}
\end{tzcode}

You can optionally specify the |[<domain>]|.

\begin{tzcode}{.3}
% \tzsecantat: domain
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a]
\tzsecantat[thick,red]{curve}{1}{4}
\tzsecantat[blue,dashed]{curve}{1}{7}[0:8]
\end{tikzpicture}
\end{tzcode}

\paragraph{Shift}
You can move |\tzsecantat| by specifying the option |<shift coor>|.

\begin{tzcode}{.3}
% \tzsecantat: domain
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzsecantat[thick,red]{curve}{1}{4}
\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a]
\tzsecantat[blue]<1,-1>{curve}{1}{3}[0:5]{shifted}[r]
\end{tikzpicture}
\end{tzcode}

\paragraph{Naming paths}
By specifying the option |"<path name">| you can name a path of |\tzsecantat|.

\begin{tzcode}{.3}
% \tzsecantat: shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzsecantat[thick,red]{curve}{1}{4}
\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a]
\tzsecantat[blue]<1,-1>"shift"{curve}{1}{3}[0:5] %%
\tzvXpointat*{shift}{3}{X}[-45]
\tzticksx(-1mm:2mm){3/$x=3$}[scale=.7]
\end{tikzpicture}
\end{tzcode}

\paragraph{\texttt{<code.append>}}
You can extend the path of |\tzsecantat| by writing \Tikz\ code in the last optional argument |<code.append>|.

\begin{tzcode}{.3}
% \tzsecantat: <code.append>
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzsecantat[blue]{curve}{1}{3}[0:5]{secant line}[a]
\tzsecantat[blue,->]<1,-1>"shift"{curve}{1}{3}[0:5] %%
                 < --++(1,-3) node [red,b] {Ends!} >
\tzvXpointat*{shift}{3}{X}[-45]
\end{tikzpicture}
\end{tzcode}



\subsection{\protect\cmd{\tzsecant}}
\label{ss:tzsecant}

\icmd{\tzsecant} uses two \xem{coordinates instead of two values} to draw a chord or a secant line of a curve, on the |behind| layer by default.
You need to specify a path name and two coordinates, then |\tzsecant| uses the $x$ values of the two coordinates.

\xem{Everything else is the same as in} |\tzsecantat|.

You can change the layer with \icmd{\settzsecantlayer}.

\begin{tzdef}{}
% syntax: minium
\tzsecant{<path>}(<coor>)(<coor>)
% syntax: medium
\tzsecant{<path>}(<coor>)(<coor>)[<domain>]{<text>}[<node opt>]
% syntax: full
\tzsecant[<opt>]<shift coor>"path name"
           {<path>}(<coor>)(<coor>)[<domain>]{<text>}[<node opt>]<code.append>
% defaults
  []<>""{<m>}{<m>}{<m>}[]{}[]<>
\end{tzdef}

The domain should be of the form |[<from num:to num>]|.
Without specifying the optional domain, |\tzsecant| draws a chord.

\begin{tzcode}{.3}
% \tzsecant: domain
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzcoor(1,0)(K)
\tzsecant[blue]{curve}(K)(3,0)[0:5]{secant line}[a]
\tzsecant[thick,red]{curve}(K)(4,0)
\tzsecant[blue,dashed]{curve}(K)(7,0)[0:8]
\end{tikzpicture}
\end{tzcode}

You can move the secant line and extend the path.

\begin{tzcode}{.3}
% \tzsecantat: <code.append>
\begin{tikzpicture}[scale=.5]
\tzhelplines(8,6)
\tzaxes(-1,-1)(8,6){$x$}{$y$}
\tzbezier+"curve"(.5,1)(1,6)(-1,-4)(7,5){curve}[ar]
\tzcoor(1,0)(K)
\tzsecant[blue]{curve}(K)(3,0)[0:5]{secant line}[a]
\tzsecant[blue,->]<1,-1>"shift"{curve}(K)(3,0)[0:5] %%
                 < --++(1,-3) node [red,b] {Ends!} >
\tzvXpointat*{shift}{3}{X}[-45]
\end{tikzpicture}
\end{tzcode}



%%------------------------------------------------------------
\section{Tangent lines}
\label{s:tangent}

\subsection{\protect\cmd{\tztangentat}}
\label{ss:tztangentat}

\icmd{\tztangentat} draws a tangent line to a curve at a specified value of $x$.
By default, the tangent line is drawn on the |behind| layer, which can be changed by \icmd{\settztangentlayer}, like |\settztangentlayer{main}|.

\begin{tzdef}{}
% syntax: minimum
\tztangentat{<path>}{<x-val>}[<domain>]
% syntax: medium
\tztangentat{<path>}{<x-val>}[<domain>]{<text>}[<node opt>]
% syntax: full
\tztangentat[<opt>]<shift coor>"<path name>"
            {<path>}{<x-val>}(<epsilon1>,<epsilon2>)
            [<domain>]{<text>}[<node opt>]<code.append>
% defaults
  []""<>{<m>}{<m>}(.01,.01)[<m>]{}[]<>
\end{tzdef}

To calculate the slope at $x$, $x$ varies over the interval $(x-\varepsilon_1,x+\varepsilon_2)$ and $\varepsilon_1=\varepsilon_2=0.01$ by default.
So the slope of tangent line is only \xem{approximate}.

\paragraph{Domain}
|\tztangentat| takes three mandatory arguments: |{<path>}|, |{<x-val>}|, and |[<domain>]|. The mandatory argument |[<domain>]| should be of the form |[<from num:to num>]|.

\begin{tzcode}{.3}
% \tztangentat
\begin{tikzpicture}[scale=.5]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangentat{AA}{2}[.5:4]
\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b]
\tzvXpointat*{AA}{4}
\tzticksx{1,7}
\end{tikzpicture}
\end{tzcode}


\paragraph{Shift}
You can move the tangent line by specifying the option |<shift coor>|.

\begin{tzcode}{.3}
% \tztangentat: shift
\begin{tikzpicture}[scale=.5]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangentat{AA}{2}[.5:4]
\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b]
\tztangentat[blue]<2,1>{AA}{4}[1:7]{tangent'}[r]
\tzvXpointat*{AA}{4}
\tzticksx{1,7}
\end{tikzpicture}
\end{tzcode}

\paragraph{Naming paths}
By specifying the option |"<path name">|, you can name the path of |\tztangentat|.

\begin{tzcode}{.3}
% \tztangentat: name path
\begin{tikzpicture}[scale=.5,font=\footnotesize]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangentat{AA}{2}[.5:4]
\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b]
\tzvXpointat*{AA}{4}
\tztangentat[blue]
            <2,1>"BB"{AA}{4}[1:7]{tangent'}[r]
\tzvXpointat*[blue]{BB}{5}(X){$x$}[45](3pt)
\tzproj(X){$x_1$}{$x_2$}
\end{tikzpicture}
\end{tzcode}

\paragraph{\texttt{<code.append>}}
You can extend the path of |\tztangentat| by writing \Tikz\ code in the last optional argument |<code.append>|.

\begin{tzcode}{.3}
% \tztangentat: <code.append>
\begin{tikzpicture}[scale=.5,font=\footnotesize]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangentat{AA}{2}[.5:4]
\tztangentat[blue]{AA}{4}[1:7]{tangent}[red,b]
\tzvXpointat*{AA}{4}
\tztangentat[blue,->]<2,1>"BB"{AA}{4}[1:7]
  < to [bend right] ++(-1,3) node [a] {Ends!} >
\tzvXpointat*[blue]{BB}{5}(X){$x$}[45](3pt)
\tzproj(X){$x_1$}{$x_2$}
\end{tikzpicture}
\end{tzcode}



\paragraph{Variations}
The slope of the tangent line is approximate, so sometimes you may want to change the variation interval to get better results.
You can change $\varepsilon_1$ and $\varepsilon_2$ by specifying the option |(epsilon1,epsilon2)| immediately after the mandatory argument |<x-val>|.
Or you can change the variations with the macro \icmd{\settztangentepsilon},
like |\settztangentepsilon{|$\varepsilon_1$|}{|$\varepsilon_2$|}|. The effect remains until the end of |tikzpicture| environment unless changed again.

\begin{tzcode}{.3}
% \tztangentat: variations, shift
\begin{tikzpicture}[scale=.5,font=\footnotesize]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangentat[blue!50,dashed]{AA}{4}[1:7]
\settztangentepsilon{0.005}{0.01}
\tztangentat[blue]{AA}{4}[1:7]{corrected}[r]
\tztangentat[red]<0,1>{AA}{4}[1:7]{shifted}[r]
\end{tikzpicture}
\end{tzcode}




\subsection{\protect\cmd{\tztangent}}
\label{ss:tztangent}


\icmd{\tztangent} uses a \xem{coordinate instead of a value} of $x$ to draw a tangent line.
For example, |\tztangent{curve}(4,0)| is equivalent to |\tztangentat{curve}{4}|.

\xem{Everything else is the same as in} |\tztangentat|.

\begin{tzdef}{}
% syntax: minimum
\tztangent{<path>}(<coor>)[<domain>]
% syntax: medium
\tztangent{<path>}(<coor>)[<domain>]{<text>}[<node opt>]
% syntax: full
\tztangent[<opt>]<shift coor>"<path name>"
          {<path>}(<coor>)(<epsilon1>,<epsilon2>)
          [<domain>]{<text>}[<node opt>]<code.append>
% defaults
  []""<>{<m>}(<m>)(.01,.01)[<m>]{}[]<>
\end{tzdef}



\begin{tzcode}{.3}
% \tztangent
\begin{tikzpicture}[scale=.5]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tzcoors(2,0)(K2)(4,0)(K4);
\tztangent{AA}(K2)[.5:4]
\tztangent[blue]{AA}(K4)[1:7]{tangent}[red,b]
\tzvXpoint*{AA}(K4)
\tzticksx{1,7}
\end{tikzpicture}
\end{tzcode}


\begin{tzcode}{.3}
% \tztangent: shift, <code.append>
\begin{tikzpicture}[scale=.5,font=\footnotesize]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tzcoors(2,0)(K2)(4,0)(K4);
\tztangent{AA}(K2)[.5:4]
\tztangent[blue]{AA}(K4)[1:7]{tangent}[red,b]
\tzvXpoint*{AA}(K4)
\tztangent[blue,->]<2,1>"BB"{AA}(K4)[1:7]
  < to [bend right] ++(-1,3) node [a] {Ends!} >
\tzvXpoint*[blue]{BB}(5,0)(X){$x$}[45](3pt)
\tzproj(X){$x_1$}{$x_2$}
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.3}
% \tztangent: variations, shift
\begin{tikzpicture}[scale=.5,font=\footnotesize]
\tzhelplines(9,8)
\tzaxes(9,8)
\tzplotcurve"AA"(1,7)(3,3)(8,1);
\tztangent[blue!50,dashed]{AA}(4,0)[1:7]
\settztangentepsilon{0.005}{0.01}
\tztangent[blue]{AA}(4,0)[1:7]{corrected}[r]
\tztangent[red]<0,1>{AA}(4,0)[1:7]{shifted}[r]
\end{tikzpicture}
\end{tzcode}


%%==================================
\chapter{Miscellany}
\label{c:misc}

%%------------------------------------------------------------
\section{\protect\cmd{\tzbrace(')}}
\label{s:tzbrace}

\icmd{\tzbrace} takes two coordinates as mandatory arguments to draw a calligraphic brace connecting them.

\begin{tzdef}{}
% syntax: minimum
\tzbrace(<coor>)(<coor>)
% syntax: medium
\tzbrace(<coor>)(<coor>){<text>}[<node opt>]
% syntax: full
\tzbrace[<draw opt>]{<raise>}[<decoration opt>]<shift coor>
        (<coor>)(<coor>){<text>}[<node opt>]
% defaults
  []{5pt}[amplitude=5pt]<>(<m>)(<m>){}[]
\end{tzdef}

The amplitude of a brace is |5pt| by default.
The |raise| value of a brace is |5pt| by default and the value can be changed by the first curly brace optional argument |{<raise>}|. 

\begin{tztikz}{}
\tzbrace[thick](0,0)(3,1) % works like:
  \draw [thick,decorate,decoration={calligraphic brace, amplitude=5pt, raise=5pt}]
        (0,0) to (3,1);
\end{tztikz}

The swap version \icmd{\tzbrace'} swaps the coordinates.
So it prints a mirror image of |\tzbrace|.

\begin{tzcode}{.3}
% \tzbrace(')
\begin{tikzpicture}[sloped]
\tzhelplines(4,2)
\tzline(0,0)(3,1)
\tzbrace(0,0)(3,1){AAA}[above=10pt,blue]
\tzbrace'[red](0,0)(3,1){BBB}[below=10pt]
\end{tikzpicture}
\end{tzcode}

You can change the style of the decorating brace by the second bracket optional argument |[<decoration opt>]|.

The color of the calligraphic brace can be changed by the option |pen colour| in the list of |[<draw option>]|.

\begin{tzcode}{.3}
% \tzbrace('): decoration options
\begin{tikzpicture}[sloped]
\tzhelplines(4,3)
\tzline(0,0)(3,1)
\tzbrace [very thick,pen colour=blue][amplitude=10pt]
         (0,0)(3,1){AAA}[a=15pt]
\tzbrace'[red,very thick]{10pt}[brace,amplitude=10pt]
         (0,0)(3,1){BBB}[b=20pt]
\end{tikzpicture}
\end{tzcode}

You can also move a brace by specifying the option |<shift coor>| immediately before the the first mandatory coordinate.

\begin{tzcode}{.3}
% \tzbrace('): shift
\begin{tikzpicture}[sloped]
\tzhelplines(4,3)
\tzline(0,0)(3,1)
\tzbrace [very thick,pen colour=blue][amplitude=10pt]
         <.5,.5>(0,0)(3,1){AAA}[a=15pt]
\tzbrace'[red,very thick]{10pt}[brace,amplitude=10pt]
         (0,0)(3,1){BBB}[b=20pt]
\end{tikzpicture}
\end{tzcode}