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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#let rtext(body)={
  text(fill:maroon,body)
}
= 布局库(Layout)
以不同的方式在页面上排列元素。

通过组合布局函数,您可以创建复杂且自动化的布局。
== 对齐(align)<align>
水平和垂直对齐内容。

=== 示例(Example)
我们先从将内容水平居中开始:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 120pt)
#set align(center)

Centered text, a sight to see \
In perfect balance, visually \
Not left nor right, it stands alone \
A work of art, a visual throne

```
  ],[
    #set align(horizon)
    #image("images/6001.png",width: auto)
    ]
)
要将对象垂直居中,请使用水平对齐:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 120pt)
#set align(horizon)

Vertically centered, \
the stage had entered, \
a new paragraph.

```
  ],[
    #set align(horizon)
    #image("images/6002.png",width: auto)
    ]
)
=== 合并比对结果(Combining alignments)<align_Combining-alignments>
你可以使用 + 运算符组合两种对齐方式。我们改用函数形式而非set规则,让该设置仅作用于一段内容:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 120pt)
Though left in the beginning ...

#align(right + bottom)[
  ... they were right in the end, \
  and with addition had gotten, \
  the paragraph to the bottom!
]

```
  ],[
    #set align(horizon)
    #image("images/6003.png",width: auto)
    ]
)
=== 嵌套对齐(Nested alignment)<align_Nested-alignment>
您可以为布局容器及其内部元素使用不同的对齐方式。通过这种方式,您可以创建复杂的布局:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#align(center, block[

  #set align(left)
  Though centered together \
  alone \
  we \
  are \
  left.
])

```
  ],[
    #set align(horizon)
    #image("images/6004.png",width: auto)
    ]
)
=== 同一行内的对齐(Alignment within the same line)
align函数执行块级对齐,因此总会中断当前段落。若要让同一行的不同部分采用不同的对齐方式,则应改用分数间距:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
Start #h(1fr) End

```
  ],[
    #set align(horizon)
    #image("images/6005.png",width: auto)
    ]
)
=== 参数(Parameters)
```typc
align(
    alignment: alignment,
    body: content,
) → content
```
- *alignment*: alignment
双轴方向上的#link(<alignment>)[对齐方式]。默认值:```typc start+top```。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 6cm)
#set text(lang: "ar")

مثال
#align(

  end + horizon,

  rect(inset: 12pt)[ركن]
)
```
  ],[
    #set align(horizon)
    #image("images/6006.png",width: auto)
    ]
)
- *body*: content
待对齐的内容。

== 对齐方式(alignment)<alignment>
沿坐标轴对齐对象的位置。

可选值如下:

-- start:按#link(<text_dir>)[文本方向]的#link(<direction_start>)[起始端]对齐。

-- end:按#link(<text_dir>)[文本方向]的#link(<direction_end>)[末尾端]对齐。

-- left:左对齐。

-- center:水平居中对齐。

-- right:右对齐。

-- top:顶部对齐。

-- horizon:垂直居中对齐。

-- bottom:底部对齐。

这些值在全局范围内以及对齐类型的作用域内均可用,因此你可以编写下面两种形式中的任意一种:
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#align(center)[Hi]
#align(alignment.center)[Hi]

)
```
  ],[
    #set align(horizon)
    #image("images/6007.png",width: auto)
    ]
)
=== 二维对齐方式(2D alignments)<alignment_2D_alignments>
若要同时沿两个轴对齐,可使用+运算符叠加两种对齐方式。例如,top + right会将内容对齐至右上角。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 3cm)
#align(center + bottom)[Hi]
)
```
  ],[
    #set align(horizon)
    #image("images/6008.png",width: auto)
    ]
)
=== 域(Fields)<alignment_Fields>
x 和 y 字段分别保存对齐方式的水平分量与垂直分量(作为另一种对齐设置),二者可以为#text(fill: red,"none")。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#(top + right).x \
#left.x \
#left.y (none)
)
```
  ],[
    #set align(horizon)
    #image("images/6009.png",width: auto)
    ]
)
=== 定义(Definitions)
- *axis*
该对齐方式所属的轴。

-- "horizontal" 对应 start、left、center、right 和 end

-- "vertical" 对应 top、horizon 和 bottom

-- none 用于二维对齐
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#left.axis() \
#bottom.axis()
)
```
  ],[
    #set align(horizon)
    #image("images/6010.png",width: auto)
    ]
)
```typc

    self.axis() → none str
```
- *inv*
反向对齐。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#top.inv() \
#left.inv() \
#center.inv() \
#(left + bottom).inv()
)
```
  ],[
    #set align(horizon)
    #image("images/6011.png",width: auto)
    ]
)

== 角度(angle)<angle>
描述旋转的角度。

Typst支持以下角度单位:

-- 度:180度

-- 弧度:3.14弧度

=== 示例(Example)
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#rotate(10deg)[Hello there!]
```
  ],[
    #set align(horizon)
    #image("images/6012.png",width: auto)
    ]
)
=== 定义(Definitions)
- *rad*
将此角度转换为弧度。
```typc
    self.rad() → float
```
- *deg*
将该角度转换为度。
```typc
    self.deg() → float
```

== 块(block)<block>
块级容器。

这类容器可用于分隔内容、设置尺寸,并为其添加背景或边框。

块元素也是控制文本是否属于段落的主要方式。更多详情可查阅#link(<Paragraph_What-becomes-a-paragraph>)[段落相关文档]。
=== 示例(Example)
使用块元素,你可以为内容设置背景,同时仍允许内容跨多页分页显示。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 100pt)
#block(

  fill: luma(230),
  inset: 8pt,
  radius: 4pt,
  lorem(30),
)
```
  ],[
    #set align(horizon)
    #image("images/6013.png",width: auto)\
    #image("images/6014.png",width: auto)
    ]
)
块还可用于将原本为行内的元素强制转为块级元素,在编写show规则时尤其有用。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#show heading: it => it.body
= Blockless
More text.

#show heading: it => block(it.body)
= Blocky
More text.
```
  ],[
    #set align(horizon)
    #image("images/6015.png",width: auto)
    ]
)
=== 参数(Parameters)
```typc
block(
    width: auto relative,
    height: auto relative fraction,
    breakable: bool,
    fill: none color gradient tiling,
    stroke: none length color gradient stroke tiling dictionary,
    radius: relative dictionary,
    inset: relative dictionary,
    outset: relative dictionary,
    spacing: auto relative fraction,
    above: auto relative fraction,
    below: auto relative fraction,
    clip: bool,
    sticky: bool,
    body: none content,
) → content
```
- *width*: auto relative<block_width>
该区块的宽度。默认值:```typc auto```。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set align(center)
#block(

  width: 60%,

  inset: 8pt,

  fill: silver,

  lorem(10),
)

```
  ],[
    #set align(horizon)
    #image("images/6016.png",width: auto)
    ]
)
- *height*: auto relative fraction<block_height>
区块的高度。当该高度大于页面剩余空间,且#link(<block_breakable>)[可分页属性]为#text(fill: red,"true" )时,区块会将剩余高度部分延续至下一页。默认值:```typc auto```。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 80pt)
#set align(center)
#block(

  width: 80%,

  height: 150%,

  fill: aqua,

)
```
  ],[
    #set align(horizon)
    #image("images/6017.png",width: auto)\
    #image("images/6018.png",width: auto)\
    ]
)
- *breakable*: bool<block_breakable>
该块是否可以断开并在下一页继续显示。默认值:```typc true```。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typ
#set page(height: 80pt)
The following block will
jump to its own page.
#block(

  breakable: false,

  lorem(15),
)
```
  ],[
    #set align(horizon)
    #image("images/6019.png",width: auto)\
    #image("images/6020.png",width: auto)\
    ]
)
- *fill*: none color gradient tiling<block_fill>
该区块的背景颜色。更多详情请参阅#link(<rect_fill>)[矩形相关文档]。默认值:```typc none```。
- *stroke*: none length color gradient stroke tiling dictionary<block_stroke>
该区块的边框颜色。更多详情请参阅#link(<rect_stroke>)[矩形文档]。默认值:```typc (:)```。
- *radius*: relative dictionary<block_radius>
区块边角的圆角大小。更多详情请参见#link(<rect_radius>)[矩形相关文档]。默认值:```typc (:)```。
- *inset*: relative dictionary<block_inset>
块内容的内边距大小。更多详情请参阅#link(<box_inset>)[盒子相关文档]。默认值:```typc (:)```。
- *outset*: relative dictionary<block_outset>
在不影响布局的前提下,该区块需要扩容至多大。更多详情请查阅#link(<box_outset>)[该组件的文档说明]。默认值:```typc (:)```。
- *spacing*: auto relative fraction<block_spacing>
块周围的间距。设为auto时,会继承段落间距。默认值:```typc 1.2em```。

对于两个相邻块,取第一个块的下方间距与第二个块的上方间距中的较大值。此外,块间距优先级高于段落间距。

请注意,这只是将上方和下方间距设置为相同值的简写方式。由于上方和下方间距的值可能不同,上下文块仅支持访问block.above和block.below,无法直接访问block.spacing。

该属性可结合显示规则使用,用来调整任意块级元素周边的间距。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  fill: luma(86.27%),
  [
    ```typ
#set align(center)
#show math.equation: set block(above: 8pt, below: 16pt)

This sum of $x$ and $y$:
$ x + y = z $
A second paragraph.
```
  ],[
    #set align(horizon)
    #image("images/6021.png",width: auto)
    ]
)
- *above*: auto relative fraction<block_above>
此区块与其前一个区块之间的间距。默认值:```typc auto```。
- *below*: auto relative fraction<block_below>
此块与其后续块之间的间距。默认值:```typc auto```。
- *clip*: bool<block_clip>
是否裁剪块内的内容。默认值:```typc false```。

当块的内容大于块本身时,裁剪功能很有用,所有超出块边界的内容都会被隐藏。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  fill: luma(86.27%),
  [
    ```typ
#block(

  width: 50pt,

  height: 50pt,

  clip: true,

  image("tiger.jpg", width: 100pt, height: 100pt)
)
```
  ],[
    #set align(horizon)
    #image("images/6022.png",width: auto)
    ]
)
- *sticky*: bool<block_sticky>
此段落是否必须紧挨下一段,中间不能有空行。默认值:```typc false```。

默认情况下,这是针对标题块设置的,以防止页面底部出现孤立的标题。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  fill: luma(86.27%),
  [
    ```typ
// Disable stickiness of headings.
#show heading: set block(sticky: false)
#lorem(20)

= Chapter
#lorem(10)
```
  ],[
    #set align(horizon)
    #image("images/6023.png",width: auto)\
    #image("images/6024.png",width: auto)
    ]
)
- *body*: none content<block_body>
区块中的内容

== 盒子(box)<box>
一种用于设定内容尺寸的行内容器。

除行内公式、文本和盒子外,所有元素均为块级元素,不能放置在#link(<Paragraph>)[段落]内部。box函数可用于将这类元素嵌入段落。盒子默认根据自身内容确定尺寸,也可显式指定大小。
=== 示例(Example)
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typst
Refer to the docs
#box(

  height: 9pt,

  image("docs.svg")
)
for more information.

```
  ],[
    #set align(horizon)
    #image("images/6025.png",width: auto)]
)
=== 参数(Parameters)
```typc
box(
    width: auto relative fraction,
    height: auto relative,
    baseline: auto relative dictionary alignment,
    fill: none color gradient tiling,
    stroke: none length color gradient stroke tiling dictionary,
    radius: relative dictionary,
    inset: relative dictionary,
    outset: relative dictionary,
    clip: bool,
    body: none content,
) → content
```
- *width*: auto relative fraction<box_width>
盒子的宽度。默认值:```typc auto```。

如下例所示,盒子可以设置#link(<fraction>)[小数]宽度。

注意:目前,段落内仅盒子支持小数尺寸,且仅宽度可设为小数。后续可能会增加对图片、形状等元素的小数尺寸支持。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

