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
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
|
%!TEX root = tzplot-doc.tex
%\begin{document}
%%%==========================
\part{Points, Lines, and Curves}
%%%==========================
\label{p:linesandcurves}
%%==================================
\chapter{Getting Ready}
\label{c:gettingready}
%%------------------------------------------------------------
\section{Styles: \texttt{tzdotted}, \texttt{tzdashed}, \texttt{tzhelplines}}
\label{s:styles:tzhelplines}
The styles \ixttw{tzdotted}, \ixttw{tzdashed}, and \ixttw{tzhelplines} are defined as follows:
\begin{tzsty}{}
% styles: tzdotted, tzdashed, tzhelplines
\tikzset{%
tzdotted/.style={line cap=round,dash pattern=on 0pt off 1cm/(#1)},
tzdotted/.default=10
}
\tikzset{%
tzdashed/.style={dashed=none,dash pattern=on 5mm/(#1) off 5mm/(#1)},
tzdashed/.default=10
}
\tikzset{%
tzhelplines/.style={help lines,-,tzdotted}
}
\end{tzsty}
The styles |tzdotted| and |tzdashed| print 10 dots and 10 dashes per 1cm, respectively, by default.
The style |tzhelplines| uses |tzdotted| by default.
%%------------------------------------------------------------
\section{\protect\cmd{\tzhelplines}, \protect\cmd{\tzhelplines*}}
\label{s:tzhelplines}
\icmd{\tzhelplines} draws |grid| from the first coordinate to the second coordinate.
If only one coordinate is specified, then the first coordinate is regarded as |(0,0)|.
The starred version \icmd{\tzhelplines*} uses the grid as a \iisw{bounding box}.
\begin{tzdef}{}
% syntax: minimum
\tzhelplines(<coor>)
% syntax: full
\tzhelplines[<opt>](<coor1>)(<coor2>)
% defaults
[help lines,tzdotted=10](<m>)()
% (<m>): mandatory argument
\end{tzdef}
Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument.
\begin{tztikz}{}
\tzhelplines(4,3) % works similarly to:
\draw [help lines] (0,0) grid (4,3);
\tzhelplines(1,1)(4,3) % works similarly to:
\draw [help lines] (1,1) grid (4,3);
\end{tztikz}
By default, |\tzhelplines| prints |grid| with |10| dots per |1cm|.
|\tzhelplines| with the option value |[tzdotted=<n>]| prints |<n>| dots per |1cm|.
(That is, the default value is |tzdotted=10|.)
\begin{tzcode}{.3}
% \tzhelplines
\begin{tikzpicture}
\tzhelplines(2,2)
\draw [help lines] (3,0) grid (5,2);
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% tzdotted: (default: 10 dots per 1cm)
\begin{tikzpicture}
\tzhelplines[thick](1,2) % 10 dots
\tzhelplines[thick,tzdotted=20](2,0)(3,2) % 20 dots
\tzhelplines[thick,tzdotted=5](4,0)(5,2) % 5 dots
\end{tikzpicture}
\end{tzcode}
With the option value, |[tzdotted=<n>/<d>]|, |\tzhelplines| prints |<n>| dots per |<d>cm|.
Similarly for |tzdashed|.
\begin{tzcode}{.3}
% tzdotted, tzdashed
\begin{tikzpicture}
\tzhelplines[thick,tzdashed](4,2)
\tzhelplines[thick,step=.5](4,2)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% scaled: 7 dots per .7cm (10 dots per hard 1cm)
\begin{tikzpicture}[scale=.7]
\tzhelplines[tzdashed](4,3)
\tzhelplines[step=.5](4,3)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% scaled: 10/.7 means 10 dots per .7cm
\begin{tikzpicture}[scale=.7]
\tzhelplines[tzdashed=10/.7](4,3) %%
\tzhelplines[step=.5,tzdotted=10/.7](4,3) %%
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzbbox}: A bounding box}
\label{s:tzbbox}
\icmd{\tzbbox} sets a bounding box.
\begin{tzdef}{}
% syntax
\tzbbox(<coor1>)(<coor2>)
% defaults
(0,0)(<m>)
\end{tzdef}
\begin{tztikz}{}
\tzbbox(-1,-1)(4,3) % is an abbreviation of:
\path [ use as bounding box ] (-1,-1) rectangle (4,3);
\end{tztikz}
If only one coordinate is specified, the first coordinate is regarded as |(0,0)|.
%%==================================
\chapter{Dots}
\label{c:dots}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcdot(*)}: A small circle}
\label{s:tzcdot}
A dot is usually expressed by a small circle.
\icmd{\tzcdot} prints a circle dot \tikz \tzcdot(0,0);.
The starred version \icmd{\tzcdot*} prints a filled circle dot \tikz \tzcdot*(0,0);.
The \xem{radius} of the circle is |1.2pt|, by default.
\begin{tzdef}{}
% syntax: minimum
\tzcdot(<coor>)
% syntax: medium
\tzcdot*(<coor>){<label>}[<angle>](<radius>)
% syntax: full
\tzcdot*[<opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<radius>)
% defaults
*[ solid,thin,tzcdot=1.2pt ]<>(<m>){}[](1.2pt)
% tzcdot is a predefined key (in this package).
% (<m>): mandatory
\end{tzdef}
Here, |(|\ixxw{<m>}|)| stands for a \xem{mandatory} argument. All others are optional arguments.
\paragraph{How to change the size}
There are three ways to change the \xem{radius} of a circle dot drawn by |\tzcdot|.
\begin{enumerate}
\item The simplest way is to use the last parenthesis option, like |\tzcdot(0,0)(3pt)|.
\begin{tztikz}{}
\tzcdot(0,0) % is an abbreviation of:
\draw (0,0) circle (1.2pt); % default radius=1.2pt
\end{tztikz}
\begin{tztikz}{}
\tzcdot*(0,0)(3pt) % is an abbreviation of:
\draw [fill] (0,0) circle (3pt);
\end{tztikz}
\item
You can use the key-value option |[tzcdot=<dim>]|, like |\tzcdot[tzcdot=3pt](0,0)|, to change the \xem{radius} of a circle dot. The |tzcdot| key is defined in the package.
If both the |tzcdot| key-value and the last parenthesis option are used, the former wins.
\begin{tztikz}{}
\tzcdot*(1,1) % works like:
\draw [fill] (1,1) circle [radius=1.2pt]; % default radius=1.2pt
\end{tztikz}
\begin{tztikz}{}
\tzcdot*[tzcdot=3pt] % works like:
\draw [fill] (0,0) circle [radius=3pt];
\end{tztikz}
\begin{tzcode}{.3}
% \tzcdot(*)
\begin{tikzpicture}
\tzhelplines(4,2)
\tzcdot(0,0) \tzcdot[tzcdot=4pt](1,1)
\tzcdot*(2,1)(2pt) \tzcdot*(3,0)(3pt)
\end{tikzpicture}
\end{tzcode}
\item
Another way to change the radius is to use a macro, like |\settzcdotradius{3pt}|,
It is effective within the |tizpicture| environment unless changed by \icmd{\settzcdotradius} again.
\begin{tzcode}{.3}
% \settzcdotradius
\begin{tikzpicture}
\tzhelplines(4,2)
\settzcdotradius{4pt}
\tzcdot(0,0) \tzcdot(1,1)
\tzcdot*(2,1)(2pt) \tzcdot*(3,0)
\end{tikzpicture}
\end{tzcode}
\end{enumerate}
\paragraph{How to label}
You can add a label to a specified coordinate by adding the optional argument |{<label>}| immediately after |(<coor>)|. You can also change the |<label>| position by the option |[<angle>]|.
(Note that you \xem{cannot} use the abbreviations such as |a|, |r|, |bl|, etc. to place label nodes.)
\begin{tztikz}{}
\tzcdot(0,0){A} % is an abbreviation of:
\draw (0,0) circle (1.2pt) node [label={:A}] {};
\tzcdot(0,0)(2pt){A}[[blue]0] % is an abbreviation of:
\draw (0,0) circle (2pt) node [label={[blue]0:A}] {};
\end{tztikz}
\begin{tzcode}{.3}
% \tzcdot: labels
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcdot(0,0){A} % default position: 90 or above
\tzcdot[tzcdot=4pt](1,1){B}[0]
\tzcdot*(2,1){C}[45](2pt)
\tzcdot*(3,0){D}[-90](3pt)
\tzcdot(4,3){E}[-90](6pt)
\end{tikzpicture}
\end{tzcode}
The label position does not depend on the size of circle dots.
\paragraph{How to change colors}
With the first optional argument |[<opt>]|, you can change the color of a dot.
You can also change the color of a label, as shown in the following example.
\begin{tzcode}{.3}
% \tzcdot(*)
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,3);
\tzcdot(0,0){A}
\tzcdot*[red](1,0){\textbf{B}}[45]
\tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt)
\tzcdot[tzcdot=2*7pt](3,2){big}[center]
\tzcdot*[fill=red,text=blue](4,3){D}(2*3pt)
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcdot: shift
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,3);
\tzcdot(0,0){A}
\tzcdot*[red]<0,2>(1,0){\textbf{B}}[45] % shift
\tzcdot*[red,fill=green](2,1){green}[[blue]0](10pt)
\tzcdot[tzcdot=2*7pt]<1,-1>(3,2){big}[center] % shift
\tzcdot*[fill=red,text=blue](4,3){D}(2*3pt)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzcdot: repeated
\begin{tikzpicture}
\tzhelplines(4,2)
\foreach \x in {0,...,4}
{ \foreach \A in {2,4,6,8}
{ \tzcdot[blue] (\x,0)(\A pt) } }
\foreach \x in {0,...,4}
{ \foreach \A in {2,4,6,8}
{ \tzcdot[red]<1,1>(\x,0)(\A pt) } } % shift
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcdots(*)}: Multiple circle dots}
\label{s:tzcdots}
The macro \icmd{\tzcdots} takes an arbitrary number of coordinates as arguments to print multiple circle dots with the radius |1.2pt|, by default.
You need to indicate when the iteration of an arbitrary number of coordinates ends, by typing a \xem{semicolon} |;|.
Let us call this kind of macro a \iisw{semicolon version} macro.
\remark
\begin{itemize}
\item DO NOT FORGET to enter `|;|' at the end of iteration.
\begin{itemize}
\item Tokens such as `|!|' and `|#|' other than the open parenthesis `|(|' work like the semicolon `|;|' to indicate the end of iteration.
But it is highly recommended to use `|;|' for consistency.
\end{itemize}
\item Without the semicolon |;|, the macro does nothing or a compile error occurs.
\end{itemize}
The starred version |\tzcdots*| prints multiple filled dots.
\begin{tzdef}{}
% syntax: minimum
\tzcdots*(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: full
\tzcdots*[<opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>]
..repeated.. (){}[] ; (<dot radius>)
% defaults
*[tzcdot=1.2pt]<>(<m>){}[]..repeated..(){}[] ; (1.2pt)
\end{tzdef}
\begin{tzcode}{.3}
% \tzcdots(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcdots(0,0)(1,1)(2,1)(3,2)(4,0);
\tzcdots*(0,3)(1,2)(2,2)(3,3)(4,3);
\end{tikzpicture}
\end{tzcode}
\paragraph{How to label}
Each coordinate can be followed by the optional arguments |{<label>}| and |[<angle>]| to label dots. So the repeating pattern is the triple |(<coor>){<label>}[<angle>]|.
\begin{tzcode}{.3}
% \tzcdots: label
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcdots(0,0){A}
(1,1)
(2,1){C}[0]
(3,2){D}[-90]
(4,0){E};
\tzcdots*(0,3)(1,2){B}(2,2){C}[45](3,3)(4,3);
\end{tikzpicture}
\end{tzcode}
\paragraph{How to change the size of dots}
There are three ways of changing the \xem{radius} of dots.
\begin{enumerate}
\item The simplest way is to use the \xem{last} parenthesis optional argument, \xem{after the semicolon}.
\item Another way is to use the \ixxw{tzcdot} key, like |\tzcdots[tzcdot=3pt]...|.
If both options are used the key-value option wins.
\item You can also use the macro \icmd{\settzcdotradius}.
The effect remains within the |tikzpicture| environment unless it is changed again.
\end{enumerate}
\begin{tzcode}{.3}
% \tzcdots: size (radius)
\begin{tikzpicture}
\tzhelplines(4,3)
\settzcdotradius{3pt}
\tzcdots(0,0)(1,0){3pt};
\tzcdots*(1,1)(2,1){1pt};(1pt) % simplest
\tzcdots[tzcdot=5pt](2,2)(3,2){5pt};
\tzcdots*(3,3)(4,3){3pt};
\end{tikzpicture}
\end{tzcode}
\paragraph{How to change colors}
With the first optional argument |[<opt>]|, you can change the color of dots.
You can also change the color of all labels at once using the first optional argument,
like |\tzcdots[text=red]...| as shown in the following example.
\begin{tzcode}{.3}
% \tzcdots: color
\begin{tikzpicture}
\tzhelplines(4,3)
\settzcdotradius{3pt}
\tzcdots*[red]
(0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
\tzcdots*[thick,blue,fill=green,text=red]
(1,2){A}(2,2){Ben}[[blue]-90](3,2){C}(4,2){D};(4pt)
\tzcdots*[blue]
(1,3){A}(2,3){B}(3,3){C}(4,3){D};
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzcdots: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
\tzcdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzdot(*)}: A single node dot}
\label{s:tzdot}
The macro \icmd{\tzdot} prints a small circle node \tikz \tzdot(0,0);, as a dot, with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default.
The starred version \icmd{\tzdot*} prints a filled dot \tikz \tzdot*(0,0);.
\begin{tzdef}{}
% syntax: minimum
\tzdot(coor)
% syntax: medium
\tzdot*(<coor>){<label>}[<angle>](<dot size>)
% syntax: full
\tzdot*[<node opt>]<shift coor>(<coor>){<label>}[<[label opt]angle>](<dot size>)
% defaults
*[ tzdot=2.4pt ]<>(<m>){}[](2.4pt)
% the style tzdot is predefined
% (<m>): mandatory
\end{tzdef}
|\tzdot(*)| accepts one mandatory argument, denoted by |(|\ixxw{<m>}|)|. All others are optional.
The style \ixxw{tzdot} is defined as follows:
\begin{tzsty}{}
% style: tzdot
\tikzset{
tzdot/.style={draw,circle,solid,thin,inner sep=0pt,minimum size=#1},
tzdot/.default=2.4pt
}
\end{tzsty}
\subsection{{\normalfont\scshape Three Ways} to change the size of node dots}
\label{ss:threeways}
There are \iscw{Three Ways} to change the \xem{diameter} (or |minimum size|) of a node dot drawn by |\tzdot(*)|.
\begin{enumerate}
\item Use the predefined style |tzdot| in the first optional agrument, like |\tzdot[tzdot=5pt](0,0)|, which gives the same result as |\tzdot[minimum size=5pt](0,0)|.
\begin{tztikz}{}
\tzdot(0,0) % works like:
\path (0,0) node [tzdot=2.4pt] {}; % default size
% or equivalently
\node [tzdot,minimum size=2.4pt] at (0,0) {};
\end{tztikz}
\item The simplest way is to use the \xem{last} parenthesis optional argument, like |\tzdot(0,0)(5pt)|, which yields the same result as in |\tzdot[tzdot=5pt](0,0)|.
If both options are used, the |tzdot| (or |minimum size|) option overwrites the last parenthesis option.
\begin{tzcode}{.3}
% \tzdot(*)
\begin{tikzpicture}
\tzhelplines(4,2)
\tzdot(0,0) \tzdot[tzdot=8pt](1,1)
\tzdot*(2,1)(4pt) \tzdot*(3,0)(6pt)
\end{tikzpicture}
\end{tzcode}
\item To change the size of all node dots drawn by |\tzdot*|, you can use the macro |\settzdotsize|. Its effect remains valid until the end of |tikzpicture| environment unless changed again.
\begin{tzcode}{.3}
% \settzdotsize
\begin{tikzpicture}
\tzhelplines(4,2)
\settzdotsize{8pt}
\tzdot(0,0) \tzdot(1,1)
\tzdot*(2,1)(4pt) \tzdot*(3,0)
\end{tikzpicture}
\end{tzcode}
\end{enumerate}
\subsection{How to label}
\label{ss:tzdot:label}
You can add a label to a specified coordinate by specifying the optional argument |{<label>}| immediately after the coordinate |(<coor>)|.
You can also change the label position by the option |[<angle>]| following |{<label>}|.
\begin{tztikz}{}
\tzdot(0,0){A}(3pt) % works like:
\path (0,0) node [tzdot=3pt,label={:A}] {};
\tzdot*(0,0){A}[[red]0](3pt) % works like:
\path (0,0) node [fill,tzdot=3pt,label={[red]0:A}] {};
\end{tztikz}
\begin{tzcode}{.3}
% \tzdot: labels
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdot(0,0){A}
\tzdot(1,1){B}[0](8pt)
\tzdot*(2,1){C}[45](4pt)
\tzdot*(3,0){D}[-90](6pt)
\tzdot(4,3){E}[-90](12pt)
\end{tikzpicture}
\end{tzcode}
Unlike |\tzcdot|, the |\tzdot|'s label position depends on the size of a circle node. In \Tikz\ jargon, |{<label>}| is 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.
\subsection{How to change colors and shapes}
\label{ss:tzdot:color}
With the first optional argument |[<node opt>]|, you can change of the color or shape of dots.
You can also change the label color using |[<label opt>]| as shown in the following example.
\remark
\begin{itemize}
\item |[<node opt>]| is for options of \xem{main nodes}, |[<label opt>]| is for options of \xem{label nodes}.
\item |[<label opt>]| is used in the form of |[<[label opt]angle>]|.
\end{itemize}
\begin{tzcode}{.3}
% \tzdot: color
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,3);
\tzdot(0,0){A}
\tzdot*[red](1,0){\textbf{B}}[45]
\tzdot*[red,fill=green](2,1){green}[[blue]0](2*10pt)
\tzdot[tzdot=4*7pt](3,2){big}[center]
\tzdot*[fill=red](4,3){D}(4*3pt)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzdot: shape
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,3);
\tzdot[regular polygon](0,0){A}(10pt)
\tzdot*[red](1,0){\textbf{B}}[45]
\tzdot*[red,fill=green,rectangle](2,1){green}[0](2*10pt)
\tzdot[tzdot=4*7pt](3,2){big}[center]
\tzdot*[fill=red,star](4,3){D}(4*3pt)
\end{tikzpicture}
\end{tzcode}
\subsection{How to move: \texttt{shift}}
\label{ss:tzdot:shift}
Dots can be shifted by specifying the optional argument |<shift coor>| immediately before |(<coor>)|. The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzdot: shift
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,3);
\tzdot[regular polygon](0,0){A}(10pt)
\tzdot*[red]<0,2>(1,0){\textbf{B}-shifted}[45] % shift
\tzdot*[red,fill=green,rectangle](2,1){green}[0](2*10pt)
\tzdot[tzdot=4*7pt]<1,-1>(3,2){big}[center] % shift
\tzdot*[fill=red,star](4,3){D}(4*3pt)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzdot: repeated
\begin{tikzpicture}
\tzhelplines(4,2)
\foreach \x in {0,...,4}
{ \foreach \A in {1,2,3,4}
{ \tzdot[blue] (\x,0)(2*\A mm) } }
\foreach \x in {0,...,4}
{ \foreach \A in {1,2,3,4}
{ \tzdot[green]<1,1>(\x,0)(2*\A mm) } } % shift
\end{tikzpicture}
\end{tzcode}
\subsection{Comparison: \protect\cmd{\tzdot} and \protect\cmd{\tzcdot}}
\label{ss:tzdot:comparison}
The most important difference between |\tzcdot| and |\tzdot| is that |\tzcdot| is affected by \Tikz's scaling factor, but |\tzdot| is not.
This is critical when |xscale| is not equal to |yscale|.
\begin{tzcode}{.3}
\begin{tikzpicture}[xscale=1.6,yscale=.8]
\tzhelplines(3,3)
\tzcdot(0,0)(3pt) % dostorted
\tzdot(1,0)(6pt)
\tzcdots*(1,1)(2,1)(3,1);(2pt) % distorted
\tzdots*(1,2)(2,2)(3,2);(4pt)
\end{tikzpicture}
\end{tzcode}
The following table further shows the differences between them.
%Everything else is the same for end-users.
\begin{tzcode}[listing only,colback=green!10!white]{.3}
% concept % single % multi % size control % [key=default size]
node [circle] \tzdot \tzdots \settzdotsize [tzdot=2.4pt] % diameter
circle \tzcdot \tzcdots \settzcdotradius [tzcdot=1.2pt] % radius
\end{tzcode}
\remark
\begin{itemize}
\item In \Tikz, a `node' is `not' affected by `scaling' unless the \Tikz\ option |transform shape| is used together.
|\tzdot| is also useful for labelling a large dot.
\begin{itemize}
\item In |\tzdot|, |<label>| is a label in a \iisw{label node} for a node dot (as a \iisw{main node}).
So if a main node dot gets larger or smaller, its label moves accordingly.
(Unlike, the labels with |\tzcdot| or |\tzcdots|.)
\item The position of |<label>| in |\tzcdot| does not depend on the size of dots.
\end{itemize}
\item The package |tzplot| takes |\tzdot| as a \xem{standard dot}, not |\tzcdot|.
So, you can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of any standard dots.
\end{itemize}
%%------------------------------------------------------------
\section{\protect\cmd{\tzdots(*)}: Multiple node dots}
\label{s:tzdots}
\icmd{\tzdots} takes an arbitrary number of coordinates as arguments to print multiple circle node dots with the \xem{diameter} (or |minimum size|) of |2.4pt|, by default.
This is a \iisw{semicolon version} macro, with the repeating pattern |(<coor>){<label>}[<angle>]|, which means that you need to type a \xem{semicolon} `|;|' at the end of the coordinate repetition. The \xem{semicolon} says, ``\xem{The repetition ends here}."
\remark
\begin{itemize}
\item DO NOT FORGET to enter `|;|' at the end of iteration.
\begin{itemize}
\item Tokens such as `|!|' and `|#|' other than the open parenthesis `|(|' work like the semicolon `|;|' to indicate the end of iteration.
But it is highly recommended to use `|;|' for consistency.
\end{itemize}
\item Without the semicolon |;|, the macro does nothing or a compile error occurs.
\end{itemize}
The starred version \icmd{\tzdots*} prints multiple filled node dots.
\begin{tzdef}{}
% syntax: minimum
\tzdots*(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: full
\tzdots*[<node opt>]<shift coor> (<coor>){<label>}[<[label opt]angle>]
..repeated.. (){}[] ; (<dot size>)
% defaults
*[tzdot=2.4pt]<> (<m>){}[] ..repeated.. (){}[] ; (2.4pt)
\end{tzdef}
\begin{tzcode}{.3}
% \tzdots(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots(0,0)(1,1)(2,1)(3,2)(4,0);
\tzdots*(0,3)(1,2)(2,2)(3,3)(4,3);
\end{tikzpicture}
\end{tzcode}
\paragraph{How to label}
Each coordinate can be followed by the optional arguments |{<label>}| and |[<angle>]| to label dots. So the triple |(<coor>){<label>}[<angle>]| is the whole repeating pattern.
\begin{tzcode}{.3}
% \tzdots: label
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots(0,0){A}
(1,1)
(2,1){C}[0]
(3,2){D}[-90]
(4,0){E};
\tzdots*(0,3)(1,2){B}(2,2){C}[45](3,3)(4,3);
\end{tikzpicture}
\end{tzcode}
\paragraph{How to change the size of dots}
There are \threeways\ of changing the \xem{diameter} of node dots, as discussed in Section \ref{ss:threeways} on page \pageref{ss:threeways}.
\begin{enumerate}
\item The simplest way is to use the \xem{last} parenthesis optional argument, \xem{after the semicolon}.
\item Another way is to use the style \ixxw{tzdot}, like |\tzdots[tzdot=3pt]...|.
If both options are used the |tzdot| option style wins.
\item You can also use the macro \icmd{\settzdotsize}.
The effect remains within the |tikzpicture| environment unless it is changed again.
\end{enumerate}
\begin{tzcode}{.3}
% \tzdots: size (diameter)
\begin{tikzpicture}
\tzhelplines(4,3)
\settzdotsize{3mm}
\tzdots(0,0)(1,0){3mm};
\tzdots*(1,1)(2,1){2mm};(2mm) % simplest
\tzdots[tzdot=4mm](2,2)(3,2){4mm};
\tzdots*(3,3)(4,3){3mm};
\end{tikzpicture}
\end{tzcode}
\paragraph{How to change colors}
With the first optional argument |[<node opt>]| you can change the color of node dots.
You can also change the color of each label by |[<label opt>]|.
\begin{tzcode}{.3}
% \tzdots: color
\begin{tikzpicture}[->]
\tzhelplines(4,3)
\settzdotsize{6pt}
\tzdots*[red]
(0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
\tzdots*[thick,blue,fill=green]
(1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt)
\tzdots*[blue]
(1,3){A}(2,3){B}(3,3){C}(4,3){D};
\end{tikzpicture}
\end{tzcode}
\remark
\begin{itemize}
\item |[<node opt>]| is the option of a \iisw{main node} and |[<label opt>]| is the option of a \iisw{label node}.
\item |[<label opt>]| is used in the form of |[<[label opt]angle>]|, like |[[red]90]|.
\item You can control all labels together using |every label/.style| as in the following examples:
\end{itemize}
\begin{tzcode}{.3}
% \tzdots: every label/.style
\begin{tikzpicture}
\tzhelplines(4,3)
\settzdotsize{6pt}
\tzdots*[red]
(0,0)(1,1){\textbf{Ben}}[[blue]-90](2,1)(3,0);
\tzdots*[thick,blue,fill=green]
(1,2){A}(2,2){Ben}[[red]-90](3,2){C}(4,2){D};(8pt)
\tikzset{every label/.style={draw,text=red}} %%
\tzdots*[blue]
(1,3){A}(2,3){B}(3,3){C}(4,3){D}[0];
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% every label/.style
\begin{tikzpicture}[every label/.style={draw,text=red}]
\tzhelplines(4,3)
\tzdots*
(0,0){Ace}[[font=\LARGE\ttfamily]-90]
(2,1){\textbf{Bob}}[[blue]135]
(3,2){$C_1$\\$N_o$}[[align=center]0];
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift} You can move the coordinates of dots by specifying |<shift coor>| option immediately before the first coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzdots: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots[red] (0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
\tikzset{every label/.style={red}}
\tzdots*<0,1>(0,0){A}(1,1)(2,1){C}(3,2){D}[0](4,0){E};
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Coordinates}
\label{c:coordinates}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcoor} and \protect\cmd{\tzcoor*}}
\label{s:tzcoor}
\subsection{\protect\cmd{\tzcoor}}
\label{ss:tzcoor}
For example, \icmd{\tzcoor}|(0,0)(A)| means that the coordinate |(0,0)| is named |(A)|.
\begin{tztikz}{}
\tzcoor(0,0)(A) % is an abbreviation of:
\path (0,0) coordinate (A);
% or
\coordinate (A) at (0,0);
\end{tztikz}
\begin{tzdef}{}
% syntax: minimum
\tzcoor(<coor>)(<name>)
% syntax: medium
\tzcoor(<coor>)(<name>){<label>}[<angle>]
% syntax: full
\tzcoor<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
% defaults
<>(<m>)(<m>){}[]
\end{tzdef}
Here, |<m>| stands for `mandatory.' |\tzcoor| takes two mandatory arguments in parenthesis.
\paragraph{How to label}
You can put a label to a coordinate by specifying the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|.
\begin{tztikz}{}
\tzcoor(0,0)(A){$A$}[0] % works like:
\path (0,0) coordinate [label={0:$A$}] (A);
\end{tztikz}
\begin{tzcode}{.3}
% \tzcoor
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor(0,0)(A){$A_1$} % TikZ default: 90 or above
\tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0]
\draw (A) -- (B);
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the coordinate by specifying the optional argument |<shift coor>| before |(<coor>)|.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoor: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor<0,1>(0,0)(A){$A_1$} %%
\tzcoor(2,1)(B){$B_2$\\ending point}[[align=left,red]0]
\tzline(A)(B)
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzcoor*}}
\label{ss:tzcoor*}
The starred version \icmd{\tzcoor*} works like |\tzcoor| with one exception. It prints a `node dot' of the size |2.4pt|, by default, at a specified coordinate.
\begin{tzdef}{}
% syntax: minimum
\tzcoor*(<coor>)(<coor name>)
% syntax: medium
\tzcoor*(<coor>)(<coor name>){<label>}[<angle>]
% syntax: full
\tzcoor*[<dot opt>]<shift coor>
(<coor>)(<name>){<label>}[[<label opt>]<angle>](<dot size>)
% defaults
*[]<>(<m>)(<m>){}[](2.4pt)
\end{tzdef}
\begin{tztikz}{}
\tzcoor*(0,0)(A) % works like:
\path (0,0) coordinate (A);
\tzdot*(0,0)
\end{tztikz}
\begin{tztikz}{}
\tzcoor(0,0)(A){$A$}[right] % works like:
\path (0,0) coordinate (A);
\tzdot*(0,0){$A$}[right]
\end{tztikz}
\begin{tzcode}{.3}
% \tzcoor*
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor*(0,0)(A){$A_1$} % TikZ default: 90 or above
\tzcoor*(30:3cm)(B){$B_2$}[[draw,blue]0]
\draw (A) -- (B);
\end{tikzpicture}
\end{tzcode}
\paragraph{Changing the color and size of a dot}
You can change the color of a dot by specifying |[<dot opt>]|, which is, in fact, \Tikz's |node| option.
To change the size of dots, you can apply the \threeways\ (see Subsection \ref{ss:threeways} on page \pageref{ss:threeways}).
\begin{tzcode}{.3}
% \tzcoor*: color, size
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor(1,1)(A){A}
\tzcoor*(2,1)(B){B}[0]
\tzcoor*[red](1,2)(C){C}[180]
\tzcoor*[fill=none,tzdot=5pt](3,2)(D){D}[45]
\tzcoor*[blue,thick,fill=green](4,0)(E){E}[180](6pt)
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift} The optional argument |<shift coor>| works just like in |\tzcoor|.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoor*: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor*<0,1>(0,0)(A){$A_1$} %%
\tzcoor*(2,1)(B){$B_2$\\end point}[[align=left,red]0]
\tzline(A)(B)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcoors} and \protect\cmd{\tzcoors*}: Semicolon versions}
\label{s:tzcoors}
\subsection{\protect\cmd{\tzcoors}}
\label{ss:tzcoors}
The macro \icmd{\tzcoors} takes an arbitrary number of pairs of coordinates and their names as arguments.
For example, |\tzcoors(0,0)(A) (1,1)(B) (2,2)(C);| means that the coordinate |(0,0)| is represented by the name |(A)|, |(1,1)| by |(B)|, and |(2,2)| by |(C)|.
\begin{tzdef}{}
% syntax: minimum
\tzcoors(<coor>)(<name>..repeated..(<coor>)(<name>) ;
% syntax: full
\tzcoors <shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
..repeated.. ()(){}[] ;
% defaults
<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ;
\end{tzdef}
This is a \xem{semicolon version} macro. The quadruple |(<coor>)(<name>){<label>}[<angle>]| is the whole repeating pattern.
It is required to type a \xem{semicolon} `|;|' to indicate when the coordinate repetition ends.
\begin{tztikz}{}
\tzcoors (0,0)(A) (1,1)(B) (2,1)(C) (3,0)(D) ; % works like:
\path (0,0) coordinate (A)
(1,1) coordinate (B)
(2,1) coordinate (C)
(3,0) coordinate (D);
\end{tztikz}
\begin{tztikz}{}
\tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C}[0] (3,0)(D){D}[90]; % works like:
\path (0,0) coordinate (A)
(1,1) coordinate (B)
(2,1) coordinate [label={0:C}] (C)
(3,0) coordinate [label={90:D}] (D);
\end{tztikz}
You can add a label to each specified coordinate by adding the optional arguments |{<label>}| and |[<angle>]| immediately after |(<name>)|.
\begin{tzcode}{.3}
% \tzcoors
\begin{tikzpicture}
\tzcoors (0,0)(A){Ace}[[font=\LARGE\ttfamily]-90]
(2,1)(B){\textbf{Bob}}[[blue]135]
(3,2)(C){$C_1$\\$N_o$}[[align=center]0];
\draw (A) -- (B) -- (C);
\end{tikzpicture}
\end{tzcode}
By the option |<shift coor>|, all specified coordinates are shifted.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoors
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoors (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D);
\tzlines(A)(B)(C)(D);
% shift
\tzcoors <1,1> (0,0)(A) (1,1)(B) (2,1)(C){C} (3,0)(D);
\tzlines[dashed](A)(B)(C)(D);
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzcoors*}}
\label{ss:tzcoors*}
The starred version \icmd{\tzcoors*} takes an arbitrary number of coordinates as arguments to print node dots at the coordinates. Full repeating pattern is |(<coor>)(<name>){<label>}[<angle>]|. It is required to type a \xem{semicolon} `|;|' to indicate when the iteration of coordinates ends.
\begin{tzdef}{}
% syntax: minimum
\tzcoors*(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
% syntax: full
\tzcoors*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
..repeated.. ()(){}[] ; (<dot size>)
% defaults
*[]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ; (2.4pt)
\end{tzdef}
You can label each dot by specifying the optional arguments |{<label>}| and |[<angle>]| after the pair |(<coor>)(<name>)|.
\begin{tzcode}{.3}
% \tzcoors*
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoors*(0,0)(A)
(1,1)(B){B}
(2,1)(C)
(3,3)(D){D}[0] ;
\end{tikzpicture}
\end{tzcode}
You can change the dot color by |[<dot opt>]| and the label color by |[<label opt>]|.
You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the dot size. The simplest way of changing the dot size is to specify the \xem{last} (even after the semicolon) parenthesis option |(<dot size>)|.
\begin{tzcode}{.3}
% \tzcoors*
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoors*[red](0,0)(A)
(1,1)(B){B}
(2,1)(C)
(3,3)(D){D}[[blue]0] ; (6pt)
\end{tikzpicture}
\end{tzcode}
By specifying the optional argument |<shift coor>| immediately before the first coordinate, you can move all specified coordinates.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoors*: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\settzdotsize{6pt}
\tzcoors*[red] (0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D);
\settzdotsize{4pt}
\tzcoors*[blue]<.5,0>(0,0)(A)(1,1)(B)(2,1)(C)(3,3)(D);
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcoorsquick} and \protect\cmd{\tzcoorsquick*}}
\label{s:tzcoorsquick}
\subsection{\protect\cmd{\tzcoorsquick}}
\label{ss:tzcoorsquick}
You can see the coordinate array at a glance using \icmd{\tzcoorsquick}, which displays specified names as text at the |center| of the coordinates, by default.
\begin{tzdef}{}
% syntax: minimum
\tzcoorsquick(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
% syntax: full
\tzcoorsquick<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
..repeated.. ()(){}[] ;
% defaults
<> (<m>)(<m>){}[center] ..repeated.. ()(){}[] ;
\end{tzdef}
\begin{tzcode}{.3}
% \tzcoorsquick
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoorsquick(0,0)(A)
(1,1)(Ben)
(2,1)(Cate)
(3,2)(Daniel);
\end{tikzpicture}
\end{tzcode}
A label can be suppressed by the empty braces |{}|.
You can move the coordinates by specifying |<shift coor>| immediately before the first coordinate. The empty option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoorsquick: shift, color
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoorsquick
(0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
\tikzset{every label/.style={blue}}
\tzcoorsquick <0,1>
(0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzcoorsquick*}}
\label{ss:tzcoorsquick*}
The starred version \icmd{\tzcoorsquick*} prints node dots on the coordinates and displays the names |above| (or |90| degree from) the dots, by default.
\begin{tzdef}{}
% syntax: minimum
\tzcoorsquick*(<coor>)(<name>)..repeated..(<coor>)(<name>) ;
% syntax: full
\tzcoorsquick*[<dot opt>]<shift coor>(<coor>)(<name>){<label>}[<[label opt]angle>]
..repeated.. ()(){}[] ;
% defaults
*[ tzdot=1.2pt ]<> (<m>)(<m>){}[] ..repeated.. ()(){}[] ;
\end{tzdef}
\begin{tzcode}{.3}
% \tzcoorsquick*
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoorsquick*(0,0)(A) (1,1)(Ben)
(2,1)(Cate) (3,2)(Daniel);
\end{tikzpicture}
\end{tzcode}
A label can be suppressed by the empty braces |{}|.
You can change the dot size using the \threeways\ (on page \pageref{ss:threeways}).
You can shift the coordinate by specifying |<shift coor>| immediately before the first coordinate. The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcoorsquick*: size, color, shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoorsquick*
(0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);
\tikzset{every label/.style={blue}}
\tzcoorsquick*[blue]<0,1>
(0,0)(A) (1,1)(Ben) (2,1)(Cate){} (3,2)(Daniel);(6pt)
\end{tikzpicture}
\end{tzcode}
\remark
The first optional argument of |\tzcoorsquick*| is for only dots.
You can use the \Tikz\ option |every label/.style={...}| to control all the labels together.
You can also control each labels using |[<label opt>]| for each coordinate.
\begin{tzcode}{.3}
% \tzcoorsquick*
\begin{tikzpicture}[every label/.style={draw,red}]
\tzhelplines(4,3)
\tzcoorsquick*[fill=none,blue,very thick]
(0,0)(A)(1,1)(B-1)(2,1)(C)(3,3)(D)[[blue]0];(8pt)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzgetxyval}}
\label{s:tzgetxyval}
\icmd{\tzgetxyval} extracts the values of x-coordinate and the y-coordinate \xem{in the unit of centimeter} from a specified coordinate and saves the values in the user-defined macros, so that you can use them later.
For example, |\tzgetxyval(3,2){\xval}{\yval}| results in |\xval=3| and |\yval=2|.
\begin{tzdef}{}
% syntax
\tzgetxyval(<coor>){<\macroXval>}{<\macroYval>}
% default
(<m>){<m>}{<m>}
\end{tzdef}
\begin{tzcode}{.3}
\begin{tikzpicture}
\tzhelplines(4,3)
\tzfn"dem"{3-(3/4)*\x}[0:4]
\tzfn"sup"{\x}[0:4]
% intersection point: (E)
\tzXpoint*{dem}{sup}(E)(5pt)
% extract x/y-coordinate from (E)
\tzgetxyval(E){\Ex}{\Ey}
\tzdots*(\Ex,\Ey){E}(\Ex+1,\Ey){F}(\Ex,\Ey+1){G};
\tzdot(E)(10pt)
\tznodeframe(2,0){x\;=\;\Ex\,cm\\ y\;=\;\Ey\,cm}
[font=\ttfamily\scriptsize,align=left]
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Plot Coordinates: \protect\cmd{\tzplot}: Semicolon Versions}
\label{c:plotcoordinates}
%%------------------------------------------------------------
\section{\protect\cmd{\tzplot} and \protect\cmd{\tzplot*}: Syntax}
\label{s:tzplot}
\icmd{\tzplot} takes an arbitrary number of coordinates as arguments.
Each |(<coor>)| can be followed by the optional arguments |{<label>}| and |[<angle>]| to label the coordinate. This is a \xem{semicolon version} and the whole repeating pattern is the triple |(<coor>){<label>}[<angle>]|. It is required to type a semicolon `|;|' to indicate when the coordinate iteration ends.
The macro |\tzplot| draws connected line segments that link specified coordinates.
\begin{tzdef}{}
% syntax: minimum
\tzplot(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: medium
\tzplot(<coor>){<label>}[<angle>]..repeated..(<coor>){<label>}[<angle>] ;
% syntax:full
\tzplot[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>"
(<coor>){<label>}[<[label opt]angle>]
..repeated..
(){}[] ; (<mark size>) <code.append>
% defaults
[tzmark=2pt]{0}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <>
\end{tzdef}
The style \ixxw{tzmark} is defined as follows:
\begin{tzsty}{}
% style: tzmark
\tikzset{
tzmark/.style=
{mark options={solid,thin},mark size=#1},
tzmark/.default=\tzmarksize
}
\end{tzsty}
\icmd{\tzmarksize} is the \xem{radius} of a |mark| and the default is |2pt| as in \Tikz.
The value of |\tzmarksize| can be changed by the macro \icmd{\settzmarksize}, like |\settzmarksize{3pt}|.
The starred version |\tzplot*| prints dot marks at specified coordinates, without drawing line segments connecting the coordinates, by default.
%%------------------------------------------------------------
\section{\protect\cmd{\tzplot*}: Dots and marks}
\label{s:tzplot-dots}
The starred version |\tzplot*| prints \Tikz\ marks (|*| by default) at specified coordinates.
You can change the mark color and mark style using the first bracket optional argument.
\begin{tztikz}{}
\tzplot*(0,0)(1,2)(2,2)(3,3); % works like:
\draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) } ;
\end{tztikz}
\begin{tzcode}{.3}
% \tzplot*
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot*(0,0)(1,1)(2,1)(3,3);
\tzplot*[mark=o](0,3)(1,3)(2,2)(3,1);
\tzplot*[red](0,2)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
\paragraph{Labels, marks, and mark size}
You can also add labels to specified coordinates with the optional arguments |{<label>}| and |[<angle>]| immediately after each |(<coor>)|.
\begin{tztikz}{}
\tzplot*(0,0){A}[90](1,2)(2,2)(3,3){D}[0]; % works like:
\draw [draw=none,mark=*] plot coordinates { (0,0)(1,1)(2,2)(3,3) }
node (0,0) [label={90:D}] {}
node (3,3) [label={0:D}] {} ;
\end{tztikz}
There are three ways to change the mark size.
\begin{enumerate}
\item The simplest way is to use the parenthesis optional argument |(<mark size>)|, \xem{immediately after the semicolon}.
\item You can use the style |tzmark|, like |tzmark=3pt|.
\item You can also use the macro |\settzmarksize|, which is effective until the end of |tikzpicture| environment.
\end{enumerate}
\begin{tzcode}{.3}
% \tzplot*: label, size
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot*(0,0){A}(1,1)(2,1)(3,3){D}[[blue]0];(1mm)
\tzplot*[mark=o,tzmark=6pt](0,3)(1,3)(2,2)(3,1);
\settzmarksize{4pt}
\tzplot*[red](0,2){A}(1,2){B}(2,0){C}[[blue]0](3,2){D};
\end{tikzpicture}
\end{tzcode}
With |\tzplot*|, you can draw line segments by giving the \Tikz's option |draw| in the first bracket optional argument, like |\tzplot*[draw]|.
\begin{tzcode}{.3}
% \tzplot*: line, more marks, size
\begin{tikzpicture}[scale=1]
\tzhelplines(4,3)
\settzmarksize{3pt}
\tzplot*[draw,mark=x](0,0)(1,1)(2,1)(3,3);
\tzplot*[blue,mark=diamond*](0,3)(1,3)(2,2)(3,1);(10pt)
\tzplot*[draw,dashed,red,mark=heart](0,2)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
\remark In \Tikz, the |mark| shapes are affected by |scale|, |xscale|, and |yscale|.
\begin{tzcode}{.3}
% \tzplot*: marks: distorted
\begin{tikzpicture}[yscale=.5]
\tzhelplines(4,3)
\settzmarksize{3pt}
\tzplot*[draw,mark=x](0,0)(1,1)(2,1)(3,3);
\tzplot*[blue,mark=diamond*](0,3)(1,3)(2,2)(3,1);(10pt)
\tzplot*[draw,dashed,red,mark=heart](0,2)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move specified coordinates using the option |<shift coor>| before the first coordinate (to be precise, immediately before the option |"<path name>"| if it exists).
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzplot*: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplot*[draw] (1,3){A}(2,3)(3,3)(4,3){D}[0];
\tzplot*[draw,red]<-1,-1>(1,3){A}(2,3)(3,3)(4,3){D}[0];
\tzplot*[draw,blue]<0,-3>(1,3){A}(2,3)(3,3)(4,3){D}[0];
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzplot}: Lines}
\label{s:tzplot-lines}
|\tzplot| draws connected line segments connecting specified coordinates.
(By default, |tension=0|.)
\begin{tztikz}{}
\tzplot(0,0)(1,2)(2,2)(3,3); % works like:
\draw [tension=0] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
\end{tztikz}
\paragraph{Options: draw, mark, mark options, etc.}
You can use the optional argument |[<opt>]| to change the style of lines and marks.
\begin{tzcode}{.3}
% \tzplot: line
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot (0,0)(1,1)(2,1)(3,3);
\tzplot[dashed,mark=o](0,3)(1,3)(2,2)(3,1);
\tzplot[red,mark=ball,mark options={ball color=purple}]
(0,1)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
To close the path of |\tzplot| you can use the option |smooth cycle| in the first bracket optional argument |[<opt>]| or in the second bracket optional argument |[<plot opt>]|.
\begin{tzcode}{.3}
% \tzplot: smooth cycle
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot (0,0)(1,1)(2,1)(3,3);
\tzplot[dashed,mark=o,smooth cycle]
(0,3)(1,3)(2,2)(3,1);
\tzplot[red,mark=*,mark options={blue}]
[smooth cycle] %%
(0,1)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
\paragraph{Labels} You can label specified coordinates with the options |{<label>}| and |[<angle>]| immediately after each |(<coor>)|.
\begin{tzcode}{.3}
% \tzplot: label
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot(0,0){A}(1,1){B}[-90](2,1)(3,3){Da}[[draw]0];
\tzplot[mark=o](0,3)(1,3){B}(2,2)(3,1){Db}[0];
\tzplot[red,mark=*,draw=blue]
(0,1)(1,2){B}(2,0)(3,2){Dc}[[blue]0];
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift} You can also move the line segments by specifying the option |<shift coor>| before the first coordinate (to be precise, immediately before the option |"<path name>"| if it exists).
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzplot: shift
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot <1,0>(0,0)(1,1)(2,1)(3,3){Da}[0];
\tzplot[mark=o] <1,0>(0,3)(1,3)(2,2)(3,1){Db}[0];
\tzplot*[draw,red]<1,0>(0,1)(1,2)(2,0)(3,2){Dc}[0];
\end{tikzpicture}
\end{tzcode}
\paragraph{\texttt{name path} for intersections}
To find the intersection 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.
\begin{tzcode}{.3}
% \tzplot: "path name"
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot[name path=Da] (0,0)(1,1)(2,1)(3,3){Da}[0];
\tzplot[mark=o] "Db"(0,3)(1,3)(2,2)(3,1){Db}[0];
\tzplot*[draw,red]"Dc"(0,1)(1,2)(2,0)(3,2){Dc}[0];
% intersection points
\tzXpoint*[gray]{Da}{Db}
\tzXpoint*[blue]{Da}{Dc}
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending the path}
In order to \xem{extend a path}, formed by |\tzplot|, \xem{from the last coordinate}, you can write \Tikz\ code in the very last optional argument |<code.append>|, \xem{after the semicolon}.
\begin{tzcode}{.3}
% \tzplot: "path name"
\begin{tikzpicture}[scale=.8]
\tzhelplines(6,4)
\tzplot(0,0)(1,1)(2,1)(3,3){Da}[0];< -- (6,4) >
\tzplot[mark=o](0,3)(1,3)(2,2)(3,1){Db}[0];(4pt)
\tzplot[mark=ball,red](0,1)(1,2)(2,0)(3,2){Dc}[0];
(5pt)< to [bend left] ++(2,-2) node {ends here!} >
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzplot}: Curves}
\label{s:tzplot:curves}
With |\tzplot|, the default value of |tension| is |0|.
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).
\begin{tztikz}{}
\tzplot[blue,smooth cycle]{1}(0,0)(1,2)(2,2)(3,3); % works like:
\draw [blue,tension=1] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
\end{tztikz}
\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot[tension=1](0,0)(1,1)(2,1)(3,3);
\tzplot[mark=o] (0,3)(1,3)(2,2)(3,1); % tension=0
\tzplot*[draw,red,smooth cycle]{1}
(0,1)(1,2)(2,0)(3,2);
\end{tikzpicture}
\end{tzcode}
To plot curves, the macro |\tzplotcurve| is provided.
Basically, |\tzplotcurve| is the |tension=1| version of |\tzplot|.
(See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve}.)
%%------------------------------------------------------------
\section{\protect\cmd{\tzplot}: Bars and combs}
\label{s:tzplot-bars}
With |\tzplot|, you can draw bars or combs, using the \Tikz\ options |ybar|, |xbar|, |ycomb|, and |xcomb|.
\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot*[draw](0,0)(1,1)(2,1)(3,3);
\tzplot[ybar](0,3)(1,3)(2,2)(3,1);
\tzplot[dashed,red,mark=heart](0,1)(1,2)(2,0)(3,2);%(5pt)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot[xbar](.5,2.5)(1,3)(2,2)(3,1);
\tzplot[xbar,bar width=2mm,fill,red!50]
(1,2.5)(1.5,2)(2,0)(3,1.5);(3pt)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
\begin{tikzpicture}[yscale=1.5]
\tzhelplines(0,-1)(4,1)
\tzplot[ycomb,mark=*,very thick,blue]
(.5,.1)(1,.3)(1.5,.4)(2,.5)
(4,-.1)(3.5,-.3)(3,-.4)(2.5,-.5);
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
\begin{tikzpicture}[scale=.8]
\tzhelplines(4,3)
\tzplot[xcomb,mark=*,very thick]
(1,2.5)(1.5,2)(2,0)(3,1.5);
\end{tikzpicture}
\end{tzcode}
\remark
\begin{itemize}
\item
Do not use |<shift coor>| for plotting bars or combs to avoid getting unexpected results. It gives you wrong bars because |<shift coor>| moves coordinates but not bars.
%\item Use the option |shift={(coor)}| to move bars.
%\begin{tzcode}{.3}
%% shift : shift={(1,1)}
%\begin{tikzpicture}[scale=1]
%\tzhelplines(4,3)
%\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3);
%\tzplot[ybar,shift={(1,1)}](0,3)(1,3)(2,2)(3,1); %%
%\tzplot[red,mark=heart]<1,1>(0,2)(1,2)(2,0)(3,2);
%\end{tikzpicture}
%\end{tzcode}
\item
It can be a mess when using the \Tikz\ option |shift={(coor)}| with the type of mixed coordinates: native and named coordinates.
%\begin{tzcode}{.3}
%% \tzplot(*)
%% shift : mixed coor : shift={(1,1)} : chaos
%\begin{tikzpicture}[scale=1]
%\tzhelplines(4,3)
%\tzcoors(0,3)(A)(1,3)(B)(2,2)(C)(3,1)(D);
%\tzcoors(0,2)(a)(1,2)(b)(2,0)(c)(3,2)(d);
%\tzplot*[draw]<1,1>(0,0)(1,1)(2,1)(3,3);
%\tzplot[ybar,shift={(1,1)}](A)(1,3)(C)(D); %%
%\tzplot[dashed,red,mark=heart]<1,1>(a)(1,2)(c)(d);
%\end{tikzpicture}
%\end{tzcode}
\end{itemize}
%%-----------------------------------
%%------------------------------------------------------------
\section{\protect\cmd{\tzplotcurve(*)}}
\label{s:tzplotcurve}
\icmd{\tzplotcurve} draws a curve connecting specified coordinates with |tension=1|, by default. Basically, it is equivalent to |\tzplot| with |[tension=1]|.
The starred version \icmd{\tzplotcurve*} draws a curve and displays marks |*|, by default.
Basically, this is equivalent to |\tzpolot*[draw,tension=1]|.
\begin{tzdef}{}
% syntax: minimum
\tzplotcurve(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: full
\tzplotcurve*[<opt>]{<tension>} [<plot opt>]<shift coor>"<path name>"
(<coor>){<label>}[<[label opt]angle>]
..repeated..
(){}[] ; (<mark size>) <code.append>
% defaults
*[tzmark=2pt]{1}[smooth] <>"" (<m>){}[] ..repeated.. (){}[] ; (2pt) <>
\end{tzdef}
\begin{tztikz}{}
\tzplotcurve(0,0)(1,2)(2,2)(3,3); % works like:
\draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
\end{tztikz}
\begin{tztikz}{}
\tzplotcurve[blue,smooth cycle]{2}(0,0)(1,2)(2,2)(3,3); % works like:
\draw [blue,tension=2] plot [smooth cycle] coordinates { (0,0)(1,1)(2,2)(3,3) } ;
\end{tztikz}
Since |\tzplotcurve| is a \xem{semicolon version}, you need to enter a semicolon to indicate when the coordinate iteration ends.
In repeating coordinates, each mandatory coordinate can have a label.
So the whole repeating pattern is the triple |(<coor>){<text>}[<pos>]|.
For example, |(A){here}[above]| represents |(A) node [above] {here}| in \Tikz.
\paragraph{Options: lines, labels, colors, smooth cycle}
Use the first bracket option to control the colors of lines or labels.
\begin{tztikz}{}
\tzplotcurve(0,0)(1,2)(2,2){A}[below](3,3){B}[right]; % works like:
\draw [tension=1] plot [smooth] coordinates { (0,0)(1,1)(2,2)(3,3) }
(2,2) node [below] {A}
(3,3) node [right] {B} ;
\end{tztikz}
You can change the color of all labels together by adding |[text=<color>]| to the first bracket option list.
\begin{tzcode}{.3}
% \tzplotcurve(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve*[red,text=blue]
(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];
\tzplotcurve(1,.5)(2,3)(3,2)(2,1)(3,1);
\end{tikzpicture}
\end{tzcode}
The simplest way to change the mark size is to specify |(<mark size>)| immediately after the semicolon |;|.
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.
\begin{tzcode}{.3}
% \tzplotcurve(*): smooth cycle, mark size
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve*[red,text=blue][smooth cycle]
(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %%
\tzplotcurve*[smooth cycle](1,.5)(2,3)(3,2)(2,1)(3,1);
\end{tikzpicture}
\end{tzcode}
\paragraph{Tension}
You can change the value of |tension| (|tension=1| by default) by specifying the option |{<tension>}| before the coordinates or between the two bracket options if they exist.
\begin{tzcode}{.3}
% \tzplotcurve: tension
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcoor(.5,.5)(A)
\tzplotcurve[blue]{2}(1,3)(A)(4,0);
\tzplotcurve[thick](1,3)(A)(4,0); % default: tension=1
\tzplotcurve[red]{.5}(1,3)(A)(4,0);
\tzplotcurve[dashed]{0}(1,3)(A)(4,0);
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift} Use the optional argument |<shift coor>| before the first coordinate (to be precise, immediately before |"<path name>"|, if exists).
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzplotcurve(*): shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve*[red,text=blue,smooth cycle]
<0,1>(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[0];(3pt) %%
\tzplotcurve*[smooth cycle]
(1,.5)(2,3)(3,2)(2,1)(3,1);
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending the path} In order to extend the path created by |\tzplotcurve(*)| from the last coordinate, you can directly write \Tikz\ code in the very last optional argument |<code.append>|, after the semicolon.
\begin{tzcode}{.3}
% \tzplotcurve(*): <code.append>
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve*[red,text=blue,thick]
(0,0)(1,2){B}(2,2)(3,3)(4,1){E}[-45];(3pt)
< arc (-90:90:1cm) node [above] {up} > %%
\tzplotcurve[dashed]
(1,.5)(2,3)(3,2)(2,1)(3,1);
< -- ++(-1,-1) node [below] {down} > %%
\end{tikzpicture}
\end{tzcode}
You can also use |<--cycle>| to \xem{close} the path \xem{with a straight line} from the last coordinate to the first coordinate.
\begin{tzcode}{.3}
% \tzplotcurve(*): <--cycle>
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve*[red,text=blue]
(0,0)(1,2)(2,2)(3,3)(4,1){A}[right] ; (3pt)<--cycle>
\tzplotcurve
(1,.5)(2,3)(3,2)(2,1)(3,1) ; <--cycle>
\end{tikzpicture}
\end{tzcode}
\paragraph{\texttt{name path} for intersection points}
You can name the path of |\tzplotcurve| by specifying the option |"<path name>"| immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzplotcurve(*): name path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzplotcurve[blue]
"IC"(.5,3)(1.5,1.2)(4,.5){$u$}[0];
\tzplot[draw=red]
"bgt"(0,3)(4,0){budget}[-90];
% intersection points
\tzXpoint{IC}{bgt}(K)
\tzdots*(K){$A_1$}[30](K-2){$A_2$};
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Nodes}
\label{c:nodes}
%%------------------------------------------------------------
\section{\protect\cmd{\tznode} and \protect\cmd{\tznode*}}
\label{s:tznode}
The macro \icmd{\tznode} allows you to put text at specified coordinates.
You can also optionally name a node so you can refer to the \iisw{node coordinate} later.
The starred version \icmd{\tznode*} is equivalent to |\tznode[draw]|, which draws the perimeter of the specified node. The default node shape is a |rectangle|.
\begin{tzdef}{}
% syntax: minimal
\tznode(<coor>){<text>}
% syntax: full
\tznode[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]
% defaults
[]<>(<m>)(){}[]
\end{tzdef}
\begin{tztikz}{}
\tznode(0,0){text} % works like:
\path (0,0) node {text};
% or
\node at (0,0) {text};
\end{tztikz}
\begin{tztikz}{}
\tznode[draw] (0,0)(A){text}[above right] % works like:
\node [draw] (A) at (0,0) [above right] {text};
\end{tztikz}
|\tznode*| prints the perimeter of a node, which is a |rectangular| by default.
\begin{tzdef}{}
% syntax: minimal
\tznode*(<coor>){<text>}
% syntax: full
\tznode*[<opt>]<shift coor>(<coor>)(<name>){<text>}[<node opt>]<code.append>
% defaults
*[draw]<>(<m>)(){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tznode* (0,0)(A){text}[above right] % works like:
\node [draw] (A) at (0,0) [above right] {text};
\end{tztikz}
\paragraph{Putting text} You can use \Tikz\ options in the first bracket optional argument |[<opt>]| or the second bracket option |[<node opt>]| to put text with different colors, fonts, and so on.
\begin{tzcode}{.3}
% \tznode(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tznode(1,1){text}
\tznode(2,2){another\\text}[align=left]
\tznode*(3,1){\textbf{text}}
\tznode*[blue](3,0){\scshape Text}[r] % right
\tznode*(4,2){another\\text}[align=center,font=\itshape]
\end{tikzpicture}
\end{tzcode}
\paragraph{Abbreviations} You can use \xem{abbreviations} such as |a| for |above|, |l| for |left|, |ar| for |above right|, |bl| for |below left|, and so on to indicate where the \xem{text} of a \xem{main node} is placed. (See also Section \ref{s:stylenames} on page \pageref{s:stylenames}.)
\begin{quote}
\warning
A \iisw{main node} is placed by the placement words, while a \iisw{label node} is placed by the placement words or the |<angle>| expression.
\begin{itemize}
\item You CANNOT use the abbreviations to place a \xem{label node} for \xem{points} or \xem{dots} or \xem{coordinates}.
\item
Instead, use |<angle>| or the original (unabridged) placement words such as |right| and |below left| to place |<label>|.
\item
Note that, on the other hand, you CANNOT use the |<angle>| option to place a \xem{main node}.
\end{itemize}
\end{quote}
\begin{tzcode}{.3}
% \tznode(*): main node, label node
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdot*(1,1)
\tznode*(1,1){A}[ar]
\tznode*[red](1,1){B}[b]
\tznode(1,1){C}[l]
\tznode*[inner sep=0pt,text=blue,scale=2]
(3,2){Text}[label=180:Left,pin=45:Above Right]
\tznode*[inner sep=0pt,text=red,scale=2]
(3,2){Text}[b=2cm] %% below=2cm
\end{tikzpicture}
\end{tzcode}
\paragraph{Naming nodes}
You can name a node at a specified coordinate |(<coor>)| by specifying |(<name>)| immediately after the coordinate. You can use the node name as a \iisw{node coordinate}.
\begin{tzcode}{.3}
% \tznode(*): name nodes
\begin{tikzpicture}
\tzhelplines(4,3)
\tznode*(1,1)(A){A}
\tznode*[fill=blue,text=yellow](2,3)(B){B}
\tznode*[circle,text=red](4,1)(C){C}
\tzline[->](A)(B)
\tzto[->,bend left,dashed](B)(C)
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the coordinates by specifying the option |<shift coor>| immediately before the coordinate |(<coor>)|.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tznode(*): shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tznode*<-1,0>(1,1)(A){A}
\tznode*[fill=blue,text=yellow]<1,-1>(2,3)(B){B}
\tznode*[circle,text=red]<-2,-1>(4,1)(C){C}
\tzline[->](A)(B)
\tzto[->,bend left,dashed](B)(C)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tznodedot(*)}}
\label{s:tznodedot}
\icmd{\tznodedot} names a node and prints a circle node dot.
|\tznodedot| is basically the same as |\tzdot|, except for one thing.
|\tznodedot| names a node.
The starred version \icmd{\tznodedot*} prints a filled circle node dot (of the size |2.4pt|, by default), just like |\tzdot*|. But it optionally names a node.
\begin{tzdef}{}
% syntax: medium
\tznodedot(<coor>)(<node name>){<label>}[<angle>]
% syntax: full
\tznodedot*[<opt>]<shift coor>
(<coor>)(<node name>){<label>}[<[label opt]angle>] (<dot size>)
% defaults
*[]<>(<m>)(){}[](2.4pt)
\end{tzdef}
Since |\tznodedot(*)| prints a node dot, its |<label>| is placed by |<angle>|.
\begin{tzcode}{.3}
% \tznodedot(*): label, color
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodedot(1,1)(A){A}[180]
\tznodedot*(2,3)(B){\textbf{B}}
\tznodedot[rectangle](4,1)(C){C}[[red]0]
\tzline[->](A)(B)
\tzto[->,bend left,dashed](B)(C)
\end{tikzpicture}
\end{tzcode}
You can apply the \threeways\ (on page \pageref{ss:threeways}) to change the size of node dots.
The simplest way is to use the last parenthesis option |(<dot size>)|.
\begin{tzcode}{.3}
% \tznodedot(*): size
\begin{tikzpicture}
\tzhelplines(4,3)
\settzdotsize{5pt} %%
\tznodedot(1,1)(A){A}[180]
\tznodedot*(2,3)(B){B}
\tznodedot[rectangle](4,1)(C){C}[0](10pt) %%
\tzline[->](A)(B)
\tzto[->,bend left,dashed](B)(C)
\end{tikzpicture}
\end{tzcode}
You can move the coordinates of dots by specifying the |<shift coor>| option immediately before the coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tznodedot(*): shift
\begin{tikzpicture}
\tzhelplines(4,3)
\settzdotsize{5pt}
\tznodedot(1,1)(A){A}[180]
\tznodedot*(2,3)(B){B}
\tznodedot[rectangle]<-1,-1>(4,1)(C){C}[0](10pt) %%
\tzline[->](A)(B)
\tzto[->,bend left,dashed](B)(C)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tznodeframe} and \protect\cmd{\tznodeframe*}}
\label{s:tznodeframe}
\icmd{\tznodeframe} draws and names a rectangle node with text in it.
%\icmd{\tznoderectangle} and \icmd{\tznodebox} are aliases of |\tznodeframe|.
\begin{tzdef}{}
% syntax:
\tznodeframe[<opt>](<coor>)(<node name>){<text>}[<node opt>]
% defaults
[]<>(<m>)(){}[text=black]
\end{tzdef}
\begin{tzcode}{.3}
% \tznodeframe
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodeframe(0,0)(A)
\tznodeframe(4,2)(B)[circle]
\tzline[blue,thick](A)(B)
\tznodeframe[scale=1.5](2,1){Node frame}
[label=180:Left, pin=-45:pin]
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tznodeframe: fill (opacity=1)
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodeframe(0,3)
\tznodeframe(0,0)(A)
\tznodeframe(4,2)(B)[circle]
\tzline[blue,thick](A)(B)
\tznodeframe[fill=green,scale=1.5](2,1){Node frame}
[label=180:Left, pin=-45:pin]
\end{tikzpicture}
\end{tzcode}
The starred version |\tznodeframe*| fills the rectangle with color (|black!50| by default) with |fill opacity=.3| but with |text opacity=1|, by default.
%\icmd{\tznoderectangle*} and \icmd{\tznodebox*} are aliases of |\tznodeframe*|.
\begin{tzdef}{}
% syntax:
\tznodeframe*[<opt>]<shift coor>
(<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>}
% defaults
*[fill=black!50,fill opacity=.3,text opacity=1] <>
(<m>)(){}[draw=black,text=black]{.3}
\end{tzdef}
\remark
|\tznodeframe| works very similar to |\tznode|, but their `starred versions' work differently.
While |\tznode*| draws the perimeter of a node, |\tznodeframe*| fills a node with color.
\begin{tzcode}{.3}
% \tznodeframe*: opacity=.3 (by default)
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodeframe(0,0)(A)
\tznodeframe(4,2)(B)[circle]
\tzline[blue,thick](A)(B)
\tznodeframe*[green,scale=1.5](2,1){Node frame}
[label=180:Left, pin=-45:pin]
\end{tikzpicture}
\end{tzcode}
You can change the |fill opacity| of |\tznodeframe*| by specifying the last curly brace option |{<fill opacity>}|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate.
(The empty shift coor |<>| is not allowed.)
\begin{tzcode}{.3}
% \tznodeframe(*): opacity, shift
\begin{tikzpicture}
\tzhelplines[solid](4,3)
\tznodebox(0,0)
\tznodeframe*(1,2)(A){A}{.1} % opacity
\tznodeframe[fill=yellow](2,2)(B){B}
\tznodeframe*[red](3,2)(C){Cat}
\tznodeframe[fill=green]<-1,-2>(4,2)(D){Dog} % shift
\tzto[->,bend left=45](A.north)(C.90)
\tzto[->,bend right=45,dashed](B.-135)(D.west)
\end{tikzpicture}
\end{tzcode}
\remark
In addition to using the option |{<fill opacity>}|, you can use a macro to change the default value.
\begin{itemize}
\item The default fill opacity can be changed by the macro \icmd{\settzfillopacity}.
\item
The default fill color is |black!50|. You can use the macro \icmd{\settzfillcolor} to change the default fill color.
\item With |\tznodeframe|, you can change the color of the perimeter and text with the second bracket option |[<node opt>]|.
\end{itemize}
%%------------------------------------------------------------
\section{\protect\cmd{\tznodecircle} and \protect\cmd{\tznodecircle*}}
\label{s:tznodecircle}
\icmd{\tznodecircle} works just like |\tznodeframe| but with a circle node.
\begin{tzdef}{}
% syntax
\tznodecircle[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]
% defaults
[circle]<>(<m>)(){}[text=black]
\end{tzdef}
\icmd{\tznodecircle*} works just like |\tznodeframe*| but with a circle node.
\begin{tzdef}{}
% syntax
\tznodecircle*[<opt>]<shift coor>
(<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>}
% defaults
*[circle,fill=black!50,fill opacity=.3,text opacity=1] <>
(<m>)(){}[draw=black,text=black]{.3}
\end{tzdef}
\begin{tzcode}{.3}
% \tznodecircle
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodecircle(0,0)(A)
\tznodecircle(4,2)(B)[circle]
\tzline[blue,thick](A)(B)
\tznodecircle[scale=1.5](2,1){Node frame}
[label=180:Left, pin=-45:pin]
\end{tikzpicture}
\end{tzcode}
You can change the |fill opacity| of |\tznodecircle*| by specifying the last curly brace option |{<fill opacity>}| or using |\settzfillopacity|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate.
(The empty shift coor |<>| is not allowed.)
\begin{tzcode}{.3}
% opacity, shift
\begin{tikzpicture}
\tzhelplines[solid](4,3)
\tznodecircle(0,0)
\tznodecircle*(1,2)(A){A}{.1} % opacity
\tznodecircle[fill=yellow](2,2)(B){B}
\tznodecircle*[red](3,2)(C){Cat}
\tznodecircle[fill=green]<-1,-2>(4,2)(D){Dog} % shift
\tzto[->,bend left=45](A.north)(C.90)
\tzto[->,bend right=45,dashed](B.-135)(D.west)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tznodeellipse} and \protect\cmd{\tznodeellipse*}}
\label{s:tznodeellipse}
\icmd{\tznodeellipse} works just like |\tznodeframe| but with an ellipse node.
\begin{tzdef}{}
% syntax:
\tznodeellipse[<opt>]<shift coor>(<coor>)(<node name>){<text>}[<node opt>]
% defaults
[ellipse]<>(<m>)(){}[text=black]
\end{tzdef}
The starred version \icmd{\tznodeellipse*} works just like |\tznodeframe*| but with an ellipse node.
\begin{tzdef}{}
% syntax:
\tznodeellipse*[<opt>]<shift coor>
(<coor>)(<node name>){<text>}[<node opt>]{<fill opacity>}
% defaults
*[ellipse,fill=black!50,fill opacity=.3,text opacity=1] <>
(<m>)(){}[draw=black,text=black]{.3}
\end{tzdef}
\begin{tzcode}{.3}
% \tznodeellipse
\begin{tikzpicture}
\tzhelplines(4,3)
\tznodeellipse(0,3)
\tznodeellipse(0,0)(A)
\tznodeellipse(4,2)(B)[circle]
\tzline[blue,thick](A)(B)
\tznodeellipse[scale=1.5](2,1){Node frame}
[label=180:Left, pin=-45:pin]
\end{tikzpicture}
\end{tzcode}
You can change the |fill opacity| of |\tznodeellipse*| by specifying the last curly brace option |{<fill opacity>}|. You can also move the node by specifying the |<shift coor>| option immediately before the coordinate.
(The empty shift coor |<>| is not allowed.)
\begin{tzcode}{.3}
% opacity, shift
\begin{tikzpicture}
\tzhelplines[solid](4,3)
\tznodeellipse(0,0)
\tznodeellipse*(1,2)(A){A}{.1} % opacity
\tznodeellipse[fill=yellow](2,2)(B){B}
\tznodeellipse*[red](3,2)(C){Cat}
\tznodeellipse[fill=green]<-1,-2>(4,2)(D){Dog} % shift
\tzto[->,bend left=45](A.north)(C.90)
\tzto[->,bend right=45,dashed](B.-135)(D.west)
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Lines}
\label{c:lines}
%%------------------------------------------------------------
\section{\protect\cmd{\tzline}: Connecting two points}
\label{s:tzline}
\icmd{\tzline} connects two points with a straight line.
\begin{tzdef}{}
% syntax: miminum
\tzline(<coor1>)(<coor2>)
% syntax: medium
\tzline[<opt>](<coor1>){<text1>}[<node opt1>]
(<coor2>){<text2>}[<node opt2>]
% syntax: full
\tzline[<opt>]<shift coor>"<path name>"
(<coor1>){<text1>}[<node opt1>]
(<coor2>){<text2>}[<node opt2>]<code.append>
% defaults
[]<>""(<m>){}[above](<m>){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tzline(0,1)(2,1) % works like:
\draw (0,1) -- (2,1);
\end{tztikz}
\subsection{Line styles}
\label{ss:tzline:linestyles}
You can use the first optional argument |[<opt>]| to control the line styles.
\begin{tztikz}{}
\tzline[blue](0,1)(2,1) % works like:
\draw [blue] (0,1) -- (2,1);
\end{tztikz}
\begin{tzcode}{.3}
% \tzline
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[blue,->](0,0)(3,3)
\tzline[*-o](0,2)(3,0)
\tzline[dashed](1,2)(4,0)
\tzdots*(1,2)(4,0);
\end{tikzpicture}
\end{tzcode}
\subsection{Adding text}
\label{ss:tzline:addingtext}
You can add text by specifying the optional arguments |{<text>}| and |[<node opt>]|.
\paragraph{Text next to the line}
With the options |{<text1>}[<node opt1>]| \xem{in-between} two coordinates, you can add text next to the line, with the option |[above,midway]| by default.
\begin{tztikz}{}
\tzline[blue](0,1){my line}[sloped](2,1) % works like:
\draw [blue] (0,1) -- node [above,sloped] {my line} (2,1) ;
\end{tztikz}
\begin{tzcode}{.3}
% \tzline: text next to line
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline(0,0){Above}(4,0) % default [above]
\tzline[blue](0,1){Near end}[b,near end](4,1) % below
\tzline[->](0,2){Sloped}[sloped](3,3) % default [above]
\end{tikzpicture}
\end{tzcode}
You can use the \xem{abbreviations} of \Tikz\ basic placement options such as |a| for |above|, |bl| for |below left|, and so on. (For more details, see page \pageref{abbreviations}.)
\paragraph{Text at or around the last coordinate}
You can also add text at (by default) or around the second coordinate by specifying |{<text2>}| and |[<node opt2>]| immediately \xem{after} the second coordinate.
\begin{tztikz}{}
\tzline[blue](0,1)(2,1){my line}[right] % works like:
\draw [blue] (0,1) -- (2,1) node [right] {my line};
\end{tztikz}
\begin{tzcode}{.3}
% \tzline
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[blue,->](0,0)(3,3){\textbf{line A}}[r]
\tzline[*-o](0,2)(3,0){line B}[red,draw=blue,b=1mm]
\tzline[dashed](1,2){dashed}[sloped](4,0){line C}[ar]
\tzdots*(1,2)(4,0);
\end{tikzpicture}
\end{tzcode}
%\subsection{Relative coordinates: \texttt{+} or \texttt{++}}
%\label{ss:tzline:relative}
%
%You can make the second coordinate relative to the first.
%You can even select `|+| relative' or `|++| relative' by specifying the option |<+>| or |<++>| immediately before the second coordinate.
%
%\begin{tztikz}{}
%\tzline+(0,0)<+>(2,1) % works like:
% \draw (1,1) -- + (2,1);
%\end{tztikz}
%
%\begin{tzcode}{.3}
%% \tzline
%\begin{tikzpicture}
%\tzhelplines(4,3)
%\tzline[blue,->](0,0) (3,3) {A}[r]
%\tzline[*-o] (0,2){b} <+>(3,-2){B}[r]
%\tzline[dashed] (1,2){c}<++>(3,-2){C}[r]
%\tzdots*(1,2)(4,0);
%\end{tikzpicture}
%\end{tzcode}
%
%Notice that, with |\tzline|, |<+>| and |<++>| make no difference.
%But with the macro |\tzlines| it is not the case.
%
%\remark
%Notice that using |<+>| and |<++>| makes no difference in |\tzline|.
%But it is not the case with the macro |\tzlines| that connects multiple coordinates.
\subsection{Moving the line: \texttt{shift}}
\label{ss:tzline:shift}
You can move the line 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).
The empty shift coor |<>| is not allowed.
\begin{tzcode}{.3}
% \tzline: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[blue,->] (0,0)(3,3){A}[r]
\tzline[blue] <1,0>(0,0)(3,3){A}[r]
\tzline[dashed] (1,2)(4,0){C}[r]
\tzline[dashed]<-.5,-.5>(1,2)(4,0){C}[r]
\tzdots*(1,2)(4,0);
\end{tikzpicture}
\end{tzcode}
\subsection{Extending the path}
\label{ss:tzline:extendingpath}
You can extend the path of |\tzline| from the last coordinate, by writing \Tikz\ code in the last optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tzline: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[blue,->](0,0)(3,3)<arc(0:-60:1cm)>
\tzline[dashed,->](1,2)(4,0)
<to[bend left] ++(-4,1) node [a] {ends here!}>
\end{tikzpicture}
\end{tzcode}
\subsection{Naming the path: Intersection points}
\label{ss:tzline:namepath}
When you specify the option |"<path name>"| immediately before the first coordinate, it works like |[name path=<path name>]| in the option list of |[<opt>]|.
You can use this name of path to find intersection points.
\begin{tzcode}{.3}
% \tzline+: name path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[blue,->] "dem" (0,0)(3,3){demand}[r]
\tzline[dashed,->]"supp"(1,2)(4,0){supply}[ar]
% intersection point
\tzXpoint*{dem}{supp}
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzline+}: Relative coordinates}
\label{s:tzline+}
The \iisw{plus version} \icmd{\tzline+} takes the second coordinate |(<coor2>)| relative (with |++|) to the first coordinate |(<coor1>)|.
%That is, |\tzline+(A)(B)| is equivalent to |\tzline(A)<++>(B)|.
\xem{Everything else is the same as in} |\tzline|.
\begin{tzdef}{}
% syntax: full
\tzline+[<opt>]<shift coor>"<path name>"
(<coor1>){<text1>}[<node opt1>]
(<coor2>){<text2>}[<node opt2>]<code.append>
% defaults
+[]<>""(<m>){}[above](<m>){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tzline+(0,1)(2,1) % works like:
\draw (0,1) -- ++ (2,1);
\end{tztikz}
\begin{tztikz}{}
\tzline+[dashed]"AA"(0,1){A}[red](2,1){B}[right,blue] % works like:
\draw [dashed,name path=AA]
(0,1) -- node [red] {A} ++ (2,1) node [right,blue] {B};
\end{tztikz}
\begin{tzcode}{.3}
% \tzline+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline+[blue,->](0,1)(3,2) {A}[r]
\tzline+[*-o] (0,2){b}(3,-2){B}[r]
\tzline+[dashed]<1,0>(0,2){b}(3,-2){B}[r]
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzline+: name path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline+[blue,->] "dem" (0,0)(3,3){demand}[r]
\tzline+[dashed,->]"supp"(1,2)(3,-2){supply}[ar]
% intersection point
\tzXpoint*{dem}{supp}
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{Styles: \texttt{tzshorten} and \texttt{tzextend}}
\label{s:tzshorten}
The styles \ixxw{tzshorten} and \ixxw{tzextend} are defined as follows.
\begin{tzsty}{}
% tzshorten
\tikzset{%
tzshorten/.style 2 args ={shorten <=#1, shorten >=#2},
tzshoretn/.default={2pt}{2pt}
}
% tzextend (negative tzshorten)
\tikzset{%
tzextend/.style 2 args ={shorten <=-#1, shorten >=-#2},
tzextend/.default={2pt}{2pt}
}
\end{tzsty}
For example, |[tzshorten={2mm}{1mm}]| is equivalent to |[shorten <=2mm,shorten >=1mm]| in \Tikz. Simple |[tzshorten]| means that |[tzshorten={2pt}{2pt}]| by default.
The style |tzextend| is a negative |tzshorten|. For example, |tzextend{2mm}{1mm}| is equivalent to |tzshorten{-2mm}{-1mm}|.
\begin{tzcode}{.3}
% tzshorten, tzextend
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots(0,0)(3,0); \tzline(0,0)(3,0)
\tzdots(0,1)(3,1);
\tzline[->,thick,blue,tzshorten={2mm}{1mm}](0,1)(3,1)
\tzdots(1,2)(3,2);
\tzline[<->,thick,red,tzextend={1cm}{1cm}](1,2)(3,2)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzlines}: Connecting multiple points: Semicolon version}
\label{s:tzlines}
\icmd{\tzlines} connects two or more points with connected line segments.
Since |\tzlines| takes an arbitrary number of coordinates as arguments, it is a \xem{semicolon version}. So, you need to enter a semicolon `|;|' to indicate when the coordinate iteration ends.
\begin{tzdef}{}
% syntax: minimum
\tzlines(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: medium
\tzlines(<coor>){<text>}[<node opt>]..repeatd..(<coor>){<text>}[<node opt>] ;
% syntax: full
\tzlines[<opt>]<shift coor>"<path name>"
(<coor>){<text>}[<node opt>]
..repeated.. (){}[] ; <code.append>
% defaults
[]<>"" (<m>){}[] ..repeated.. (){}[] ; <>
\end{tzdef}
\begin{tztikz}{}
\tzlines(1,1)(2,2)(3,1)(4,3); % works like:
\draw (1,1) -- (2,2) -- (3,1) -- (4,3);
\end{tztikz}
The whole repeating pattern in |\tzlines| is the triple |(<coor>){<text>}[<node opt>]|.
%Any |<+ or ++>| after the last coordinate, if any, is ignored.
\begin{tztikz}{}
\tzlines(1,1)(2,2)(3,1){C}(4,3){D}[r]; % works like:
\draw (1,1) -- (2,2) -- (3,1) -- node {C} (4,3) node [right] {D};
\end{tztikz}
\paragraph{Line styles}
Use the first optional argument |[<opt>]| to control the style of the connected line drawn by |\tzlines|.
\begin{tzcode}{.3}
% \tzlines: line style
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[blue,<->](0,1)(1,2)(3,1)(4,3);
\tzlines[dashed](0,0)(1,1)(2,1)(3,0);
\end{tikzpicture}
\end{tzcode}
\paragraph{Adding text}
You can add text in the |midway|, by default, of each line segment by specifying the options |{<text>}| and |[<node opt>]| immediately after each coordinate (except the last one).
The options |{<text>}| and |[<node opt>]| after the last coordinate put |<text>| at or around the last coordinate.
\begin{tzcode}{.3}
% \tzlines: adding text
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[red,thick,<->,text=blue]
(0,1){Up}
(1,2){Down}[a,sloped]
(3,1){Up}
(4,3){line A} ;
\tzlines[dashed](0,0)(1,1)(2,1)(3,0){line B}[r];
\end{tikzpicture}
\end{tzcode}
%\paragraph{Relative coordinates: \texttt{+} and \texttt{++}}
%
%You can make the coordinates (from the second coordinate) relative to the previous one by specifying the option |<+>| and |<++>| immediately before the coordinates.
%(In \Tikz, only |<++>| refreshes the \xem{current point} to new one.)
%
%\begin{tzcode}{.3}
%% \tzlines
%\begin{tikzpicture}
%\tzhelplines(4,3)
%\tzlines[red,thick,<->,text=blue]
% (0,1){Up}
% <+>(1,1){Down}[a,sloped] % current point: (0,1)
% <++>(3,0){Up} % new current point: (3,1)
% <++>(1,2){line A} ;
%\tzlines[dashed](0,0)(1,1)(2,1)<++>(1,-1){line B}[r];
%\end{tikzpicture}
%\end{tzcode}
\paragraph{Shift}
You can move the connected line by specifying |<shift coor>| before the first coordinate or immediately before the option |"<path name>"| if it exists.
(The empty shift option |<>| is not allowed.)
\begin{tzcode}{.3}
% \tzlines: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[red,thick,<->,text=blue]
<0,-1>(0,1)
(1,2)
(3,1)
(4,3){shifted\\line A}[align=left,ar] ;
\tzlines[dashed]<1,0>(0,0)(1,1)(2,1)(3,0){line B}[r] ;
\end{tikzpicture}
\end{tzcode}
\paragraph{Naming paths}
You can name the path of |\tzlines| by specifying the option |"<path name>"| immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzlines: shift, intersection
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[red,thick,<->,text=blue]
<0,-1>"AA"(0,1)
(1,2)(3,1)(4,3){shifted\\line A}[align=left,ar] ;
\tzlines[dashed]
<1,0>"BB"(0,0)(1,1)(2,1)(3,0){line B}[r] ;
% intersection points
\tzXpoint*{AA}{BB}(X){X1}[-90] % [<angle>] for point
\tzdot(X-2){X2}[0] % [<angle>] for dot
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending the path}
You can extend the path of |\tzlines| by writing \Tikz\ code in the last (even \xem{after the semicolon}) optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tzlines: <code.append>
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[red,thick,<->,text=blue]
(0,1){Up}
(1,2){Down}[a,sloped]
(3,1){Up}
(4,3) ;
<arc(0:90:1cm)>
\tzlines[dashed]
(0,0)(1,1)(2,1)(3,0) ;
<to[bend right] ++(2,2) node{Here!}>
\end{tikzpicture}
\end{tzcode}
You can close the path with a straight line by |<--cycle>|.
\begin{tzcode}{.3}
% \tzlines: closed path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines[red,thick,<->,text=blue]
(0,1){Up}
(1,2){Down}[a,sloped]
(3,1){Up}
(4,3){line A} ; <--cycle>
\tzlines[dashed]
(0,0)(1,1)(2,1)(3,0){line B}[r] ; <--cycle>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzlines+}: Relative coordinates: Semicolon version}
\label{s:tzlines+}
The \iisw{plus version} \icmd{\tzlines+} connects two or more points with connected line segments, but each coordinate (except the first one) is \xem{relative} to the previous coordinate.
%For example, |\tzline+(A)(B)(C)(D);| is equivalent to |\tzline(A)<++>(B)<++>(C)<++>(D);|.
\xem{Everything else is the same as in} |\tzlines|.
It is also required to enter a \xem{semicolon} to indicate when the coordinate iteration ends.
\begin{tzdef}{}
% syntax: full
\tzlines+[<opt>]<shift coor>"<path name>"
(<coor>){<text>}[<node opt>]
..repeated.. (){}[] ; <code.append>
% defaults
[]<>"" (<m>){}[] ..repeated.. (){}[] ; <>
\end{tzdef}
\begin{tztikz}{}
\tzlines+(0,1)(1,1)(2,-1)(1,2); % works like:
\draw (0,1) -- ++(1,1) -- ++(2,-1) -- ++(1,2);
\end{tztikz}
\begin{tztikz}{}
\tzlines+[dashed]"AA"(0,1){A}(1,1){B}(2,-1){C}(1,2){D}[right]; % works like:
\draw [dashed,name path=AA]
(0,1) -- node {A} ++(1,1)
-- node {B} ++(2,-1)
-- node {C} ++(1,2) node [right] {D} ;
\end{tztikz}
\begin{tzcode}{.3}
% \tzlines+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzlines+[red,thick,<->,text=blue]
(0,1){Up}
(1,1){Down}[a,sloped]
(2,-1){Up}
(1,2){line A} ;
\tzlines+[dashed,auto,text=red]
(0,0){A}
(1,1){B}
(1,0){C}
(1,-1){line B}[blue,draw,r] ;
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Connecting Points}
\label{c:tzto}
%%------------------------------------------------------------
\section{\protect\cmd{\tzto}: Two points}
\label{s:tzto}
\icmd{\tzto} connects two points with a straight or curved line, using \Tikz's |to| operation.
So |\tzto| is more general than |\tzline|, which connects points only with a straight line.
\begin{tzdef}{}
% syntax: minimum
\tzto(<coor>)(<coor>)
% syntax: medium
\tzto[<opt>](<coor>){<text>}[<node opt>](<coor>){<text>}[<node opt>]
% syntax: full
\tzto[<opt>]<shift coor>"<path name>"
(<coor>){<text>}[<node opt>]
(<coor>){<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>){}[above](<m>){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tzto[dashed](1,1)(3,2) % works like:
\draw [dashed] (1,1) to (3,2);
\end{tztikz}
\paragraph{Line styles}
You can control line styles with the first optional argument |[<opt>]|.
\begin{tzcode}{.3}
% \tzto
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto[blue,thick,->](0,1)(3,3)
\tzto[out=0](0,0)(4,2)
\tzto[bend right,dashed](2,0)(4,1)
\end{tikzpicture}
\end{tzcode}
\paragraph{Adding text}
You can add text \xem{next to the line} (|[midway,above]|, by default) by specifying the options |{<text>}| and |[<node opt>]| \xem{in-between} the two coordinates.
\begin{tztikz}{}
\tzto[->,bend right](1,1){A}[near start](3,2) % works like:
\draw [->,bend right] (1,1) to node [near start] {A} (3,2);
\tzto[->,bend right](1,1){A}[near start](3,2){B}[right] % works like:
\draw [->,bend right] (1,1) to node [near start] {A}
(3,2) node [right] {B};
\end{tztikz}
You can also add text \xem{at or around} the last coordinate by the options |{<text>}| and |[<node opt>]| \xem{immediately after} the last coordinate.
\begin{tzcode}{.3}
% \tzto: adding text
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto[blue,thick,->](0,1){line}[sloped](3,3)
\tzto[out=0](0,0){curve}[pos=.8](4,2){line B}[r]
\tzto[bend right,dashed](2,0)(4,1){line C}[red,r]
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the line by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"| if it exists.
(The empty shift option |<>| is not allowed.)
\begin{tzcode}{.3}
% \tzto: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto[blue,thick,->]<0,1>(0,1){line}[sloped](3,3)
\tzto[out=0]<1,1>(0,0){curve}[pos=.8](4,2){line B}[r]
\tzto[bend right,dashed]<-1,0>(2,0)(4,1){line C}[red,r]
\end{tikzpicture}
\end{tzcode}
\paragraph{Naming paths: Intersections}
You can name the path of |\tzto| by specifying the option |"<path name>"| immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzto: name path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto[bend right=45,blue,thick,->]"curveA"(1,3)(4,0)
\tzto[out=0]"curveB"(0,0)(4,2){line B}[r]
% intersection point
\tzXpoint*{curveA}{curveB}
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending the path}
You can extend the path of |\tzto| by writing \Tikz\ code in the last optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tzto: extending path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto[bend right=45,blue,thick,->]
(1,3)(4,0)<--([turn]0:1cm) node [b] {extended}>
\tzto[out=0]
(0,0)(4,2)<--([turn]0:1cm) node [r] {extended}>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzto+}: Relative coordinates}
\label{s:tzto+}
The \iisw{plus version} \icmd{\tzto+} uses the second coordinate relative to the first coordinate.
\xem{Everything else is the same as in} |\tzto|.
\begin{tztikz}{}
\tzto+(1,1)(3,2) % works like:
\draw (1,1) to ++(3,2);
\end{tztikz}
\begin{tzcode}{.3}
% \tzto+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto+[blue,thick,->](0,1){line}[sloped](3,2)
\tzto+[out=0](0,0){curve}[pos=.8](4,2){line B}[r]
\tzto+[bend right,dashed](2,0)(2,1){line C}[red,r]
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzto+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzto+[bend right=45,blue,thick,->]
(1,3)(3,-3)<--([turn]0:1cm) node [b] {extended}>
\tzto+[out=0]
(0,0)(4,2)<--([turn]0:1cm) node [r] {extended}>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tztos}: Multiple points: Semicolon version}
\label{s:tztos}
\icmd{\tztos} takes an arbitrary number of coordinates as arguments to connect them by \Tikz's |to| operation. Since this is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate iteration ends.
\begin{tzdef}{}
% syntax
\tztos[<opt>]<shift coor>"<path name>"
(<coor1>)[<to opt>]{<text>}[<node opt>]..repeated..()[]{}[] ; <code.append>
% defaults
[]<>""(<m>)[]{}[]..repeated..()[]{}[]<>
\end{tzdef}
The quadruple |(<coor>)[<to opt>]{<text>}[<node opt>]| is
the whole repeating pattern.
Here, |[<to opt>]| is for the options of \Tikz's |to| operation such as |[bend right]|, |[bend left]|, |[bend left=<angle>]|, |[out=<angle>,in=<angle>]| and so on.
\begin{tztikz}{}
\tztos(0,0)(1,2)(3,1); % works like:
\draw (0,0) to (1,2) to (3,1);
\end{tztikz}
\begin{tztikz}{}
\tztos[blue] (0,0) [bend right] (1,2) [out=-60,in=45] (3,1); % works like:
\draw[blue] (0,0) to [bend right] (1,2) to [out=-60,in=45] (3,1);
\end{tztikz}
\paragraph{How to connect coordinates}
You can use the options of \Tikz's |to| operation to connect the coordinates with different types of curves.
\begin{tzcode}{.3}
% \tztos
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos[blue,<->](0,1)(1,2)(3,1)(4,3);
\tztos[red,thick]
(0,0)[bend right]
(1,1)
(2,1)[out=-135,in=45]
(3,0);
\end{tikzpicture}
\end{tzcode}
\paragraph{Adding text}
You can add text next to lines or curves by specifying the options |{<text>}| and |[<node opt>]| \xem{in-between} coordinates or \xem{after} the option |[<to opt>]|, if it exists.
You can also add text at or around the last coordinate by the last options |{<text>}| and |[<node opt>]|.
\begin{tzcode}{.3}
% \tztos: adding text
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos(0,1)[bend right]{A}
(1,2) {Ben}[red,sloped,a]
(3,1)[bend right]{Cate}[sloped,near end]
(4,3) {Name}[draw,blue,a] ;
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the line or curve of |\tztos|
using the option |<shift coor>| before the first coordinate or immediately before the option |"<path name">|, if any.
(The empty shift option |<>| is not allowed.)
\begin{tzcode}{.3}
% \tztos: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos[blue,<->](0,1)(1,2)(3,1)(4,3);
\tztos[red,thick]
<1,1>(0,0)[bend right]
(1,1)
(2,1)[out=-135,in=45]
(3,0);
\end{tikzpicture}
\end{tzcode}
\paragraph{\texttt{name path} for intersections}
You can name the path of |\tztos| by specifying |"<path name>"| immediately before the first mandatory coordinate.
\begin{tzcode}{.3}
% \tztos: name path, intersection points
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos[blue,<->]"AA"(0,1)(1,2)(3,1)(4,3);
\tztos[red,thick]
<1,1>"BB"(0,0)[bend right]
(1,1)
(2,1)[out=-135,in=45]
(3,0);
% intersection points
\tzXpoint*{AA}{BB}(X)
\tzdot(X-2)(4pt)
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending paths}
You can extend the path of |\tztos| from the last coordinate,
by writing \Tikz\ code in the last (after the semicolon) optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tztos
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos[blue,<->](0,1)(1,2)(3,1)(4,3);<--cycle>
\tztos[red,thick]
(0,0)[bend right]
(1,1)
(2,1)[out=-135,in=45]
(3,0); < to ([turn]0:1.5cm) >
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tztos+}: Relative coordinates: Semicolon version}
\label{s:tztos+}
The \iisw{plus version} \icmd{\tztos+} takes each coordinate (except the first coordinate) relative (with |++|) to the previous coordinate.
\xem{Everything else is the same as in} |\tztos|.
\begin{tzcode}{.3}
% \tztos+
\begin{tikzpicture}
\tzhelplines(4,3)
\tztos+[blue,<->](0,1)(1,1)(2,-1)(1,2);<--cycle>
\tztos+[red,thick]
(0,0)[bend right]
(1,1)
(1,0)[out=-135,in=45]
(1,-1); < to ([turn]0:1.5cm) >
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Filling Area}
\label{c:fillingarea}
%%------------------------------------------------------------
\section{\protect\cmd{\tzpath}: Semicolon version}
\label{s:tzpath}
\icmd{\tzpath} creates a path connecting an arbitrary number of coordinates, but it does not stroke the path. You can visualize the path with |\tzpath[draw]|.
Since |\tzpath| is a \iisw{semicolon version} macro, you need to enter a \xem{semicolon} `|;|' to indicate where the coordinate iteration ends.
\begin{tzdef}{}
% syntax: minimal
\tzpath (<coor>)(<coor>) ..repeated.. (<coor>) ;
% syntax: full
\tzpath{<path style>}[<opt>]<shift coor>"<path name>"
(<coor>)[<path style>]{<text>}[<node opt>]
..repeated.. ()[]{}[] ; {<fill opacity>} <code.append>
% defaults: \tzpath
{to}[]<>"" (<m>)[]{}[] ..repeated.. ()[]{}[] ; {}<>
\end{tzdef}
The main purpose of |\tzpath| is to fill an enclosed area with color or pattern.
You can use |\tzpath[fill]| or |\tzpath[pattern=<...>]| to do it.
\paragraph{Path construction operation}
(If you are not an experienced user of \Tikz\, just skip this part.)
|\tzpath| is similar to |\tztos|, but it is more flexible in constructing paths.
|\tzpath| allows you to choose how to construct a path using the |[<path style>]| option \xem{in-between} coordinates. \xem{Path extension operation} can be selected from `|--|', `|to|', `\verb+|-+', `\verb+-|+', etc.
You can use \xem{the first brace option} |{<path style>}| to change all the |<path style>| in-between coordinates.
\begin{tzcode}{.3}
% \tzpath: path construction
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3);
\tzpath[draw]
(0,0)[to[bend right]]
(1,1)
(2,1)[to[out=-135,in=45]]
(3,0);
\end{tikzpicture}
\end{tzcode}
The default path style is `|to|' and can also be changed by \icmd{\settzpathstyle}, like, for example, |\settzpathstyle{--}|. The effect remains valid until the end of |tikzpicture| environment unless changed again.
\begin{tzcode}{.3}
% \tzpath: \settzpathstyle
\begin{tikzpicture}
\tzhelplines(4,3)
\settzpathstyle{to[bend right]}
\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3);
\tzpath[draw]
(0,0)[to[bend right]]
(1,1)
(2,1)[to[out=-135,in=45]]
(3,0);
\end{tikzpicture}
\end{tzcode}
You can extend the path of |\tzpath| by writing \Tikz\ code in the last (after the semicolon) optional argument |<code.append>|.
So |<--cycle>| closes the path with a straight line.
\begin{tzcode}{.3}
% \tzpath: <code.append>
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpath[draw](0,1)(1,2)[-|](3,1)(4,3);
< to [bend right=60] (0,1) >
\tzpath[fill]
(0,0)[to[bend right]]
(1,1)
(2,1)[to[out=-135,in=45]]
(3,0); <--cycle>
\end{tikzpicture}
\end{tzcode}
\section{\protect\cmd{\tzpath*}: Semicolon version}
\label{s:tzpath*}
The starred version \icmd{\tzpath*} additionally fills the interior of |\tzpath| with |black!50| with |fill opacity=.3| and |text opacity=1|, by default.
|\tzpath*| works like |\tzpath[fill=black!50,fill opacity=.3,text opacity=1]|.
You can change the defaults by \icmd{\settzfillcolor} and \icmd{\settzfillopacity}.
\begin{tzdef}{}
% syntax: minimal
\tzpath*(<coor>)(<coor>) ..repeated.. (<coor>) ; {<fill opacity>}
% syntax: full
\tzpath*{<path style>}[<opt>]<shift coor>"<path name>"
(<coor>)[<path style>]{<text>}[<node opt>]
..repeated.. ()[]{}[] ; {<fill opacity>} <code.append>
% defaults: \tzpath*
*{to}[fill=black!50,fill opacity=.3,text opacity=1]<>""
(<m>)[]{}[] ..repeated.. ()[]{}[] ; {.3}<>
\end{tzdef}
\paragraph{Filling the interior}
You can optionally change the opacity of fill color using the \Tikz\ option |fill opacity|.
\begin{tzcode}{.3}
% \tzpath: fill, fill opacity
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[red,very thick](0,3)(4,0)
\tzpath[fill](0,0)(3,1)(2,3)(0,2); % default opacity=1
\tzpath[fill,green,fill opacity=.5]
<1,-1>(0,0)(3,1)(2,3)(0,2);
\end{tikzpicture}
\end{tzcode}
You can also change the fill opacity by specifying the \xem{last} curly brace optional argument |{<fill opacity>}|, \xem{after the semicolon}.
\begin{tzcode}{.3}
% \tzpath*
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[red,very thick](0,3)(4,0)
\tzpath*(0,0)(3,1)(2,3)(0,2);
\tzpath*[fill=green]
<1,-1>(0,0)(3,1)(2,3)(0,2); {.5} %%
\end{tikzpicture}
\end{tzcode}
You can also use the macros |\settzfillcolor| and |\settzfillopacity| to change the defaults.
The effect remains valid until the end of the |tikzpicture| environment, unless changed again.
\begin{tzcode}{.3}
% \tzpath*: \settzfillcolor
\begin{tikzpicture}
\tzhelplines(4,3)
\settzfillcolor{red}
\tzpath*[blue](0,1)(1,2)[-|](3,1)(4,3);
< to [bend right=60] (0,1) >
\tzpath*
(0,0)[to[bend right]]
(1,1)
(2,1)[to[out=-135,in=45]]
(3,0); <--cycle>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzpath+} and \protect\cmd{\tzpath*+}: Relative coordinates: Semicolon versions}
\label{s:tzpath+}
The \iisw{plus version} \icmd{\tzpath+} uses each coordinate (except for the first coordinate) relative (with |++|) to the previous coordinate.
\xem{Everything else is the same as in} |\tzpath|.
\icmd{\tzpath*+} is simply the plus version of |\tzpath*|.
\begin{tzcode}{.3}
% \tzpath+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[red,very thick](0,3)(4,0)
\tzpath+[pattern=bricks,preaction={fill=brown}]
(0,0)(3,1)(-1,2)(-2,-1);
\tzpath+[pattern=north east lines,opacity=.5]
<1,-1>(0,0)(3,1)(-1,2)(-2,-1);
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzpath*+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzline[red,very thick](0,3)(4,0)
\tzpath*+(0,0)(3,1)(-1,2)(-2,-1);
\tzpath*+[fill=green]
<1,-1>(0,0)(3,1)(-1,2)(-2,-1); {.5} %%
\end{tikzpicture}
\end{tzcode}
%%=======================================
%%==================================
\chapter{Curves}
\label{c:curves}
There are many ways to draw curves.
%%-----------------------------------
%%------------------------------------------------------------
\section{B\'{e}zier curves}
\label{s:beziercurves}
\icmd{\tzbezier} draws a B\'{e}zier curve with one or two control points.
\subsection{\protect\cmd{\tzbezier}}
\label{ss:tzbezier}
\begin{tzdef}{}
% syntax: minimal
\tzbezier(<start-coor>)(cntl-coor>)(<last-coor>)
\tzbezier(<start-coor>)(cntl-coor>)(<cntl-coor>)(<last-coor>)
% syntax: full
\tzbezier[<draw opt>]<shift coor>"<name path>"
(<start-coor>)(cntl-coor>)(<cntl-coor>)(<last-coor>)
{<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>)(<m>)()(<m>){}[]<>
\end{tzdef}
\paragraph{Control points}
You can specify one or two control points, |(<cntl-coor>)|.
So |\tzbezier| accepts three or four coordinates as arguments.
\begin{tztikz}{}
% three coordinates: one control point
\tzbezier(0,1)(1,0)(4,3) % works like:
\draw (0,0) ..controls (1,0).. (4,3);
\end{tztikz}
\begin{tztikz}{}
% four coordinates: two control points
\tzbezier(0,1)(1,0)(2,4)(4,3) % works like:
\draw (0,0) ..controls (1,0) and (2,4).. (4,3);
\end{tztikz}
\begin{tzcode}{.3}
% \tzbezier
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[red](0,3)(1,2)(2,4)(4,3)
\tzbezier[blue](0,2)(1,.5)(4,0)
\end{tikzpicture}
\end{tzcode}
The style \ixxw{tzshowcontrols} displays the control points by drawing dotted lines, by default.
You can also change the dotted line style, like |tzshowcontrols={dashed,green}|.
\begin{tzcode}{.3}
% \tzbezier: tzshowcontrols
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[blue,tzshowcontrols](0,2)(1,.5)(4,0)
\tzdots*[blue](0,2)(1,.5)(4,0);
\tzbezier[red,tzshowcontrols={green,dashed}]
(0,3)(1,2)(2,4)(4,3)
\tzdots*[red](0,3)(1,2)(2,4)(4,3);
\end{tikzpicture}
\end{tzcode}
\paragraph{Adding text}
You can add text next to the curve or at the last coordinate
by specifying the options |{<text>}| and |[<node opt>]| immediately after the last coordinate.
\begin{tzcode}{.3}
% \tzbezier: adding text
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[blue](0,2)(1,.5)(4,0){curve}[draw,black,r]
\tzbezier[red](0,3)(1,2)(2,4)(4,3){bezier}[near end,a]
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the curve of |\tzbezier| by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if any.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzbezier: shift
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[blue]
(0,2)(1,.5)(4,0){curve}[draw,black,r]
\tzbezier[blue,dashed]
<1,1>(0,2)(1,.5)(4,0){curve}[r]
\tzbezier[red]
(0,3)(1,2)(2,4)(4,3){bezier}[near end,a]
\tzbezier[red,dashed]
<0,-1>(0,3)(1,2)(2,4)(4,3){bezier}[blue,near end,a]
\end{tikzpicture}
\end{tzcode}
\paragraph{\texttt{name path}}
You can name the path of |\tzbezier| by specifying the option |"<path name>"| immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzbezier: name path, intersection
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[blue,dashed,thick]<1,1>"curve"
(0,2)(1,.5)(4,0){curve}[r]
\tzbezier[red,dashed,thick]<0,-1>"bezier"
(0,3)(1,2)(2,4)(4,3){bezier}[blue,near end,a]
% intersection point
\tzXpoint*{curve}{bezier}(X){X}[-90] % <angle>
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending paths}
You can extend the path of |\tzbezier| from the last coordinate, by writing \Tikz\ code
in the last optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tzbezier: extending path
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier[red](0,3)(1,2)(2,4)(4,3){bezier}[near end,a]
< to [bend right] ++(-1,-1) node [below] {A} >
\tzbezier[blue,->](0,2)(1,.5)(4,0)
< |- ++(-2,1) node [above] {B} >
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzbezier+}: Relative coordinates}
\label{ss:tzbezier+}
For the \iisw{plus version} |\tzbezier+(A)(B)(C)|, |(B)| and |(C)| are relative to |(A)|, as in \Tikz.
For |\tzbezier+(A)(B)(C)(D)|, |(B)| and |(D)| are relative to |(A)|, and |(C)| is relative to |(D)|, as in \Tikz.
\begin{tztikz}{}
% three coordinates
\tzbezier+(0,1)(1,-1)(4,3) % works like:
\draw (0,1) ..controls +(1,-1).. ($(0,1)+(4,3)$);
\end{tztikz}
\begin{tztikz}{}
% four coordinates
\tzbezier+(0,1)(1,-1)(-2,1)(4,3) % works like:
\draw (0,1) ..controls +(1,-1) and +(-2,1).. ($(0,1)+(4,3)$);
\end{tztikz}
\begin{tzcode}{.3}
% \tzbezier+
\begin{tikzpicture}
\tzhelplines(4,4)
\tzbezier+(0,3)(1,-1)(-2,1)(4,0){bezier}[near end,a]
< to [bend right] ++(-1,-1) node [below] {A} >
\tzbezier+[blue,->](0,2)(1,-1.5)(4,-2)
< |- ++(-2,1) node [above] {B} >
\end{tikzpicture}
\end{tzcode}
%%-----------------------------------
%%------------------------------------------------------------
\section{Parabolas}
\label{s:parabolas}
\subsection{\protect\cmd{\tzparabola}}
\label{ss:tzparabola}
\icmd{\tzparabola} draws a parabola going through specified coordinates.
It accepts two or three coordinates.
In the case of three coordinates, the parabola bends at the second coordinate.
\begin{tztikz}{}
% two coordinates
\tzparabola(0,0)(3,2) % works like:
\draw (0,0) parabola (3,2);
\end{tztikz}
\begin{tztikz}{}
% three coordinates
\tzparabola(0,0)(1,1)(3,2) % works like:
\draw (0,0) parabola bend (1,1) (3,2);
\end{tztikz}
\begin{tzdef}{}
% syntax: minimal
\tzparabola(<coor>)(<coor>)
\tzparabola(<coor>)(<coor>)(<coor>)
% syntax: full
\tzparabola[<opt1>]<shift coor>"<path name>"
(<coor>)(<coor>)(<coor>){<text>}[<node opt>]<code.append>
% default
[]<>""(<m>)()(<m>){}[]<>
\end{tzdef}
\paragraph{Parabolas}
|\tzplot| draws the graph of a quadratic function $f(x)=ax^2+bx+c$ for appropriate values of $a$, $b$, and $c$.
\begin{tzcode}{.3}
% \tzparabola: two coordinates
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[thick](0,0)(2,2)
\tzparabola[bend at end,dashed](0,0)(2,2)
\tzparabola[red,thick,bend pos=.5](2,0)(4,3)
\tzparabola[blue,parabola height=-2cm](2,3)(4,2)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzparabola: three coordinates
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[thick](0,2)(1,0)(2,2)
\tzparabola[blue](0,3)(2,1)(4,2)
\tzparabola[red,thick](2,0)(3,2)(4,3)
\end{tikzpicture}
\end{tzcode}
\paragraph{Adding text}
You can add text at or around the last coordinate by specifying the options |{<text>}| and |[<node opt>]| immediately after the last coordinate.
\begin{tzcode}{.3}
% \tzparabola: adding text
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[thick](0,0)(2,2){parabola}[blue,draw,a]
\tzparabola[blue](0,3)(2,1)(4,2){AC}[r]
\tzparabola[red,thick,bend pos=.5](2,0)(4,3){C}[ar]
\end{tikzpicture}
\end{tzcode}
\paragraph{Shift}
You can move the parabola by specifying the option |<shift coor>| before the first coordinate or immediately before the option |"<path name>"|, if any.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzparabola: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[blue] (0,3)(2,1)(4,2){AC}[r]
\tzparabola[dashed]<0,-.5>(0,3)(2,1)(4,2){AC}[r]
\tzparabola[dotted]<0,-1> (0,3)(2,1)(4,2){AC}[r]
\end{tikzpicture}
\end{tzcode}
\paragraph{\texttt{name path}}
You can name the path of |\tzparabola| by specifying the option |"<path name>"| immediately before the first coordinate.
\begin{tzcode}{.3}
% \tzparabola: name path, intersection
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[blue]"AC"(0,3)(2,1)(4,2){AC}[r]
\tzparabola"BB"(1,0)(2,2)(3,0)
% intersection points
\tzXpoint*{AC}{BB}(X)
\tzdot(X-2)(3pt)
\end{tikzpicture}
\end{tzcode}
\paragraph{Extending paths}
You can extend the path of |\tzparabola| from the last coordinate by writing \Tikz\ code in the last optional argument |<code.append>|.
\begin{tzcode}{.3}
% \tzparabola: extending path
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola[blue,->]"AC"(0,3)(2,1)(4,2)
< -- ++ (-1,1) >
\tzparabola"BB"(1,0)(2,2)(3,0)
< -| ++ (1,1) node [right] {K!} >
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzparabola+}: Relative coordinates}
\label{ss:tzparabola+}
For the \iisw{plus version} \icmd{\tzparabola+}, the second and the third coordinates are relative to the first coordinate.
\xem{Everything else is the same as in} |\tzparabola|.
\begin{tztikz}{}
% two coordinates
\tzparabola+(0,1)(3,2) % works like:
\draw (0,1) parabola ($(0,1)+(1,2)$);
\end{tztikz}
\begin{tztikz}{}
% three coordinates
\tzparabola+(0,1)(1,1)(3,-1) % works like:
\draw (0,1) parabola bend +(1,1) ($(0,1)+(3,-1)$);
\end{tztikz}
\begin{tzcode}{.3}
% \tzparabola+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzparabola+[thick](0,0)(2,2){parabola}[blue,draw,a]
\tzparabola+[blue](0,3)(2,-2)(4,-1){AC}[r]
\tzparabola+[red,thick,bend pos=.5](2,0)(2,3){C}[ar]
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzplotcurve}}
\label{s:tzplot}
See Section \ref{s:tzplotcurve} on page \pageref{s:tzplotcurve}, for more details on |\tzplotcurve|.
%%------------------------------------------------------------
\section{\protect\cmd{\tzto}, \protect\cmd{\tztos}}
\label{s:curves:tzto}
See Section \ref{s:tzto} on page \pageref{s:tzto}, for more details on |\tzto|.
See Section \ref{s:tztos} on page \pageref{s:tztos}, for more details on |\tztos|.
%%------------------------------------------------------------
\section{\protect\cmd{\tzfn}}
\label{s:curves:tzfn}
With \icmd{\tzfn}, you can plot functions such as $f(x)=\frac13(x-1)^3+1$, $g(x)=\sin x$, $h(x)=\sqrt{x-1}$, and so on.
See Section \ref{s:tzfn} on page \pageref{s:tzfn}, for more details on |\tzfn|.
%%==================================
\chapter{Polygons and Circles}
\label{c:polygons}
%%------------------------------------------------------------
\section{\protect\cmd{\tzpolygon}: Semicolon verion}
\label{s:tzpolygon}
\icmd{\tzpolygon} connects an arbitrary number of coordinates to draw a polygon, a closed figure. |\tzpolygon| is equivalent to a closed |\tzlines|. Since |\tzpolygon| is a \xem{semicolon version}, you need to enter a \xem{semicolon} to indicate when the coordinate repetition ends.
\begin{tzdef}{}
% syntax: minimum
\tzpolygon(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: medium
\tzpolygon (<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt>] ;
% syntax: full
\tzpolygon[<opt>]<shift coor>"<path name>"
(<coor>){<text>}[<node opt>]
..repeated.. (){}[] ; <code.append>
% defaults
[]<>""(<m>){}[] ..repeated.. (){}[] ; <>
\end{tzdef}
\begin{tztikz}{}
\tzpolygon(1,1)(2,2)(3,1)(4,3); % works like:
\draw (1,1) -- (2,2) -- (3,1) -- (4,3) -- cycle;
\end{tztikz}
You can add text next to lines by specifying the options |{<text>}| and |[<node opt>]| \xem{in-between} coordinates.
\begin{tzcode}{.3}
% \tzpolygon
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpolygon[fill,blue,auto]
(0,1){Side A}[sloped,red]
(1,3){B}
(2,3)
(3,2){Side D}[swap,sloped]
(1,0);
\end{tikzpicture}
\end{tzcode}
You can also move the polygon by specifying the option |<shift coor>| before the first coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzpolygon: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpolygon[blue,auto]
(0,1){Side A}[sloped,red]
(1,3){B}
(2,3)
(3,2){Side D}[swap,sloped]
(1,0);
\tzpolygon[auto,dashed]<1,-.5>
(0,1)(1,3)(2,3){C}(3,2)(1,0);
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzpolygon*}: Semicolon version}
\label{s:tzpolygon*}
\icmd{\tzpolygon*} paints the interior of the polygon with |black!50| with |fill opacity=.3| but with |text opacity=1|, by default.
\begin{tzdef}{}
% syntax: minimum
\tzpolygon*(<coor>)(<coor>)..repeated..(<coor>) ;
% syntax: medium
\tzpolygon*(<coor>){<text>}[<node opt>]..repeated..(<coor>){<text>}[<node opt] ;
% syntax: full
\tzpolygon*[<opt>]<shift coor>"<path name>"
(<coor>){<text>}[<node opt>]
..repeated.. (){}[] ; {<fill opacity>} <code.append>
% defaults
*[fill=black!50,fill opacity=.3,text opacity=1]<>""
(<m>){}[] .. repeated.. (){}[] ; {} <>
\end{tzdef}
You can change the fill opacity by specifying the the last curly brace option |{<fill opacity>}| immediately \xem{after the semicolon}.
\begin{tzcode}{.3}
% \tzpolygon: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpolygon*[draw=blue,auto]
(0,1){Side A}[sloped,red]
(1,3){B}
(2,3)
(3,2){Side D}[swap,sloped]
(1,0);
\tzpolygon*[green,auto,dashed,text=black]<1,-.5>
(0,1)(1,3)(2,3){C}(3,2)(1,0); {.7}
\end{tikzpicture}
\end{tzcode}
You can also change the defaults using |\settzfillcolor| and |\sttzfillopacity|.
%%------------------------------------------------------------
\section{\protect\cmd{\tzpolygon+} and \protect\cmd{\tzpolygon*+}: Relative coordinates: Semicolon verion}
\label{s:tzpolygon}
The plus version \icmd{\tzpolygon+} uses each coordinate (except the first one) relative (with |++|) to the previous coordinate.
\xem{Everything else is the same as in} |\tzpolygon|.
\icmd{\tzpolygon*+} is just a plus version of |\tzpolygon*|.
\begin{tztikz}{}
\tzpolygon+(1,1)(2,2)(3,1)(4,3); % works like:
\draw (1,1) -- ++(2,2) -- ++(3,1) -- ++(4,3) -- cycle;
\end{tztikz}
\begin{tztikz}{}
\tzpolygon+[dashed]"AA"(1,1)(2,2){A}(3,1){B}[below]; % works like:
\draw [dashed,name path=AA] (1,1)
-- ++(2,2)
-- ++(3,1) node {A}
-- ++(4,3) node [below] {B}
-- cycle;
\end{tztikz}
\begin{tzcode}{.3}
% \tzpolygon: shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzpolygon*+[blue,auto]
(0,1){Side A}[sloped,red]
(1,2){B}
(1,0)
(1,-1){Side D}[swap,sloped]
(-2,-2);
\tzpolygon*+[green,auto,dashed,text=black]<1,-.5>
(0,1)(1,2)(1,0){C}(1,-1)(-2,-2); {.7}
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzframe} and \protect\cmd{\tzframe*}}
\label{s:tzframe}
\icmd{\tzframe} accepts two coordinates draws a rectangle.
\begin{tzdef}{}
% syntax: minimum
\tzframe(<coor>)(<coor>)
% syntax: full
\tzframe[<opt>]<shift coor>"<path name>"(<coor1>)(<coor2>)<code.append>
% defaults
[]<>""(<m>)(<m>)<>
\end{tzdef}
\icmd{\tzrectangle} is an alias of |\tzframe|.
\begin{tztikz}{}
\tzframe(0,1)(3,2) % works like:
\draw (0,1) rectangle (3,2);
\end{tztikz}
The plus version \icmd{\tzframe+} uses the second coordinate as the coordinate relative (with |++|) to the first. \icmd{\tzrectangle+} is an alias of |\tzframe+|.
\begin{tztikz}{}
\tzframe+(0,1)(3,2) % works like:
\draw (0,1) rectangle ++(3,2);
\end{tztikz}
\begin{tzcode}{.3}
% \tzframe, \tzframe+
\begin{tikzpicture}
\tzhelplines(4,3)
\tzframe(0,0)(3,2)
\tzframe+[blue,rounded corners=2mm](1,3)(1,-2)
\end{tikzpicture}
\end{tzcode}
The starred version \icmd{\tzframe*} fills the interior
with |black!50| with |fill opacity=.3|, by default.
(\icmd{\tzrectangle*} is an alias of |\tzframe*|.)
|\tzframe+| has also its starred version \icmd{\tzframe*+}.
(\icmd{\tzrectangle*+} is an alias of |\tzframe*+|.)
\begin{tzdef}{}
% syntax
\tzframe*[<opt>]<shift coor>"<path name>"
(<coor1>)(<coor2>){<fill opacity>}<code.append>
% defaults
*[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3}<>
\end{tzdef}
With the starred versions, you can change the fill opacity using the last option |{<fill opacity>}|.
\begin{tzcode}{.3}
% \tzframe*(+)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzframe[fill](0,0)(3,2)
\tzframe*+[green,rounded corners=2mm](1,3)(1,-2){.7} %%
\end{tikzpicture}
\end{tzcode}
You can move |\tzframe| and its variants by specifying the option |<shift coor>| immediately before the first mandatory coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzframe(*)(+): shift
\begin{tikzpicture}
\tzhelplines*(4,4)
\tzframe(0,0)(3,2)
\tzframe[blue,dashed]<1,1>(0,0)(3,2)
\tzcoors(1,3)(A)(1,-2)(B);
\tzframe*+[blue,rounded corners=2mm](A)(B)
\tzframe*+[red,rounded corners=2mm]<-.5,-.5>(A)(B)
\tzframe*+[green,rounded corners=2mm]<1,1>(A)(B)
\end{tikzpicture}
\end{tzcode}
You can extend the path by the option |<code.append>|.
\begin{tzcode}{.3}
% \tzframe(*), \tzrectangle(*): <code.append>
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors(2,2)(A)(3,1)(B);
\tzrectangle*[blue,even odd rule](0,0)(3,2)
<(.5,.5) rectangle (2.5,1.5)>
\tzframe[fill=green,even odd rule](2,1)(4,4)
<(2.3,1.2) rectangle (3.5,3.6)>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzcircle} and \protect\cmd{\tzcircle*}}
\label{s:tzcircle}
\icmd{\tzcircle} draws a circle around a specified coordinate with a specified radius.
The coordinate and the radius are mandatory.
\begin{tzdef}{}
% syntax
\tzcircle[<opt>]<shift coor>"<path name>"(<coor>)(<radius>)<code.append>
% defaults
[]<>""(<m>)(<m>)<>
\end{tzdef}
\begin{tztikz}{}
\tzcircle(0,0)(1cm) % works like:
\draw (0,0) circle (1cm);
\end{tztikz}
The starred version \icmd{\tzcircle*} fills the interior
with |black!50| with |fill opacity=.3|, by default.
You can change the fill opacity using the last option |{<fill opacity>}|.
\begin{tzdef}{}
% syntax
\tzcircle*[<opt>]<shift coor>"<path name>"
(<coor>)(<radius>){<fill opacity>}<code.append>
% defaults
*[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3}<>
\end{tzdef}
\begin{tzcode}{.3}
% \tzcircle(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzcircle(2,2)(1)
\tzcircle[fill=red](3,1)(.5cm)
\tzcircle*[blue](2,1)(1){.5}
\tzcircle*[green](3,.5)(.5cm)
\end{tikzpicture}
\end{tzcode}
You can move the circle by specifying the option |<shift coor>| immediately before the center coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzcircle(*): shift
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors(2,2)(A)(3,1)(B);
\tzcircle(2,2)(1)
\tzcircle[blue,dashed]<-.5,0>(A)(1)
\tzcircle*(3,1)(.5cm)
\tzcircle*[blue]<.5,0>(B)(.5cm)
\end{tikzpicture}
\end{tzcode}
You can extend the path by the option |<code.append>|.
\begin{tzcode}{.3}
% \tzcircle(*): <code.append>
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors(2,2)(A)(3,1)(B);
\tzcircle*[blue,even odd rule](2,2)(1)
<(2,2) circle (1.5)>
\tzcircle[fill=green,even odd rule](3,1)(1)
<(3,1) circle (.7)>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzellipse} and \protect\cmd{\tzellipse*}}
\label{s:tzellipse}
\icmd{\tzellipse} draws an ellipse around a specified coordinate with the specified x-radius and y-radius.
\begin{tzdef}{}
% syntax
\tzellipse[<opt>]<shift coor>"<path name>"(<coor>)(<x and y radius>)<code.append>
% defaults
[]<>""(<m>)(<m>)<>
\end{tzdef}
\icmd{\tzoval} is an alias of |\tzellipse|.
\begin{tztikz}{}
\tzellipse(0,0)(1 and .5) % works like:
\draw (0,0) ellipse (1 and .5);
\end{tztikz}
The starred version \icmd{\tzellipse*} fills the interior
with |black!50| with |fill opacity=.3|, by default.
You can change the fill opacity using the last option |{<fill opacity>}|.
\begin{tzdef}{}
% syntax
\tzellipse*[<opt>]<shift coor>"<path name>"
(<coor>)(<x and y radius>){<fill opacity>}<code.append>
% defaults
*[fill=black!50,fill opacity=.3]<>""(<m>)(<m>){.3}<>
\end{tzdef}
\begin{tzcode}{.3}
% \tzellipse(*)
\begin{tikzpicture}
\tzhelplines(4,3)
\tzellipse(2,2)(1.5 and 1)
\tzellipse[fill=red](3,1)(1cm and .5cm)
\tzellipse*[blue](2,1)(1 and 1.5){.5}
\tzellipse*[green](3,.5)(1cm and .5cm)
\end{tikzpicture}
\end{tzcode}
You can move the ellipse by specifying the option |<shift coor>| immediately before the mandatory coordinate.
The empty shift option |<>| is not allowed.
\begin{tzcode}{.3}
% \tzellipse(*): shift
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors(2,2)(A)(3,1)(B);
\tzellipse(2,2)(1.5 and 1)
\tzellipse[blue,dashed]<-.5,0>(A)(1.5 and 1)
\tzellipse*(3,1)(1cm and .5cm)
\tzellipse*[blue]<.5,0>(B)(1cm and .5cm)
\end{tikzpicture}
\end{tzcode}
You can extend the path by the option |<code.append>|.
Note also that \icmd{\tzoval*} is an alias of |\tzellipse*|.
\begin{tzcode}{.3}
% \tzellipse(*), \tzoval(*): <code.append>
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoors(2,2)(A)(3,1)(B);
\tzoval*[blue,even odd rule](2,2)(1.5 and 1)
<(2,2) ellipse (2 and 1.5)>
\tzellipse[fill=green,even odd rule](3,1)(1 and 1)
<(3,1) ellipse (.5 and .8)>
\end{tikzpicture}
\end{tzcode}
%%==================================
\chapter{Arcs and Wedges}
\label{c:arcs}
%%------------------------------------------------------------
\section{\protect\cmd{\tzarc(')}: Centered arcs}
\label{s:tzarc}
\subsection{Arcs}
\label{ss:tzarc}
\icmd{\tzarc} draws an arc around a specified center coordinate.
\begin{tzdef}{}
% syntax: minimum
\tzarc(<coor>)(<angA:angB:radius>)
% syntax: full
\tzarc[<opt>]<shift coor>"<path name>"
(<coor>)(<angA:angB:radius>){<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>)(<m>){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tzarc(1,1)(30:120:1) % works like:
\draw (1,1) ++(30:1) arc (30:120:1);
\end{tztikz}
The \iisw{swap version} \icmd{\tzarc'} switches its drawing direction from \ixxw{counterclockwise} to \ixxw{clockwise} and vice versa.
\begin{tztikz}{}
\tzarc'(1,1)(30:120:1) % works like:
\draw (1,1) ++(30:1) arc (30:120-360:1);
\end{tztikz}
\begin{tzcode}{.3}
% \tzarc, \tzarc'
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots*(1,1)(3,2);
\tzarc [blue,->] (1,1)(-45:180:1)
\tzarc'[dashed,->] (1,1)(-45:180:1)
\draw [->](3,2) ++(-45:1) arc (-45:180:1);
\draw [dashed,->](3,2) ++(-45:1) arc (-45:180-360:1);
\end{tikzpicture}
\end{tzcode}
You can add text along the arc by specifying the options |{<text>}| and |[<node opt>]| immediately after the two mandatory arguments.
\begin{tzcode}{.3}
% \tzarc('): adding text
\begin{tikzpicture}
\tzhelplines(4,3)
\tzarc [blue,->] (1,1)(-45:180:1){A}[r]
\tzarc'[dashed,->](1,1)(-45:180:1)
\tzarc[->] (3,2)(-45:180:1){arc}[midway,sloped]
\tzarc'[dashed,->](3,2)(-45:180:1)
\end{tikzpicture}
\end{tzcode}
You can move arcs by specifying the option |<shift coor>| just before the center coordinate.
\begin{tzcode}{.3}
% \tzarc('): shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzarc [blue,->] (1,1)(-45:180:1){A}[r]
\tzarc'[dashed,->] (1,1)(-45:180:1)
\tzarc [blue,->] <2,1>(1,1)(-45:180:1){A-shifted}[r]
\tzarc'[dashed,->]<2,1>(1,1)(-45:180:1)
\end{tikzpicture}
\end{tzcode}
You can also extend the path of |\tzarc| by specifying the last option |<code.append>| with \Tikz\ code written in it. For example, |<--cycle>| makes a closed path.
\begin{tzcode}{.3}
% \tzarc('): <code.append>
\begin{tikzpicture}
\tzhelplines(4,3)
\tzarc [blue,->](1,1)(-45:180:1)<--++(1,2)>
\tzarc'[dashed,->] (1,1)(-45:180:1)
\tzarc [blue,->] <2,1>(1,1)(-45:180:1)<--cycle>
\end{tikzpicture}
\end{tzcode}
\subsection{Elliptical arcs}
\label{ss:ellipticalarc}
|\tzarc| draws an elliptical arc if you specify |x-radius| and |y-radius|.
\begin{tzcode}{.3}
% \tzarc: elliptical
\begin{tikzpicture}
\tzhelplines(4,4)
\tzarc[->,red](1,1)(30:270:1.5 and 0.5)
\tzarc'[->,dotted](1,1)(30:270:1.5 and 0.5)
\tzdots*(1,1)(2,2);
\tzarc[->,blue,dashed](2,2)(0:-270:1 and 2)
\tzarc'[->](2,2)(0:-270:1 and 2)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzarc: elliptical
\begin{tikzpicture}
\tzhelplines(4,4)
\tzarc[->,red](1,1)(30:270:1.5 and 0.5)
\tzdots*(1,1)(2,2);
\tzarc[->,blue,dashed,fill=green,fill opacity=.3]
(2,2)(0:-270:1 and 2)<--(2,2)> % code.append
\tzarc[->,blue,dashed]
<1,0>(2,2)(0:-270:1 and 2) % shift
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzarcfrom(')}: Arcs as in \Tikz}
\label{s:tzarcfrom}
\icmd{\tzarcfrom} draws an arc starting from a specified point, like \Tikz\ does.
\begin{tzdef}{}
% syntax: minimum
\tzarcfrom(<coor>)(<angA:angB:radius>)
% syntax: full
\tzarcfrom[<opt>]<shift coor>"<path name>"
(<coor>)(<angA:angB:radius>){<text>}[<node opt>]<code.append>
% defaults
[]<>""(<m>)(<m>){}[]<>
\end{tzdef}
\begin{tztikz}{}
\tzarcfrom(1,1)(30:120:1) % works like:
\draw (1,1) arc (30:120:1);
\end{tztikz}
\xem{Everything else is the same as in }|\tzarc|.
\icmd{\tzarcfrom'} is the \iisw{swap version} of |\tzarcfrom|.
\begin{tzcode}{.3}
% \tzarcfrom
\begin{tikzpicture}
\tzhelplines(4,3)
\tzdots*(1,1)(3,2);
\tzarcfrom [blue,->] (1,1)(-45:180:1){A}[r]
\tzarcfrom'[dashed,->](1,1)(-45:180:1)
\tzarcfrom[->](3,2)(-45:180:1){arc}[midway,sloped]
\tzarcfrom'[dashed,->](3,2)(-45:180:1)
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{\protect\cmd{\tzarcsfrom}: Connected arcs: Semicolon version}
\label{s:tzarcsfrom}
The macro \icmd{\tzarcsfrom} (i.e. |\tzarcs + from|) accepts an arbitrary number of parenthesis arguments in the form of |(<angA:AngB:radius>)| following the start coordinate. You need to enter a \xem{semicolon} to indicate when the repetition ends.
\begin{tzdef}{}
% syntax: minimum
\tzarcsfrom(<start coor>)
(<angA:angB:radius>)..repeated..(<angA:angB:radius>) ;
% syntax: full
\tzarcsfrom[<opt>]<shift coor>"<path name>"
(<start coor>)(<angA:angB:radius>){<text>}[<node opt>]
..repeated..(){}[] ; <code.append>
% defaults
[]<>""(<m>)(<m>){}[]..repeated..(){}[] ; <>
\end{tzdef}
\begin{tzcode}{.4}
% \tzarcfrom: adding text, <code.append>
\begin{tikzpicture}
\tzhelplines(4,4)
\tzcoor*(3,2)(A)
\tzarcsfrom[->,auto](A)
(0:180:1){1}[midway]
(180:360:1.2){2}[midway]
(0:180:1.4){3}[midway,swap]
(180:360:1.6){4}[midway,swap];
< node [right,blue] {End!} >
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.4}
% \tzarcfrom: shift
% flag: step 1
\begin{tikzpicture}
\tzhelplines(-2,-2)(2,2)
\tzdot*(0,0)
\edef\x{atan(2/3)}
\tzarcsfrom[red,->](0,0)
(-\x:-\x-180:1){red 1}[midway];
\tzarcsfrom[blue,->](0,0)
(180-\x:-\x:1){blue 1}[midway];
\tzarcsfrom[dashed,->]<.5,.5>(0,0)
(180-\x:-\x:1){blue 1}[midway];
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.4}
% flag: step 2
\begin{tikzpicture}
\edef\x{atan(2/3)}
\tzarcsfrom[red](0,0)
(-\x:-\x-180:1){1}[midway]
(-\x+180:-\x:2){2}[midway];
\tzarcsfrom[blue](0,0)
(180-\x:-\x:1){1}[midway]
(-\x:-\x-180:2){2}[midway];
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.4}
% flag: step 3
\definecolor{flagred}{RGB}{205,48,57}
\definecolor{flagblue}{RGB}{17,73,156}
\begin{tikzpicture}[scale=1]
\edef\x{atan(2/3)}
\tzarcsfrom[draw=none,fill=flagred](0,0)
(-\x:-\x-180:1)
(-\x+180:-\x:2)
(-\x:-\x+180:1);<-- cycle>
\tzarcsfrom[draw=none,fill=flagblue](0,0)
(180-\x:-\x:1)
(-\x:-\x-180:2)
(-\x+180:-\x+360:1);<-- cycle>
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.4}
% flag: shift
\definecolor{flagred}{RGB}{205,48,57}
\definecolor{flagblue}{RGB}{17,73,156}
\begin{tikzpicture}[scale=1]
\edef\x{atan(2/3)}
\tzarcsfrom[draw=none,fill=flagred]<.1,.3>(0,0)
(-\x:-\x-180:1)
(-\x+180:-\x:2)
(-\x:-\x+180:1);<-- cycle>
\tzarcsfrom[draw=none,fill=flagblue](0,0)
(180-\x:-\x:1)
(-\x:-\x-180:2)
(-\x+180:-\x+360:1);<-- cycle>
\end{tikzpicture}
\end{tzcode}
%%------------------------------------------------------------
\section{Wedges}
\label{s:wedges}
\subsection{\protect\cmd{\tzwedge(')}}
\label{ss:tzwedge}
\icmd{\tzwedge} draws a wedge around a specified center coordinate.
|\tzwedge| works similarly to |\tzarc|, but it forms a closed path from the center coordinate.
\begin{tzdef}{}
% syntax
\tzwedge[<opt>]<shift coor>"<path name>"
(<coor>)(<angA:angB:radius>){<text>}[<node opt>]
% defaults
[]<>""(<m>)(<m>){}[midway]
\end{tzdef}
\begin{tztikz}{}
\tzwedge(1,1)(30:120:1) % works like:
\draw (1,1) -- ++(30:1) arc (30:120:1) -- cycle;
\end{tztikz}
The macro \icmd{\tzwedge'} is the \iisw{swap version} of \icmd{\tzwedge}.
It switches the drawing direction from \ixxw{counterclockwise} to \ixxw{clockwise} and vice versa.
\begin{tztikz}{}
\tzwedge'(1,1)(30:120:1) % works like:
\draw (1,1) -- ++(30:1) arc (30:120-360:1) -- cycle;
\end{tztikz}
\begin{tzcode}{.3}
% \tzwedge, \tzwedge'
\begin{tikzpicture}
\tzcoor*(2,1)(A)(3pt)
\tzhelplines(4,3)
\tzwedge[blue,very thick](A)(30:120:1.5)
\tzarc[->,green] (A)(30:120:1.3)
\tzwedge'[dashed](A)(0:135:1.5){clockwise}[sloped,red]
\tzarc'[->,green](A)(0:135:1.3)
\tzwedge'[fill](A)(-60:240:1)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzwedge('): shift
\begin{tikzpicture}
\tzcoor*(2,1)(A)
\tzhelplines(4,3)
\tzwedge[blue,very thick]<.1,.1>(A)(30:120:1.5) % shift
\tzarc[->,lightgray]<.1,.1>(A)(30:120:1.3) % shift
\tzwedge'[dashed](A)(0:135:1.5){clockwise}[sloped,red]
\tzarc'[->,lightgray](A)(0:135:1.3)
\tzwedge'[fill]<2,0>(A)(-60:240:1) % shift
\end{tikzpicture}
\end{tzcode}
\subsection{\protect\cmd{\tzwedge*(')}}
\label{ss:tzwedge*}
The starred version \icmd{\tzwedge*} works just like |\tzwedge|, but it fills wedges with |black!50| with |fill opacity=.3| and |fill opacity=1|, by default.
You can change the defaults with |\settzfillcolor| and |\settzfillopacity|.
You can also change the fill opacity by specifying the last optional argument |{<fill opacity>}|.
\begin{tzdef}{}
% syntax
\tzwedge*[<opt>]<shift coor>"<path name>"
(<coor>)(<angA:angB:radius>){<text>}[<node opt>]{<fill opacity>}
% defaults
[fill=black!50,fill opacity=.3,text opacity=1]<>""(<m>)(<m>){}[midway]{.3}
\end{tzdef}
\icmd{\tzwedge*'} is the \iisw{swap version} of |\tzwedge*|.
\begin{tzcode}{.3}
% \tzwedge*, \tzwedge*'
\begin{tikzpicture}[->,>=stealth]
\tzhelplines(3,3)
\tzwedge[very thick,blue](1,1)(30:120:1.5)
\tzwedge*[-,very thick,blue,fill=red](1,1)(30:120:1)
\tzwedge'[dashed](1,1)(30:120:1.5){clockwise}[pos=.45]
\tzwedge*'[dashed,fill=green](1,1)(-90:180:1)
\tzdot*(1,1)
\end{tikzpicture}
\end{tzcode}
\begin{tzcode}{.3}
% \tzwedge*('): shift, fill opacity
\begin{tikzpicture}
\tzdot*(1,1)
\tzhelplines(3,3)
\tzwedge[blue,very thick](1,1)(30:120:1.5)
\tzwedge[red,very thick]<.5,.5>(1,1)(30:120:1.5)
\tzwedge'[dashed](1,1)(0:135:1.5)
\tzwedge*[fill=blue](1,1)(300:240:1){B}[b]
\tzwedge*[blue]<2,0>(1,1)(300:240:1){B}[b]{.7}
\end{tikzpicture}
\end{tzcode}
|