Line in #box(width: 1fr, line(length: 100%)) between.
    ```
  ],
  [
    #set quote(block: true)
    #show quote: set align(center)
    #rect(

      fill: luma(240),
      width: 100%,
      height: auto,
      quote[
      #image("images/6026.png",width: 80%)
    ]
    )
  ]
)
- *height*: auto relative<box_height>
箱子的高度。默认值:```typc auto```。
- *baseline*: auto relative dictionary alignment<box_baseline>
盒子基线的垂直位置。该属性用于将盒子与其段落内周围的文本对齐,默认情况下基线位于文本正下方。默认值:```typc (at:auto,shift:0%+0pt)```。

默认状态下,盒子的基线与其内容(例如盒内的文本或公式)的基线保持一致,这就是#text(fill: red,"auto")选项。不过基线可通过两种方式调整。第一种是直接选择一种垂直#link(<alignment>)[对齐方式],如顶端、中线或底端,将基线定位在相对于盒子总高度(包含内边距)的对应位置。

另一种调整方式是按指定的相对长度,将默认基线沿垂直方向偏移一定距离。例如,取值#text(fill: red,"2pt")会将基线向上移动该长度(对齐点上移,使得内容相对下移);而#text(fill: red,"-40%")代表基线向下偏移盒子总高度(含内边距)的40%(内容因此相对上移)。

这两种选项可以同时设置,使用包含at和shift键的字典分别指定。例如设置(at: bottom, shift: 10pt)时,盒子基线会定位在距离内容底端向上恰好#text(fill: red,"10pt")的位置。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

Image: #box(baseline: 40%, image("tiger.jpg", width: 2cm)).
    ```
  ],
  [
    #set quote(block: true)
    #show quote: set align(center)
    #rect(

      fill: luma(240),
      width: 100%,
      height: auto,
      quote[
      #image("images/6027.png",width: 80%)
    ]
    )
  ]
)
- *fill*: none color gradient tiling<box_fill>
该盒子的背景颜色。更多信息请参阅#link(<rect_fill>)[矩形组件文档]。默认值:```typc none```。
- *stroke*: none length color gradient stroke tiling dictionary<box_stroke>
该盒子的边框颜色。更多详情请参阅#link(<rect_stroke>)[矩形组件的文档]。默认值:```typc (:)```。
- *radius*: relative dictionary<box_radius>
盒子圆角的大小。更多详情请参阅#link(<rect_radius>)[矩形文档]。默认值:```typc (:)```。
- *inset*: relative dictionary<box_inset>
框内容的内边距大小。默认值:```typc (:)```。

该参数可以是适用于所有边的单一长度值,也可以是分别设置各边长度的字典。传入字典时,可包含以下键(优先级从高到低):top、right、bottom、left(分别控制单元格对应边),x、y(控制水平、垂直内嵌边距),rest(覆盖字典中其他项未设置的所有内嵌边距)。所有键均为可选;省略的键会沿用之前设置的值,若从未设置则使用默认值。

该参数的#link(<relative>)[相对长度]基于不含#link(<box_outset>)[外扩边距]的盒子尺寸计算。请注意:相对内嵌边距与外扩边距不同于相对#link(<box_width>)[宽]#link(<box_height>)[高],后者是相对于容器计算的。

注意:当盒子内包含文本时,其实际尺寸由当前#link(<text_top-edge>)[文本边界]决定。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typst
#rect(inset: 0pt)[Tight]
```
  ],[
    #set align(horizon)
    #image("images/6028.png",width: auto)]
)
- *outset*: relative dictionary<box_outset>
在不影响布局的情况下,盒子尺寸需要扩大多少。默认值:```typc (:)```。

该值可以是适用于所有边的单一长度,也可以是存放各边长度的字典。此参数的[相对长度]是相对于不包含外延距离的盒子尺寸。更多详情可参考上文#link(<box_inset>)[内边距]的文档。

该功能可用于避免内边距影响文本行布局。下方示例的通用版本,请参阅#link(<raw_block>)[原始文本的块参数]文档。
#table(

  columns: (1fr,1fr),
  align: (left,left),
  stroke: none,
  fill: (rgb(250, 250, 250),luma(86.27%)),
  [
    ```typst
An inline
#box(

  fill: luma(235),
  inset: (x: 3pt, y: 0pt),
  outset: (y: 3pt),
  radius: 2pt,
)[rectangle].
```
  ],[
    #set align(horizon)
    #image("images/6029.png",width: auto)]
)
- *clip*: bool
是否裁剪容器内的内容。默认值:```typc false```。

当容器中的内容超出容器本身大小时,裁剪功能十分有用,所有超出容器边界的内容都会被隐藏。
#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#box(

  width: 50pt,

  height: 50pt,

  clip: true,

  image("images/tiger.png"", width: 100pt, height: 100pt)

)

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6030.png",width: 80%)

    ]

    )

  ]

)

- *body*: none content

盒子里的内容。



== 列分隔符(colbreak)<colbreak>

强制分栏。



在单栏布局或页面的最后一栏中使用该功能时,其效果等同于分页符。否则,分栏符之后的内容将放置在下一栏。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(columns: 2)

Preliminary findings from our

ongoing research project have

revealed a hitherto unknown

phenomenon of extraordinary

significance.



#colbreak()

Through rigorous experimentation

and analysis, we have discovered

a hitherto uncharacterized process

that defies our current

understanding of the fundamental

laws of nature.

```

  ],[

    #set align(horizon)

    #image("images/6031.png",width: auto)]

)

=== 参数(Parameters)

```typc

colbreak(weak: bool) → content

```

- *weak*: bool 

如果为真,当当前列已经为空时,将跳过分栏符。默认值:```typc false```。



== 列数(columns)<columns>

将一个区域分隔为多个等宽列。



column函数可将任意容器内部拆分为多列。目前该函数不会自动均衡各列高度,各列高度将取容器高度或页面剩余高度。均衡列高的功能已列入后续开发计划。



在跨多列排布内容时,可使用#link(<colbreak>)[colbreak]强制将后续内容换到下一列。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#columns(2, gutter: 8pt)[

  This text is in the

  first column.



  #colbreak()



  This text is in the

  second column.

]

```

  ],[

    #set align(horizon)

    #image("images/6032.png",width: auto)]

)

=== 页面级列(Page-level columns)<columns_Page-level-columns>

如果需要在整个文档中插入列,请使用页面功能的#link(<page_columns>)[列参数]。这将直接在页面级别创建列,而不是将所有内容包裹在布局容器中。因此,#link(<pagebreak>)[分页符]、#link(<footnote>)[脚注]和#link(<Paragraph_line>)[行号]等功能将继续按预期正常工作。有关更多信息,请同时阅读#link(<page_guide>)[页面设置指南的相关部分]。

=== 突破列布局(Breaking out of columns)<columns_Breaking-out-of-columns>

如需临时脱离分栏布局(例如论文标题),可使用父级作用域浮动定位:

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(columns: 2, height: 150pt)



#place(

  top + center,

  scope: "parent",

  float: true,

  text(1.4em, weight: "bold")[

    My document

  ],

)



#lorem(40)

```

  ],[

    #set align(horizon)

    #image("images/6033.png",width: auto)]

)

=== 参数(Parameters)

```typst

columns(

    count: int,

    gutter: relative,

    body: content,

) → content

```

- *count*: int

列数。默认值:```typc 2```。

- *gutter*: relative

各列之间的沟槽间距大小。默认值:```typc 4%+0pt```。

- *body*: content

需要分栏排版的内容。



== 方向(direction)<direction>

内容可排布的四个方向。



可选值如下:



-- ltr:从左到右。



-- rtl:从右到左。



-- ttb:从上到下。



-- btt:从下到上。



这些值在全局范围内以及方向类型的作用域内均可用,因此你可以编写下面两种形式中的任意一种:

#table(

  columns: (1.5fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#stack(dir: rtl)[A][B][C]

#stack(dir: direction.rtl)[A][B][C]

```

  ],[

    #set align(horizon)

    #image("images/6034.png",width: auto)]

)

=== 定义(Definitions)

- *from*

从起点返回一个方向。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#direction.from(left) \

#direction.from(right) \

#direction.from(top) \

#direction.from(bottom)

```

  ],[

    #set align(horizon)

    #image("images/6035.png",width: auto)]

)

```typst

direction.from(side: alignment) → direction

```

- *to*

从终点返回一个方向。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#direction.to(left) \

#direction.to(right) \

#direction.to(top) \

#direction.to(bottom)

```

  ],[

    #set align(horizon)

    #image("images/6036.png",width: auto)]

)

```typst

direction.to(side: alignment) → direction

```

- *axis*

该方向所属的轴,取值为“horizontal”或“vertical”。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#ltr.axis() \

#ttb.axis()

```

  ],[

    #set align(horizon)

    #image("images/6037.png",width: auto)]

)

```typst

direction.axis() → str

```

- *sign*

用于计算的对应符号。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#ltr.sign() \

#rtl.sign() \

#ttb.sign() \

#btt.sign()



```

  ],[

    #set align(horizon)

    #image("images/6038.png",width: auto)]

)

```typst

direction.sign() → int

```

- *start*<direction_start>

作为对齐基准,此方向的起始点。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#ltr.start() \

#rtl.start() \

#ttb.start() \

#btt.start()

```

  ],[

    #set align(horizon)

    #image("images/6039.png",width: auto)]

)

```typst

self.start() → alignment

```

- *end*<direction_end>

该方向的终点,作为对齐基准。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#ltr.end() \

#rtl.end() \

#ttb.end() \

#btt.end()

```

  ],[

    #set align(horizon)

    #image("images/6040.png",width: auto)]

)

```typst

self.end() → alignment

```

- *inv*<direction_inv>

相反方向。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#ltr.inv() \

#rtl.inv() \

#ttb.inv() \

#btt.inv()

```

  ],[

    #set align(horizon)

    #image("images/6041.png",width: auto)]

)

```typst

self.inv() → direction

```



== 小数(fraction)<fraction>



定义布局中剩余空间的分配方式。



每个按比例分配尺寸的元素,将根据自身比例值与所有比例值总和的比值来获取空间。



更多详情可参见 h、v 函数以及 grid 函数。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

Left #h(1fr) Left-ish #h(2fr) Right

```

  ],[

    #set align(horizon)

    #image("images/6042.png",width: auto)]

)



== 网格(grid)<grid>

以网格形式排布内容。



网格元素可让你将内容按网格排布。你可以定义行数与列数,同时设置行列之间的间距大小。行列支持多种尺寸模式,可用来创建复杂布局。



网格元素与表格元素虽然功能很相似,但二者适用场景不同,语义含义也不一样。网格元素用于展示和页面布局;而#link(<table>)[表格]元素,广义上来说,用于展示多条相关数据。在其中一种元素上设置并启用的规则不会影响另一种元素。请查阅#link(<grid_Accessibility>)[无障碍章节],了解屏幕阅读器等辅助技术(AT)会如何向用户呈现网格与表格。

=== 确定轨道尺寸(Sizing the tracks)<grid_Sizing-the-tracks>

网格的尺寸由参数中指定的轨道大小决定。包含多项尺寸参数:#link(<grid_columns>)[列]、#link(<grid_rows>)[行]与#link(<grid_gutter>)[间距]。由于各项尺寸参数可接收的值相同,我们在此统一说明。每个尺寸参数接收一组独立的轨道尺寸数组。轨道尺寸可为以下类型之一:

#set par(hanging-indent: 1.3cm)

-- #rtext()[auto]:轨道尺寸将自适应容纳其内容,最大不超过剩余空间。若存在多个#rtext()[auto]轨道宽度,且它们所需空间总和超出可用空间,则这些#rtext()[auto]轨道会平分可用空间。



-- 固定长度或相对长度(例如 #rtext()[10pt] 或 #rtext()[20% - 1cm]):轨道将严格采用该尺寸。



-- 分数长度(例如 #rtext()[1fr]):在所有其他轨道完成尺寸计算后,剩余空间将按照分数比例分配给分数轨道。例如,若有两条分数轨道,每条的值均为#rtext()[1fr],则二者将各占用一半剩余空间。

#set par(hanging-indent: 0cm)



如需指定单条轨道,可省略数组,直接使用单个数值。如需指定多条自动轨道,请输入轨道数量而非数组。例如,```typc columns: 3``` 等价于```typc columns: (auto,auto,auto)```。

=== 示例(Examples)

下面的示例展示了不同的轨道尺寸设置选项。同时演示了如何使用 grid.cell 让单个单元格跨越两条网格轨道。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

// We use `rect` to emphasize the

// area of cells.

#set rect(

  inset: 8pt,

  fill: rgb("e4e5ea"),

  width: 100%,

)



#grid(

  columns: (60pt, 1fr, 2fr),

  rows: (auto, 60pt),

  gutter: 3pt,

  rect[Fixed width, auto height],

  rect[1/3 of the remains],

  rect[2/3 of the remains],

  rect(height: 100%)[Fixed height],

  grid.cell(

    colspan: 2,

    image("tiger.jpg", width: 100%),

  ),

)

```

  ],[

    #set align(horizon)

    #image("images/6043.png",width: auto)]

)

你也可以将字符串或内容数组#link(<arguments_Spreading>)[展开]到网格中,填充网格单元格。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#grid(

  columns: 5,

  gutter: 5pt,

  ..range(25).map(str)

)



```

  ],[

    #set align(horizon)

    #image("images/6044.png",width: auto)]

)

=== 设置网格样式(Styling the grid)<grid_Styling-the-grid>

网格元素与表格元素的工作原理类似。如需实操讲解,请参阅#link(<table>)[表格指南];若只想快速了解概览,请继续阅读。



可通过不同参数自定义网格的外观,以下是其中最重要的几项:

#set par(hanging-indent: 1.3cm)

-- #link(<grid_align>)[align] 用于修改单元格的对齐方式



-- #link(<grid_inset>)[inset] 可选择为单元格添加内边距



-- #link(<grid_fill>)[fill] 用于设置单元格的背景色



-- #link(<grid_stroke>)[stroke] 可选择启用带指定描边样式的网格线

#set par(hanging-indent: 0cm)

为满足不同需求,可以通过多种方式对它们进行设置。



如果需要为单个单元格覆盖上述选项,可以使用 #link(<grid_cell>)[grid.cell] 元素。同样,你可以通过 #link(<grid_hline>)[grid.hline] 和 #link(<grid_vline>)[grid.vline] 元素单独覆盖网格线。



若要为网格配置整体样式,你可以改用以下任意一种方式设置选项:

#set par(hanging-indent: 1.3cm)

-- 单个值,作用于全部单元格。



-- 与每列对应的数值数组。当列数多于数组元素数量时,数组会循环复用。



-- 形如 `(x, y) => value` 的函数。该函数接收单元格的列索引与行索引(索引均从0开始),并返回应用到该单元格的对应值。

#set par(hanging-indent: 0cm)

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#grid(

  columns: 5,



  // By a single value

  align: center,

  // By a single but more complicated value

  inset: (x: 2pt, y: 3pt),

  // By an array of values (cycling)

  fill: (rgb("#239dad50"), none),

  // By a function that returns a value

  stroke: (x, y) => if calc.rem(x + y, 3) == 0 { 0.5pt },



  ..range(5 * 3).map(n => numbering("A", n + 1))

)

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6045.png",width: 80%)

    ]

    )

  ]

)

除此之外,你还可以为网格(grid)以及网格单元格(grid.cell)设置样式规则。特别地,网格单元格(grid.cell)的x、y字段可用于where选择器,从而能够对特定列、特定行或是单独位置的单元格设置样式。



*描边样式优先级(Stroke styling precedence)*



如上所述,设置网格单元格描边有三种方式:通过 grid.cell 的 stroke 字段、使用 grid.hline 和 grid.vline,或是设置网格的 stroke 字段。当存在多项冲突的设置时,hline 和 vline 设置优先级最高,其次是单元格设置,最后是网格设置。



此外,重复显示的网格表头或表尾的描边,优先级高于普通单元格描边。



=== 无障碍性(Accessibility)<grid_Accessibility>

网格不具备任何特殊语义。辅助技术(AT)无法在网格内按单元格进行二维导航。如果你需要展示表格数据,请改用table元素。



辅助技术会按照语义顺序读取网格单元格。通常,该顺序就是你传入网格的顺序。但是,如果你通过grid.cell的x、y参数手动设置单元格位置,单元格将按行读取,在从左向右排版的文档中为从左到右。单元格会在首次遍历到其位置时被读取。



=== 参数(Parameters)

```typc

grid(

    columns: auto int relative fraction array,

    rows: auto int relative fraction array,

    gutter: auto int relative fraction array,

    column-gutter: auto int relative fraction array,

    row-gutter: auto int relative fraction array,

    inset: relative array dictionary function,

    align: auto array function alignment,

    fill: none color gradient tiling array function,

    stroke: none length color gradient stroke tiling array dictionary function,

    children: content,

) → content

```

- *columns*: auto int relative fraction array<grid_columns>

列的尺寸。默认值:```typc ()```。



可以指定一个轨道尺寸数组,或者传入一个整数,以此创建拥有对应数量#text(fill: red,"auto")尺寸列的网格。请注意,与行和间距不同,仅提供单个轨道尺寸将只会生成一列。



更多详情请参阅上文的#link(<grid_Sizing-the-tracks>)[轨道尺寸]部分。

- *rows*: auto int relative fraction array<grid_rows>

行尺寸。默认值:```typc ()```。



如果单元格数量超出定义行所能容纳的数量,则重复最后一行,直至所有单元格都排布完毕。



更多详情请参阅上文的#link(<grid_Sizing-the-tracks>)[轨道尺寸]部分。

- *gutter*: auto int relative fraction array<grid_gutter>

行与列之间的间距。这是将列间距和行间距设为相同值的简写方式。默认值:```typc ()```。



如果间距数量大于已定义的尺寸,将重复使用最后一个间距。



更多详情请参见上方的轨道尺寸章节。

- *column-gutter*: auto int relative fraction array<grid_column-gutter>

列之间的间距。默认值:```typc ()```。

- *row-gutter*: auto int relative fraction array<grid_row-gutter>

行与行之间的间距。默认值:```typc ()```。

- *inset*: relative array dictionary function<grid_inset>

单元格内容的内边距大小。默认值:```typc (:)```。



如需为所有单元格设置统一内边距,可以使用单个长度值作用于全部四边,或是使用包含各边长度的字典。更多详情请参阅#link(<box_inset>)[容器]文档。



如需为不同单元格设置不同内边距,你可以采用以下方式:

#set par(hanging-indent: 1cm)

-- 为全部单元格使用同一个内边距\

-- 使用与每一列对应的内边距数组\

-- 使用函数,将单元格位置映射为对应的内边距

#set par(hanging-indent: 0cm)

更多详情请参考上方#link(<grid_Styling-the-grid>)[样式]部分。



此外,你可以在 #link(<table_inset>)[table.inset] 参数处查看示例。

- *align*: auto array function alignment<grid_align>

如何对齐单元格内容。默认值:```typc auto```。



若设置为auto,则采用外部对齐方式。



你可以通过以下任意一种方式指定对齐方式:

#set par(hanging-indent: 1cm)

-- 为所有单元格设置统一的对齐方式\

-- 使用与每一列对应的对齐方式数组\

-- 使用一个函数,将单元格位置映射为其对齐方式



详细信息请参阅上方的#link(<grid_Styling-the-grid>)[样式]部分。



此外,你可以在 #link(<table_align>)[table.align] 参数处查看示例。

- *fill*: none color gradient tiling array function<grid_fill>

如何填充单元格。默认值:```typc none```。

#set par(hanging-indent: 1.3cm)

可以采用以下方式:



-- 所有单元格使用单一颜色



-- 与每一列对应的颜色数组



-- 将单元格位置映射为对应颜色的函数

#set par(hanging-indent: 0cm)

值得重点说明的是,数组和函数可用于创建条纹网格。更多详情请参阅上方的#link(<grid_Styling-the-grid>)[样式]设置部分。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#grid(

  fill: (x, y) =>

    if calc.even(x + y) { luma(230) }

    else { white },

  align: center + horizon,

  columns: 4,

  inset: 2pt,

  [X], [O], [X], [O],

  [O], [X], [O], [X],

  [X], [O], [X], [O],

  [O], [X], [O], [X],

)

```

  ],[

    #set align(horizon)

    #image("images/6046.png",width: auto)]

)

- *stroke*: none length color gradient stroke tiling array dictionary function<grid_stroke>

如何设置单元格描边。默认值:```typc (:)```。



网格默认没有描边,可通过将此选项设置为目标描边样式来开启。



如果需要绘制能够跨过分隔槽(#link(<grid_gutter>)[gutter]选项生成的单元格间距)的线条,或是覆盖多个特定单元格之间的描边,可在定义网格单元格的同时,设置#link(<grid_hline>)[grid.hline]和#link(<grid_vline>)[grid.vline]中的一项或多项。



如需为所有单元格设置相同描边,可对全部四边使用同一种描边,也可以使用描边字典单独定义每一条边。更多信息请参阅矩形相关文档。

#set par(hanging-indent: 1.5cm)

如需为不同单元格设置各不相同的描边,你可以:\

-- 对所有单元格使用同一种描边\

-- 使用与每一列对应的描边数组\

-- 使用函数,将单元格位置映射为对应的描边

#set par(hanging-indent: 0cm)

更多详情请参考上方的#link(<grid_Styling-the-grid>)[样式]设置章节。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set page(width: 420pt)

#set text(number-type: "old-style")

#show grid.cell.where(y: 0): set text(size: 1.3em)



#grid(

  columns: (1fr, 2fr, 2fr),

  row-gutter: 1.5em,

  inset: (left: 0.5em),

  stroke: (x, y) => if x > 0 { (left: 0.5pt + gray) },

  align: horizon,



  [Winter \ 2007 \ Season],

  [Aaron Copland \ *The Tender Land* \ January 2007],

  [Eric Satie \ *Gymnopedie 1, 2* \ February 2007],



  [],

  [Jan 12 \ *Middlebury College \ Center for the Arts* \ 20:00],

  [Feb 2 \ *Johnson State College Dibden Center for the Arts* \ 19:30],



  [],

  [Skip a week \ #text(0.8em)[_Prepare your exams!_]],

  [Feb 9 \ *Castleton State College \ Fine Arts Center* \ 19:30],



  [],

  [Jan 26, 27 \ *Lyndon State College Alexander Twilight Theater* \ 20:00],

  [

    Feb 17 --- #smallcaps[Anniversary] \

    *Middlebury College \ Center for the Arts* \

    19:00 #text(0.7em)[(for a special guest)]

  ],

)



    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6047.png",width: 100%)

    ]

    )

  ]

)

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set page(height: 13em, width: 26em)



#let cv(..jobs) = grid(

  columns: 2,

  inset: 5pt,

  stroke: (x, y) => if x == 0 and y > 0 {

    (right: (

      paint: luma(180),

      thickness: 1.5pt,

      dash: "dotted",

    ))

  },

  grid.header(grid.cell(colspan: 2)[

    *Professional Experience*

    #box(width: 1fr, line(length: 100%, stroke: luma(180)))

  ]),

  ..{

    let last = none

    for job in jobs.pos() {

      (

        if job.year != last [*#job.year*],

        [

          *#job.company* - #job.role _(#job.timeframe)_ \

          #job.details

        ]

      )

      last = job.year

    }

  }

)



#cv(

  (

    year: 2012,

    company: [Pear Seed & Co.],

    role: [Lead Engineer],

    timeframe: [Jul - Dec],

    details: [

      - Raised engineers from 3x to 10x

      - Did a great job

    ],

  ),

  (

    year: 2012,

    company: [Mega Corp.],

    role: [VP of Sales],

    timeframe: [Mar - Jun],

    details: [- Closed tons of customers],

  ),

  (

    year: 2013,

    company: [Tiny Co.],

    role: [CEO],

    timeframe: [Jan - Dec],

    details: [- Delivered 4x more shareholder value],

  ),

  (

    year: 2014,

    company: [Glorbocorp Ltd],

    role: [CTO],

    timeframe: [Jan - Mar],

    details: [- Drove containerization forward],

  ),

)

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6048.png",width: 100%)\

      #image("images/6049.png",width: 100%)

    ]

    )

  ]

)

- *children*: content

网格单元格中的内容,以及通过 #link(<grid_hline>)[grid.hline] 和 #link(<grid_vline>)[grid.vline] 元素指定的所有额外网格线。



单元格以行优先顺序填充。



=== 定义(Definitions)

- *cell*<grid_cell>

网格中的单元格。你可以在网格的参数列表里使用该函数,以覆盖单个单元格的网格样式属性,或将其手动放置在网格内。你也可以在显示规则中使用该函数,一次性为多个单元格应用指定样式。



例如,您可以为单个单元格覆盖位置和笔画:

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set text(15pt, font: "Noto Sans Symbols 2")

#show regex("[♚-♟︎]"): set text(fill: rgb("21212A"))

#show regex("[♔-♙]"): set text(fill: rgb("111015"))



#grid(

  fill: (x, y) => rgb(

    if calc.odd(x + y) { "7F8396" }

    else { "EFF0F3" }

  ),

  columns: (1em,) * 8,

  rows: 1em,

  align: center + horizon,



  [♖], [♘], [♗], [♕], [♔], [♗], [♘], [♖],

  [♙], [♙], [♙], [♙], [],  [♙], [♙], [♙],

  grid.cell(

    x: 4, y: 3,

    stroke: blue.transparentize(60%)

  )[♙],



  ..(grid.cell(y: 6)[♟],) * 8,

  ..([♜], [♞], [♝], [♛], [♚], [♝], [♞], [♜])

    .map(grid.cell.with(y: 7)),

)



    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6050.png",width: 80%)

    ]

    )

  ]

)

你也可以对 grid.cell 设置显示规则,一次性为所有单元格设置样式。例如,你可以根据单元格的位置来应用样式。更多相关内容请参考 #link(<table_cell>)[table.cell] 元素的示例。

```typc

grid.cell(

    body: content,

    x: auto int,

    y: auto int,

    colspan: int,

    rowspan: int,

    inset: auto relative dictionary,

    align: auto alignment,

    fill: none auto color gradient tiling,

    stroke: none length color gradient stroke tiling dictionary,

    breakable: auto bool,

) → content

```



-- *body*: content



单元格内容。



-- *x*: auto int<grid_cell_x>



单元格所在列(从零开始索引)。此字段可用于显示规则中,根据单元格所在列设置单元格样式。默认值:```typc auto```。



你可以重写该字段,指定单元格需要放置在哪一列。如果未选择行(y),单元格将被放置在该列可用的第一行(从第0行开始);若无可用行,则新建一行。但如果同时指定了x和y,单元格将被放置在该精确位置。若该位置已被占用,会抛出错误(因此,通常建议先定义自定义位置的单元格,再定义自动位置的单元格)。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let circ(c) = circle(

  fill: c,

  width: 5mm,

)



#grid(

  columns: 4,

  rows: 7mm,

  stroke: .5pt + blue,

  align: center + horizon,

  inset: 1mm,



  grid.cell(x: 2, y: 2, circ(aqua)),

  circ(yellow),

  grid.cell(x: 3, circ(green)),

  circ(black),

)



```

  ],[

    #set align(horizon)

    #image("images/6051.png",width: auto)]

)

-- *y*: auto int<grid_cell_y>



单元格所在行(从零开始索引)。此字段可用于显示规则,根据单元格所在行设置单元格样式。默认值:```typc auto```。



你可以重写此字段,指定单元格必须放置在哪一行。如果未选择列(x),单元格将放置在所选定行中可用的第一列(从0号列开始)。若选定行中的所有列均已被占用,则会抛出错误。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let tri(c) = polygon.regular(

  fill: c,

  size: 5mm,

  vertices: 3,

)



#grid(

  columns: 2,

  stroke: blue,

  inset: 1mm,



  tri(black),

  grid.cell(y: 1, tri(teal)),

  grid.cell(y: 1, tri(red)),

  grid.cell(y: 2, tri(orange))

)

```

  ],[

    #set align(horizon)

    #image("images/6052.png",width: auto)]

)

-- *colspan*: int<grid_cell_colspan>



此单元格跨越的列数。默认值:```typc 1```。



-- *rowspan*: int<grid_cell_rowspan>



该单元格所跨的行数。默认值:```typc 1```。



-- *inset*: auto relative dictionary<grid_cell_inset>



单元格的#link(<grid_inset>)[内嵌]覆盖。默认值:```typc auto```。



-- *align*: auto alignment<grid_cell_align>



单元格的对齐覆盖设置。默认值:```typc auto```。



-- *fill*: none auto color gradient tiling<grid_cell_fill>



单元格的填充覆盖。默认值:```typc auto```。



-- *stroke*: none length color gradient stroke tiling dictionary<grid_cell_stroked>



单元格描边覆盖。默认值:```typc (:)```。



-- *breakable*: auto bool<grid_cell_breakable>



该单元格所跨的行是否可以分布在不同页面。取值为auto时,仅跨固定尺寸行的单元格不可分页,而至少跨一行自动尺寸行的单元格支持分页。默认值:```typc auto```。



- *hline*<grid_hline>

网格中的一条水平线。



它会覆盖所有单元格描边,包括通过网格的stroke字段指定的描边。可以跨越由网格的column-gutter选项生成的单元格间距。



该函数的示例可参见#link(<table_hline>)[table.hline]元素。

```typc

grid.hline(

    y: auto int,

    start: int,

    end: none int,

    stroke: none length color gradient stroke tiling dictionary,

    position: alignment,

) → content

```

-- *y*: auto int<grid_hline_y>



水平线放置在该行的上方(从零开始索引)。如果position字段设置为bottom,则该线条会放置在指定索引行的下方(详见#link(<grid_hline_position>)[grid.hline.position])。



设置为auto时,线条将置于网格子元素里,位于该线条之前、最后一个自动定位单元格(即没有坐标覆盖的单元格)的下一行。若线条前方不存在这类单元格,则线条放置在网格最顶部(第0行)。注意:若为此选项填写网格的总行数,这条水平线会覆盖网格的下边框;而取值为0时,则会覆盖上边框。默认值:```typc auto```。



-- *start*: int<grid_hline_start>



水平线起始的列(从零开始索引,包含该列)。默认值:```typc 0```。



-- *end*: none int<grid_hline_end>



水平线终止所在列(从零开始索引,不包含该列)。也就是说,水平线将绘制到 end - 1 列并贯穿该列。默认值:```typc none```。



若取值为 none 或等于总列数,则水平线会一直延伸至网格末尾。



-- *stroke*: none length color gradient stroke tiling dictionary<grid_hline_stroke>



线条的描边。默认值:```typc 1pt+black```。



指定为无会移除先前在该线条范围内绘制的所有线条,包括水平横线或其下方单元格描边。



-- *position*: alignment<grid_hline_position>



给定线条所在行(y),确定线条的放置位置:可选顶部(绘制在该行上方)或底部(绘制在该行下方)。默认值:```typc top```。



该设置仅在启用行间距时生效(其他情况下不建议使用,可直接将y字段值加1来实现),因为启用行间距后,某一行下方的位置与下一行上方的位置会因两者之间的间隔而有所差异。



- *vline*<grid_vline>

网格中的竖线。



它会覆盖所有单元格描边,包括通过网格的stroke字段指定的描边。该竖线可以穿过由网格row-gutter选项生成的单元格间距区域。

```typc

grid.hline(

    x: auto int,

    start: int,

    end: none int,

    stroke: none length color gradient stroke tiling dictionary,

    position: alignment,

) → content

```

-- *x*: auto int<grid_vline_x>



竖线放置在该列之前(采用从零开始的索引)。如果position字段设置为end,则该线条会放置在指定索引列的后方(详见#link(<grid_vline_position>)[grid.vline.position])。默认值:```typc auto```。



设置为#text(fill: red,"auto")时,线条将放置在网格子元素中、线条前方最后一个自动定位单元格(即未手动指定坐标的单元格)的后一列。若线条前方不存在这类单元格,则线条置于网格首列(第0列)之前。请注意:当该选项的值恰好等于网格总列数时,这条竖线会覆盖网格的末端边框(从左到右布局下为右侧,从右到左布局下为左侧);而取值为0时,会覆盖起始边框(从左到右布局下为左侧,从右到左布局下为右侧)。



-- *start*: int<grid_vline_start>



竖线起始所在行(从零开始索引,包含该行)。默认值:```typc 0```。



-- *end*: none int<grid_vline_end>



竖线终止所在的行(从零开始索引,不包含该行)。因此,竖线会绘制至 end - 1 行并贯穿该行。默认值:```typc none```。



取值为 none 或等于总行数时,竖线将一直延伸到网格底部。



-- *stroke*: none length color gradient stroke tiling dictionary<grid_vline_stroke>



线条的描边。默认值:```typc 1pt+black```。



指定为无会清除此前在该线条范围内绘制的所有线条,包括垂直线或其下方的单元格描边。



-- *position*: alignment<grid_vline_position>



线条的放置位置,由其所在列(x)决定——可以选择在该列之前开始绘制,或是在该列之后结束绘制。默认值:```typc start```。



也支持使用 left 和 right 值,但不推荐,因为这会导致网格在从左到右和从右到左的文档中出现不一致。



该设置仅在启用列间距时生效(其他情况下不应使用,建议直接将x字段加1即可),因为启用列间距后,受两列之间空隙的影响,一列结束后的位置与下一列开始前的位置不再相同。



- *header* 

可重复的网格表头。



如果repeat设置为true,表头将跨页面重复显示。示例可参考#link(<table_header>)[table.header]元素以及#link(<grid_stroke>)[grid.stroke]参数。

```typc

grid.header(

    repeat: bool,

    level: int,

    children:..content,

) → content

```

-- *repeat*: bool



此表头是否需要跨页重复显示。默认值:```typc true```。



-- *level*: int



标题的层级,不得为零。默认值:```typc 1```。



该设置支持一次性重复多个标题。不同层级的标题可一起重复,前提是层级呈升序排列。



值得注意的是,当更低层级的标题开始重复时,所有更高层级或同等层级的标题将停止重复(它们会被新标题“替换”)。



-- *children*: content



表头内的单元格与线条。



- *footer* 

可重复网格页脚。



与grid.header元素类似,该页脚可以在网格的每一页重复显示。



页脚之后不能放置任何其他网格单元格。

```typc

grid.footer(

    repeat: bool,

    children:..content,

) → content

```

-- *repeat*: bool



是否在所有页面重复显示该页脚。默认值:```typc true```。



-- *children*: content



页脚内的单元格和线条。



== 隐藏(hide)<hide>

隐藏内容但不改变布局。



hide函数可以隐藏内容,布局仍能“识别”到该内容。这适合创建和某些内容大小完全一致的空白区域。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

Hello Jane \

#hide[Hello] Joe

```

  ],[

    #set align(horizon)

    #image("images/6053.png",width: auto)]

)

=== 修订(Redaction)<hide_Redaction>

此函数在编辑内容时可能也很有用,因为其参数既不会直观显示,也无法被辅助技术访问。话虽如此,隐藏的内容仍可能留下一些痕迹(例如PDF文档大纲中的书签标题)。



请注意,根据具体情况,有可能根据布局中的内容大小对其进行逆向工程。因此,我们不建议使用此功能来隐藏高度敏感的信息。

=== 参数(Parameters)

```typc

    hide(body: content) → content

```

- *body*: content

需要隐藏的内容。



== 布局(layout)<layout>

提供对当前外部容器(若无容器则为页面)尺寸(宽度和高度)的访问能力。



接收一个函数,该函数接收单个参数,此参数是包含 width 和 height 键的字典,二者均为#link(<length>)[长度]类型。该函数自带#link(<Context>)[上下文],即无需搭配 context 关键字使用。这也是下方示例中可以调用 #link(<measure>)[measure] 的原因。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let text = lorem(30)

#layout(size => [

  #let (height,) = measure(

    width: size.width,

    text,

  )

  This text is #height high with

  the current page width: \

  #text

])

```

  ],[

    #set align(horizon)

    #image("images/6054.png",width: auto)]

)

请注意,布局函数会将其内容强制放入一个块级容器中,因此无法在该容器内部设置相对于页面或分页符的位置。



如果布局调用置于一个宽#rtext()[800pt]、高#rtext()[400pt]的盒子内,那么指定函数会收到参数(宽度:#rtext()[800pt],高度:#rtext()[400pt])。如果直接放在页面中,它获取的是页面尺寸减去页边距后的数值。该特性大多配合尺寸测量使用。



若要获取页面的剩余高度而非页面总尺寸,可以将布局调用包裹在 ```typc block(height: 1fr)``` 中。其原理是该块会自动拉伸以填满剩余空间(更多细节可参阅#link(<fraction>)[分数]单位文档)。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(height: 150pt)



#lorem(20)



#block(height: 1fr, layout(size => [

  Remaining height: #size.height

]))

```

  ],[

    #set align(horizon)

    #image("images/6055.png",width: auto)]

)



你也可以使用该函数将比例换算为固定长度。当你在构建自定义布局抽象层时,这个功能会很有用。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#layout(size => {

  let half = 50% * size.width

  [Half a page is #half wide.]

})

```

  ],[

    #set align(horizon)

    #image("images/6056.png",width: auto)]

)

请注意:如果对应的页面尺寸设置为#rtext()[auto],布局所提供的宽度或高度将为无限值。



=== 参数(Parameters)

```typc

layout(func: function) → content

```

- *func*:function

接收外部容器尺寸并执行调用的函数。该函数的返回值会显示在文档中。



容器尺寸以字典形式提供,包含 width(宽度)和 height(高度)两个键,二者均为长度类型。



每当 layout 返回的内容在文档中渲染一次,该函数就会被调用一次。利用这一特性,可以生成依赖容器尺寸的内容。



== 长度(length)<length>

尺寸或距离,可附带上下文单位进行表示。

Typst支持以下长度单位:



-- 磅:72pt



-- 毫米:254mm



-- 厘米:2.54cm



-- 英寸:1in



-- 相对于字体大小:2.5em



你可以对长度乘以或除以整数与浮点数。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rect(width: 20pt)

#rect(width: 2em)

#rect(width: 1in)



#(3em + 5pt).em \

#(20pt).em \

#(40em + 2pt).abs \

#(5em).abs

```

  ],[

    #set align(horizon)

    #image("images/6057.png",width: auto)]

)

=== 域(Fields)<length_fields>

-- abs:仅包含当前长度绝对部分的长度(即排除em分量)。



-- em:此长度中的em单位数量,为浮点数。



=== 定义(Definitions)

- *pt*<length_pt>

将此长度转换为磅值。



若该长度包含非零em单位(例如 5em + 2pt,而非仅 2pt),则会报错。可使用 abs 字段(例如 (5em + 2pt).abs.pt())忽略长度中的em部分(仅转换其绝对分量)。



```typc

self.pt() → float

```



- *mm*<length_mm>

将此长度转换为毫米。



若该长度包含非零em单位,则会报错。更多详情请参见pt方法。

```typc

self.mm() → float

```

- *cm*<length_cm>

将此长度转换为厘米。



如果该长度包含非零em单位,则会报错。更多详情请参阅pt方法。

```typc

self.cm() → float

```



- *inches*<length_inches>

将此长度转换为英寸。



如果此长度包含非零 em 单位,则执行失败并报错。更多详情请参见 #link(<length_pt>)[pt] 方法。

- *to-absolute*<length_to-absolute>

将该长度解析为绝对长度。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set text(size: 12pt)

#context [

  #(6pt).to-absolute() \

  #(6pt + 10em).to-absolute() \

  #(10em).to-absolute()

]



#set text(size: 6pt)

#context [

  #(6pt).to-absolute() \

  #(6pt + 10em).to-absolute() \

  #(10em).to-absolute()

]

```

  ],[

    #set align(horizon)

    #image("images/6058.png",width: auto)]

)

```typc

self.to-absolute() → length

```



== 测量(measure)<measure>

测量内容完成布局后的尺寸。



measure函数用于获取内容完成布局后的尺寸。默认情况下会假定空间无限大,因此测量得到的尺寸不一定和内容最终的实际尺寸一致。如果你希望基于当前布局尺寸进行测量,可以将measure与#link(<layout>)[layout]配合使用。

=== 示例(Example)

同样的内容,尺寸会随其所处的上下文环境而变化。在下面的示例中,当我们增大字体大小时,#link(<content>)[content]区域自然会变大。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let content = [Hello!]

#content

#set text(14pt)

#content

```

  ],[

    #set align(horizon)

    #image("images/6059.png",width: auto)]

)

因此,只有在具备上下文的情况下,你才能进行测量。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let thing(body) = context {

  let size = measure(body)

  [Width of "#body" is #size.width]

}



#thing[Hey] \

#thing[Welcome]

```

  ],[

    #set align(horizon)

    #image("images/6060.png",width: auto)]

)

measure函数会返回一个包含width和height项的字典,两项均为#link(<length>)[长度]类型。

=== 参数(Parameters)

```typc

measure(

    width: auto length,

    height: auto length,

    content: content,

) → dictionary

```

- *width*: auto length

用于布局内容的可用宽度。默认值:```typc auto```。



将此项设为auto代表可用宽度为无限大。



注意:使用该函数的宽度和高度参数,与测量包含内容的定尺寸区#link(<block>)[块]有所不同。在下面的示例中,前者获取的是内部内容的尺寸,而非区块本身的尺寸。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#context measure(lorem(100), width: 400pt)



#context measure(block(lorem(100), width: 400pt))

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6061.png",width: 80%)

    ]

    )

  ]

)

- *height*: auto length

可用于布局内容的可用高度。默认值:```typc auto```。



将此项设置为auto表示可用高度为无限。

- *content*: content

待测量大小的内容。



== 移动(move)<move>

移动内容而不影响布局。



move函数支持移动内容,同时布局仍“认为”该内容位于原始位置。容器的尺寸计算方式保持不变,如同内容未被移动。



=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rect(inset: 0pt, fill: gray, move(

  dx: 4pt, dy: 6pt,

  rect(

    inset: 8pt,

    fill: white,

    stroke: black,

    [Abra cadabra]

  )

))

```

  ],[

    #set align(horizon)

    #image("images/6062.png",width: auto)]

)

=== 无障碍性(Accessibility)

移动效果对辅助技术(AT)是透明的。无论视觉上如何移动,辅助技术都会按照内容在源文件中的显示顺序读取内容。如果在导出PDF时需要让辅助技术完全忽略某部分内容,可以考虑使用pdf.artifact。

=== 参数(Parameters)

```typc

move(

    dx: relative,

    dy: relative,

    body: content,

) → content

```

- *dx*: relative

内容的水平位移。默认值:```typc 0%+0pt```。

- *dy*: relative

内容的垂直位移。默认值:```typc 0%+0pt```。

- *body*: content

待移动的内容。



== 边距(pad)<pad>

为内容四周添加间距。



可以单独设置每一侧的间距,也可以通过指定位置参数一次性设置全部四个侧边的间距。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set align(center)



#pad(x: 16pt, image("typing.jpg"))

_Typing speeds can be

 measured in words per minute._

```

  ],[

    #set align(horizon)

    #image("images/6063.png",width: auto)]

)

=== 参数(Parameters)

```typc

pad(

    left: relative,

    top: relative,

    right: relative,

    bottom: relative,

    x: relative,

    y: relative,

    rest: relative,

    body: content,

) → content

```

- *left*: relative<pad_left>

左侧的内边距。默认值:```typc 0%+0pt```。

- *top*: relative<pad_top>

顶部的内边距。默认值:```typc 0%+0pt```。

- *right*: relative<pad_right>

右侧的内边距。默认值:```typc 0%+0pt```。

- *bottom*: relative<pad_bottom>

底部的内边距。默认值:```typc 0%+0pt```。

- *x*: relative<pad_x>

一种将左侧和右侧设为相同值的简写方式。默认值:```typc 0%+0pt```。

- *y*: relative<pad_y>

可同时将上边距和下边距设为相同值的简写方式。默认值:```typc 0%+0pt```。

- *rest*: relative<pad_rest>

一种简写方式,可将四条边设置为相同的值。默认值:```typc 0%+0pt```。

- *body*: content<pad_body>

需要在两侧填充的内容。



== 页面(page)<page>

将其子元素布局到一页或多页上。



虽然该函数主要在集合规则中用于设置页面属性,但也可以用来将参数内容显式渲染到一组独立页面中。



页面的宽度或高度可以设置为auto。在这种情况下,页面会沿对应轴自动延展以适配内容。



页面设置指南讲解了如何使用本函数及相关函数来配置文档,并附带大量示例。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page("us-letter")



There you go, US friends!

```

  ],[

    #set align(horizon)

    #image("images/6064.png",width: auto)]

)

=== 无障碍(Accessibility)

屏幕阅读器等辅助技术(AT)无法读取页面页眉、页脚、前景和背景中的内容,辅助技术仅会读取页面主体部分。请勿将文档其他位置未包含的重要信息放置在这些区域。

=== 样式(Styling)<page_Styling>

请注意,页面元素无法通过显示规则设定目标;编写 show page: .. 不会产生任何效果。若要在每一页重复显示内容,你可以改用 set 规则配置页眉、页脚、背景和前景属性。



=== 参数(Parameters)

```typc

page(

paper: str,

width: auto length,

height: auto length,

flipped: bool,

margin: auto relative dictionary,

bleed: relative dictionary,

binding: auto alignment,

columns: int,

fill: none auto color gradient tiling,

numbering: none str function,

supplement: none auto content,

number-align: alignment,

header: none auto content,

header-ascent: relative,

footer: none auto content,

footer-descent: relative,

background: none content,

foreground: none content,

body: content,

) → content

```

- *paper*: str<page_paper>

用于设置宽高的标准纸张尺寸。默认值:```typc "a4"```。



这只是设置宽高的简写形式,因此无法在上下文表达式中获取该值。

#table(

  columns: (1fr,1.5fr),

  align: left,

  stroke: none,

  table.header([Variant],[Details]),

  table.hline(),

  ["a0"],[尺寸为841.0 × 1189.0毫米的纸张。],

["a1"],[尺寸为594.0 × 841.0毫米的纸张。],

["a2"],[尺寸为420.0 × 594.0毫米的纸张。],

["a3"],[尺寸为297.0 × 420.0毫米的纸张。],

["a4"],[尺寸为210.0 × 297.0毫米的纸张。],

["a5"],[尺寸为148.0 × 210.0毫米的纸张。],

["a6"],[尺寸为105.0 × 148.0毫米的纸张。],

["a7"],[尺寸为74.0 × 105.0毫米的纸张。],

["a8"],[尺寸为52.0 × 74.0毫米的纸张。],

["a9"],[尺寸为37.0 × 52.0毫米的纸张。],

["a10"],[尺寸为26.0 × 37.0毫米的纸张。],

["a11"],[尺寸为18.0 × 26.0毫米的纸张。],

["iso-b1"],[尺寸为707.0 × 1000.0毫米的纸张。],

["iso-b2"],[尺寸为500.0 × 707.0毫米的纸张。],

["iso-b3"],[尺寸为353.0 × 500.0毫米的纸张。],

["iso-b4"],[尺寸为250.0 × 353.0毫米的纸张。],

["iso-b5"],[尺寸为176.0 × 250.0毫米的纸张。],

["iso-b6"],[尺寸为125.0 × 176.0毫米的纸张。],

["iso-b7"],[尺寸为88.0 × 125.0毫米的纸张。],

["iso-b8"],[尺寸为62.0 × 88.0毫米的纸张。],

["iso-c3"],[尺寸为324.0 × 458.0毫米的纸张。],

["iso-c4"],[尺寸为229.0 × 324.0毫米的纸张。],

["iso-c5"],[尺寸为162.0 × 229.0毫米的纸张。],

["iso-c6"],[尺寸为114.0 × 162.0毫米的纸张。],

["iso-c7"],[尺寸为81.0 × 114.0毫米的纸张。],

["iso-c8"],[尺寸为57.0 × 81.0毫米的纸张。],

["din-d3"],[尺寸为272.0 × 385.0毫米的纸张。],

["din-d4"],[尺寸为192.0 × 272.0毫米的纸张。],

["din-d5"],[尺寸为136.0 × 192.0毫米的纸张。],

["din-d6"],[尺寸为96.0 × 136.0毫米的纸张。],

["din-d7"],[尺寸为68.0 × 96.0毫米的纸张。],

["din-d8"],[尺寸为48.0 × 68.0毫米的纸张。],

["sis-g5"],[尺寸为169.0 × 239.0毫米的纸张。],

["sis-e5"],[尺寸为115.0 × 220.0毫米的纸张。],

["ansi-a"],[尺寸为216.0 × 279.0毫米的纸张。],

["ansi-b"],[尺寸为279.0 × 432.0毫米的纸张。],

["ansi-c"],[尺寸为432.0 × 559.0毫米的纸张。],

["ansi-d"],[尺寸为559.0 × 864.0毫米的纸张。],

["ansi-e"],[尺寸为864.0 × 1118.0毫米的纸张。],

["arch-a"],[尺寸为229.0 × 305.0毫米的纸张。],

["arch-b"],[尺寸为305.0 × 457.0毫米的纸张。],

["arch-c"],[尺寸为457.0 × 610.0毫米的纸张。],

["arch-d"],[尺寸为610.0 × 914.0毫米的纸张。],

["arch-e1"],[尺寸为762.0 × 1067.0毫米的纸张。],

["arch-e"],[尺寸为914.0 × 1219.0毫米的纸张。],

["jis-b0"],[尺寸为1030.0 × 1456.0毫米的纸张。],

["jis-b1"],[尺寸为728.0 × 1030.0毫米的纸张。],

["jis-b2"],[尺寸为515.0 × 728.0毫米的纸张。],

["jis-b3"],[尺寸为364.0 × 515.0毫米的纸张。],

["jis-b4"],[尺寸为257.0 × 364.0毫米的纸张。],

["jis-b5"],[尺寸为182.0 × 257.0毫米的纸张。],

["jis-b6"],[尺寸为128.0 × 182.0毫米的纸张。],

["jis-b7"],[尺寸为91.0 × 128.0毫米的纸张。],

["jis-b8"],[尺寸为64.0 × 91.0毫米的纸张。],

["jis-b9"],[尺寸为45.0 × 64.0毫米的纸张。],

["jis-b10"],[尺寸为32.0 × 45.0毫米的纸张。],

["jis-b11"],[尺寸为22.0 × 32.0毫米的纸张。],

["sac-d0"],[尺寸为764.0 × 1064.0毫米的纸张。],

["sac-d1"],[尺寸为532.0 × 760.0毫米的纸张。],

["sac-d2"],[尺寸为380.0 × 528.0毫米的纸张。],

["sac-d3"],[尺寸为264.0 × 376.0毫米的纸张。],

["sac-d4"],[尺寸为188.0 × 260.0毫米的纸张。],

["sac-d5"],[尺寸为130.0 × 184.0毫米的纸张。],

["sac-d6"],[尺寸为92.0 × 126.0毫米的纸张。],

["iso-id-1"],[尺寸为85.6 × 53.98毫米的纸张。],

["iso-id-2"],[尺寸为74.0 × 105.0毫米的纸张。],

["iso-id-3"],[尺寸为88.0 × 125.0毫米的纸张。],

["asia-f4"],[尺寸为210.0 × 330.0毫米的纸张。],

["jp-shiroku-ban-4"],[尺寸为264.0 × 379.0毫米的纸张。],

["jp-shiroku-ban-5"],[尺寸为189.0 × 262.0毫米的纸张。],

["jp-shiroku-ban-6"],[尺寸为127.0 × 188.0毫米的纸张。],

["jp-kiku-4"],[尺寸为227.0 × 306.0毫米的纸张。],

["jp-kiku-5"],[尺寸为151.0 × 227.0毫米的纸张。],

["jp-business-card"],[尺寸为91.0 × 55.0毫米的纸张。],

["cn-business-card"],[尺寸为90.0 × 54.0毫米的纸张。],

["eu-business-card"],[尺寸为85.0 × 55.0毫米的纸张。],

["fr-tellière"],[尺寸为340.0 × 440.0毫米的纸张。],

["fr-couronne-écriture"],[尺寸为360.0 × 460.0毫米的纸张。],

["fr-couronne-édition"],[尺寸为370.0 × 470.0毫米的纸张。],

["fr-raisin"],[尺寸为500.0 × 650.0毫米的纸张。],

["fr-carré"],[尺寸为450.0 × 560.0毫米的纸张。],

["fr-jésus"],[尺寸为560.0 × 760.0毫米的纸张。],

["uk-brief"],[尺寸为406.4 × 342.9毫米的纸张。],

["uk-draft"],[尺寸为254.0 × 406.4毫米的纸张。],

["uk-foolscap"],[尺寸为203.2 × 330.2毫米的纸张。],

["uk-quarto"],[尺寸为203.2 × 254.0毫米的纸张。],

["uk-crown"],[尺寸为508.0 × 381.0毫米的纸张。],

["uk-book-a"],[尺寸为111.0 × 178.0毫米的纸张。],

["uk-book-b"],[尺寸为129.0 × 198.0毫米的纸张。],

["us-letter"],[尺寸为215.9 × 279.4毫米的纸张。],

["us-legal"],[尺寸为215.9 × 355.6毫米的纸张。],

["us-tabloid"],[尺寸为279.4 × 431.8毫米的纸张。],

["us-executive"],[尺寸为184.15 × 266.7毫米的纸张。],

["us-foolscap-folio"],[尺寸为215.9 × 342.9毫米的纸张。],

["us-statement"],[尺寸为139.7 × 215.9毫米的纸张。],

["us-ledger"],[尺寸为431.8 × 279.4毫米的纸张。],

["us-oficio"],[尺寸为215.9 × 340.36毫米的纸张。],

["us-gov-letter"],[尺寸为203.2 × 266.7毫米的纸张。],

["us-gov-legal"],[尺寸为215.9 × 330.2毫米的纸张。],

["us-business-card"],[尺寸为88.9 × 50.8毫米的纸张。],

["us-digest"],[尺寸为139.7 × 215.9毫米的纸张。],

["us-trade"],[尺寸为152.4 × 228.6毫米的纸张。],

["newspaper-compact"],[尺寸为280.0 × 430.0毫米的纸张。],

["newspaper-berliner"],[尺寸为315.0 × 470.0毫米的纸张。],

["newspaper-broadsheet"],[尺寸为381.0 × 578.0毫米的纸张。],

["presentation-16-9"],[尺寸为297.0 × 167.0625毫米的纸张。],

["presentation-4-3"],[尺寸为280.0 × 210.0毫米的纸张。],

)

- *width*: auto length<page_width>

应用所有裁切后最终页面的宽度。默认值:```typc 595.28pt```。



在专业印刷设置中,该尺寸可能小于送入打印机的纸张尺寸。



有关如何设置裁切或溢出区域的详细信息,请参阅溢出参数。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(

  width: 3cm,

  margin: (x: 0cm),

)



#for i in range(3) {

  box(square(width: 1cm))

}

```

  ],[

    #set align(center)

    #image("images/6065.png",width: auto)]

)

- *height*: auto length<page_height>

应用所有裁切设置后的最终页面区域高度。默认值:```typc 841.89pt```。



如果该项设置为auto,则仅能通过插入分页符或添加其他非空页面集规则手动触发分页。本文档中的大多数示例都将页面高度设为auto,以便页面可动态伸缩来适配内容。

- *flipped*: bool<page_flipped>

页面是否翻转至横向方向。默认值:```typc false```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(

  "us-business-card",

  flipped: true,

  fill: rgb("f2e5dd"),

)



#set align(bottom + end)

#text(14pt)[*Sam H. Richards*] \

_Procurement Manager_



#set text(10pt)

23 W 23rd Street \

New York, NY 10010 \

+1 (212) 555-0155

```

  ],[

    #set align(center)

    #image("images/6066.png",width: auto)]

)

- *margin*: auto relative dictionary<page_margin>\ 页面的边距。默认值:```typc auto```。

  - #rtext()[auto]:边距自动设置为页面较小边长的2.5/21。对于A4页面,该设置会得到2.5厘米的边距。

  - 单一长度值:四周使用相同的边距。

  - 字典:使用字典可以分别设置各边边距。字典可包含以下键,优先级依次为:

    - 上边(top):上边距。

    - 右边(right):右边距。

    - 下边(bottom):下边距。

    - 左边(left):左边距。

    - 内侧(inside):页面内侧边距(装订所在一侧)。

    - 外侧(outside):页面外侧边距(与装订侧相对)。

    - x:水平边距。

    - y:垂直边距。

    - 其余(rest):除字典中明确指定尺寸之外所有方向的边距。

  

所有键均为可选项;省略的键将使用其先前设置的值,如果从未设置过,则使用默认边距。此外,left(左侧)和right(右侧)的值与inside(内侧)和outside(外侧)的值互斥。取值应为相对长度或auto。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(

 width: 3cm,

 height: 4cm,

 margin: (x: 8pt, y: 4pt),

)



#rect(

  width: 100%,

  height: 100%,

  fill: aqua,

)

```

  ],[

    #set align(center)

    #image("images/6067.png",width: auto)]

)

- *bleed*: relative dictionary<page_bleed>\ 页面的溢出边距。默认值:```typc (:)```。\ 溢出区是指超出页面最终裁剪尺寸的内容区域。它确保即使发生微小的裁剪偏差,最终产品也不会出现未打印的边缘。\ 可接受值:

  - 单倍长度:四周溢出量相同。

  - 字典:使用字典,可以单独设置溢出边距。字典可能包含以下键,按优先级顺序列出:

    - 顶部(top):顶部溢出边距。

    - 右侧(right):右侧溢出边距。

    - 底部(bottom):底部溢出边距。

    - 左侧(left):左侧溢出边缘。

    - 内侧(inside):页面内侧(#link(<page_binding>)[装订处])的溢出边距。

    - 外侧(outside):页面外侧(与装订处相对)的溢出边距。

    - x:水平溢出边距。

    - y:垂直溢出边距。

    - 其余(rest):除词典明确设定尺寸的边外,其余各边均留有溢出边距。



所有键均为可选键;省略的键将使用其之前设置的值,如果从未设置,则使用0pt。此外,left和right的值与inside和outside的值互斥。这些值应为相对长度。

在PDF导出中,如果溢出区域非零,则会为页面定义一个裁剪框。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set page(

  width: 8cm,

  height: 5cm,

  margin: 1cm,

  // The bleed is not visible in the preview;

  // it exceeds beyond the page.

  bleed: 0.5cm,

  // Fills the entire bleed area, so there will

  // be no white strips after printing and trimming.

  background: rect(width: 100%, height: 100%, fill: aqua),

)



#rect(width: 100%, height: 100%, fill: white)



    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6068.png",width: 80%)

    ]

    )

  ]

)

- *binding*: auto alignment<page_binding>\ 页面将在哪一侧装订。默认值:```typc auto```。

  - 自动:文本从左向右排版时等同于左侧;文本从右向左排版时等同于右侧。

  - 左侧:在左侧装订。

  - 右侧:在右侧装订。

该设置会影响内边距和外边距选项的含义。

- *columns*: int<page_columns>

该页面有多少列。默认值:```typc 1```。



如果需要在页面或其他容器中插入多列,也可以使用#link(<columns>)[分栏函数]。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(columns: 2, height: 4.8cm)

Climate change is one of the most

pressing issues of our time, with

the potential to devastate

communities, ecosystems, and

economies around the world. It's

clear that we need to take urgent

action to reduce our carbon

emissions and mitigate the impacts

of a rapidly changing climate.

```

  ],[

    #set align(horizon)

    #image("images/6069.png",width: auto)]

)

- *fill*: none auto color gradient tiling<page_fill>

页面的背景填充。默认值:```typc auto```。



将此项设置为非透明颜色时,会告知打印机对整页进行着色。如果考虑大批量印刷,采购预染色纸张、不设置此属性会更加环保且划算。



设为none时,背景变为透明。请注意,PDF页面在查看器中依旧会显示(通常为白色的)背景,但它们实际上是透明的。(打印时,背景不会使用任何色彩。)



默认值auto在输出PDF时等同于none,输出PNG和SVG时等同于白色。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(fill: rgb("444352"))

#set text(fill: rgb("fdfdfd"))

*Dark mode enabled.*

```

  ],[

    #set align(horizon)

    #image("images/6070.png",width: auto)]

)

- *numbering*: none str function<page_numbering>\ 如何对页面进行编号。你可以参考页面设置指南来自定义页码。默认值:```typc none```。\ 支持编号样式,或是接收一个或两个数值参数的函数:

  + 第一个数值为当前页码。

  + 第二个数值为总页数。在编号样式中,第二个数值可以省略。如果传入函数,在链接或引用场景下该函数接收一个参数;生成可见页码时则接收两个参数。

这些是由页面计数器控制的逻辑页码,因此可能与物理页码不一致。具体来说,它们是 counter(page) 的[当前值]与[最终值]。更多详情请参阅[计数器]文档。



如果指定了显式页脚(顶部对齐编号时则为页眉),则该编号设置会被忽略。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(

  height: 100pt,

  margin: (top: 16pt, bottom: 24pt),

  numbering: "1 / 1",

)



#lorem(48)

```

  ],[

    #set align(horizon)

    #image("images/6071.png",width: auto)\

    #image("images/6072.png",width: auto)

    ]

)

- *supplement*: none auto content<page_supplement>

页面补充说明。默认值:```typc auto```。



在引用页码时,该内容添加于页码之前。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set page(numbering: "1.", supplement: [p.])



= Introduction <intro>

We are on #ref(<intro>, form: "page")!

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6073.png",width: 80%)

    ]

    )

  ]

)

- *number-align*: alignment<page_number-align>

页码的对齐方式。默认值:```typc center+bottom```。



若垂直位置为顶部,则页码放置在页眉;若垂直位置为底部,则页码放置在页脚。不允许设置水平对齐。如果指定了显式匹配的页眉或页脚,则页码设置无效。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(

  margin: (top: 16pt, bottom: 24pt),

  numbering: "1",

  number-align: right,

)



#lorem(30)

```

  ],[

    #set align(horizon)

    #image("images/6074.png",width: auto)]

)

- *header*: none auto content<page_header>\ 页面的页眉。占据每页的上边距区域。默认值:```typc auto```。

  - 内容:将指定内容显示为页眉。

  - 自动:若已设置编号且编号对齐方式为顶部,则显示页码。

  - 无:不显示页眉。

  #table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set par(justify: true)

#set page(

  margin: (top: 32pt, bottom: 20pt),

  header: [

    #set text(8pt)

    #smallcaps[Typst Academy]

    #h(1fr) _Exercise Sheet 3_

  ],

)



#lorem(19)

```

  ],[

    #set align(horizon)

    #image("images/6075.png",width: auto)]

)

- *header-ascent*: relative<page_header-ascent>

页眉向上伸入上边距的距离。该比例相对于上边距的高度。默认值:```typc 30%+0pt```。

- *footer*: none auto content<page_footer>\ 页面的页脚。填充每一页的底部边距。默认值:```typc auto```。

  - 内容:将该内容显示为页脚。

  - 自动:若已设置编号且编号对齐方式为底部,则显示页码。

  - 无:不显示页脚。

仅需要页码时,使用编号属性通常就足够。如果你想创建自定义页脚同时仍然显示页码,可以直接调用页面计数器。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set par(justify: true)

#set page(

  height: 100pt,

  margin: 20pt,

  footer: context [

    #set align(right)

    #set text(8pt)

    #counter(page).display(

      "1 of I",

      both: true,

    )

  ]

)



#lorem(48)

```

  ],[

    #set align(horizon)

    #image("images/6076.png",width: auto)\

    #image("images/6077.png",width: auto)

    ]

)

- *footer-descent*: relative<page_footer-descent>

页脚向下延伸至下边距的距离。该比例相对于下边距的高度。默认值:```typc 30%+0pt```。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6078.png",width: 80%)

    ]

    )

  ]

)

- *background*: none content<page_background>

页面背景中的内容。默认值:```typc none```。



该内容会置于页面主体的后方,可用于放置背景图片或水印。



为方便使用,在背景内容中使用[相对长度]时,会依据包含页面#link(<page_bleed>)[溢出]在内的页面尺寸进行解析。例如,页面宽度为100毫米,溢出位为5毫米,则100%宽度的计算结果为5毫米 + 100毫米 + 5毫米。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(background: rotate(24deg,

  text(18pt, fill: rgb("FFCBC4"))[

    *CONFIDENTIAL*

  ]

))



= Typst's secret plans

In the year 2023, we plan to take

over the world (of typesetting).

```

  ],[

    #set align(horizon)

    #image("images/6079.png",width: auto)]

)

- *foreground*: none content<page_foreground>

页面前景中的内容。默认值:```typc none```。



该内容将覆盖页面主体。



相对长度将依据包含#link(<page_bleed>)[溢出]的页面尺寸进行解析,遵循与#link(<page_background>)[背景]相同的规则。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(foreground: text(24pt)[🤓])



Reviewer 2 has marked our paper

"Weak Reject" because they did

not understand our approach...

```

  ],[

    #set align(horizon)

    #image("images/6080.png",width: auto)]

)

- *body*: content<page_body>

页面内容。



如果内容无法在单页容纳,将会创建多个页面。正文排版完成后,会新建一个页面,该页面保留调用函数前的页面属性。



== 分页(pagebreak)<pagebreak>

手动分页符。



不得在任何容器内部使用。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

The next page contains

more details on compound theory.

#pagebreak()



== Compound Theory

In 1984, the first ...

```

  ],[

    #set align(horizon)

    #image("images/6081.png",width: auto)

    #image("images/6082.png",width: auto)

    ]

)

即使不设置手动分页符,内容也会根据配置的页面尺寸自动分页。你可以将#link(<page_height>)[页面高度]设置为#text(fill: red,"auto"),让页面动态延展,直至遇到手动分页符。



分页机制会尽量避免在页面顶部或底部出现单行文本(这类单行被称为孤行)。你可以调整 #link(<text_costs>)[text.costs] 参数关闭该功能。

=== 参数(Parameters)

```typc

pagebreak(

    weak: bool,

    to: none str,

) → content

```

- *weak*: bool

如果为真(#text(fill: red,"true")),当当前页面已经为空时,将跳过分页符。默认值:```typc false```。

- *to*: none str

如果设置该参数,则可确保下一页为偶数页或奇数页;必要时会在中间插入空白页。默认值:```typc none```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(height: 30pt)



First.

#pagebreak(to: "odd")

Third.



```

  ],[

    #set align(horizon)

    #image("images/6083.png",width: auto)

    #image("images/6084.png",width: auto)

    #image("images/6085.png",width: auto)

    ]

)

#table(

  columns: (1fr,1.5fr),

  align: left,

  stroke: none,

  table.header([Variant],[Details]),

  table.hline(),

  [\"even\"],[下一页将是偶数页。],

  [\"odd\"],[下一页将是奇数页。]

)



== 放置(place)<place>

将内容相对于其父容器进行放置。



被放置的内容可以是叠加模式(默认)或浮动模式。叠加模式的内容会按照指定#link(<place_alignment>)[对齐方式]与父容器对齐,并显示在容器内目前已添加的所有其他内容之上。浮动模式的内容放置在容器的顶部或底部,会相应将其他内容向下或向上挤开。两种模式下,都可通过#link(<place_dx>)[dx]、#link(<place_dy>)[dy]偏移量调整内容位置,且不会影响整体布局。



父元素可以是任意容器,例如#link(<block>)[块]、#link(<box>)[盒子]、矩形等。顶层place调用会直接将内容放置在当前页面的文本区域内,可用于页面上的绝对定位:采用上+左#link(<alignment>)[对齐]时,偏移量dx和dy会以文本区域左上角为基准,设定元素左上角的位置。如果需要在包含页边距的完整页面上实现绝对定位,可在#link(<page_foreground>)[page.foreground]或#link(<page_background>)[page.background]中使用place。

=== 示例(Examples)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(height: 120pt)

Hello, world!



#rect(

  width: 100%,

  height: 2cm,

  place(horizon + right, square()),

)



#place(

  top + left,

  dx: -5pt,

  square(size: 5pt, fill: red),

)

```

  ],[

    #set align(horizon)

    #image("images/6086.png",width: auto)

    ]

)

=== 对其他元素位置的影响(Effect on the position of other elements)

叠加元素不会在内容流中占用空间,但位置调用会在内容流中插入一个不可见的块级元素。这可能会打断当前段落,进而影响布局。为避免该问题,当在段落中间执行位置调用时,可以将位置调用包裹在一个容器内。随后,对齐方式与偏移量将相对于这个零尺寸容器生效。为确保它不会干扰间距,该容器应使用连字符连接符附着在某个字词上。



例如,下面这段代码定义了一个函数,用于将注释附加到后续单词上:

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#let annotate(..args) = {

  box(place(..args))

  sym.wj

  h(0pt, weak: true)

}



A placed #annotate(square(), dy: 2pt)

square in my text.

```

  ],[

    #set align(horizon)

    #image("images/6087.png",width: auto)

    ]

)

零宽弱间距用于舍弃函数调用与下一个单词之间的空格。

=== 参数(Parameters)

```typc

place(

    alignment:auto alignment,

    scope: str,

    float: bool,

    clearance: length,

    dx: relative,

    dy: relative,

    body: content,

) → content

```

- *alignment*: auto alignment<place_alignment>\ 设置内容相对于父容器的放置位置。

  - 若float为#rtext()[false],则该值可设置为除auto以外的任意对齐方式。

  - 若float为#rtext()[true],则该值必须为#rtext()[auto]、top或bottom。

当float为#rtext()[false]且未指定垂直对齐方式时,内容将放置在垂直轴上的当前位置。

- *scope*:  str<place_scope>

某物放置所参照的包含作用域。



父级作用域主要用于图形,正因如此,图形函数设有对应的#link(<figure>)[作用域参数]。不过,它同样可用于更通用的场景,实现跨列排版。典型示例:在双栏文档中#link(<page_guide-Add-columns>)[创建一个通栏的标题区域]。



请注意,父级作用域定位目前仅在浮动(float)开启时支持。该限制未来可能会调整。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(height: 150pt, columns: 2)

#place(

  top + center,

  scope: "parent",

  float: true,

  rect(width: 80%, fill: aqua),

)



#lorem(25)

```

  ],[

    #set align(horizon)

    #image("images/6088.png",width: auto)

    ]

)

#table(

  columns: (0.5fr,1.5fr),

  align: left,

  stroke: none,

  table.header([Variant],[Details]),

  table.hline(),

  [\"column\"],[放入当前列。],

  [\"parent\"],[相对于父元素进行定位,使内容跨所有列显示。]

)

- *float*:  bool<place_float>

所放置元素是否为浮动布局。默认值:```typc false```。



浮动元素位于父容器的顶部或底部,会挤占常规流中的内容。它们之间始终按照常规流顺序摆放,同时会置于后续#link(<place_flush>)[place.flush]元素之后的所有内容之前。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#set page(height: 150pt)

#let note(where, body) = place(

  center + where,

  float: true,

  clearance: 6pt,

  rect(body),

)



#lorem(10)

#note(bottom)[Bottom 1]

#note(bottom)[Bottom 2]

#lorem(40)

#note(top)[Top]

#lorem(10)

```

  ],[

    #set align(horizon)

    #image("images/6089.png",width: auto)

    #image("images/6090.png",width: auto)

    ]

)

- *clearance*:  length<place_clearance>

浮动布局中,已放置元素与其他元素之间的间距。

当float为#rtext()[false]时,该属性不生效。默认值:```typc 1.5em```。

- *dx*:  relative<place_dx>

所放置内容的水平位移。默认值:```typc 0%+0pt```。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set page(height: 100pt)

#for x in range(-8, 8) {

  place(center + horizon,

    dx: x * 8pt, dy: x * 4pt,

    text(

      size: calc.root(x + 10, 3) * 6pt,

      fill: color.mix((green, 8 - x), (blue, 8 + x)),

    )[T]

  )

}

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6091.png",width: 80%)

    ]

    )

  ]

)

这不会影响流式内容的布局。换句话说,放置的内容会被视作包裹在移动元素内进行处理。

- *dy*:  relative<place_dy>

所放置内容的垂直位移。默认值:```typc 0%+0pt```。



这不会影响常规流内内容的布局。换言之,该放置内容的处理方式,如同其被包裹在一个移动元素中。

- *body*:  content<place_body>

待放置的内容。

=== 定义(Definition)

- *flush*<place_flush>

请求布局算法先放置待处理的浮动元素,再继续处理后续内容。

这有助于防止浮动图元溢入下一个章节。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#lorem(15)



#figure(

  rect(width: 100%, height: 50pt),

  placement: auto,

  caption: [A rectangle],

)



#place.flush()



This text appears after the figure.

```

  ],[

    #set align(horizon)

    #image("images/6092.png",width: auto)

    #image("images/6093.png",width: auto)

    ]

)



== 比率(ratio)<ratio>

一个整体的比率。



比率通常以数字形式表示,后面跟一个百分号。比率通常作为#link(<relative>)[相对长度]的一部分出现,用于指定某个布局元素相对于页面或某个容器的尺寸。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rect(width: 25%)

```

  ],[

    #set align(horizon)

    #image("images/6094.png",width: auto)

    ]

)

然而,它们也可以描述任何其他相对于某个基点的属性,例如,[水平缩放量]或#link(<Left_Right_lr_size>)[括号相对于其所包含内容的高度]。

=== 脚本(Scripting)<ratio_Scripting>

在您自己的代码中,您可以随意使用比率。您可以将它们与如下所示的各种其他类型相乘:

#table(

  columns: (1fr,2fr,1fr),

  align: left,

  stroke: none,

  table.header([*Multiply by*],[*Example*],[*Result*]),

  table.hline(),

  [#link(<ratio>)[ratio]],[27% \* 10%],[2.7%],

  [#link(<length>)[length]],[27% \* 100pt],[27pt],

  [#link(<relative>)[relative]],[27% \* (10% + 100pt)],[2.7% + 27pt],

  [#link(<angle>)[angle]],[27% \* 100deg],[27deg],

  [#link(<Integer>)[int]],[27% \* 2],[54%],

  [#link(<float>)[float]],[27% \* 0.37037],[10%],

  [#link(<frac>)[fraction]],[27% \* 3fr],[0.81fr],

)

文档中显示的比率会四舍五入到两位有效数字,以提高可读性。



== 相对长度(relative)<relative>

与某个已知长度相关的长度。



这种类型是#link(<length>)[长度]与#link(<ratio>)[比例]的组合。它通过长度与比例的加减运算得出。在需要相对长度的地方,也可以直接使用单纯的长度或比例。



=== 相对于页面(Relative to the page)

一种常见使用场景是将布局元素(例如#link(<block>)[块]、#[矩形]等)的宽度或高度设置为页面宽度的某个百分比。本例中,矩形的宽度被设置为#rtext()[25%],因此它占据页面内部宽度(总宽度减去边距)的四分之一。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rect(width: 25%)

```

  ],[

    #set align(horizon)

    #image("images/6094.png",width: auto)

    ]

)

在需要相对长度的场景中,纯长度值或比例值始终有效,并且二者可以自由混用:

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rect(width: 25%+1cm)

```

  ],[

    #set align(horizon)

    #image("images/6095.png",width: auto)

    ]

)

页面#link(<page_background>)[背景]与#link(<page_foreground>)[前景]中的内容,其相对长度将参照包含#link(<page_bleed>)[溢出]位的页面尺寸进行解析。做出该选择是出于使用便利的考虑:要创建适配溢出位的背景,本身就需要将背景延伸至溢出区域内。



如果你想调整元素尺寸,使其占满页面的完整宽度,有几种可行方案(具体选用哪一种很大程度上取决于你的实际使用场景):

#set par(hanging-indent: 2cm)

+ 将页面边距设为0磅(```typ #set page(margin: 0pt)```)

+ 用比例乘以已知的页面总宽度(```typc 21cm × 69%```)

+ 使用内边距抵消边距(```typ #pad(x: -2.5cm, ...)```)

+ 使用页面#link(<page_background>)[背景]或#link(<page_foreground>)[前景]字段,这类字段不会计入边距(注意:该方式会让内容脱离文档流渲染,可使用place控制内容位置)

#set par(hanging-indent: 0cm)

=== 相对于容器(Relative to a container)

当布局元素(例如#link(<rect>)[矩形])嵌套在另一个布局容器(例如#link(<block>)[块])中,而不是页面的直接子元素时,相对宽度将相对于该容器计算:

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#block(

  width: 100pt,

  fill: aqua,

  rect(width: 50%),

)

```

  ],[

    #set align(horizon)

    #image("images/6096.png",width: auto)

    ]

)

=== 脚本(Scripting)

你可以将相对长度与比率、整数以及浮点数相乘。



相对长度包含以下字段:



-- length:它的#link(<length>)[长度]分量。



-- ratio:它的#link(<ratio>)[比率]分量。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#(100% - 50pt).length \

#(100% - 50pt).ratio

```

  ],[

    #set align(horizon)

    #image("images/6097.png",width: auto)

    ]

)



== 重复(repeat)<repeat>

在可用空间内重复内容。



这在实现自定义索引、引用或大纲时非常有用。



正文参数的实例之间可以插入空格,因此请务必相应地调整#link(<repeat_justify>)[justify]参数。



如果可用空间没有界限,则会出现错误,因为这会导致内容无限生成。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

Sign on the dotted line:

#box(width: 1fr, repeat[.])



#set text(10pt)

#v(8pt, weak: true)

#align(right)[

  Berlin, the 22nd of December, 2022

]



```

  ],[

    #set align(horizon)

    #image("images/6098.png",width: auto)

    ]

)

=== 无障碍性(Accessibility)

重复的内容会被自动标记为工件,并在辅助技术(AT)中隐藏。请勿使用此功能创建对文档意义有贡献的内容。

=== 参数(Parameters)

```typc

repeat(

    body: content,

    gap: length,

    justify: bool,

) → content

```

- *body*: content<repeat_body>

需要重复的内容。

- *gap*: length<repeat_gap>

实体各个内容之间的间隙。默认值:```typc 0pt```。

- *justify*: bool<repeat_justify>

是否增加实例之间的间距,以完全填满可用空间。默认值:```typc true```。



== 旋转(rotate)<rotate>

在不影响布局的情况下旋转内容。



按指定角度旋转元素。除非设置```typc reflow: true ```,否则布局表现如同该元素未发生旋转。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#stack(

  dir: ltr,

  spacing: 1fr,

  ..range(16)

    .map(i => rotate(24deg * i)[X]),

)



```

  ],[

    #set align(horizon)

    #image("images/6099.png",width: auto)

    ]

)

=== 参数(Parameters)

```typc

rotate(

    angle: angle,

    origin: alignment,

    reflow: bool,

    body: content,

) → content

```

- *angle*: angle<rotate_angle>

旋转量。默认值:```typc 0deg```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#rotate(-1.571rad)[Space!]



```

  ],[

    #set align(horizon)

    #image("images/6100.png",width: auto)

    ]

)

- *origin*: alignment<rotate_origin>

旋转的原点。默认值:```typc center+horizon```。



例如,如果你希望旋转元素的左下角保持与基线对齐,则需要将其设置为下+左。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set text(spacing: 8pt)

#let square = square.with(width: 8pt)



#box(square())

#box(rotate(30deg, origin: center, square()))

#box(rotate(30deg, origin: top + left, square()))

#box(rotate(30deg, origin: bottom + right, square()))



    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6101.png",width: 80%)

    ]

    )

  ]

)

- *reflow*: bool<rotate_reflow>

旋转是否影响布局。默认值:```typc false```。



若设置为#text(fill: red,"false"),旋转后的内容将保留原始内容的边界框。若设置为#text(fill: red,"true"),边界框会将内容的旋转纳入考量,并相应调整布局。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

Hello #rotate(90deg, reflow: true)[World]!

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6102.png",width: 80%)

    ]

    )

  ]

)

- *body*: content

要旋转的内容。



== 缩放(scale)<scale>

缩放内容而不影响布局。



可通过在单个轴上指定负缩放值来镜像内容。

=== 示例(Example)

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

#set align(center)

#scale(x: -100%)[This is mirrored.]

#scale(x: -100%, reflow: true)[This is mirrored.]

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6103.png",width: 80%)

    ]

    )

  ]

)

=== 参数(Parameters)

```typc

scale(

    factor: auto length ratio,

    x: auto length ratio,

    y: auto length ratio,

    origin: alignment,

    reflow: bool,

    body: content,

) → content

```

- *factor*: auto length ratio<scale_factor>

作为位置参数的双轴缩放系数。这只是一种可选的简写形式,用于将x轴与y轴设置为相同数值。默认值:```typc 100%```。

- *x*: auto length ratio<scale_x>

水平缩放系数。默认值:```typc 100%```。



如果该参数为负值,物体会进行水平镜像翻转。

- *y*: auto length ratio<scale_y>

垂直缩放系数。默认值:```typc 100%```。



如果该参数为负值,物体会沿垂直方向镜像翻转。

- *origin*: alignment<scale_origin>

变换的原点。默认值:```typc center+horizon```。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

A#box(scale(75%)[A])A \

B#box(scale(75%, origin: bottom + left)[B])B

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6104.png",width: 80%)

    ]

    )

  ]

)

- *reflow*: bool<scale_reflow>

缩放是否影响布局。默认值:```typc false```。



若设置为false,缩放后的内容允许与其他内容重叠。若设置为true,则会计算缩放后内容的新尺寸,并相应调整布局。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

Hello #scale(x: 20%, y: 40%, reflow: true)[World]!

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6105.png",width: 80%)

    ]

    )

  ]

)

- *body*: content

待扩容的内容。



== 倾斜(skew)<skew>

使内容发生倾斜。



沿水平方向、垂直方向(或同时沿两个方向)倾斜元素。除非设置reflow: #text(fill: red,"true"),否则布局表现将如同该元素未发生倾斜。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#skew(ax: -12deg)[

  This is some fake italic text.

]

```

  ],[

    #set align(horizon)

    #image("images/61006.png",width: auto)

    ]

)



=== 参数(Parameters)

```typc

skew(

    ax: angle,

    ay: angle,

    origin: alignment,

    reflow: bool,

    body: content,

) → content

```

- *ax*: angle<skew_ax>

水平偏斜角。默认值:```typc 0deg```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#skew(ax: 30deg)[Skewed]

```

  ],[

    #set align(horizon)

    #image("images/61007.png",width: auto)

  ]

)

- *ay*: angle<skew_ay>

垂直偏斜角。默认值:```typc 0deg```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#skew(ay: 30deg)[Skewed]

```

  ],[

    #set align(horizon)

    #image("images/61008.png",width: auto)

  ]

)

- *origin*: alignment<skew_origin>

倾斜变换的原点。默认值:```typc center+horizon```。



运算过程中原点保持固定不变。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  [

    ```typst

X #box(skew(ax: -30deg, origin: center + horizon)[X]) X \

X #box(skew(ax: -30deg, origin: bottom + left)[X]) X \

X #box(skew(ax: -30deg, origin: top + right)[X]) X

    ```

  ],

  [

    #set quote(block: true)

    #show quote: set align(center)

    #rect(

      fill: luma(240),

      width: 100%,

      height: auto,

      quote[

      #image("images/6109.png",width: 80%)

    ]

    )

  ]

)

- *reflow*: bool<skew_reflow>

倾斜变换是否会影响布局。默认值:```typc false```。



若设为false,经过倾斜处理的内容将保留原始内容的边界框。若设为#text(fill: red,"true"),边界框会将内容的变换纳入考量,并相应调整布局。

#table(

  columns: 1fr,

  align: left,

  stroke: none,

  fill: (x,y)=>

    if (y==0) {white}

    else if (y==1) {luma(220)}

    ,

  [

    ```typst

Hello #skew(ay: 30deg, reflow: true, "World")!

    ```

  ],

  [

    #image("images/6110.png",width: 80%)

  ]

)

- *body*: content

待倾斜的内容。



== 水平间距(h)<spacing_h>

在段落中插入水平间距。



该间距可以是绝对值、相对值或比例值。若为比例值,该行剩余空间会按照各比例间距的占比分配给所有比例间距。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

First #h(1cm) Second \

First #h(30%) Second

```

  ],[

    #set align(horizon)

    #image("images/61011.png",width: auto)

  ]

)

=== 分数间距(Fractional spacing)<spacing_h-Fractional>

采用分数间距时,你可以在同一行内对齐元素,而无需强制分段(#link(<align>)[align] would 则会强制分段)。每个设置了分数尺寸的元素,会根据自身分数占所有分数总和的比例分配空间。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

First #h(1fr) Second \

First #h(1fr) Second #h(1fr) Third \

First #h(2fr) Second #h(1fr) Third

```

  ],[

    #set align(horizon)

    #image("images/61012.png",width: auto)

  ]

)

=== 数学间距(Mathematical Spacing)<spacing_h-Mathematical>

在#link(<math>)[数学公式]中,你还可以使用以下常量在元素之间添加间距:thin(1/6 字符宽度)、med(2/9 字符宽度)、thick(5/18 字符宽度)、quad(1 字符宽度)、wide(2 字符宽度)。

=== 参数(Parameters)

```typc

h(

    amount: relative fraction,

    weak: bool,

) → content

```

- *amount*: relative fraction

插入多少间距。

- *weak*: bool

如果为#rtext()[true],段落开头或结尾处的间距会合并。此外,多个相邻的弱间距中,除最大的那个之外其余全部合并。默认值:```typc false```。



标记内的弱间距还会移除所有相邻的标记空格,无论插入的间距大小。若要在弱间距旁强制保留空格,可以显式编写 #" "(普通空格)或 ~(不间断空格)。后者可用于实现这样一种结构:始终通过一个不间断空格连接前一个单词,不受前方是否存在标记空格的影响。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#h(1cm, weak: true)

We identified a group of _weak_

specimens that fail to manifest

in most cases. However, when

#h(8pt, weak: true) supported

#h(8pt, weak: true) on both sides,

they do show up.



Further #h(0pt, weak: true) more,

even the smallest of them swallow

adjacent markup spaces.

```

  ],[

    #set align(horizon)

    #image("images/61013.png",width: auto)

  ]

)



== 垂直间距(v)<spacing_v>

在块元素流中插入垂直间距。



该间距可以是绝对值、相对值或比例值。若是比例值,页面上的剩余空间会按照各比例间距的相对占比分配给所有比例间距。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#grid(

  rows: 3cm,

  columns: 6,

  gutter: 1fr,

  [A #parbreak() B],

  [A #v(0pt) B],

  [A #v(10pt) B],

  [A #v(0pt, weak: true) B],

  [A #v(40%, weak: true) B],

  [A #v(1fr) B],

)

```

  ],[

    #set align(horizon)

    #image("images/61014.png",width: auto)

  ]

)

=== 参数(Parameters)

```typc

v(

    amount: relative fraction,

    weak: bool,

) → content

```

- *amount*: relative fraction

插入多少间距。

- *weak*: bool

若为#rtext()[true],则流的起始或末尾处的间距会合并。此外,多个相邻的弱间距中,除最大的那个外其余都会合并。弱间距始终会合并相邻的段落间距,即便该段落间距更大。默认值:```typc false```。

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

The following theorem is

foundational to the field:

#v(4pt, weak: true)

$ x^2 + y^2 = r^2 $

#v(4pt, weak: true)

The proof is simple:

```

  ],[

    #set align(horizon)

    #image("images/61015.png",width: auto)

  ]

)



== 堆叠(stack)<stack>

沿水平或垂直方向排布内容与间距。



堆叠组件会沿着一条轴线放置一组项目,项目之间可设置可选间距。

=== 示例(Example)

#table(

  columns: (1fr,1fr),

  align: (left,left),

  stroke: none,

  fill: (rgb(250, 250, 250),luma(86.27%)),

  [

    ```typst

#stack(

  dir: ttb,

  rect(width: 40pt),

  rect(width: 120pt),

  rect(width: 90pt),

)

```

  ],[

    #set align(horizon)

    #image("images/61016.png",width: auto)

  ]

)

=== 无障碍性(Accessibility)

堆栈不带有任何特殊语义。辅助技术(AT)会按照传入此函数的顺序读取堆栈中的内容。

=== 参数(Parameters)

```typc

stack(

    dir: direction,

    spacing: none relative fraction,

    children:..relative fraction content,

) → content

```

- *dir*: direction\ 项目堆叠的方向。可选值如下:

#set par(hanging-indent: 1.3cm)

  -- ltr:从左到右。



  -- rtl:从右到左。



  -- ttb:从上到下。



  -- btt:从下到上。

#set par(hanging-indent: 0cm)

你可以使用 start 和 end 方法,分别获取该方向作为对齐方式时的起点与终点。也可以使用 axis 方法判断一个方向属于```typc "horizontal"```还是```typc "vertical"```。inv 方法返回该方向的反向方向。



例如,```typc ttb.start()``` 为顶部,```typc ttb.end()``` 为底部,```typc ttb.axis()``` 为```typc "vertical"```,```typc ttb.inv()``` 等价于 btt。

- *spacing*: none relative fraction

未指定明确间距时,项目之间插入的间距。默认值:```typc none```。

- *children*:..relative fraction content

让子内容沿着轴线堆叠。