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

\keepsilent
\askforoverwritefalse

\preamble

Copyright (C) 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>

This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3c of this license
or (at your option) any later version. The latest version of this
license is in
   http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2005/12/01 or later.

This work is "maintained" (as per the LPPL maintenance status)
by Hideo Umeki.

This work consists of the files geometry.dtx and
the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.

\endpreamble

\generate{%
  \file{geometry.ins}{\from{geometry.dtx}{install}}%
  \file{geometry.drv}{\from{geometry.dtx}{driver}}%
  \usedir{tex/latex/geometry}%
  \file{geometry.sty}{\from{geometry.dtx}{package}}%
  \file{geometry.cfg}{\from{geometry.dtx}{config}}%
  \file{geometry-samples.tex}{\from{geometry.dtx}{samples}}%
}

\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by LaTeX:}
\Msg{*}
\Msg{* \space\space geometry.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `geometry.drv'}
\Msg{* through (PDF)LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\ProvidesFile{geometry.drv}
\documentclass{ltxdoc}
\usepackage[colorlinks, linkcolor=blue]{hyperref}
\usepackage[a4paper, hmargin={3.8cm,1.5cm},vmargin={1.5cm,1cm},
  includeheadfoot, marginpar=3.5cm]{geometry}
\begin{document}
 \DocInput{geometry.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{2601}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{geometry.sty}
%
% \title{The \textsf{geometry} package}
% \date{\filedate\ \fileversion}
% \author{Hideo Umeki\\\texttt{latexgeometry@gmail.com}}
%
% \def\OpenB{{\ttfamily\char`\{}}
% \def\Comma{{\ttfamily\char`,}}
% \def\CloseB{{\ttfamily\char`\}}}
% \newcommand\argii[2]{\OpenB\meta{#1}\Comma\meta{#2}\CloseB}
% \newcommand\argiii[3]{\OpenB\meta{#1}\Comma\meta{#2}\Comma\meta{#3}\CloseB}
% \newcommand\vargii[2]{\OpenB#1\Comma#2\CloseB}
% \newcommand\vargiii[3]{\OpenB#1\Comma#2\Comma#3\CloseB}
% \newcommand\OR{\ \strut\vrule width .4pt\ }
% \newcommand\gpart[1]{\textsl{#1}}
% \newcommand\glen[1]{\textsf{#1}}
% \newcommand\New[1]{\llap{$^{\star#1\:}$}}
% \newcommand\Mod[1]{\llap{$^{\dagger#1\:}$}}
% \newenvironment{key}[2]{\expandafter\macro\expandafter{`#2'}}{\endmacro}
% \newenvironment{Options}%
%  {\begin{list}{}{%
%   \renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
%   \setlength{\itemsep}{-.5\parsep}
%   \settowidth{\labelwidth}{\texttt{xxxxxxxxxxx\space}}%
%   \setlength{\leftmargin}{\labelwidth}%
%   \addtolength{\leftmargin}{\labelsep}}%
%   \raggedright}
%  {\end{list}}
%
% \maketitle
%
% \MakeShortVerb{|}
%
% \begin{abstract}
% This package provides a flexible and easy interface to page dimensions.
% You can set the page layout with intuitive parameters. For instance,
% if you want to set a margin to 2cm from each edge of the paper,
% you can go just |\usepackage[margin=2cm]{geometry}|.
% \end{abstract}
%
% \newif\ifmulticols
% \IfFileExists{multicol.sty}{\multicolstrue}{}
% \ifmulticols
% \addtocontents{toc}{%
% \protect\setlength{\columnsep}{3pc}%
% \protect\begin{multicols}{2}}
% \fi
% {\parskip 0pt
% \tableofcontents
% }
%
% \section{Preface to version 4}
%
% Many improvements to the code and documentation were made according to
% suggestions and comments from users.
% Main changes are listed below.
% \begin{itemize}
%  \item \textbf{More robust driver detection.}\par
%  The driver detection method has been totally rewritten so that
%  it can automatically detect the driver appropriate for the
%  typesetting program in use. Therefore, explicit driver setting is no longer
%  needed in most cases, except for the driver |dvipdfm|.
%  This improvement makes \textsf{geometry} work more robustly
%  for typesetting programs under e\TeX, Xe\TeX{} and
%  V\TeX{} as well as normal \TeX{} environment. The packages
%  \textsf{ifpdf} and \textsf{ifvtex} are used, which are available in CTAN.
%  See Section~\ref{sec:drivers} for details.
%  Note that \textsf{ifvtex} package v1.3 (2007/09/09) had a
%  bug (a typo) that made the detection of VTeX wrong.
%  So make sure \textsf{ifvtex} v1.4 or later is being used.
%  \item \textbf{New option: |resetpaper|.}\par
%  This option disables explicit paper setting in \textsf{geometry} and
%  uses the paper size specified before \textsf{geometry}. This option
%  may be useful to print nonstandard sized documents with normal
%  printers and papers.
%  \item \textbf{Added adjustment to |topskip|.}\par
%    When |lines| option and large font sizes are specified, \cs{topskip}
%   can be adjusted so that the formula
%    ``$\cs{textheight} = (lines - 1) \times \cs{baselineskip} + \cs{topskip}$''
%    to be correct. To do this, \cs{topskip} is set to \cs{ht}\cs{strutbox},
%  if \cs{topskip} is smaller than \cs{ht}\cs{strutbox}.
%  \item \textbf{Added ANSI paper sizes.}\par
%  New paper size definitions for ANSI A to E are added.
%  \item \textbf{Fixed wrong ISO paper sizes.}\par
%  The paper sizes for A1,A2,A5 and A6 were wrong (by 1mm).
%  \item \textbf{Fixed pdf\TeX{} magnification problem.}\par
%  PDF paper offset is adjusted properly when magnification is set by |mag|
%  option with pdf\TeX{}. 
%  \item \textbf{Changed package source organization.}\par
%  Files |geometry.ins| and |geometry-samples.tex| as well as |geometry.sty|
%  are integrated into |geometry.dtx| so that they can be generated from
%  |geometry.dtx| by `tex' command. Documentation can be also generated
%  directly from |geometry.dtx| by `(pdf)latex' command.
% \end{itemize}
%
% \section{Preface to version 3}
%
% The \textsf{geometry} package becomes even more flexible and powerful with
% the release of version 3. This new release contains major changes and
% enhancements in user interface, calculation schemes and the default settings
% of the page dimensions.
% \begin{itemize}
%  \item \textbf{New default layout.}\par
%  The `automatic' centering is no longer default layout. Instead of
%  centering, the idea of margin ratio and common values for default settings
%  are introduced: the ratio of left (inner) margin to right (outer) margin
%  is set 1:1 (2:3 for twoside), and the ratio of top to bottom is set 2:3.
%  The margin ratios can be specified by newly introduced options,
%  e.g. |marginratio| (see Section~\ref{sec:completion} and \ref{sec:margin}
%  for the detail). In addition, the spaces for the head and foot of the
%  page are disregarded in calculating the placement of the text area by
%  default. Furthermore the default |scale| of the type area is set to
%  |0.7| with 70\% of the width and height of the paper. 
%  If you want to use the old default layout of version 2.3 or earlier,
%  add |compat2| as a first option, e.g., 
%  |\usepackage[compat2,left=1.5in]{geometry}|, which sets
%  the old default options 
%  \texttt{[scale=\{0.8,0.9\}, centering, includeheadfoot]} and allows
%  the subsequent options to behave as if they are used in the old version.
%  See also Section~\ref{sec:default} for the detail of the default layout. 
%
%  \item \textbf{Option |twosideshift| is obsoleted.} \par
%  |twoside| and other geometry options can substitute for it. 
%  A new option |bindingoffset| might be also helpful to control margins for 
%  oneside/twoside. For the detail, see Section~\ref{sec:margin}.
%
%  \item \textbf{Option |includemp| becomes independent of |marginparwidth|
%  and |marginparsep|.} \par
%  In the previous version, |marginparwidth| or |marginparsep| 
%  automatically set |includemp=true|. Now if you want |includemp| mode,
%  |includemp| should be set explicitly.
%
%  \item \textbf{Options |nohead|, |nofoot| and |noheadfoot| become
%  order-dependent and overwritable} \par
%  In the previous version, these options was order-independent:
%  |nohead,headsep=10pt| resulted in just |nohead| (\cs{headsep}|=0pt|,
%  \cs{headheight}|=0pt|), for example. But now they are overwritable 
%  by subsequent options. The above case results in \cs{headheight}|=0pt|
%  and \cs{headsep}|=10pt|.
%
%  \item \textbf{A complete set of options |ignore*| and |include*| for
%  head, foot and marginpar.}\par
%  The previous version has only |includemp|, which denotes that the width
%  of marginpar is included in the total body width. 
%  Now |ignore|\{|head|, |foot|, |headfoot|, |mp|, |all|\} and 
%  |include|\{|head|, |foot|, |headfoot|, |all|\} are newly added.
%  If one of these |ignore*| is set, the corresponding space(s) are 
%  disregarded in auto-completion calculation. 
%  In version 3, |ignoreall| is set by default. So if you need to include
%  the spaces for the head, foot and marginpar, the corresponding |include*|
%  should be set explicitly. In addition, unlike the previous version, 
%  neither |reversemp|, |marginparwidth| nor |marginparsep| sets |includemp|
%  automatically.
%
%  \item \textbf{New option |lines|.}\par
%  The option enables users to specify \cs{textheight} by the number of
%  lines included in \cs{textheight}, e.g., |lines=20|.
%
%  \item \textbf{New option |heightrounded|.}\par
%  The option rounds \cs{textheight} to \textit{n}-times (\textit{n}:
%  an integer) of \cs{baselineskip} plus \cs{topskip} to avoid ``underfull
%  vbox'' in some cases.
%
%  \item \textbf{New option |screen|.}\par
%  To make presentation with PC and video projector, geometry option
%  |screen,centering| with `slide' documentclass would be the best choice.
%
%  \item \textbf{New option |asymmetric|.}\par
%  The option implements a twosided layout in which margins are not swapped
%  on alternate pages and the marginal notes stay always on the same side.
%
%  \item \textbf{New option |showframe|.}\par
%  The option displays visible frames for the text area and page, and lines
%  for the head and foot to check layout in detail. Therefore |showframe.sty|
%  is excluded from the \textsf{geometry} package distribution.
%
%  \item \textbf{New option |pass|.}\par
%  The option disables auto-layout and all of the geometry settings except
%  |verbose| and |showframe|. It can be used for checking out the page
%  layout of the documentclass, other packages and manual settings
%  without \textsf{geometry}. 
% \end{itemize}
% See the text for the detail. All the new and modified options in this
% release are marked with `$\star3$' and `$\dagger3$' respectively.
%
% \section{Introduction}
%
% To set dimensions for page layout in \LaTeX\ is not straightforward. 
% You need to adjust several \LaTeX{} native dimensions to place a text area
% where you want
% If you want to center the text area in the paper you use, for example, 
% you have to specify native dimensions as follows:
% \begin{quote}
%    |\usepackage{calc}|\\
%    |\setlength\textwidth{7in}|\\
%    |\setlength\textheight{10in}|\\
%    |\setlength\oddsidemargin{(\paperwidth-\textwidth)/2 - 1in}|\\
%    |\setlength\topmargin{(\paperheight-\textheight|\\
%    |                      -\headheight-\headsep-\footskip)/2 - 1in}|.
% \end{quote}
% Without package \textsl{calc}, the above example would need
% more tedious settings. Package \textsf{geometry} provides an easy
% way to set page layout parameters. In this case, what you have to do
% is just
% \begin{quote}
%    |\usepackage[text={7in,10in},centering]{geometry}|. 
% \end{quote}
% Besides centering problem, setting margins from each edge of the paper is
% also troublesome. But \textsf{geometry} also make it easy.
% If you want to set each margin 1.5in, you can go 
% \begin{quote}
%    |\usepackage[margin=1.5in]{geometry}| 
% \end{quote}
% In both cases, the unspecified dimensions are automatically determined.
% The package will be also useful when you have to set page layout obeying
% the following strict instructions: for example,
% \begin{quote}\slshape
%   The total allowable width of the text area is 6.5 inches wide by 8.75
%   inches high. The top margin on each page should be 1.2 inches from
%   the top edge of the page. The left margin should be 0.9 inch from 
%   the left edge. The footer with page number should be at the bottom
%   of the text area.
% \end{quote}
% In this case, using \textsf{geometry} you can go 
% \begin{quote}
% |\usepackage[total={6.5in,8.75in},|\\
% |            top=1.2in, left=0.9in, includefoot]{geometry}|.
% \end{quote}
%
% Setting a text area on the paper in document preparation system has some
% analogy to placing a window on the background in the window system. 
% The name `geometry' comes from the |-geometry| option used for specifying
% a size and location of a window in X Window System.
%
% \section{Page geometry}
% \subsection{Layout dimensions}
% To realize a straightforward setting for page layout, the following page
% structure is introduced: A paper contains a total body (printable area)
% and margins. The total body consists of a body (text area) with optional
% a header, a footer and marginal notes (marginpar). There are four margins:
% the left, right, top and bottom margins. For twosided documents, horizontal
% margins should be called the inner and outer margins.
% \begin{quote}
%  \begin{tabular}{rcl}
%   \gpart{paper}&:&\gpart{total body} and
%   \gpart{margins}\\
%   \gpart{total body}&:&\gpart{body} (text area)\quad
%             (optional \gpart{head}, \gpart{foot} and \gpart{marginpar})\\
%   \gpart{margins}&:&\gpart{left}(\gpart{inner}), 
%      \gpart{right}(\gpart{outer}), \gpart{top} and \gpart{bottom}
%   \end{tabular}
% \end{quote}
% Each margin is measured from the corresponding edge of a paper. 
% For example, left margin (inner margin) means a horizontal distance
% between the left (inner) edge of the paper and that of the total body.
% Therefore the left and top margins defined in \textsf{geometry}
% are different from the native dimensions \cs{leftmargin}
% and \cs{topmargin}.
% The size of a body (text area) can be modified by \cs{textwidth} and
% \cs{textheight}. 
%
% The layout parts and the corresponding dimension names used in this
% package are showed schematically in Figure~\ref{fig:layout}.
% \begin{figure}
%  \centering\small
%  {\unitlength=.65pt
%  \begin{picture}(450,250)(0,-10)
%  \put(20,0){\framebox(170,230){}}
%  \put(20,235){\makebox(170,230)[br]{\gpart{paper}}}
%  \put(40,30){\framebox(120,170){}}
%  \put(40,30){\makebox(120,165)[tr]{\gpart{total body}~}}
%  \put(45,30){\makebox(0,170)[l]{|height|}}
%  \put(50,35){\makebox(120,0)[bc]{|width|}}
%  \put(50,-20){\makebox(120,0)[bc]{|paperwidth|}}
%  \put(10,45){\makebox(0,170)[r]{|paperheight|}}
%  \put(90,200){\makebox(0,30)[lc]{|top|}}
%  \put(90,0){\makebox(0,30)[lc]{|bottom|}}
%  \put(10,70){\makebox(0,0)[r]{|left|}}
%  \put(10,55){\makebox(0,0)[r]{(|inner|)}}
%  \put(200,70){\makebox(0,0)[l]{|right|}}
%  \put(200,55){\makebox(0,0)[l]{(|outer|)}}
%  \put(80,230){\vector(0,-1){30}}\put(80,30){\vector(0,-1){30}}
%  \put(80,200){\vector(0,1){30}}\put(80,0){\vector(0,1){30}}
%  \put(20,70){\vector(1,0){20}}\put(40,70){\vector(-1,0){20}}
%  \put(160,70){\vector(1,0){30}}\put(190,70){\vector(-1,0){30}}
%  \multiput(160,30)(5,0){24}{\line(1,0){2}}
%  \multiput(160,200)(5,0){24}{\line(1,0){2}}
%  \put(280,30){\framebox(120,170){}}
%  \put(280,30){\makebox(120,165)[tr]{\gpart{total body}~}}
%  \put(280,220){\line(1,0){120}}
%  \put(280,208){\makebox(120,20)[bc]{\gpart{head}}}
%  \put(280,207){\line(1,0){120}}
%  \put(410,215){\makebox(0,0)[l]{|headheight|}}
%  \put(410,203){\makebox(0,0)[l]{|headsep|}}
%  \put(410,110){\makebox(0,0)[l]{|textheight|}}
%  \put(280,35){\makebox(120,0)[bc]{|textwidth|}}
%  \put(410,20){\makebox(0,0)[l]{|footskip|}}
%  \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
%  \put(280,15){\makebox(120,10)[c]{\gpart{foot}}}
%  \put(280,14){\line(1,0){120}}
%  \end{picture}}
%  \caption[Dimension names for \textsf{geometry}]{%
%  \begin{minipage}[t]{.8\textwidth}\raggedright\small
%  Dimension names used in the \textsf{geometry} package.
%  |width|=|textwidth| and |height|=|textheight| by default.
%  |left|, |right|, |top| and |bottom| are margins. 
%  If margins on verso pages are swapped by |twoside| option,
%  margins specified by |left| and |right| options
%  are used for the inside and outside margins respectively.
%  |inner| and |outer| are aliases of |left| and |right|
%  respectively.
%  \end{minipage}}
%  \label{fig:layout}
% \end{figure}
% The dimensions for paper, total body and margins have the following
% relations.
% \begin{eqnarray}
%  \label{eq:paperwidth}
%  |paperwidth| &=& |left|+|width|+|right| \\
%  |paperheight| &=& |top|+|height|+|bottom|
%  \label{eq:paperheight}
% \end{eqnarray}
% The dimensions of the total body, |width| and |height|, are defined
% as follows:
% \begin{eqnarray}
%  \label{eq:width}
%  |width| &:=& |textwidth| \quad( +  |marginparsep| + |marginparwidth| )\\
%  |height| &:=& |textheight| \quad(+ |headheight| + |headsep| + |footskip| )
%  \label{eq:height}
% \end{eqnarray}
% In Equation (\ref{eq:width}), |width:=textwidth| by default, 
% but |marginparsep| and |marginparwidth| are included in |width|
% if |includemp| option is set |true|. 
% In Equation (\ref{eq:height}), |height:=textheight| by default. 
% If |includehead| is set to |true|, |headheight| and |headsep| are
% considered as a part of |height| in the the vertical completion calculation.
% In the same way, |includefoot| includes
% |footskip|. Note that options |ignore*| just exclude the corresponding
% spaces from |textheight|, but do not change those lengths themselves.
% Figure~\ref{fig:includes} shows how these options work.
% \begin{figure}
%  \centering\small
%  {\unitlength=.65pt
%  \begin{picture}(490,280)(0,-10)
%  \put(25,255){\makebox(120,0)[bl]{\textbf{(a)}~\textit{default}}}%
%  \put(20,0){\framebox(170,230){}}
%  \put(20,230){\makebox(170,230)[br]{\gpart{paper}}}
%  \put(40,30){\framebox(120,165){}}
%  \put(70,165){\vector(0,1){30}}
%  \put(55,145){\makebox(0,20)[lc]{|textheight|}}
%  \put(70,145){\vector(0,-1){115}}
%  \multiput(40,203)(5,0){24}{\line(1,0){3}}
%  \multiput(40,213)(5,0){24}{\line(1,0){3}}
%  \multiput(40,10)(5,0){24}{\line(1,0){3}}
%  \put(40,203){\makebox(120,20)[bc]{\gpart{head}}}
%  \put(40,40){\makebox(120,140)[c]{\gpart{body}}}
%  \put(40,10){\makebox(120,10)[c]{\gpart{foot}}}
%  \put(150,230){\vector(0,-1){35}}\put(150,30){\vector(0,-1){30}}
%  \put(150,195){\vector(0,1){35}}\put(150,0){\vector(0,1){30}}
%  \put(160,197){\makebox(0,30)[lc]{|top|}}
%  \put(160,0){\makebox(0,30)[lc]{|bottom|}}
%  \multiput(160,30)(5,0){24}{\line(1,0){2}}
%  \multiput(160,195)(5,0){24}{\line(1,0){2}}
%  \put(265,255){\makebox(120,0)[bl]
%      {\textbf{(b)}~|includehead| and |includefoot|}}%
%  \put(260,0){\framebox(170,230){}}
%  \put(260,230){\makebox(170,230)[br]{\gpart{paper}}}
%  \put(280,30){\framebox(120,165){}}
%  \put(310,150){\vector(0,1){25}}
%  \put(295,130){\makebox(0,20)[lc]{|textheight|}}
%  \put(310,130){\vector(0,-1){80}}
%  \multiput(280,183)(5,0){24}{\line(1,0){3}}
%  \multiput(280,175)(5,0){24}{\line(1,0){3}}
%  \multiput(280,50)(5,0){24}{\line(1,0){3}}
%  \put(280,183){\makebox(120,20)[bc]{\gpart{head}}}
%  \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
%  \put(400,140){\line(1,1){45}}
%  \put(437,187){\makebox(50,10)[l]{\gpart{total body}}}
%  \put(280,30){\makebox(120,10)[c]{\gpart{foot}}}
%  \put(370,230){\vector(0,-1){35}}\put(370,30){\vector(0,-1){30}}
%  \put(370,195){\vector(0,1){35}}\put(370,0){\vector(0,1){30}}
%  \put(380,197){\makebox(0,30)[lc]{|top|}}
%  \put(380,0){\makebox(0,30)[lc]{|bottom|}}
%  \end{picture}}
%  \caption[An effect of \texttt{includehead} and \texttt{includefoot}.]{%
%  \begin{minipage}[t]{.8\textwidth}\raggedright\small
%    |includehead| and |includefoot| include the head and foot respectively
%    into \gpart{total body}. \textbf{(a)} |height| $=$ |textheight| (default).
%    \textbf{(b)} |height| $=$ |textheight| $+$ |headheight| $+$ |headsep| $+$ 
%    |footskip| if |includehead| and |includefoot|. If the top and bottom
%    margins are fixed, |includehead| and |includefoot| make |textheight|
%    shorter than default.
%  \end{minipage}}
%  \label{fig:includes}
% \end{figure}
% Each of the seven dimensions in the right-hand side of Equations
% (\ref{eq:width}) and (\ref{eq:height}) corresponds to the ordinary
% \LaTeX\ control sequence with the same name.
%
% Figure~\ref{fig:modes} illustrates various layouts with different layout
% modes. The dimensions for a header and a footer can be controlled by
% |nohead| or |nofoot| mode, which sets each length to 0pt directly.
% On the other hand, options |ignore*| do \textit{not} change
% the corresponding native dimensions.
% \begin{figure}
%  \centering\small
%  {\unitlength=.65pt
%  \begin{picture}(460,525)(0,0)
%  \put( 20,310){\framebox(120,170){}}
%  \put( 20,507){\makebox(120,0)[bl]%
%  {\textbf{(a)}~|includeheadfoot|}}
%  \put( 20,460){\line(1,0){120}}\put( 20,450){\line(1,0){120}}
%  \put( 20,330){\line(1,0){120}}
%  \put( 20,485){\makebox(120,0)[br]{\gpart{total body}}}
%  \put( 20,335){\makebox(120,0)[bc]{|textwidth|}}
%  \put(150,470){\makebox(0,0)[l]{|headheight|}}
%  \put(150,450){\makebox(0,0)[l]{|headsep|}}
%  \put(150,390){\makebox(0,0)[l]{|textheight|}}
%  \put(150,320){\makebox(0,0)[l]{|footskip|}}
%  \put( 10,460){\makebox(120,20)[bc]{\gpart{head}}}
%  \put( 10,320){\makebox(120,140)[c]{\gpart{body}}}
%  \put( 10,310){\makebox(120,10)[c]{\gpart{foot}}}
%  \put(250,310){\framebox(120,170){}}
%  \put(250,507){\makebox(120,0)[bl]%
%  {\textbf{(b)}~|includeall|}}
%  \put(250,460){\line(1,0){95}}\put(250,450){\line(1,0){95}}
%  \put(250,330){\line(1,0){95}}\put(345,330){\line(0,1){120}}
%  \put(350,330){\line(0,1){120}}\put(350,450){\line(1,0){20}}
%  \put(350,330){\line(1,0){20}}
%  \put(250,485){\makebox(120,0)[br]{\gpart{total body}}}
%  \put(250,460){\makebox(95,20)[bc]{\gpart{head}}}
%  \put(250,320){\makebox(95,140)[c]{\gpart{body}}}
%  \put(385,390){\makebox(95,0)[cl]%
%  {\gpart{\shortstack[l]{marginal\\note}}}}
%  \put(250,310){\makebox(95,10)[c]{\gpart{foot}}}
%  \put(250,335){\makebox(95,0)[bc]{|textwidth|}}
%  \multiput(360, 390)(4,0){6}{\line(1,0){2}}
%  \multiput(348,333)(0,-4){12}{\line(0,1){2}}
%  \multiput(360,333)(0,-4){8}{\line(0,1){2}}
%  \put(355,292){\makebox(0,0)[bl]{|marginparwidth|}}
%  \put(345,275){\makebox(0,0)[bl]{|marginparsep|}}
%  \put( 20, 40){\framebox(120,170){}}
%  \put( 20,237){\makebox(120,0)[bl]%
%  {\textbf{(c)}~|includefoot|}}
%  \put( 20, 60){\line(1,0){120}}
%  \put( 20,215){\makebox(120,0)[br]{\gpart{total body}}}
%  \put(150,130){\makebox(0,0)[l]{|textheight|}}
%  \put(150, 50){\makebox(0,0)[l]{|footskip|}}
%  \put( 20, 50){\makebox(120,160)[c]{\gpart{body}}}
%  \put( 20, 40){\makebox(120,10)[c]{\gpart{foot}}}
%  \put( 20, 65){\makebox(120,10)[c]{|textwidth|}}
%  \put(250, 40){\framebox(120,170){}}
%  \put(250,237){\makebox(120,0)[bl]%
%  {\textbf{(d)}~|includefoot,includemp|}}
%  \put(250, 60){\line(1,0){95}}\put(350, 60){\line(1,0){20}}
%  \put(250,215){\makebox(120,0)[br]{\gpart{total body}}}
%  \put(250, 50){\makebox(95,160)[c]{\gpart{body}}}
%  \put(385,130){\makebox(95,0)[cl]%
%  {\gpart{\shortstack[l]{marginal\\note}}}}
%  \put(250, 40){\makebox(95,10)[c]{\gpart{foot}}}
%  \put(250, 65){\makebox(95,0)[bc]{|textwidth|}}
%  \put(345, 60){\line(0,1){150}}\put(350, 60){\line(0,1){150}}
%  \multiput(360, 130)(4,0){6}{\line(1,0){2}}
%  \multiput(348, 63)(0,-4){12}{\line(0,1){2}}
%  \multiput(360, 63)(0,-4){8}{\line(0,1){2}}
%  \put(355,22){\makebox(0,0)[bl]{|marginparwidth|}}
%  \put(345, 5){\makebox(0,0)[bl]{|marginparsep|}}
%  \end{picture}}
%  \caption[Sample layouts for \gpart{total body} with different 
%     layout modes]{%
%  \begin{minipage}[t]{.8\textwidth}\small
%    Sample layouts for \gpart{total body} with different switches.
%    (a) |includeheadfoot|, (b) |includeall|, (c) |includefoot|
%     and (d) |includefoot,includemp|. 
%    If |reversemp| is set to |true|, the location of the
%    marginal notes are swapped on every page.
%    Option |twoside| swaps both margins and marginal notes on verso pages.
%    Note that the marginal notes are printed on the page, even when
%    |ignoremp| or |includemp=false|, but can fall off the page in some cases.
%  \end{minipage}}
%  \label{fig:modes}
% \end{figure}
%
% \subsection{Auto-completion scheme}\label{sec:completion}
%
% Suppose that the paper size is pre-defined in Equation~(\ref{eq:paperwidth})
% or (\ref{eq:paperheight}), if two dimensions out of the three dimensions
% in the right-hand side of each equation are specified,  the rest of the
% dimensions can be determined by the specified ones. However, when none or
% only one of the three dimensions is specified, the rest of the dimensions
% can't generally be determined without some assumptions. 
%
% The \textsf{geometry} package has an auto-completion scheme with some
% default parameters to determine the unspecified dimensions independently
% for each direction. If the size of \gpart{total body} (i.e., |width| in
% the horizontal direction) is specified, the margins (|left| and |right|)
% can be determined with a default ratio of one margin to the other
% (|left/right|).
% If one margin is specified, the rest of dimensions can also be determined
% by the default margin ratio. 
% Page margin setting by margin ratio was introduced in KOMA 
% script\footnote{CTAN:~\texttt{macros/latex/contrib/koma-script}
% by Frank Neukam and Markus Kohm.}.
%
% The default vertical margin ratio is $2/3$, namely,
% \begin{equation}
%  |top| : |bottom| = 2 : 3 \qquad\textit{default}.
% \end{equation}
% As for the horizontal margin ratio, the default value depends on
% whether the document is onesided or twosided,
% \begin{equation}
%  |left|\;(|inner|) : |right|\;(|outer|) 
%       = \left\{ \begin{array}{ll}
%              1 : 1 \qquad\textit{default for oneside},\\
%              2 : 3 \qquad\textit{default for twoside}.
%         \end{array}\right.
% \end{equation}
% Obviously the default horizontal margin ratio for oneside is `centering'.
%
% For example, if one specifies |right=2.4cm| with a \textit{twosided}
% layout in A4 paper (21.0cm$\times$29.7cm), unspecified |left| and |width|
% are automatically determined using the default horizontal margin ratio
% (2/3) as follows:
% \begin{eqnarray}
%      |left| &=& \langle\textsf{horizontal-margin-ratio}\rangle
%                 \times |right| \nonumber\\
%             &=& |2/3| \times |2.4cm| = |1.6cm|\\[1ex]
%    |width|  &=& |paperwidth| - |left| - |right| \nonumber\\
%             &=& |21.0cm| - |1.6cm| - |2.4cm|  = |17.0cm|.
% \end{eqnarray}
% In this case, the vertical dimensions |top|, |height| and |bottom|
% are determined by the default vertical margin ratio with 2:3
% and the default size of \gpart{total body} with 70\% of the paper height:
% \begin{eqnarray}\displaystyle
%   |height| &=&  |0.7| \times |paperheight|\nonumber\\
%            &=&  |0.7| \times |29.7cm| = |20.79cm| \\[1ex]
%   |top|    &=& \frac{\langle\textsf{vertical-margin-ratio}\rangle}
%                     {1+\langle\textsf{vertical-margin-ratio}\rangle}
%                \times (|paperheight| - |height|) \nonumber\\
%            &=& \frac{2}{2+3}\times(|29.7cm| - |20.79cm|)\nonumber\\[1ex]
%            &=& 0.4\times |8.91cm| = |3.564cm|\\[2ex]
%   |bottom| &=& 0.6\times |8.91cm| = |5.346cm|
% \end{eqnarray}
%
% The auto-completion rules are shown in Table~\ref{tab:completion}
% and Equation~(\ref{eq:completion}).
% $A$, $B$ and $C$ in Table~\ref{tab:completion} are user-specified values,
% $*$ denotes unspecified ones. The right-hand side table shows the
% corresponding results of auto-completion. The unspecified values can be
% determined by $A$, $B$ and $L$ (|paperwidth| or |paperheight|).
% In Table~\ref{tab:completion}, functions ${\cal R}(x)$ and ${\cal M}(x)$
% are defined as follows:
% \begin{equation}
%  \begin{array}{rcl}
%    {\cal R}(x) &=& L-x\\
%    {\cal M}(x) &=& {\cal R}(x)\;/\;(1+\sigma)\\
%  \end{array}
%  \label{eq:completion}
% \end{equation}
% Here $\sigma$ denotes the ratio of left margin (inner) to right margin
% (outer) or the ratio of top to bottom. To set $\sigma$ as a geometry option,
% you can use \{|h|,|v|\}|marginratio| options with |a:b|-type value,
% for example, |hmarginratio=2:3|. 
% \begin{eqnarray}
%  \label{eq:hratios}
%  |hmarginratio| &=& |left| : |right|\\
%  |vmarginratio| &=& |top| : |bottom|
%  \label{eq:vratios}
% \end{eqnarray}
% By default, $\sigma$ is 1/1 (=1) for oneside and 2/3 for twoside
% in the horizontal direction, and 2/3 in the vertical.
% If none of three dimensions is specified in each direction, the default
% setting is used: width and height is set to 70\% of the paper width 
% and height respectively. If all the three dimensions would be specified,
% margins remain and width or height is ignored.
%
% \begin{table}
% \def\AST{\texttt{*}}\centering
% \begin{tabular}{cccccccl}
% \multicolumn{3}{c}{Settings}& &\multicolumn{3}{c}{Results}\\
% \noalign{\vspace{.1em}}
% \cline{1-3}\cline{5-7}
% \parbox{3em}{\hfil\glen{left}}&\parbox{3em}{\hfil\glen{width}}&
% \parbox{3em}{\hfil\glen{right}}&&%
% \parbox{3em}{\hfil\glen{left}}&\parbox{3em}{\hfil\glen{width}}&
% \parbox{3em}{\hfil\glen{right}}&\\
% \cline{1-3}\cline{5-7}
% \glen{top}&\glen{height}&\glen{bottom}&&%
% \glen{top}&\glen{height}&\glen{bottom}&\\
% \cline{1-3}\cline{5-7}
% \noalign{\vspace{.2em}}
% \AST & \AST & \AST && $\sigma{\cal M}(0.7L)$ & $0.7L$ & ${\cal M}(0.7L)$&\\
% \AST & $A$  & \AST && $\sigma{\cal M}(A)$ & $A$ & ${\cal M}(A)$ &\\
% $A$  & \AST & \AST && $A$   & ${\cal R}(A+A/\sigma)$ & $A/\sigma$ &\\
% \AST & \AST & $A$  &$\Longrightarrow$%
%                      & $\sigma A$ & ${\cal R}(A+\sigma{}A)$ & $A$ &\\
% $A$  & $B$  & \AST && $A$   & $B$    & ${\cal R}(A+B)$ &\\
% \AST & $A$  & $B$  && ${\cal R}(A+B)$ & $A$    & $B$   &\\
% $A$  & \AST & $B$  && $A$   & ${\cal R}(A+B)$  & $B$   &\\
% $A$  & $C$  & $B$  && $A$   & ${\cal R}(A+B)$  & $B$   &\\
% \cline{1-3}\cline{5-7}
% \end{tabular}
% \caption[Auto-comletion rules]{%
% \begin{minipage}[t]{.8\textwidth}\small
% Auto-completion rules. The mark `|*|' in each row (left table) denotes
% the dimensions not specified explicitly, which can be determined as the 
% corresponding Results (right table). $\sigma$ denotes the value of 
% margin ratio. Functions ${\cal R}(x)$ and ${\cal M}(x)$ are defined
% in Equation~(\ref{eq:completion}). The bottom case shows
% over-specification, which gives in the same result as the $A$-\AST-$B$ case.
% \end{minipage}}
% \label{tab:completion}
% \end{table}
%
% \section{User interface}
% \subsection{General features}
%
% The geometry options using the \textsf{keyval} interface
% `\meta{key}=\meta{value}' can be set either in the optional argument to
% the \cs{usepackage} command, or in the argument of the
% \cs{geometry} macro. This macro, if necessary, should be used only in the
% preamble, i.e., before |\begin{document}|.
% In either case, the argument consists of a list of
% comma-separated \textsf{keyval} options.
% The main features of setting options are listed below.
% \begin{itemize}\itemsep=0pt
% \item Multiple lines are allowed. (But blank lines are not allowed.)
% \item Any spaces between words are ignored.
% \item Options are basically order-independent.\\
% (There are some exceptions. See Section~\ref{sec:order-depend}
%  for details.)
% \end{itemize}
%  For example,
% \begin{quote}
% |\usepackage[ a5paper ,  hmargin = { 3cm,|\\
% |                .8in } , height|\\
% |         =  10in ]{geometry}|
% \end{quote}
% is equivalent to 
% \begin{quote}
%   |\usepackage[height=10in,a5paper,hmargin={3cm,0.8in}]{geometry}|
% \end{quote}
% Some options are allowed to have sub-list, e.g. |{3cm,0.8in}|.
% Note that the order of values in the sub-list is significant.
% The above setting is also equivalent to the followings:
% \begin{quote}
%   |\usepackage{geometry}|\\
%   |\geometry{height=10in,a5paper,hmargin={3cm,0.8in}}|
% \end{quote}
% or 
% \begin{quote}
%   |\usepackage[a5paper]{geometry}|\\
%   |\geometry{hmargin={3cm,0.8in},height=8in}|\\
%   |\geometry{height=10in}|.
% \end{quote}
% Thus, multiple use of \cs{geometry} just appends options.
%
% \textsf{Geometry} supports package 
% \textsl{calc}\footnote{CTAN:~\texttt{macros/latex/required/tools}}.
% For example,
% \begin{quote}
%   |\usepackage{calc}|\\
%   |\usepackage[textheight=20\baselineskip+10pt]{geometry}|
% \end{quote}
%
% \subsection{Option types}
% \textsf{Geometry} options are categorized into four types:
%
% \begin{enumerate}\itemsep=0pt
% \item \textbf{Boolean type}
%
%    takes a boolean value (|true| or |false|). If no value,
%    |true| is set by default.
%    \begin{quote}
%       \meta{key}|=true|\OR|false|.\\
%       \meta{key} with no value is equivalent to 
%       \meta{key}|=true|.
%    \end{quote}
%    \textit{Examples:}~ |verbose=true|, |includehead|, 
%    |twoside=false|.\\
%    Paper name is the exception. The preferred paper name should be set
%    with no values. Whatever value is given, it is ignored. For
%    instance, |a4paper=XXX| is equivalent to |a4paper|.
%
% \item \textbf{Single-valued type}
%
%    takes a mandatory value.
%    \begin{quote}
%    \meta{key}|=|\meta{value}.
%    \end{quote}
%    \textit{Examples:}~ |width=7in|, |left=1.25in|,
%    |footskip=1cm|, |height=.86\paperheight|.
%
% \item \textbf{Double-valued type}
%
%    takes a pair of comma-separated values in braces. The two values can
%    be shortened to one value if they are identical.
%    \begin{quote}
%    \meta{key}|=|\argii{value1}{value2}.\\
%    \meta{key}|=|\meta{value} is equivalent to 
%              \meta{key}|=|\argii{value}{value}.
%    \end{quote}
%    \textit{Examples:}~ |hmargin={1.5in,1in}|, |scale=0.8|,
%    |body={7in,10in}|.
%
% \item \textbf{Triple-valued type}
%
%    takes three mandatory, comma-separated values in braces.
%    \begin{quote}
%    \meta{key}|=|\argiii{value1}{value2}{value3}
%    \end{quote}
%    Each value must be a dimension or null. When you give an empty value
%    or `|*|', it means null and leaves the appropriate value 
%    to the auto-completion mechanism. You need to specify at least one
%    dimension, typically two dimensions. You can set nulls for all the 
%    values, but it makes no sense.
%    \textit{Examples:}\\
%    \hspace*{2em} |hdivide={2cm,*,1cm}|, |vdivide={3cm,19cm, }|,
%                   |divide={1in,*,1in}|.
% \end{enumerate}
%
% \section{Option specification}
%
% This section describes all the options provided by \textsf{geometry}.
%
% \subsection{Paper size}
% 
% The options below set paper/media size and orientation.
% \begin{Options}
% \item[paper\OR papername] ~\\ 
%    specifies a paper name. The paper names available in \textsf{geometry}.
%    |paper=|\meta{paper-name}. For example |paper=a4paper|, which is 
%    equivalent to just |a4paper|.
% \item[\vtop{
%  \hbox{a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paper}
%  \hbox{b0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paper}
%  \hbox{ansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaper}
%  \hbox{letterpaper, executivepaper, legalpaper}}]~\\[1ex] 
%    specifies paper name. They can typically be used with no values.
%    Note that whatever value (even |false|) is given to this option, the
%    value will be ignored. For example, the followings have the same effect:
%    |a5paper|, |a5paper=true|, |a5paper=false| and |a5paper=XXXX|.
% \item[screen] a special paper size with (W,H) = (225mm,180mm).
%    For presentation with PC and video projector, ``|screen,centering|''
%    with `slide' documentclass would be useful.
% \item[paperwidth] width of the paper. |paperwidth=|\meta{length}.
% \item[paperheight] height of the paper. |paperheight=|\meta{length}.
% \item[papersize] width and height of the paper.\\
%    |papersize=|\argii{width}{height} or |papersize=|\meta{length}.
% \item[landscape] switches the paper orientation to landscape mode.
% \item[portrait] switches the paper orientation to portrait mode.
%    This is equivalent to |landscape=false|.
% \end{Options}
%
% Options for paper names (e.g., |a4paper|) and orientation
% (|portrait| and |landscape|) can be set as document class options. 
% For example, you can set |\documentclass[a4paper,landscape]{article}|, 
% then |a4paper| and |landscape| are processed in \textsf{geometry} as well.
% This is also the case for |twoside| and |twocolumn|
% (see also Section~\ref{sec:dimension}).
%
% \subsection{Body size}\label{sec:body}
%
% The options specifying the size of \gpart{total body} are described in this
% section.
% \begin{Options}
% \item[hscale]
%    ratio of width of \gpart{total body} to \cs{paperwidth}. 
%    |hscale=|\meta{h-scale}, e.g., |hscale=0.8| is equivalent to
%    |width=0.8|\cs{paperwidth}. (|0.7| by default)
% \item[vscale]
%    ratio of height of \gpart{total body} to \cs{paperheight}, e.g.,
%    |vscale=|\meta{v-scale}. (|0.7| by default) |vscale=0.9| is equivalent
%    to |height=0.9|\cs{paperheight}.
% \item[scale] ratio of \gpart{total body} to the paper.
%    |scale=|\argii{h-scale}{v-scale} or |scale=|\meta{scale}.
%    (|0.7| by default)
% \item[width\OR totalwidth] ~\\
%    width of \gpart{total body}. |width=|\meta{length} or
%    |totalwidth=|\meta{length}. This dimension should not be confused with
%    |textwidth|. Generally, |width| $\ge$ |textwidth| because |width|
%    includes the width of the marginal notes if |includemp| is set to |true|.
%    If |textwidth| and |width| are specified at the same time, |width| is
%    ignored.
% \item[height\OR totalheight] ~\\
%    height of \gpart{total body}, excluding header and footer by default.
%    If |includehead| or |includefoot| is set, |height| includes
%    the head or foot of the page as well as |textheight|.
%    |height=|\meta{length} or |totalheight=|\meta{length}. If both
%    |textheight| and |height| are specified, |height| will be ignored.
% \item[total] width and height of \gpart{total body}.\\
%    |total=|\argii{width}{height} or |total=|\meta{length}.
% \item[textwidth] modifies \cs{textwidth}, the width of \gpart{body} 
%    (the text are). |textwidth=|\meta{length}.
% \item[textheight] modifies \cs{textheight}, the height of \gpart{body}.
%    |textheight=|\meta{length}.
% \item[text\OR body] sets both \cs{textwidth} and \cs{textheight} of the body
%    of page. |body=|\argii{width}{height} or |text=|\meta{length}.
% \item[lines] enables users to specify \cs{textheight} by the number
%    of lines. |lines|=\meta{integer}.
% \item[includehead] includes the head of the page, \cs{headheight}
%    and \cs{headsep}, into \gpart{total body}. It is set to |false| by
%    default. It is opposite to |ignorehead|. See Figure~\ref{fig:includes}.
% \item[includefoot] includes the foot of the page, \cs{footskip},
%    into \gpart{total body}. It is opposite to |ignorefoot|.
%    It is |false| by default. See Figure~\ref{fig:includes}.
% \item[includeheadfoot]~\\ 
%    sets both |includehead| and |includefoot| to |true|, which is opposite
%    to |ignoreheadfoot|. See Figure~\ref{fig:includes}.
% \item[includemp] includes the margin notes,  \cs{marginparwidth}
%    and \cs{marginparsep}, into \gpart{body} when calculating horizontal
%    calculation. In version 3, |includemp| is independent of options 
%    |marginparwidth| and |marginparsep|, and set to |false| by default.
% \item[includeall] sets both |includeheadfoot| and |includemp| to
%    |true|. See Figure~\ref{fig:includes} and Figure~\ref{fig:modes}.
% \item[ignorehead] disregards the head of the page,
%    |headheight| and |headsep|, in determining vertical layout, but does not
%    change those lengths. It is equivalent to |includehead=false|. It is set
%    to |true| by default. See also |includehead|.
% \item[ignorefoot] disregards the foot of page, |footskip|,
%    in determining vertical layout, but does not change that length.
%    This option is set to |true| by default. See also |includefoot|.
% \item[ignoreheadfoot]~\\ sets both |ignorehead| and |ignorefoot|
%    to |true|. See also |includeheadfoot|.
% \item[ignoremp] disregards the marginal notes in determining the
%    horizontal margins (|true| is set by default). If marginal notes fall off
%    the page, the warning message will be displayed when |verbose=true|.
%    See also Figure~\ref{fig:modes} and |includemp|.
% \item[ignoreall] sets both |ignoreheadfoot| and |ignoremp| to |true|. 
%    See also |includeall|.
% \item[heightrounded]~\\
%    This option rounds \cs{textheight} to \textit{n}-times (\textit{n}:
%    an integer) of \cs{baselineskip} plus \cs{topskip} to avoid 
%    ``underfull vbox'' in some cases. For example, if \cs{textheight} is
%    486pt with \cs{baselineskip} 12pt and \cs{topskip} 10pt, then
%    \begin{quote}
%      $(39\times12\textrm{pt}+10\textrm{pt}=)\: 478\textrm{pt}
%       < 486\textrm{pt} < 
%      490\textrm{pt} \:(=40\times12\textrm{pt}+10\textrm{pt})$,
%    \end{quote}
%    as a result \cs{textheight} is rounded to 490pt. |heightrounded=false|
%    by default.
% \end{Options}
%
% The following options can specify body and margins simultaneously with
% three comma-separated values in braces.
% \begin{Options}
% \item[hdivide] horizontal partitions (left,width,right).
%   |hdivide=|\argiii{left margin}{width}{right margin}. 
%   Note that you should not specify all of the three parameters.
%   The best way of using this option is to specify two of three and 
%   leave the rest with null(nothing) or `|*|'. For example, when you set
%   |hdivide={2cm,15cm, }|, the margin from the right-side edge of page
%   will be determined calculating |paperwidth-2cm-15cm|.
% \item[vdivide] vertical partitions (top,height,bottom).
%   |vdivide=|\argiii{top margin}{height}{bottom margin}.
% \item[divide] |divide=|\vargiii{$A$}{$B$}{$C$} is interpreted  as 
%   |hdivide=|\vargiii{$A$}{$B$}{$C$} and |vdivide=|\vargiii{$A$}{$B$}{$C$}.
% \end{Options}
%
% \subsection{Margin size}\label{sec:margin}
%
% The options specifying the size of visible margins are listed below.
% \begin{Options}
% \item[left\OR lmargin\OR inner]~\\
%    left margin (for oneside) or inner margin (for twoside) of 
%    \gpart{total body}. In other words, the distance between the left (inner)
%    edge of the paper and that of \gpart{total body}. |left=|\meta{length}.
%    |inner| has no special meaning, just an alias of |left| and |lmargin|.
% \item[right\OR rmargin\OR outer]~\\ 
%    right or outer margin of \gpart{total body}. |right=|\meta{length}.
% \item[top\OR tmargin] top margin of the page. |top=|\meta{length}.
%    Note this option has nothing to do with the native dimension
%    \cs{topmargin}.
% \item[bottom\OR bmargin]~\\ 
%    bottom margin of the page. |bottom=|\meta{length}.
% \item[hmargin] left and right margin.
%   |hmargin=|\argii{left margin}{right margin} or |hmargin=|\meta{length}.
% \item[vmargin] top and bottom margin.
%   |vmargin=|\argii{top margin}{bottom margin} or |vmargin=|\meta{length}.
% \item[margin] |margin=|\vargii{$A$}{$B$} is equivalent to 
%   |hmargin=|\vargii{$A$}{$B$} and |vmargin=|\vargii{$A$}{$B$}.
%   |margin=|$A$ is automatically expanded to |hmargin=|$A$ and |vmargin=|$A$.
% \item[hmarginratio]
%   horizontal margin ratio of |left| (inner) to |right| (outer). 
%   The value of \meta{ratio} should be specified with colon-separated 
%   two values. Each value should be a positive integer less than 100
%   to prevent arithmetic overflow, e.g., |2:3| instead of |1:1.5|.
%   The default ratio is |1:1| for oneside, |2:3| for twoside.
% \item[vmarginratio]
%    vertical margin ratio of |top| to |bottom|. The default ratio is |2:3|.
% \item[marginratio\OR ratio]~\\
%    horizontal and vertical margin ratios.
%   |marginratio=|\argii{horizontal ratio}{vertical ratio} or
%   |marginratio=|\meta{ratio}.
% \item[hcentering] sets auto-centering horizontally and is
%   equivalent to |hmarginratio=1:1|. It is set to |true| by default for
%   oneside. See also |hmarginratio|.
% \item[vcentering] sets auto-centering vertically and is
%   equivalent to |vmarginratio=1:1|. The default is |false|.
%   See also |vmarginratio|.
% \item[centering] sets auto-centering and is equivalent to
%   |marginratio=1:1|. See also |marginratio|. The default is |false|.
%   See also |marginratio|.
% \item[twoside] switches on twoside mode with left and right margins swapped
%   on verso pages. The option sets \cs{@twoside} and \cs{@mparswitch} 
%   switches. See also |asymmetric|.
% \item[asymmetric] implements a twosided layout in which margins are
%   not swapped on alternate pages (by setting \cs{oddsidemargin} to 
%   \cs{evensidemargin} |+| |bindingoffset|) and in which the marginal notes
%   stay always on the same side. This option can be used as an alternative
%   to the twoside option. See also |twoside|.
% \item[bindingoffset]~\\ removes a specified space 
%   from the lefthand-side of the page for oneside or the inner-side for
%   twoside. |bindingoffset=|\meta{length}. This is useful if pages 
%   are bound by a press binding (glued, stitched, stapled \ldots).
%   See Figure~\ref{fig:bindingoffset}.
% \item[hdivide] See description in Section~\ref{sec:body}.
% \item[vdivide] See description in Section~\ref{sec:body}.
% \item[divide] See description in Section~\ref{sec:body}.
% \end{Options}
% \begin{figure}
%  \centering\small
%  {\unitlength=.65pt
%  \begin{picture}(500,270)(0,0)
%  \put(20,0){\framebox(170,230){}}
%  \put(20,255){\makebox(80,20)[l]{\textbf{a)}~every page for oneside or}}
%  \put(20,240){\makebox(80,20)[l]{\hspace{3ex}odd pages for twoside}}
%  \put(110,225){\makebox(80,20)[r]{\gpart{paper}}}
%  \put(55,37){\framebox(110,170)[tc]{\gpart{total body}}}
%  \multiput(38,0)(0,7){33}{\line(0,1){4}}
%  \put(38,100){\vector(1,0){17}}\put(55,100){\vector(-1,0){17}}
%  \put(60,95){\makebox(80,10)[l]{|left|}}
%  \put(60,80){\makebox(80,10)[l]{(|inner|)}}
%  \put(165,100){\vector(1,0){25}}\put(190,100){\vector(-1,0){25}}
%  \put(195,95){\makebox(80,10)[l]{|right|}}
%  \put(195,80){\makebox(80,10)[l]{(|outer|)}}
%  \put(20,16){\vector(1,0){18}}
%  \put(45,10){\makebox(80,10)[bl]{|bindingoffset|}}
%  \put(280,255){\makebox(80,20)[l]{\textbf{b)}~even (back) pages for twoside}}
%  \put(280,0){\framebox(170,230){}}
%  \put(370,225){\makebox(80,20)[r]{\gpart{paper}}}
%  \put(305,37){\framebox(110,170)[tc]{\gpart{total body}}}
%  \multiput(432,0)(0,7){33}{\line(0,1){4}}
%  \put(280,100){\vector(1,0){25}}\put(305,100){\vector(-1,0){25}}
%  \put(310,95){\makebox(80,10)[l]{|outer|}}
%  \put(310,80){\makebox(80,10)[l]{(|right|)}}
%  \put(415,100){\vector(1,0){17}}\put(432,100){\vector(-1,0){17}}
%  \put(373,95){\makebox(80,10)[l]{|inner|}}
%  \put(373,80){\makebox(80,10)[l]{(|left|)}}
%  \put(450,16){\vector(-1,0){18}}
%  \put(330,10){\makebox(80,10)[bl]{|bindingoffset|}}
%  \end{picture}}
%  \caption[\texttt{bindingoffset} option]{%
%   \begin{minipage}[t]{.8\textwidth}\raggedright\small
%   |bindingoffset| option. Note that |twoside| option swaps the horizontal
%    margins and the marginal notes together with |bindingoffset| on even
%    pages (see \textbf{b)}), but |asymmetric| option suppresses the swap
%    of the margins and marginal notes (but |bindingoffset| is still swapped).
%   \end{minipage}}
%  \label{fig:bindingoffset}
% \end{figure}
%
% \subsection{Native dimensions}\label{sec:dimension}
%
% The options below specify \LaTeX\ native dimensions and switches for page
% layout. See Figure~\ref{fig:layout}. Note that unlike version 2.3,
% |nohead|, |nofoot| and |noheadfoot| become overwritable, in other words,
% just shorthand for setting the corresponding LaTeX dimensions
% (\cs{headheight}, \cs{headsep} and \cs{footskip}) to 0pt.
%
% \begin{Options}
% \item[headheight\OR head]~\\
%    modifies \cs{headheight}, height of header.
%    |headheight=|\meta{length} or |head=|\meta{length}.
% \item[headsep] modifies \cs{headsep}, separation between header and text
%    (body). |headsep=|\meta{length}.
% \item[footskip\OR foot]~\\ modifies \cs{footskip}, distance separation
%    between baseline of last line of text and baseline of footer.
%    |footskip=|\meta{length} or |foot=|\meta{length}.
% \item[nohead] eliminates spaces for the head of the page, which is
%    equivalent to both \cs{headheight}|=0pt| and \cs{headsep}|=0pt|.
% \item[nofoot] eliminates spaces for the foot of the page, which is
%    equivalent to \cs{footskip}|=0pt|.
% \item[noheadfoot] equivalent to |nohead| and |nofoot|, which means that
%    \cs{headheight}, \cs{headsep} and \cs{footskip} are all set to |0pt|.
% \item[footnotesep] changes the dimension \cs{skip}\cs{footins}, separation
%    between the bottom of text body and the top of footnote text.
% \item[marginparwidth\OR marginpar]~\\ 
%    modifies \cs{marginparwidth}, width of the marginal notes.
%    |marginparwidth=|\meta{length}.
%    Unlike version 2.3, it does \textit{not} set |includemp=true|.
% \item[marginparsep] modifies \cs{marginparsep}, separation between
%    body and marginal notes. |marginparsep=|\meta{length}.
%    Unlike version 2.3, it does \textit{not} set |includemp=true|.
% \item[nomarginpar] shrinks spaces for marginal notes to 0pt, which
%    is equivalent to \cs{marginparwidth}|=0pt| and \cs{marginparsep}|=0pt|.
% \item[columnsep] modifies \cs{columnsep}, the separation between two
%    columns in |twocolumn| mode.
% \item[hoffset]  modifies \cs{hoffset}. |hoffset=|\meta{length}.
% \item[voffset]  modifies \cs{voffset}. |voffset=|\meta{length}.
% \item[offset] horizontal and vertical offset.\\
%    |offset=|\argii{hoffset}{voffset} or |offset=|\meta{length}.
% \item[twocolumn] sets |twocolumn| mode with \cs{@twocolumntrue}.
%   |twocolumn=false| denotes onecolumn mode with\cs{@twocolumnfalse}.
% \item[twoside] sets both \cs{@twosidetrue} and \cs{@mparswitchtrue}.
%   See Section~\ref{sec:margin}.
% \item[textwidth] sets \cs{textwidth} directly. See Section~\ref{sec:body}.
% \item[textheight] sets \cs{textheight} directly. See Section~\ref{sec:body}.
% \item[reversemp\OR reversemarginpar]~\\
%   makes the marginal notes appear in the left (inner) margin with
%   \cs{@reversemargintrue}. Unlike version 2.3 or earlier,
%   it does \textit{not} change |includemp| mode. This is |false| by default.
% \end{Options}
%
% \subsection{drivers}\label{sec:drivers}
% 
% Package \textsf{geometry} supports |dvips|, |dvipdfm| including its
% derivatives \textsf{dvipdfmx} and \textsf{xdvipdfmx}, |pdftex|
% for \textsf{pdflatex}, and |vtex| for V\TeX{} environment.
% These driver options are exclusive. The driver can be set by either
% |driver=|\meta{driver name} or any of the drivers directly like |pdftex|.
% A driver auto-detection mechanism is introduced in version 4.
% Therefore, you don't have to set a driver in most cases, except for
% |dvipdfm|.
% Setting |driver=auto| makes the auto-detection work whatever
% the previous setting is. Setting |driver=none| does nothing for driver. 
% \begin{Options}
% \item[driver] sets driver. |driver=|\meta{driver name}. 
% |dvips|, |dvipdfm|, |pdftex|, |vtex|, |auto| and |none| are available as a
% driver name.
% \end{Options}
% The options below can be set directly instead of |driver=|\meta{value}.
% \begin{Options}
% \item[dvips] writes the paper size in dvi output with the \cs{special}
%     macro. If you use \textsl{dvips} as a DVI-to-PS driver,
%     for example, to print a document with |\geometry{a3paper,landscape}|
%     on A3 paper in landscape orientation, you don't need options
%     ``|-t a3 -t landscape|'' to \textsl{dvips}. 
% \item[dvipdfm] works like |dvips| except landscape correction.
% \item[pdftex] sets \cs{pdfpagewidth} and \cs{pdfpageheight} internally.
% \item[vtex] sets dimensions \cs{mediawidth} and \cs{mediaheight}
%     for V\TeX. When this driver is selected (explicitly or
%     automatically), \textsf{geometry} will auto-detect which output mode
%     (DVI, PDF or PS) is selected in V\TeX, and do proper
%     settings for it.
% \end{Options}
% If explicit driver setting is mismatched with the typesetting program
% in use, the default driver |dvips| would be selected.
%
% \subsection{Other options}
%
%  The other useful options are described here.
% \begin{Options}
% \item[verbose] displays parameter results on the terminal.
%   |verbose=false| (default) still puts them into the log file.
% \item[reset] sets back the layout dimensions and switches to the
%   settings before \textsf{geometry} is loaded. Options given in 
%   |geometry.cfg| are also cleared.
%   Note that this cannot reset |pass| and |mag| with |truedimen|.
%   |reset=false| has no effect and cannot cancel the previous
%   |reset|(|=true|) if any. For example, when you go
%   \begin{quote}
%     |\documentclass[landscape]{article}|\\
%     |\usepackage[twoside,reset,left=2cm]{geometry}|
%   \end{quote}
%   with |\ExecuteOptions{scale=0.9}| in |geometry.cfg|,
%   then as a result, |landscape| and |left=2cm| remain effective,
%   and |scale=0.9| and |twoside| are ineffective.
% \item[mag] sets magnification value (\cs{mag}) and automatically modifies 
%   \cs{hoffset} and \cs{voffset} according to the magnification.
%   |mag=|\meta{value}. Note that \meta{value} should be an integer value
%   with 1000 as a normal size. For example, |mag=1414| with |a4paper|
%   provides an enlarged print fitting in |a3paper|, which is $1.414$
%   (=$\sqrt{2}$) times larger than |a4paper|. Font enlargement needs extra
%   disk space. \textbf{Note that setting |mag| should precede any other
%   settings with `true' dimensions, such as  |1.5truein|, |2truecm|
%   and so on.} See also |truedimen| option.
% \item[truedimen] changes all internal explicit dimension values into 
%   \textit{true} dimensions, e.g., |1in| is changed to |1truein|.
%   Typically this option will be used together with |mag| option. Note that
%   this is ineffective against externally specified dimensions. For example,
%   when you set ``\texttt{mag=1440, margin=10pt, truedimen}'', margins are
%   not `true' but magnified. If you want to set exact margins, you should
%   set like ``\texttt{mag=1440, margin=10truept, truedimen}'' instead.
% \item[pass] disables all of the geometry options and calculations
%   except |verbose| and |showframe|. It can be used for checking
%   out the page layout of the documentclass, other packages and manual
%   settings without \textsf{geometry}.
% \item[showframe] shows visible frames for the text area and page,
%   and the lines for the head and foot on the first page.
% \item[compat2] sets all kind of options so that 
%   |\usepackage[compat2]{geometry}| would behave as if one is using
%   the old version (v2.3) with the old default layout:
%   \texttt{[scale=\{0.8,0.9\}, centering, includeheadfoot]},
%   which is here expressed by options available in version 3.
%   Note this option should be set as a first option.
% \end{Options}
%
% \section{Default settings}
%
% \subsection{Default layout}\label{sec:default}
%
% Let us recapitulate the default layout here.
% The \textsf{geometry} package has the following default page layout
% for onesided documents:
% \begin{quote}
%   |scale=0.7, marginratio={1:1, 2:3}, ignoreall|
% \end{quote}
% For twoside, the horizontal margin ratio is also set |2:3|,
% \begin{quote}
%   |scale=0.7, marginratio=2:3, ignoreall|.
% \end{quote}
% Of course, you don't need to set them explicitly. |\usepackage{geometry}|
% will internally set the above options.
% Additional options will overwrite the layout dimensions. For example,
% \begin{quote}
% |\usepackage[hmargin=2cm]{geometry}|
% \end{quote}
% will overwrite horizontal dimensions, but use the default for vertical
% layout. Page dimensions specified by the documentclass being used 
% and other direct settings before \textsf{geometry} is loaded are passed
% down to \textsf{geometry}.
%
% Note version 2.3 or earlier had default layout different from the
% version 3. The old default options can be expressed with options 
% available in the current version:
% \begin{quote}
%   |scale={0.8,0.9}, centering, includeheadfoot|.
% \end{quote}
% Adding |compat2| as a first option sets those options so that, for example,
% \begin{quote}
% |\usepackage[compat2, width=10cm]{geometry}|
% \end{quote}
% would behave as if one is using the old version (v2.3).
%
% \subsection{Configuration file}
%
% One can set up a configuration file to make default options. To do this, 
% produce a file |geometry.cfg| containing an \cs{ExecuteOptions} macro,
% for example, 
% \begin{quote}
% |\ExecuteOptions{a4paper,dvips}|
% \end{quote}
% and install it somewhere \TeX{} can find it.
% 
% The options specified in the |geometry.cfg| can be cleared by 
% option |reset|.
%
% \section{Relations between options}
% This section shows how complexity is solved when options are over-specified.
%
% \subsection{Order dependence}\label{sec:order-depend}
%
% The \textsf{geometry} options are basically order-independent, but there
% are some exceptions. For multiple specification of the same option,
% the last setting is adopted. For example,
% \begin{quote}
%   |verbose=true, verbose=false|
% \end{quote}
% obviously results in |verbose=false|.
% If you set
% \begin{quote}
%   |hmargin={3cm,2cm}, left=1cm|
% \end{quote}
% the left(or inner) margin is overwritten by |left=1cm|. As a result, it is
% equivalent to |hmargin={1cm,2cm}|. 
% 
% The |reset| option removes all the geometry options (except |pass|)
% before it. If you set
% \begin{quote}
% |\documentclass[landscape]{article}|\\
% |\usepackage[margin=1cm,twoside]{geometry}|\\
% |\geometry{a5paper, reset, left=2cm}|
% \end{quote}
% then |margin=1cm|, |twoside| and |a5paper| are removed.
% As a result, this case is equivalent to
% \begin{quote}
% |\documentclass[landscape]{article}|\\
% |\usepackage[left=2cm]{geometry}|
% \end{quote}
%
% The |mag| option should be set in advance of any other settings with
% `true' length, such as |left=1.5truecm|, |width=5truein| and so on.
% The |\mag| primitive can be set before this package is called.
%
% \subsection{Priority}
%  
% There are several ways to set dimensions of the printable area:
% |scale|, |total|, |text| and |lines|. Basically specification with the more
% concrete dimension has the higher priority:
% \[\begin{array}{c}
%  \textrm{low}\quad\longrightarrow\quad\textrm{high}
%              \quad(\textrm{priority})\\[1em]
% \left\{\begin{array}{l}|hscale|\\|vscale|\\|scale|
%        \end{array}\right\} <
% \left\{\begin{array}{l}|width|\\|height|\\|total|
%        \end{array}\right\} <
% \left\{\begin{array}{l}|textwidth|\\|textheight|
%         \\|text|\end{array}\right\} < |lines|.
% \end{array}\]
% For example, 
% \begin{quote}
%  |\usepackage[hscale=0.8, textwidth=7in, width=18cm]{geometry}|
% \end{quote}
% is the same as |\usepackage[textwidth=7in]{geometry}|. Another example:
% \begin{quote}
%  |\usepackage[lines=30, scale=0.8, text=7in]{geometry}|
% \end{quote}
% results in \texttt{[lines=30, textwidth=7in]}.
%
% Options determining margin size also have priority rule:
% margin ratios versus margin length. For example, if both |marginratio=1:2|
% and |margin=1cm| are set at the same time, |margin=1cm| wins because
% |margin=1cm| is more concrete dimension than ratios. That is why normal
% margin options work well with default margin ratios 
% (|marginratio={1:1, 2:3}| for oneside).
% \[\begin{array}{c}
%  \textrm{low}\quad\longrightarrow\quad\textrm{high}
%              \quad(\textrm{priority})\\[1em]
% \left\{\begin{array}{l}|hmarginratio|\\|vmarginratio|\\|marginratio|
%        \end{array}\right\} <
% \left\{\begin{array}{l}
%            |hmargin|\:\textit{or}\:|left|\:\textrm{\&}\:|right|\\
%            |vmargin|\:\textit{or}\:|top|\:\textrm{\&}\:|bottom|\\
%            |margin|
%        \end{array}\right\}.
% \end{array}\]
%
% \section{Examples}
%
% \begin{itemize}
% \item A onesided page layout with the text area centered in the paper.
% The examples below have the same result because the horizontal margin ratio
% is set |1:1| for oneside by default.
% \begin{itemize}
%   \item |centering|
%   \item |marginratio=1:1|
%   \item |vcentering|
% \end{itemize}
%
% \item A twosided page layout with the inside offset for binding |1cm|.
% \begin{itemize}
%   \item |twoside, bindingoffset=1cm|
% \end{itemize}
% In this case, |textwidth| is shorter than the case without
% |bindingoffset=1cm| by $0.7\times|1cm|$ ($=$|0.7cm|).
%
% \item A layout with the left, right, and top margin |3cm|, |2cm| and
% |2.5in| respectively, with textheight of 40 lines, and with the head and
% foot of the page included in \gpart{total body}.
% The two examples below have the same result.
% \begin{itemize}
%   \item |left=3cm, right=2cm, lines=40, top=2.5in, includeheadfoot|
%   \item |hmargin={3cm,2cm}, tmargin=2.5in, lines=40, includeheadfoot|
% \end{itemize}
%
% \item A layout with the height of \gpart{total body} |10in|, the bottom
%  margin |2cm|, and the default width. The top margin will be calculated
%  automatically. Each solution below results in the same page layout.
% \begin{itemize}
%     \item |vdivide={*, 10in, 2cm}|
%     \item |bmargin=2cm, height=10in|
%     \item |bottom=2cm, textheight=10in| 
% \end{itemize}
% Note that dimensions for \gpart{head} and \gpart{foot} are excluded from
% |height| of \gpart{total body}. An additional |includefoot| makes
% \cs{footskip} included in |totalheight|. Therefore, in the two cases below,
% |textheight| in the former layout is shorter than the latter
% (with 10in exactly) by \cs{footskip}. In other words, 
% |height| = |textheight| + |footskip| when |includefoot=true| in this case.
% \begin{itemize}
%     \item |bmargin=2cm, height=10in, includefoot|
%     \item |bottom=2cm, textheight=10in, includefoot|
% \end{itemize}
%
% \item A layout with \glen{textwidth} and \glen{textheight} 90\% of the
% paper and with \gpart{body} centered.
% Each solution below results in the same page layout.
% \begin{itemize}
%   \item |scale=0.9, centering|
%   \item |text={.9\paperwidth,.9\paperheight}, ratio=1:1|
%   \item |width=.9\paperwidth, vmargin=.05\paperheight, marginratio=1:1|
%   \item |hdivide={*,0.9\paperwidth,*}, vdivide={*,0.9\paperheight,*}|
%   (as for onesided documents)
%   \item |margin={0.05\paperwidth,0.05\paperheight}|
% \end{itemize}
% You can add |heightrounded| to avoid an ``underfull vbox warning'' like
% \begin{quote}\small
%  |Underfull \vbox (badness 10000) has occurred while \output is active|.
% \end{quote}
% See Section~\ref{sec:body} for the detail description about |heightrounded|.
%
% \item A layout with the width of marginal notes |3cm| and included in the
% width of \gpart{total body}. The following examples are the same.
% \begin{itemize}
%   \item |marginparwidth=3cm, includemp|
%   \item |marginpar=3cm, ignoremp=false|
% \end{itemize}
%
% \item A layout the full scale \gpart{body} of the paper with A5 paper in
% landscape. The following examples are the same.
% \begin{itemize}
%   \item |a5paper, landscape, scale=1.0|
%   \item |landscape=TRUE, paper=a5paper, margin=0pt|
% \end{itemize}
%
% \item  A screen size layout appropriate to presentation with PC and video
%        projector.
% \begin{verbatim}
%   \documentclass{slide}
%   \usepackage[screen,margin=0.8in]{geometry}
%    ...
%   \begin{slide}
%      ...
%   \end{slide}\end{verbatim}
% \item A layout with fonts and spaces both enlarged from A4 to A3.
%  In the case below, the resulted paper size is A3.
% \begin{itemize}
%     \item |a4paper, mag=1414|.
% \end{itemize}
% If you want to have a layout with two times bigger fonts, but without
% changing paper size, you can go 
% \begin{itemize}
%   \item |letterpaper, mag=2000, truedimen|.
% \end{itemize}
%  You can add |dvips| option, that is useful to preview it with proper
%  paper size by |dviout| or |xdvi|.
%
% \item An old style setting with v2.3 or earlier
% \begin{verbatim}
%  \usepackage[a4paper,mag=1200,truedimen,margin=2cm,
%      twosideshift=10pt,
%      headsep=7pt,headheight=14.5pt,
%      marginparwidth=30pt]{geometry}\end{verbatim}
% can be rewritten with options in version 3 without |compat2|:
% \begin{verbatim}
%  \usepackage{calc}
%  \usepackage[a4paper,mag=1200,truedimen,margin=2cm,
%      twoside, left=2cm+10pt, right=2cm-10pt,
%      includeheadfoot, headsep=7pt,headheight=14.5pt,
%      includemp, marginparwidth=30pt]{geometry}\end{verbatim}
% In this case, |includeall| can be used instead of |includeheadfoot| and 
% |includemp|.
%
% \item A complex page layout.
% \begin{verbatim}
%  \usepackage[a5paper, landscape, twocolumn, twoside,
%      left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt, 
%      bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
%      columnsep=1cm, dvips,  verbose]{geometry}\end{verbatim}
% Try typesetting it and checking out the result yourself. |:-)|
% \end{itemize}
%
% \section{Known problems}
% \begin{itemize}
%  \item With |pdftex=true|, |mag| $\neq 1000$ and |truedimen|,
%  |paperwidth| and |paperheight| shown in verbose mode are different
%  from the real size of the resulted PDF. The PDF itself is correct anyway.
%
%  \item With |pdftex=true|, |mag| $\neq 1000$, \textit{no} |truedimen|,
%  and \textsf{hyperref}, \textsf{hyperref} should be loaded
%  by \cs{usepackage} before \textsf{geometry}. 
%  Otherwise the resulted PDF size will become wrong.
%
%  \item With \textsf{crop} package and |mag| $\neq 1000$,
%  |center| option of \textsf{crop} doesn't work well.
% \end{itemize}
%
% \section{Acknowledgments}
%  The author appreciates helpful suggestions and comments from
%  Jean-Bernard Addor,
%  Frank Bennett,
%  Alexis Dimitriadis,
%  Friedrich Flender,
%  Stephan Hennig,
%  Morten H\o{}gholm,
%  Jonathan Kew,
%  James Kilfiger,
%  Jean-Marc Lasgouttes,
%  Wlodzimierz Macewicz,
%  Rolf Niepraschk,
%  Hans Fr.~Nordhaug,
%  Keith Reckdahl, 
%  Peter Riocreux,
%  Will Robertson,
%  Nico Schl\"{o}emer,
%  Perry C.~Stearns, 
%  Frank Stengel,
%  Plamen Tanovski,
%  Petr Uher,
%  Piet van Oostrum,
%  Vladimir Volovich,
%  and
%  Michael Vulis.
%  
%  The author is deeply grateful to Frank Mittelbach for checking the codes patiently
%  and providing extremely helpful insight and suggestions for version 3.
%
% \StopEventually{%
%  \ifmulticols
%  \addtocontents{toc}{\protect\end{multicols}}
%  \fi
% }
%
% \section{Implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    This package requires three other packages: \textsf{keyval} in \LaTeX\ graphics bundle,
%    \textsf{ifpdf} and \textsf{ifvtex} in `oberdiek' bundle.
%    \begin{macrocode}
\RequirePackage{keyval}%
\RequirePackage{ifpdf}%
\RequirePackage{ifvtex}%
%    \end{macrocode}
% 
%    Internal switches are declared here.
%    \begin{macrocode}
\newif\ifGm@verbose
\newif\ifGm@landscape
\newif\ifGm@includehead
\newif\ifGm@includefoot
\newif\ifGm@includemp
\newif\ifGm@hbody
\newif\ifGm@vbody
\newif\ifGm@heightrounded
\newif\ifGm@showframe
\newif\ifGm@compatii
\newif\ifGm@sworient\Gm@sworientfalse
\newif\ifGm@pass\Gm@passfalse
\newif\ifGm@resetpaper
%    \end{macrocode}
%    \begin{macro}{\Gm@cnth}
%    \begin{macro}{\Gm@cntv}
%    Counters for horizontal and vertical partitioning patterns.
%    \begin{macrocode}
\newcount\Gm@cnth
\newcount\Gm@cntv
%    \end{macrocode}
%    \end{macro}\end{macro}
%    \begin{macro}{\c@Gm@tempcnt}
%    The counter is used to set number with \textsf{calc}.
%    \begin{macrocode}
\newcount\c@Gm@tempcnt
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@bindingoffset}
%    An additional inner offset for binding.
%    \begin{macrocode}
\newdimen\Gm@bindingoffset
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@wd@mp}
%    \begin{macro}{\Gm@odd@mp}
%    \begin{macro}{\Gm@even@mp}
%    Correction lengths for \cs{textwidth}, \cs{oddsidemargin} and 
%    \cs{evensidemargin} in |includemp| mode.
%    \begin{macrocode}
\newdimen\Gm@wd@mp
\newdimen\Gm@odd@mp
\newdimen\Gm@even@mp
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}
%    \begin{macro}{\Gm@dimlist}
%    Native dimension setting list.
%    \begin{macrocode}
\newtoks\Gm@dimlist
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@warning}
%    Macro for printing warning messages.
%    \begin{macrocode}
\def\Gm@warning#1{\PackageWarningNoLine{geometry}{#1}}%
\@onlypreamble\Gm@warning
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@Dhratio}
%    \begin{macro}{\Gm@Dhratiotwo}
%    \begin{macro}{\Gm@Dvratio}
%    The default values for the horizontal and vertical \textsl{marginalratio}
%    are defined. \cs{Gm@Dhratiotwo} denotes the default value of
%    horizonal \textsl{marginratio} for twoside page layout with
%    left and right margins swapped on verso pages, which is 
%    set by |twoside|.
%    \begin{macrocode}
\def\Gm@Dhratio{1:1}% = left:right default for oneside
\def\Gm@Dhratiotwo{2:3}% = inner:outer default for twoside.
\def\Gm@Dvratio{2:3}% = top:bottom default
\@onlypreamble\Gm@Dhratio
\@onlypreamble\Gm@Dhratiotwo
\@onlypreamble\Gm@Dvratio
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}
%
%    \begin{macro}{\Gm@Dhscale}
%    \begin{macro}{\Gm@Dvscale}
%    The default values for the horizontal and vertical \textsl{scale}
%    are defined. In version 3 the default scale has been changed from 
%    \{0.8, 0.9\} to \{0.7, 0.7\} in each direction.
%    \begin{macrocode}
\def\Gm@Dhscale{0.7}%
\def\Gm@Dvscale{0.7}%
\@onlypreamble\Gm@Dhscale
\@onlypreamble\Gm@Dvscale
%    \end{macrocode}
%    \end{macro}\end{macro}
%
%    \begin{macro}{\Gm@dvips}%
%    \begin{macro}{\Gm@dvipdfm}%
%    \begin{macro}{\Gm@pdftex}%
%    \begin{macro}{\Gm@vtex}%
%    The driver names.
%    \begin{macrocode}
\def\Gm@dvips{dvips}%
\def\Gm@dvipdfm{dvipdfm}%
\def\Gm@pdftex{pdftex}%
\def\Gm@vtex{vtex}%
\@onlypreamble\Gm@dvips
\@onlypreamble\Gm@dvipdfm
\@onlypreamble\Gm@pdftex
\@onlypreamble\Gm@vtex
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}\end{macro}
%
%    \begin{macro}{\Gm@true}%
%    \begin{macro}{\Gm@false}%
%    \begin{macrocode}
\def\Gm@true{true}%
\def\Gm@false{false}%
%    \end{macrocode}
%    \end{macro}\end{macro}
%
%    \begin{macro}{\Gm@orgpw}
%    \begin{macro}{\Gm@orgph}
%    These macros keep original paper (media) size intact.
%    \begin{macrocode}
\edef\Gm@orgpw{\the\paperwidth}%
\edef\Gm@orgph{\the\paperheight}%
%    \end{macrocode}
%    \end{macro}\end{macro}
%
%    \begin{macro}{\Gm@dorg}
%    The macro saves \LaTeX{} native dimensions and switches before
%    processing \textsf{geometry} options, and is called when |reset|
%    or |pass| is set.
%    \begin{macrocode}
\edef\Gm@dorg{%
  \noexpand\setlength{\paperwidth}{\the\paperwidth}%
  \noexpand\setlength{\paperheight}{\the\paperheight}%
  \noexpand\setlength{\textheight}{\the\textheight}%
  \noexpand\setlength{\textwidth}{\the\textwidth}%
  \noexpand\setlength{\oddsidemargin}{\the\oddsidemargin}%
  \noexpand\setlength{\evensidemargin}{\the\evensidemargin}%
  \noexpand\setlength{\topmargin}{\the\topmargin}%
  \noexpand\setlength{\headsep}{\the\headsep}%
  \noexpand\setlength{\headheight}{\the\headheight}%
  \noexpand\setlength{\footskip}{\the\footskip}%
  \noexpand\setlength{\marginparwidth}{\the\marginparwidth}%
  \noexpand\setlength{\marginparsep}{\the\marginparsep}%
  \noexpand\setlength{\columnsep}{\the\columnsep}%
  \noexpand\setlength{\skip\footins}{\the\skip\footins}%
  \noexpand\setlength{\hoffset}{\the\hoffset}%
  \noexpand\setlength{\voffset}{\the\voffset}%
  \expandafter\noexpand\csname @twocolumn\if@twocolumn
    \Gm@true\else\Gm@false\fi\endcsname
  \expandafter\noexpand\csname @twoside\if@twoside
    \Gm@true\else\Gm@false\fi\endcsname
  \expandafter\noexpand\csname @mparswitch\if@mparswitch
    \Gm@true\else\Gm@false\fi\endcsname
  \expandafter\noexpand\csname @reversemargin\if@reversemargin
    \Gm@true\else\Gm@false\fi\endcsname
  \noexpand\mag=\the\mag}%
\@onlypreamble\Gm@dorg
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@init}
%    The macro for initializing modes and flags is defined here. This macro
%    is called at the beginning of the package and when |reset| is specified.
%    \begin{macrocode}
\def\Gm@init{%
  \Gm@hbodyfalse\Gm@vbodyfalse
  \Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse
  \Gm@landscapefalse\Gm@compatiifalse\Gm@heightroundedfalse
  \Gm@verbosefalse\Gm@showframefalse\Gm@resetpaperfalse
  \let\Gm@paper\@undefined
  \let\Gm@width\@undefined\let\Gm@height\@undefined
  \let\Gm@textwidth\@undefined\let\Gm@textheight\@undefined
  \let\Gm@hscale\@undefined\let\Gm@vscale\@undefined
  \let\Gm@hmarginratio\@undefined\let\Gm@vmarginratio\@undefined
  \let\Gm@lmargin\@undefined\let\Gm@rmargin\@undefined
  \let\Gm@tmargin\@undefined\let\Gm@bmargin\@undefined
  \let\Gm@driver\@empty\let\Gm@truedimen\@empty
  \Gm@bindingoffset\z@\Gm@dimlist={}}%
\@onlypreamble\Gm@init
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@setdriver}
%    The macro sets the specified driver.
%    \begin{macrocode}
\def\Gm@setdriver#1{%
  \expandafter\let\expandafter\Gm@driver\csname Gm@#1\endcsname}%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@unsetdriver}
%    The macro unsets the specified driver if it has been set.
%    \begin{macrocode}
\def\Gm@unsetdriver#1{%
  \expandafter\ifx\csname Gm@#1\endcsname\Gm@driver
    \let\Gm@driver\@empty
  \fi}%
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@setbool}
%    \begin{macro}{\Gm@setboolrev}
%    The macros set a boolean option.
%    \begin{macrocode}
\def\Gm@setbool{\@dblarg\Gm@@setbool}%
\def\Gm@setboolrev{\@dblarg\Gm@@setboolrev}%
\def\Gm@@setbool[#1]#2#3{\Gm@doif{#1}{#3}{\csname Gm@#2\Gm@bool\endcsname}}%
\def\Gm@@setboolrev[#1]#2#3{\Gm@doifelse{#1}{#3}%
  {\csname Gm@#2\Gm@false\endcsname}{\csname Gm@#2\Gm@true\endcsname}}%
\@onlypreamble\Gm@setbool
\@onlypreamble\Gm@setboolrev
\@onlypreamble\Gm@@setbool
\@onlypreamble\Gm@@setboolrev
%    \end{macrocode}
%    \end{macro}\end{macro}
%    \begin{macro}{\Gm@doif}
%    \begin{macro}{\Gm@doifelse}
%    \cs{Gm@doif} excutes the third argument |#3| using a boolean value
%    |#2| of a option |#1|. \cs{Gm@doifelse} executes the third
%    argument |#3| if a boolean option |#1| with its value |#2| is |true|,
%    and executes the fourth argument |#4| if |false|.
%    \begin{macrocode}
\def\Gm@doif#1#2#3{%
  \lowercase{\def\Gm@bool{#2}}%
  \ifx\Gm@bool\@empty
    \let\Gm@bool\Gm@true
  \fi
  \ifx\Gm@bool\Gm@true
  \else
    \ifx\Gm@bool\Gm@false
    \else
      \let\Gm@bool\relax
    \fi
  \fi
  \ifx\Gm@bool\relax
    \Gm@warning{`#1' should be set to `true' or `false'}%
  \else
    #3
  \fi}%
\def\Gm@doifelse#1#2#3#4{%
  \Gm@doif{#1}{#2}{\ifx\Gm@bool\Gm@true #3\else #4\fi}}%
\@onlypreamble\Gm@doif
\@onlypreamble\Gm@doifelse
%    \end{macrocode}
%    \end{macro}\end{macro}
%
%    \begin{macro}{\Gm@reverse}
%    The macro reverses a bool value.
%    \begin{macrocode}
\def\Gm@reverse#1{%
  \csname ifGm@#1\endcsname
  \csname Gm@#1false\endcsname\else\csname Gm@#1true\endcsname\fi}%
\@onlypreamble\Gm@reverse
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@checkbool}
%    The macro is used in \cs{Gm@showparams} to print |true| or nothing.
%    \begin{macrocode}
\def\Gm@checkbool#1{#1: \csname ifGm@#1\endcsname true\else --\fi^^J}%
\@onlypreamble\Gm@checkbool
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@defbylen}
%    \begin{macro}{\Gm@defbycnt}
%    Macros \cs{Gm@defbylen} and \cs{Gm@defbycnt} can be used to define
%    \cs{Gm@xxxx} variables by length and counter respectively
%    with \textsf{calc} package.
%    \begin{macrocode}
\def\Gm@defbylen#1#2{%
  \setlength\@tempdima{#2}%
  \expandafter\edef\csname Gm@#1\endcsname{\the\@tempdima}}%
\def\Gm@defbycnt#1#2{%
  \setcounter{Gm@tempcnt}{#2}%
  \expandafter\edef\csname Gm@#1\endcsname{\the\value{Gm@tempcnt}}}%
\@onlypreamble\Gm@defbylen
\@onlypreamble\Gm@defbycnt
%    \end{macrocode}
%    \end{macro}\end{macro}
%    \begin{macro}{\Gm@set@ratio}
%    The macro parses the value of options specifying marginal ratios,
%    which is used in \cs{Gm@setbyratio} macro.
%    \begin{macrocode}
\def\Gm@sep@ratio#1:#2{\@tempcnta=#1\@tempcntb=#2}%
\@onlypreamble\Gm@set@ratio
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@setbyratio}
%    The macro determines the dimension specified by |#4| calculating
%    |#3|$\times a / b$, where $a$ and $b$ are given by \cs{Gm@mratio}
%    with $a:b$ value. If |#1| in brackets is |b|, $a$ and $b$ are swapped.
%    The second argument with |h| or |v| denoting horizontal or vertical
%    is not used in this macro.
%    \begin{macrocode}
\def\Gm@setbyratio[#1]#2#3#4{% determine #4 by ratio
  \expandafter\Gm@sep@ratio\Gm@mratio\relax
  \if#1b
    \edef\@@tempa{\the\@tempcnta}%
    \@tempcnta=\@tempcntb
    \@tempcntb=\@@tempa\relax
  \fi
  \expandafter\setlength\expandafter\@tempdimb\expandafter
    {\csname Gm@#3\endcsname}%
  \ifnum\@tempcntb>\z@
    \multiply\@tempdimb\@tempcnta
    \divide\@tempdimb\@tempcntb
  \fi
  \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdimb}}%
\@onlypreamble\Gm@setbyratio
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@detiv}
%    This macro determines the fourth length(|#4|) from |#1|(\glen{paperwidth}
%    or \glen{paperheight}), |#2| and |#3|. It is used in
%    \cs{Gm@detall} macro.
%    \begin{macrocode}
\def\Gm@detiv#1#2#3#4{% determine #4.
  \expandafter\setlength\expandafter\@tempdima\expandafter
    {\csname paper#1\endcsname}%
  \expandafter\setlength\expandafter\@tempdimb\expandafter
    {\csname Gm@#2\endcsname}%
  \addtolength\@tempdima{-\@tempdimb}%
  \expandafter\setlength\expandafter\@tempdimb\expandafter
    {\csname Gm@#3\endcsname}%
  \addtolength\@tempdima{-\@tempdimb}%
  \ifdim\@tempdima<\z@
    \Gm@warning{`#4' results in NEGATIVE (\the\@tempdima).%
    ^^J\@spaces `#2' or `#3' should be shortened in length}%
  \fi
  \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdima}}%
\@onlypreamble\Gm@detiv
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@detiiandiii}
%    This macro determines |#2| and |#3| from |#1| with the first argument
%    (|#1|) can be |width| or |height|, which is expanded into dimensions
%    of paper and total body. It is used in \cs{Gm@detall} macro.
%    \begin{macrocode}
\def\Gm@detiiandiii#1#2#3{% determine #2 and #3.
  \expandafter\setlength\expandafter\@tempdima\expandafter
    {\csname paper#1\endcsname}%
  \expandafter\setlength\expandafter\@tempdimb\expandafter
    {\csname Gm@#1\endcsname}%
  \addtolength\@tempdima{-\@tempdimb}%
  \ifdim\@tempdima<\z@
    \Gm@warning{`#2' and `#3' result in NEGATIVE (\the\@tempdima).%
                  ^^J\@spaces `#1' should be shortened in length}%
  \fi
  \ifx\Gm@mratio\@undefined
    \divide\@tempdima\tw@
    \@tempdimb=\@tempdima
  \else
    \@tempdimb=\@tempdima
    \expandafter\Gm@sep@ratio\Gm@mratio\relax
    \advance\@tempcntb\@tempcnta
    \ifnum\@tempcntb>\z@
      \divide\@tempdima\@tempcntb
      \multiply\@tempdima\@tempcnta
      \advance\@tempdimb-\@tempdima
    \else
      \divide\@tempdima\tw@
      \@tempdimb=\@tempdima
    \fi
  \fi
  \expandafter\edef\csname Gm@#2\endcsname{\the\@tempdima}%
  \expandafter\edef\csname Gm@#3\endcsname{\the\@tempdimb}}%
\@onlypreamble\Gm@detiiandiii
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@detall}
%    This macro determines partition of each direction.
%    The first argument (|#1|) should be |h| or |v|, the second (|#2|)
%    |width| or |height|, the third (|#3|) |lmargin| or |top|, and 
%    the last (|#4|) |rmargin| or |bottom|.
%    \begin{macrocode}
\def\Gm@detall#1#2#3#4{%
  \@tempcnta\z@
  \edef\Gm@mratio{\@nameuse{Gm@#1marginratio}}%
%    \end{macrocode}
%    \cs{@tempcnta} is treated as a three-digit binary value with
%    top, middle and bottom denoted |left|(|top|), |width|(|height|)
%    and |right|(|bottom|) margins user specified respectively.
%    \begin{macrocode}
  \if#1h
    \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta4\relax\fi
    \ifGm@hbody\advance\@tempcnta2\relax\fi
    \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta1\relax\fi
    \Gm@cnth\@tempcnta
  \else
    \ifx\Gm@tmargin\@undefined\else\advance\@tempcnta4\relax\fi
    \ifGm@vbody\advance\@tempcnta2\relax\fi
    \ifx\Gm@bmargin\@undefined\else\advance\@tempcnta1\relax\fi
    \Gm@cntv\@tempcnta
  \fi
%    \end{macrocode}
%    Case the value is |000| (=0) with nothing fixed (default):
%    \begin{macrocode}
  \ifcase\@tempcnta
    \if#1h
      \edef\Gm@width{\Gm@Dhscale\paperwidth}%
    \else
      \edef\Gm@height{\Gm@Dvscale\paperheight}%
    \fi
    \Gm@detiiandiii{#2}{#3}{#4}%
%    \end{macrocode}
%    Case |001| (=1) with |right|(|bottom|) fixed:
%    \begin{macrocode}
  \or\Gm@setbyratio[f]{#1}{#4}{#3}\Gm@detiv{#2}{#3}{#4}{#2}%
%    \end{macrocode}
%    Case |010| (=2) with |width|(|height|) fixed:
%    \begin{macrocode}
  \or\Gm@detiiandiii{#2}{#3}{#4}%
%    \end{macrocode}
%    Case |011| (=3) with both |width|(|height|) and |right|(|bottom|) fixed:
%    \begin{macrocode}
  \or\Gm@detiv{#2}{#2}{#4}{#3}%
%    \end{macrocode}
%    Case |100| (=4) with |left|(|top|) fixed:
%    \begin{macrocode}
  \or\Gm@setbyratio[b]{#1}{#3}{#4}\Gm@detiv{#2}{#3}{#4}{#2}%
%    \end{macrocode}
%    Case |101| (=5) with both |left|(|top|) and |right|(|bottom|) fixed:
%    \begin{macrocode}
  \or\Gm@detiv{#2}{#3}{#4}{#2}%
%    \end{macrocode}
%    Case |110| (=6) with both |left|(|top|) and |width|(|height|) fixed:
%    \begin{macrocode}
  \or\Gm@detiv{#2}{#2}{#3}{#4}%
%    \end{macrocode}
%    Case |111| (=7) with all fixed though it is over-specified:
%    \begin{macrocode}
  \or\Gm@warning{Over-specification in `#1'-direction.%
                  ^^J\@spaces `#2' (\@nameuse{Gm@#2}) is ignored}%
    \Gm@detiv{#2}{#3}{#4}{#2}%
  \else\fi}%
\@onlypreamble\Gm@detall
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@clean}
%    The macro for setting unspecified dimensions to be \cs{@undefined}.
%    This is used by \cs{geometry} macro.
%    \begin{macrocode}
\def\Gm@clean{%
  \ifnum\Gm@cnth<4\let\Gm@lmargin\@undefined\fi
  \ifodd\Gm@cnth\else\let\Gm@rmargin\@undefined\fi
  \ifnum\Gm@cntv<4\let\Gm@tmargin\@undefined\fi
  \ifodd\Gm@cntv\else\let\Gm@bmargin\@undefined\fi
  \ifGm@hbody\else
    \let\Gm@hscale\@undefined
    \let\Gm@width\@undefined
    \let\Gm@textwidth\@undefined
  \fi
  \ifGm@vbody\else
    \let\Gm@vscale\@undefined
    \let\Gm@height\@undefined
    \let\Gm@textheight\@undefined
  \fi
  \if@twoside
    \ifx\Gm@hmarginratio\Gm@Dhratiotwo
      \let\Gm@hmarginratio\@undefined
    \fi
  \else
    \ifx\Gm@hmarginratio\Gm@Dhratio
      \let\Gm@hmarginratio\@undefined
    \fi
  \fi}%
\@onlypreamble\Gm@clean
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@parse@divide}
%    The macro parses (|h|,|v|)|divide| options.
%    \begin{macrocode}
\def\Gm@parse@divide#1#2#3#4{%
  \def\Gm@star{*}%
  \@tempcnta\z@
  \@for\Gm@tmp:=#1\do{%
    \expandafter\KV@@sp@def\expandafter\Gm@frag\expandafter{\Gm@tmp}%
    \edef\Gm@value{\Gm@frag}%
    \ifcase\@tempcnta\relax\edef\Gm@key{#2}%
      \or\edef\Gm@key{#3}%
      \else\edef\Gm@key{#4}%
    \fi
    \@nameuse{Gm@set\Gm@key false}%
    \ifx\empty\Gm@value\else
    \ifx\Gm@star\Gm@value\else
      \setkeys{Gm}{\Gm@key=\Gm@value}%
    \fi\fi
    \advance\@tempcnta\@ne}%
  \let\Gm@star\relax}%
\@onlypreamble\Gm@parse@divide
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@branch}
%    The macro splits a value into the same two values.
%    \begin{macrocode}
\def\Gm@branch#1#2#3{%
  \@tempcnta\z@
  \@for\Gm@tmp:=#1\do{%
    \KV@@sp@def\Gm@frag{\Gm@tmp}%
    \edef\Gm@value{\Gm@frag}%
    \ifcase\@tempcnta\relax% cnta == 0
      \setkeys{Gm}{#2=\Gm@value}%
    \or% cnta == 1
      \setkeys{Gm}{#3=\Gm@value}%
    \else\fi
    \advance\@tempcnta\@ne}%
  \ifnum\@tempcnta=\@ne
    \setkeys{Gm}{#3=\Gm@value}%
  \fi}%
\@onlypreamble\Gm@branch
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@magtooffset}
%    This macro is used to adjust offsets by \cs{mag}.
%    \begin{macrocode}
\def\Gm@magtooffset{%
  \@tempdima=\mag\Gm@truedimen sp%
  \@tempdimb=1\Gm@truedimen in%
  \divide\@tempdimb\@tempdima
  \multiply\@tempdimb\@m
  \addtolength{\hoffset}{1\Gm@truedimen in}%
  \addtolength{\voffset}{1\Gm@truedimen in}%
  \addtolength{\hoffset}{-\the\@tempdimb}%
  \addtolength{\voffset}{-\the\@tempdimb}}%
\@onlypreamble\Gm@magtooffset
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@setafter}
%    This macro stores \LaTeX{} native dimensions, which are stored and 
%    set afterwards.
%    \begin{macrocode}
\def\Gm@setafter#1#2{%
  \let\Gm@len=\relax\let\Gm@td=\relax
  \edef\addtolist{\noexpand\Gm@dimlist=%
  {\the\Gm@dimlist \Gm@len{#1}{#2}}}\addtolist}%
\@onlypreamble\Gm@setafter
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@processdimlist}
%    This macro processes \cs{Gm@dimlist}.
%    \begin{macrocode}
\def\Gm@processdimlist{%
  \def\Gm@td{\Gm@truedimen}%
  \def\Gm@len##1##2{\setlength{##1}{##2}}%
  \the\Gm@dimlist}%
\@onlypreamble\Gm@processdimlist
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@setpaper}
%    The macro sets |paperwidth| and |paperheight| dimensions
%    using \cs{Gm@setafter} macro.
%    \begin{macrocode}
\def\Gm@setpaper(#1,#2)#3{%
  \let\Gm@td\relax
  \Gm@setafter\paperwidth{#1\Gm@td #3}%
  \Gm@setafter\paperheight{#2\Gm@td #3}%
  \ifGm@landscape\Gm@sworienttrue\else\Gm@sworientfalse\fi}%
\@onlypreamble\Gm@setpaper
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@chpaper}
%    The macro changes the paper size.
%    \begin{macrocode}
\def\Gm@chpaper{\@nameuse{Gm@\Gm@paper}}%
\@onlypreamble\Gm@chpaper
%    \end{macrocode}
%    \end{macro}
%    Various paper size are defined here.
%    \begin{macrocode}
\@namedef{Gm@a0paper}{\Gm@setpaper(841,1189){mm}}%
\@namedef{Gm@a1paper}{\Gm@setpaper(594,841){mm}}%
\@namedef{Gm@a2paper}{\Gm@setpaper(420,594){mm}}%
\@namedef{Gm@a3paper}{\Gm@setpaper(297,420){mm}}%
\@namedef{Gm@a4paper}{\Gm@setpaper(210,297){mm}}%
\@namedef{Gm@a5paper}{\Gm@setpaper(148,210){mm}}%
\@namedef{Gm@a6paper}{\Gm@setpaper(105,148){mm}}%
\@namedef{Gm@b0paper}{\Gm@setpaper(1000,1414){mm}}%
\@namedef{Gm@b1paper}{\Gm@setpaper(707,1000){mm}}%
\@namedef{Gm@b2paper}{\Gm@setpaper(500,707){mm}}%
\@namedef{Gm@b3paper}{\Gm@setpaper(353,500){mm}}%
\@namedef{Gm@b4paper}{\Gm@setpaper(250,353){mm}}%
\@namedef{Gm@b5paper}{\Gm@setpaper(176,250){mm}}%
\@namedef{Gm@b6paper}{\Gm@setpaper(125,176){mm}}%
\@namedef{Gm@ansiapaper}{\Gm@setpaper(8.5,11){in}}%
\@namedef{Gm@ansibpaper}{\Gm@setpaper(11,17){in}}%
\@namedef{Gm@ansicpaper}{\Gm@setpaper(17,22){in}}%
\@namedef{Gm@ansidpaper}{\Gm@setpaper(22,34){in}}%
\@namedef{Gm@ansiepaper}{\Gm@setpaper(34,44){in}}%
\@namedef{Gm@letterpaper}{\Gm@setpaper(8.5,11){in}}%
\@namedef{Gm@legalpaper}{\Gm@setpaper(8.5,14){in}}%
\@namedef{Gm@executivepaper}{\Gm@setpaper(7.25,10.5){in}}%
\@namedef{Gm@screen}{\Gm@setpaper(225,180){mm}}%
%    \end{macrocode}
%
%    All the available options are defined below.
%  \begin{key}{Gm}{paper}
%    |paper| takes paper name as its value. Available paper names are listed
%     below.
%    \begin{macrocode}
\define@key{Gm}{paper}{\setkeys{Gm}{#1}}%
\let\KV@Gm@papername\KV@Gm@paper
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{a[0-6]paper}
%  \begin{key}{Gm}{b[0-6]paper}
%  \begin{key}{Gm}{ansi[a-e]paper}
%  \begin{key}{Gm}{letterpaper}
%  \begin{key}{Gm}{legalpaper}
%  \begin{key}{Gm}{executivepaper}
%  \begin{key}{Gm}{screen}
%    The following paper names are available. |screen| and ANSI paper sizes
%    have been introduced in ver.3, but of course they can't be used as
%    a documentclass option.
%    \begin{macrocode}
\define@key{Gm}{a0paper}[true]{\def\Gm@paper{a0paper}\Gm@chpaper}%
\define@key{Gm}{a1paper}[true]{\def\Gm@paper{a1paper}\Gm@chpaper}%
\define@key{Gm}{a2paper}[true]{\def\Gm@paper{a2paper}\Gm@chpaper}%
\define@key{Gm}{a3paper}[true]{\def\Gm@paper{a3paper}\Gm@chpaper}%
\define@key{Gm}{a4paper}[true]{\def\Gm@paper{a4paper}\Gm@chpaper}%
\define@key{Gm}{a5paper}[true]{\def\Gm@paper{a5paper}\Gm@chpaper}%
\define@key{Gm}{a6paper}[true]{\def\Gm@paper{a6paper}\Gm@chpaper}%
\define@key{Gm}{b0paper}[true]{\def\Gm@paper{b0paper}\Gm@chpaper}%
\define@key{Gm}{b1paper}[true]{\def\Gm@paper{b1paper}\Gm@chpaper}%
\define@key{Gm}{b2paper}[true]{\def\Gm@paper{b2paper}\Gm@chpaper}%
\define@key{Gm}{b3paper}[true]{\def\Gm@paper{b3paper}\Gm@chpaper}%
\define@key{Gm}{b4paper}[true]{\def\Gm@paper{b4paper}\Gm@chpaper}%
\define@key{Gm}{b5paper}[true]{\def\Gm@paper{b5paper}\Gm@chpaper}%
\define@key{Gm}{b6paper}[true]{\def\Gm@paper{b6paper}\Gm@chpaper}%
\define@key{Gm}{ansiapaper}[true]{\def\Gm@paper{ansiapaper}\Gm@chpaper}%
\define@key{Gm}{ansibpaper}[true]{\def\Gm@paper{ansibpaper}\Gm@chpaper}%
\define@key{Gm}{ansicpaper}[true]{\def\Gm@paper{ansicpaper}\Gm@chpaper}%
\define@key{Gm}{ansidpaper}[true]{\def\Gm@paper{ansidpaper}\Gm@chpaper}%
\define@key{Gm}{ansiepaper}[true]{\def\Gm@paper{ansiepaper}\Gm@chpaper}%
\define@key{Gm}{letterpaper}[true]{\def\Gm@paper{letterpaper}\Gm@chpaper}%
\define@key{Gm}{legalpaper}[true]{\def\Gm@paper{legalpaper}\Gm@chpaper}%
\define@key{Gm}{executivepaper}[true]{\def\Gm@paper{executivepaper}%
  \Gm@chpaper}%
\define@key{Gm}{screen}[true]{\def\Gm@paper{screen}\Gm@chpaper}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \end{key}\end{key}
%  \begin{key}{Gm}{paperwidth}
%  \begin{key}{Gm}{paperheight}
%  \begin{key}{Gm}{papersize}
%    Direct specification for paper size is also possible.
%    \begin{macrocode}
\define@key{Gm}{paperwidth}{%
  \Gm@setafter\paperwidth{#1}\def\Gm@paper{user defined}}%
\define@key{Gm}{paperheight}{%
  \Gm@setafter\paperheight{#1}\def\Gm@paper{user defined}}%
\define@key{Gm}{papersize}{\Gm@branch{#1}{paperwidth}{paperheight}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{landscape}
%  \begin{key}{Gm}{portrait}
%    Paper orientation setting is also available.
%    \begin{macrocode}
\define@key{Gm}{landscape}[true]{\Gm@doifelse{landscape}{#1}%
  {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}%
  {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}}%
\define@key{Gm}{portrait}[true]{\Gm@doifelse{portrait}{#1}%
  {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}%
  {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}}%
%    \end{macrocode}
%  \end{key}\end{key}
%  \begin{key}{Gm}{hscale}
%  \begin{key}{Gm}{vscale}
%  \begin{key}{Gm}{scale}
%    These options can determine the length(s) of \gpart{total body}
%    giving \textit{scale(s)} against the paper size.
%    \begin{macrocode}
\define@key{Gm}{hscale}{\Gm@hbodytrue\edef\Gm@hscale{#1}}%
\define@key{Gm}{vscale}{\Gm@vbodytrue\edef\Gm@vscale{#1}}%
\define@key{Gm}{scale}{\Gm@branch{#1}{hscale}{vscale}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{width}
%  \begin{key}{Gm}{height}
%  \begin{key}{Gm}{total}
%  \begin{key}{Gm}{totalwidth}
%  \begin{key}{Gm}{totalheight}
%    These options give concrete dimension(s) of \gpart{total body}.
%    |totalwidth| and |totalheight| are aliases of |width| and |height|
%    respectively.
%    \begin{macrocode}
\define@key{Gm}{width}{\Gm@hbodytrue\Gm@defbylen{width}{#1}}%
\define@key{Gm}{height}{\Gm@vbodytrue\Gm@defbylen{height}{#1}}%
\define@key{Gm}{total}{\Gm@branch{#1}{width}{height}}%
\let\KV@Gm@totalwidth\KV@Gm@width
\let\KV@Gm@totalheight\KV@Gm@height
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{textwidth}
%  \begin{key}{Gm}{textheight}
%  \begin{key}{Gm}{text}
%  \begin{key}{Gm}{body}
%    These options directly sets the dimensions \cs{textwidth} and
%    \cs{textheight}. |body| is an alias of |text|.
%    \begin{macrocode}
\define@key{Gm}{textwidth}{\Gm@hbodytrue\Gm@defbylen{textwidth}{#1}}%
\define@key{Gm}{textheight}{\Gm@vbodytrue\Gm@defbylen{textheight}{#1}}%
\define@key{Gm}{text}{\Gm@branch{#1}{textwidth}{textheight}}%
\let\KV@Gm@body\KV@Gm@text
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{lines}
%    The option sets \cs{textheight} with the number of lines.
%    \begin{macrocode}
\define@key{Gm}{lines}{\Gm@vbodytrue\Gm@defbycnt{lines}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{includehead}
%  \begin{key}{Gm}{includefoot}
%  \begin{key}{Gm}{includeheadfoot}
%  \begin{key}{Gm}{includemp}
%  \begin{key}{Gm}{includeall}
%    |include*| options include the corresponding part(s) in
%    \gpart{total body}.
%    \begin{macrocode}
\define@key{Gm}{includehead}[true]{\Gm@setbool{includehead}{#1}}%
\define@key{Gm}{includefoot}[true]{\Gm@setbool{includefoot}{#1}}%
\define@key{Gm}{includeheadfoot}[true]{\Gm@doifelse{includeheadfoot}{#1}%
  {\Gm@includeheadtrue\Gm@includefoottrue}%
  {\Gm@includeheadfalse\Gm@includefootfalse}}%
\define@key{Gm}{includemp}[true]{\Gm@setbool{includemp}{#1}}%
\define@key{Gm}{includeall}[true]{\Gm@doifelse{includeall}{#1}%
  {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}%
  {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{ignorehead}
%  \begin{key}{Gm}{ignorefoot}
%  \begin{key}{Gm}{ignoreheadfoot}
%  \begin{key}{Gm}{ignoremp}
%  \begin{key}{Gm}{ignoreall}
%  |ignore*| options disregard \gpart{head}, \gpart{foot}
%  and \gpart{marginpars} in determining the location of \gpart{total body}.
%    \begin{macrocode}
\define@key{Gm}{ignorehead}[true]{%
  \Gm@setboolrev[ignorehead]{includehead}{#1}}%
\define@key{Gm}{ignorefoot}[true]{%
  \Gm@setboolrev[ignorefoot]{includefoot}{#1}}%
\define@key{Gm}{ignoreheadfoot}[true]{\Gm@doifelse{ignoreheadfoot}{#1}%
  {\Gm@includeheadfalse\Gm@includefootfalse}%
  {\Gm@includeheadtrue\Gm@includefoottrue}}%
\define@key{Gm}{ignoremp}[true]{%
  \Gm@setboolrev[ignoremp]{includemp}{#1}}%
\define@key{Gm}{ignoreall}[true]{\Gm@doifelse{ignoreall}{#1}%
  {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}%
  {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{heightrounded}
%    The option rounds \cs{textheight} to n-times of \cs{baselineskip}
%    plus \cs{topskip}.
%    \begin{macrocode}
\define@key{Gm}{heightrounded}[true]{\Gm@setbool{heightrounded}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{hdivide}
%  \begin{key}{Gm}{vdivide}
%  \begin{key}{Gm}{divide}
%    The options are useful to specify partitioning
%    in each direction of the paper.
%    \begin{macrocode}
\define@key{Gm}{hdivide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}}%
\define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
\define@key{Gm}{divide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}%
  \Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%
%  \begin{key}{Gm}{lmargin}
%  \begin{key}{Gm}{rmargin}
%  \begin{key}{Gm}{tmargin}
%  \begin{key}{Gm}{bmargin}
%  \begin{key}{Gm}{left}
%  \begin{key}{Gm}{inner}
%  \begin{key}{Gm}{innermargin}
%  \begin{key}{Gm}{right}
%  \begin{key}{Gm}{outer}
%  \begin{key}{Gm}{outermargin}
%  \begin{key}{Gm}{top}
%  \begin{key}{Gm}{bottom}
%    These options set \gpart{margins}.
%    |left|, |inner|, |innermargin| are aliases of |lmargin|.
%    |right|, |outer|, |outermargin| are aliases of |rmargin|.
%    |top| and |bottom| are aliases of |tmargin| and |bmargin| respectively.
%    \begin{macrocode}
\define@key{Gm}{lmargin}{\Gm@defbylen{lmargin}{#1}}%
\define@key{Gm}{rmargin}{\Gm@defbylen{rmargin}{#1}}%
\let\KV@Gm@left\KV@Gm@lmargin
\let\KV@Gm@inner\KV@Gm@lmargin
\let\KV@Gm@innermargin\KV@Gm@lmargin
\let\KV@Gm@right\KV@Gm@rmargin
\let\KV@Gm@outer\KV@Gm@rmargin
\let\KV@Gm@outermargin\KV@Gm@rmargin
\define@key{Gm}{tmargin}{\Gm@defbylen{tmargin}{#1}}%
\define@key{Gm}{bmargin}{\Gm@defbylen{bmargin}{#1}}%
\let\KV@Gm@top\KV@Gm@tmargin
\let\KV@Gm@bottom\KV@Gm@bmargin
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \end{key}\end{key}
%  \begin{key}{Gm}{hmargin}
%  \begin{key}{Gm}{vmargin}
%  \begin{key}{Gm}{margin}
%  These options are shorthands for setting \gpart{margins}.
%    \begin{macrocode}
\define@key{Gm}{hmargin}{\Gm@branch{#1}{lmargin}{rmargin}}%
\define@key{Gm}{vmargin}{\Gm@branch{#1}{tmargin}{bmargin}}%
\define@key{Gm}{margin}{\Gm@branch{#1}{lmargin}{tmargin}%
  \Gm@branch{#1}{rmargin}{bmargin}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{hmarginratio}
%  \begin{key}{Gm}{vmarginratio}
%  \begin{key}{Gm}{marginratio}
%  \begin{key}{Gm}{hratio}
%  \begin{key}{Gm}{vratio}
%  \begin{key}{Gm}{ratio}
%  Options specifying the margin ratios.
%    \begin{macrocode}
\define@key{Gm}{hmarginratio}{\edef\Gm@hmarginratio{#1}}%
\define@key{Gm}{vmarginratio}{\edef\Gm@vmarginratio{#1}}%
\define@key{Gm}{marginratio}{\Gm@branch{#1}{hmarginratio}{vmarginratio}}%
\let\KV@Gm@hratio\KV@Gm@hmarginratio
\let\KV@Gm@vratio\KV@Gm@vmarginratio
\let\KV@Gm@ratio\KV@Gm@marginratio
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{hcentering}
%  \begin{key}{Gm}{vcentering}
%  \begin{key}{Gm}{centering}
%    Useful shorthands to make \gpart{body} centered.
%    \begin{macrocode}
\define@key{Gm}{hcentering}[true]{\Gm@doifelse{hcentering}{#1}%
  {\def\Gm@hmarginratio{1:1}}{}}%
\define@key{Gm}{vcentering}[true]{\Gm@doifelse{vcentering}{#1}%
  {\def\Gm@vmarginratio{1:1}}{}}%
\define@key{Gm}{centering}[true]{\Gm@doifelse{centering}{#1}%
  {\def\Gm@hmarginratio{1:1}\def\Gm@vmarginratio{1:1}}{}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{twoside}
%    If |twoside=true|, \cs{@twoside} and \cs{@mparswitch} is set to |true|.
%    \begin{macrocode}
\define@key{Gm}{twoside}[true]{\Gm@doifelse{twoside}{#1}%
  {\@twosidetrue\@mparswitchtrue}{\@twosidefalse\@mparswitchfalse}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{asymmetric}
%    |asymmetric| sets \cs{@mparswitchfalse} and \cs{@twosidetrue}
%     A |asymmetric=false| has no effect.
%    \begin{macrocode}
\define@key{Gm}{asymmetric}[true]{\Gm@doifelse{asymmetric}{#1}%
  {\@twosidetrue\@mparswitchfalse}{}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{bindingoffset}
%    The macro specifies a white space added to the left or inner margin.
%    \begin{macrocode}
\define@key{Gm}{bindingoffset}{\Gm@setafter\Gm@bindingoffset{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{headheight}
%  \begin{key}{Gm}{headsep}
%  \begin{key}{Gm}{footskip}
%  \begin{key}{Gm}{head}
%  \begin{key}{Gm}{foot}
%    The direct settings of \gpart{head} and/or \gpart{foot} dimensions.
%    \begin{macrocode}
\define@key{Gm}{headheight}{\Gm@setafter\headheight{#1}}%
\define@key{Gm}{headsep}{\Gm@setafter\headsep{#1}}%
\define@key{Gm}{footskip}{\Gm@setafter\footskip{#1}}%
\let\KV@Gm@head\KV@Gm@headheight
\let\KV@Gm@foot\KV@Gm@footskip
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{nohead}
%  \begin{key}{Gm}{nofoot}
%  \begin{key}{Gm}{noheadfoot}
%    They are only shorthands to set \gpart{head} and/or \gpart{foot}
%    to be |0pt|.
%    \begin{macrocode}
\define@key{Gm}{nohead}[true]{\Gm@doifelse{nohead}{#1}%
  {\Gm@setafter\headheight\z@\Gm@setafter\headsep\z@}{}}%
\define@key{Gm}{nofoot}[true]{\Gm@doifelse{nofoot}{#1}%
  {\Gm@setafter\footskip\z@}{}}%
\define@key{Gm}{noheadfoot}[true]{\Gm@doifelse{noheadfoot}{#1}%
  {\Gm@setafter\headheight\z@\Gm@setafter\headsep
  \z@\Gm@setafter\footskip\z@}{}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{footnotesep}
%    The option directly sets a native dimension \cs{footnotesep}.
%    \begin{macrocode}
\define@key{Gm}{footnotesep}{\Gm@setafter{\skip\footins}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{marginparwidth}
%  \begin{key}{Gm}{marginpar}
%  \begin{key}{Gm}{marginparsep}
%    They directly set native dimensions \cs{marginparwidth} and
%    \cs{marginparsep}. For compatibility, |includemp| is set to |true|
%    if |compat2| is set.
%    \begin{macrocode}
\define@key{Gm}{marginparwidth}{\ifGm@compatii\Gm@includemptrue\fi
  \Gm@setafter\marginparwidth{#1}}%
\let\KV@Gm@marginpar\KV@Gm@marginparwidth
\define@key{Gm}{marginparsep}{\ifGm@compatii\Gm@includemptrue\fi
  \Gm@setafter\marginparsep{#1}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{nomarginpar}
%    The macro is a shorthand for \cs{marginparwidth}|=0pt| and
%    \cs{marginparsep}|=0pt|.
%    \begin{macrocode}
\define@key{Gm}{nomarginpar}[true]{\Gm@doifelse{nomarginpar}{#1}%
  {\Gm@setafter\marginparwidth\z@\Gm@setafter\marginparsep\z@}{}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{columnsep}
%    The option sets a native dimension \cs{columnsep}.
%    \begin{macrocode}
\define@key{Gm}{columnsep}{\Gm@setafter\columnsep{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{hoffset}
%  \begin{key}{Gm}{voffset}
%  \begin{key}{Gm}{offset}
%    The former two options set native dimensions \cs{hoffset} and
%    \cs{voffset}. |offset| can set both of them with the same value.
%    \begin{macrocode}
\define@key{Gm}{hoffset}{\Gm@setafter\hoffset{#1}}%
\define@key{Gm}{voffset}{\Gm@setafter\voffset{#1}}%
\define@key{Gm}{offset}{\Gm@branch{#1}{hoffset}{voffset}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}
%  \begin{key}{Gm}{twocolumn}
%    The option sets \cs{twocolumn} switch.
%    \begin{macrocode}
\define@key{Gm}{twocolumn}[true]{%
  \Gm@doif{twocolumn}{#1}{\csname @twocolumn\Gm@bool\endcsname}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{reversemp}
%  \begin{key}{Gm}{reversemarginpar}
%    The both options set \cs{reversemargin}.
%    \begin{macrocode}
\define@key{Gm}{reversemp}[true]{%
  \Gm@doif{reversemp}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
\define@key{Gm}{reversemarginpar}[true]{%
  \Gm@doif{reversemarginpar}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
%    \end{macrocode}
%  \end{key}\end{key}
%  \begin{key}{Gm}{dviver}
%    \begin{macrocode}
\define@key{Gm}{driver}{\edef\@@tempa{#1}\edef\@@auto{auto}\edef\@@none{none}%
  \ifx\@@tempa\@empty\let\Gm@driver\relax\else
  \ifx\@@tempa\@@none\let\Gm@driver\relax\else
  \ifx\@@tempa\@@auto\let\Gm@driver\@empty\else
  \setkeys{Gm}{#1}\fi\fi\fi\let\@@auto\relax\let\@@none\relax}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{dvips}
%  \begin{key}{Gm}{dvipdfm}
%  \begin{key}{Gm}{pdftex}
%  \begin{key}{Gm}{vtex}
%    The \textsf{geometry} package supports |dvips|, |dvipdfm|, 
%    |pdflatex| and |vtex|. |dvipdfm| works like |dvips|.
%    \begin{macrocode}
\define@key{Gm}{dvips}[true]{%
  \Gm@doifelse{dvips}{#1}{\Gm@setdriver{dvips}}{\Gm@unsetdriver{dvips}}}%
\define@key{Gm}{dvipdfm}[true]{%
  \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}%
\define@key{Gm}{pdftex}[true]{%
  \Gm@doifelse{pdftex}{#1}{\Gm@setdriver{pdftex}}{\Gm@unsetdriver{pdftex}}}%
\define@key{Gm}{vtex}[true]{%
  \Gm@doifelse{vtex}{#1}{\Gm@setdriver{vtex}}{\Gm@unsetdriver{vtex}}}%
%    \end{macrocode}
%  \end{key}\end{key}\end{key}\end{key}
%  \begin{key}{Gm}{verbose}
%    The verbose mode.
%    \begin{macrocode}
\define@key{Gm}{verbose}[true]{\Gm@setbool{verbose}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{reset}
%    The option cancels all the options specified before |reset|,
%    except |pass|. |mag| ($\neq1000$) with |truedimen| cannot be also
%    reset.
%    \begin{macrocode}
\define@key{Gm}{reset}[true]{\Gm@doifelse{reset}{#1}%
  {\Gm@init\Gm@dorg\ProcessOptionsKV[c]{Gm}\Gm@setdefaultpaper}{}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{resetpaper}
%    If |resetpaper| is set to |true|, the paper size redefined in the package
%    is discarded and the original one is restored. This option may be useful
%    to print nonstandard sized documents with normal printers and papers.
%    \begin{macrocode}
\define@key{Gm}{resetpaper}[true]{\Gm@setbool{resetpaper}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{mag}
%    |mag| is expanded immediately when it is specified. So |reset| can't
%    reset |mag| when it is set with |truedimen|.
%    \begin{macrocode}
\define@key{Gm}{mag}{\mag=#1}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{truedimen}
%    If |truedimen| is set to |true|, all of the internal explicit dimensions
%    is changed to \textit{true} dimensions, e.g., |1in| is changed to
%    |1truein|.
%    \begin{macrocode}
\define@key{Gm}{truedimen}[true]{\Gm@doifelse{truedimen}{#1}%
  {\let\Gm@truedimen\Gm@true}{\let\Gm@truedimen\@empty}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{pass}
%    The option makes all the options specified ineffective except
%    verbose switch.
%    \begin{macrocode}
\define@key{Gm}{pass}[true]{\Gm@setbool{pass}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{showframe}
%    The showframe option.
%    \begin{macrocode}
\define@key{Gm}{showframe}[true]{\Gm@setbool{showframe}{#1}}%
%    \end{macrocode}
%  \end{key}
%  \begin{key}{Gm}{compat2}
%    The option sets the old default options for compatibility
%    with version 2. |compat2=false| does nothing.
%    \begin{macrocode}
\define@key{Gm}{compat2}[true]{%
  \Gm@doifelse{compat2}{#1}{\Gm@compatiitrue
  \setkeys{Gm}{scale={0.8,0.9},centering,includeheadfoot}}{}}%
%    \end{macrocode}
%  \end{key}
%    Option |twosideshift| has been obsoleted. But for compatibility
%    with version 2, one can use |twosideshift| when |compat2| is set
%    to |true|.
%    \begin{macrocode}
\define@key{Gm}{twosideshift}{%
  \ifGm@compatii\@twosidetrue\@mparswitchtrue\Gm@defbylen{twosideshift}{#1}%
  \else\Gm@warning{`twosideshift' is obsolete}%
  \fi}%
%    \end{macrocode}
%
%    \begin{macro}{\Gm@setdefaultpaper}
%    The macro stores paper dimensions.
%    This macro should be called after |\ProcessOptionsKV[c]{Gm}|.
%    \begin{macrocode}
\def\Gm@setdefaultpaper{%
  \ifx\Gm@paper\@undefined
    \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
    \Gm@sworientfalse
  \fi}%
\@onlypreamble\Gm@setdefaultpaper
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Gm@checkpaper}
%    The macro checks if paperwidth/height is larger than 0pt,
%    which is used in \cs{Gm@process}.
%    \begin{macrocode}
\def\Gm@checkpaper{%
  \ifdim\paperwidth>\p@\else
    \PackageError{geometry}{%
    You must set \string\paperwidth\space properly}{%
    Set your paper type (e.g., `a4paper' for A4) as a class option^^J%
    or as a geometry package option.}%
  \fi
  \ifdim\paperheight>\p@\else
    \PackageError{geometry}{%
    You must set \string\paperheight\space properly}{%
    Set your paper type (e.g., `a4paper' for A4) as a class option^^J%
    or as a geometry package option.}%
  \fi}%
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@checkmp}
%    The macro checks if marginpars fall off the page.
%    \begin{macrocode}
\def\Gm@checkmp{%
  \ifGm@includemp\else
    \@tempcnta\z@\@tempcntb\@ne
    \if@twocolumn
      \@tempcnta\@ne
    \else
      \if@reversemargin
        \@tempcnta\@ne\@tempcntb\z@
      \fi
    \fi
    \@tempdima\marginparwidth
    \advance\@tempdima\marginparsep
    \ifnum\@tempcnta=\@ne
      \@tempdimc\@tempdima
      \setlength\@tempdimb{\Gm@lmargin}%
      \advance\@tempdimc-\@tempdimb
      \ifdim\@tempdimc>\z@
        \Gm@warning{The marginal notes would fall off the page.^^J
           \@spaces Add \the\@tempdimc\space and more to the left margin}%
      \fi
    \fi
    \ifnum\@tempcntb=\@ne
      \@tempdimc\@tempdima
      \setlength\@tempdimb{\Gm@rmargin}%
      \advance\@tempdimc-\@tempdimb
      \ifdim\@tempdimc>\z@
        \Gm@warning{The marginal notes would fall off the page.^^J
           \@spaces Add \the\@tempdimc\space and more to the right margin}%
      \fi
    \fi
  \fi}%
\@onlypreamble\Gm@checkmp
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@checkdrivers}
%    The macro checks the typeset environment and changes the driver option
%    if necessary. To make the engine detection more robust, the macro is
%    rewritten in version 4 with packages \textsf{ifpdf} and \textsf{ifvtex}.
%    \begin{macrocode}
\def\Gm@checkdrivers{%
%    \end{macrocode} 
%    If the driver option is not specified explicitly, then driver
%    auto-detection works.
%    \begin{macrocode} 
  \ifx\Gm@driver\@empty
    \typeout{*geometry auto-detecting driver*}%
%    \end{macrocode} 
%    \cs{ifpdf} is defined in \textsf{ifpdf} package in `oberdiek' bundle.
%    \begin{macrocode} 
    \ifpdf
      \Gm@setdriver{pdftex}%
    \else
      \Gm@setdriver{dvips}%
    \fi
%    \end{macrocode} 
%   Xe\TeX{} supports the same page size parameter as pdf\TeX.
%    \begin{macrocode}
    \@ifundefined{XeTeXrevision}{}{\Gm@setdriver{pdftex}}%
%    \end{macrocode} 
%    \cs{ifvtex} is defined in \textsf{ifvtex} package in `oberdiek'
%    bundle. 
%    \begin{macrocode} 
    \ifvtex
      \Gm@setdriver{vtex}%
    \fi
%    \end{macrocode}
%    When the driver option is set by the user, check if it is valid or not. 
%    \begin{macrocode} 
  \else
    \ifx\Gm@driver\Gm@pdftex
      \ifpdf\else
         \@ifundefined{XeTeXrevision}{\Gm@warning{%
            Wrong driver setting: `pdftex'; using default driver}%
            \Gm@setdriver{dvips}}{}%
      \fi
    \fi
    \ifx\Gm@driver\Gm@vtex
      \ifvtex\else
        \Gm@warning{Wrong driver setting: `vtex'; using default driver}%
        \Gm@setdriver{dvips}%
      \fi
    \fi
  \fi}%
\@onlypreamble\Gm@checkdrivers
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Gm@mpfix}
%    The macro sets marginpar correction when |includemp| is set,
%    which is used in \cs{Gm@process}.
%    Local variables \cs{Gm@wd@mp}, \cs{Gm@odd@mp} and \cs{Gm@even@mp}
%    are set here. Note that \cs{Gm@even@mp} should be used only for twoside
%    layout.
%    \begin{macrocode}
\def\Gm@mpfix{%
  \@tempdimb\marginparwidth
  \advance\@tempdimb\marginparsep
  \Gm@wd@mp\@tempdimb
  \Gm@odd@mp\z@
  \Gm@even@mp\z@
  \if@twocolumn
    \Gm@wd@mp2\@tempdimb
    \Gm@odd@mp\@tempdimb
    \Gm@even@mp\@tempdimb
  \else
    \if@reversemargin
      \Gm@odd@mp\@tempdimb
      \if@mparswitch\else
        \Gm@even@mp\@tempdimb
      \fi
    \else
      \if@mparswitch
        \Gm@even@mp\@tempdimb
      \fi
    \fi
  \fi}%
\@onlypreamble\Gm@mpfix
%    \end{macrocode}
%    \end{macro}
%    
%    \begin{macro}{\Gm@process}
%    The main macro processing specified layout dimensions is defined.
%    \begin{macrocode}
\def\Gm@process{%
%    \end{macrocode}
%    If |pass| is set, the original dimensions and switches are restored
%    and process is ended here.
%    \begin{macrocode}
  \ifGm@pass
    \Gm@dorg
  \else
%    \end{macrocode}
%    The stored native dimension settings are processed here.
%    \begin{macrocode}
  \Gm@processdimlist
%    \end{macrocode}
%    The margin ratios are set to the default if not specified.
%    \begin{macrocode}
  \ifx\Gm@hmarginratio\@undefined
    \if@twoside
      \edef\Gm@hmarginratio{\Gm@Dhratiotwo}%
    \else
      \edef\Gm@hmarginratio{\Gm@Dhratio}%
    \fi
  \fi
  \ifx\Gm@vmarginratio\@undefined
    \edef\Gm@vmarginratio{\Gm@Dvratio}%
  \fi
%    \end{macrocode}
%    The paper size is checked here.
%    \begin{macrocode}
  \Gm@checkpaper
%    \end{macrocode}
%    The paper dimensions can be swapped when paper orientation
%    is changed over by |landscape| and |portrait| options.
%    \begin{macrocode}
  \ifGm@sworient
    \setlength\@tempdima{\paperwidth}%
    \setlength\paperwidth{\paperheight}%
    \setlength\paperheight{\@tempdima}%
    \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
    \Gm@sworientfalse
  \fi
%    \end{macrocode}
%    The bindingoffset value is removed from the paper width,
%    which will be set back after auto-completion calculation.
%    \begin{macrocode}
  \addtolength\paperwidth{-\Gm@bindingoffset}%
%    \end{macrocode}
%    The local variables are set here for marginpar correction
%    \cs{Gm@wd@mp}, \cs{Gm@odd@mp} and \cs{Gm@even@mp}
%    when |includemp| is set.
%    \begin{macrocode}
  \ifGm@includemp
    \Gm@mpfix
  \fi
%    \end{macrocode}
%    If the horizontal dimension of \gpart{body} is specified by user,
%    \cs{Gm@width} is set properly here.
%    \begin{macrocode}
  \ifGm@hbody
    \ifx\Gm@width\@undefined
      \ifx\Gm@hscale\@undefined
        \edef\Gm@width{\Gm@Dhscale\paperwidth}%
      \else
        \edef\Gm@width{\Gm@hscale\paperwidth}%
      \fi
    \fi
    \ifx\Gm@textwidth\@undefined\else
      \setlength\@tempdima{\Gm@textwidth}%
      \ifGm@includemp
        \advance\@tempdima\Gm@wd@mp
      \fi
      \edef\Gm@width{\the\@tempdima}%
    \fi
  \fi
%    \end{macrocode}
%    If the vertical dimension of \gpart{body} is specified by user,
%    \cs{Gm@height} is set properly here.
%    \begin{macrocode}
  \ifGm@vbody
    \ifx\Gm@height\@undefined
      \ifx\Gm@vscale\@undefined
        \edef\Gm@height{\Gm@Dvscale\paperheight}%
      \else
        \edef\Gm@height{\Gm@vscale\paperheight}%
      \fi
    \fi
    \ifx\Gm@lines\@undefined\else
%    \end{macrocode}
%    \cs{topskip} has to be adjusted so that the formula
%    ``$\cs{textheight} = (lines - 1) \times \cs{baselineskip} + \cs{topskip}$''
%    to be correct even if large font sizes are specified by users.
%    If \cs{topskip} is smaller than \cs{ht}\cs{strutbox}, then \cs{topskip}
%    is set to \cs{ht}\cs{strutbox}.
%    \begin{macrocode}
      \ifdim\topskip<\ht\strutbox
        \setlength\@tempdima{\topskip}%
        \setlength\topskip{\ht\strutbox}%
        \Gm@warning{\noexpand\topskip was changed from \the\@tempdima\space
        to \the\topskip}%
      \fi
      \setlength\@tempdima{\baselineskip}%
      \multiply\@tempdima\Gm@lines
      \addtolength\@tempdima{\topskip}%
      \addtolength\@tempdima{-\baselineskip}%
      \edef\Gm@textheight{\the\@tempdima}%
    \fi
    \ifx\Gm@textheight\@undefined\else
      \setlength\@tempdima{\Gm@textheight}%
      \ifGm@includehead
        \addtolength\@tempdima{\headheight}%
        \addtolength\@tempdima{\headsep}%
      \fi
      \ifGm@includefoot
        \addtolength\@tempdima{\footskip}%
      \fi
      \edef\Gm@height{\the\@tempdima}%
    \fi
  \fi
%    \end{macrocode}
%    The auto-completion calculation is executed for each direction.
%    \begin{macrocode}
  \Gm@detall{h}{width}{lmargin}{rmargin}%
  \Gm@detall{v}{height}{tmargin}{bmargin}%
%    \end{macrocode}
%    The real dimensions are set properly according to the result
%    of the auto-completion calculation.
%    \begin{macrocode}
  \setlength\textwidth{\Gm@width}%
  \setlength\textheight{\Gm@height}%
  \setlength\topmargin{\Gm@tmargin}%
  \setlength\oddsidemargin{\Gm@lmargin}%
  \addtolength\oddsidemargin{-1\Gm@truedimen in}%
%    \end{macrocode}
%    If |includemp| is set to |true|, \cs{textwidth} and \cs{oddsidemargin}
%    are adjusted. 
%    \begin{macrocode}
  \ifGm@includemp
    \advance\textwidth-\Gm@wd@mp
    \advance\oddsidemargin\Gm@odd@mp
  \fi
%    \end{macrocode}
%    Determining \cs{evensidemargin}.
%    In the twoside page layout, the right margin value 
%    \cs{Gm@rmargin} is used.
%    If the marginal note width is included,
%    \cs{evensidemargin} should be corrected by \cs{Gm@even@mp}.
%    \begin{macrocode}
  \if@mparswitch
    \setlength\evensidemargin{\Gm@rmargin}%
    \addtolength\evensidemargin{-1\Gm@truedimen in}%
    \ifGm@includemp
      \advance\evensidemargin\Gm@even@mp
    \fi
    \ifGm@compatii
      \ifx\Gm@twosideshift\@undefined
        \def\Gm@twosideshift{20\Gm@truedimen pt}%
      \fi
      \addtolength\oddsidemargin{\Gm@twosideshift}%
      \addtolength\evensidemargin{-\Gm@twosideshift}%
    \fi
  \else
    \evensidemargin\oddsidemargin
  \fi
%    \end{macrocode}
%    The bindingoffset correction for \cs{oddsidemargin}.
%    \begin{macrocode}
  \advance\oddsidemargin\Gm@bindingoffset
%    \end{macrocode}
%    \cs{topmargin} is adjusted here.
%    \begin{macrocode}
  \addtolength\topmargin{-1\Gm@truedimen in}%
%    \end{macrocode}
%    If the head of the page is included in \gpart{total body}, 
%    \cs{headheight} and \cs{headsep} are removed from \cs{textheight},
%    otherwise from \cs{topmargin}.
%    \begin{macrocode}
  \ifGm@includehead
    \addtolength\textheight{-\headheight}%
    \addtolength\textheight{-\headsep}%
  \else
    \addtolength\topmargin{-\headheight}%
    \addtolength\topmargin{-\headsep}%
  \fi
%    \end{macrocode}
%    If the foot of the page is included in \gpart{total body},
%    \cs{footskip} is removed from \cs{textheight}.
%    \begin{macrocode}
  \ifGm@includefoot
    \addtolength\textheight{-\footskip}%
  \fi
%    \end{macrocode}
%    If |heightrounded| is set, \cs{textheight} is rounded.
%    \begin{macrocode}
  \ifGm@heightrounded
    \setlength\@tempdima{\textheight}%
    \addtolength\@tempdima{-\topskip}%
    \@tempcnta\@tempdima
    \@tempcntb\baselineskip
    \divide\@tempcnta\@tempcntb
    \setlength\@tempdimb{\baselineskip}%
    \multiply\@tempdimb\@tempcnta
    \advance\@tempdima-\@tempdimb
    \multiply\@tempdima\tw@
    \ifdim\@tempdima>\baselineskip
      \addtolength\@tempdimb{\baselineskip}%
    \fi
    \addtolength\@tempdimb{\topskip}%
    \textheight\@tempdimb
  \fi
%    \end{macrocode}
%    The paper width is set back by adding \cs{Gm@bindingoffset}.
%    \begin{macrocode}
  \addtolength\paperwidth{\Gm@bindingoffset}%
 \fi}%
\@onlypreamble\Gm@process
%    \end{macrocode}
%    \end{macro}
%    
%    \begin{macro}{\Gm@showparam}
%    The macro for typeout of geometry status and native dimensions for
%    page layout.
%    \begin{macrocode}
\def\Gm@showparams{%
  -------------------- Geometry parameters^^J%
  \ifGm@pass
  'pass' is specified!! (disables the geometry layouter)^^J%
  \else
  paper: \ifx\Gm@paper\@undefined class default\else\Gm@paper\fi^^J%
  \Gm@checkbool{landscape}%
  twocolumn: \if@twocolumn\Gm@true\else--\fi^^J%
  twoside: \if@twoside\Gm@true\else--\fi^^J%
  asymmetric: \if@mparswitch --\else\if@twoside\Gm@true\else --\fi\fi^^J%
  h-parts: \Gm@lmargin, \Gm@width, \Gm@rmargin%
  \ifnum\Gm@cnth=\z@\space(default)\fi^^J%
  v-parts: \Gm@tmargin, \Gm@height, \Gm@bmargin%
  \ifnum\Gm@cntv=\z@\space(default)\fi^^J%
  hmarginratio: \ifnum\Gm@cnth<5 \ifnum\Gm@cnth=3--\else%
    \Gm@hmarginratio\fi\else--\fi^^J%
  vmarginratio: \ifnum\Gm@cntv<5 \ifnum\Gm@cntv=3--\else%
    \Gm@vmarginratio\fi\else--\fi^^J%
  lines: \@ifundefined{Gm@lines}{--}{\Gm@lines}^^J%
  \Gm@checkbool{heightrounded}%
  bindingoffset: \the\Gm@bindingoffset^^J%
  truedimen: \ifx\Gm@truedimen\@empty --\else\Gm@true\fi^^J%
  \Gm@checkbool{includehead}%
  \Gm@checkbool{includefoot}%
  \Gm@checkbool{includemp}%
  driver: \if\Gm@driver\relax --\else\Gm@driver\fi^^J%
  \fi
  -------------------- Page layout dimensions and switches^^J%
  \string\paperwidth\space\space\the\paperwidth^^J%
  \string\paperheight\space\the\paperheight^^J%
  \string\textwidth\space\space\the\textwidth^^J%
  \string\textheight\space\the\textheight^^J%
  \string\oddsidemargin\space\space\the\oddsidemargin^^J%
  \string\evensidemargin\space\the\evensidemargin^^J%
  \string\topmargin\space\space\the\topmargin^^J%
  \string\headheight\space\the\headheight^^J%
  \string\headsep\@spaces\the\headsep^^J%
  \string\footskip\space\space\space\the\footskip^^J%
  \string\marginparwidth\space\the\marginparwidth^^J%
  \string\marginparsep\space\space\space\the\marginparsep^^J%
  \string\columnsep\space\space\the\columnsep^^J%
  \string\skip\string\footins\space\space\the\skip\footins^^J%
  \string\hoffset\space\the\hoffset^^J%
  \string\voffset\space\the\voffset^^J%
  \string\mag\space\the\mag^^J%
  \if@twocolumn\string\@twocolumntrue\space\fi%
  \if@twoside\string\@twosidetrue\space\fi%
  \if@mparswitch\string\@mparswitchtrue\space\fi%
  \if@reversemargin\string\@reversemargintrue\space\fi^^J%
  (1in=72.27pt, 1cm=28.45pt)^^J%
  -----------------------}%
\@onlypreamble\Gm@showparams
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\ProcessOptionsKV}
%    This macro can process class and package options using `key=value'
%    scheme. Only class options are processed with an optional argument `|c|',
%    package options with `|p|' , and both of them by default.
%    \begin{macrocode}
\def\ProcessOptionsKV{\@ifnextchar[%]
  {\@ProcessOptionsKV}{\@ProcessOptionsKV[]}}%
\def\@ProcessOptionsKV[#1]#2{%
  \let\@tempa\@empty
  \@tempcnta\z@
  \if#1p\@tempcnta\@ne\else\if#1c\@tempcnta\tw@\fi\fi
  \ifodd\@tempcnta
   \edef\@tempa{\@ptionlist{\@currname.\@currext}}%
  \else
    \@for\CurrentOption:=\@classoptionslist\do{%
      \@ifundefined{KV@#2@\CurrentOption}%
      {}{\edef\@tempa{\@tempa,\CurrentOption,}}}% 
    \ifnum\@tempcnta=\z@
      \edef\@tempa{\@tempa,\@ptionlist{\@currname.\@currext}}%
    \fi
  \fi
  \edef\@tempa{\noexpand\setkeys{#2}{\@tempa}}%
  \@tempa
  \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
\@onlypreamble\ProcessOptionsKV
\@onlypreamble\@ProcessOptionsKV
%    \end{macrocode}
%    \end{macro}
%    
%    Geometry parameters are initialized here.
%    \cs{Gm@init} can be called by |reset| or |pass| options.
%    \begin{macrocode}
\Gm@init
%    \end{macrocode}
%    The optional arguments to \cs{documentclass} are processed here.
%    \begin{macrocode}
\ProcessOptionsKV[c]{Gm}%
%    \end{macrocode}
%    Paper dimensions given by class default are stored.
%    \begin{macrocode}
\Gm@setdefaultpaper
%    \end{macrocode}
%    \begin{macro}{\Gm@setkey}
%    \cs{ExecuteOptions} is replaced with \cs{Gm@setkey} to make it
%    possible to deal with '\meta{key}=\meta{value}' as its argument.
%    \begin{macrocode}
\def\Gm@setkeys{\setkeys{Gm}}%
\@onlypreamble\Gm@setkeys
\let\Gm@origExecuteOptions\ExecuteOptions
\let\ExecuteOptions\Gm@setkeys
%    \end{macrocode}
%    \end{macro}
%    A local configuration file may define more options. 
%    To set A4 paper as default, \texttt{geometry.cfg} gg to contain
%    |\ExecuteOptions{a4paper}|.
%    \begin{macrocode}
\InputIfFileExists{geometry.cfg}{}{}%
%    \end{macrocode}
%    The original definition for \cs{ExecuteOptions} macro is restored.
%    \begin{macrocode}
\let\ExecuteOptions\Gm@origExecuteOptions
%    \end{macrocode}
%    The optional arguments to \cs{usepackage} are processed here.
%    \begin{macrocode}
\ProcessOptionsKV[p]{Gm}%
%    \end{macrocode}
%    Actual settings and calculation for layout dimensions are processed.
%    \begin{macrocode}
\Gm@process
%    \end{macrocode}
%
%    |verbose|, |showframe| and driver options are processed
%    at \cs{begin}|{document}|.
%    \begin{macrocode}
\AtBeginDocument{%
%    \end{macrocode}
%    Paper size is temporally adjusted according to \cs{mag} for
%    printing devices.
%    \begin{macrocode}
  \ifGm@resetpaper
    \edef\Gm@pw{\Gm@orgpw}%
    \edef\Gm@ph{\Gm@orgph}%
  \else
    \edef\Gm@pw{\the\paperwidth}%
    \edef\Gm@ph{\the\paperheight}%
  \fi    
%    \end{macrocode}
%    If |pass| is set to |true|, no adjustment for page dimensions is done.
%    \begin{macrocode}
  \ifGm@pass\else
    \ifnum\mag=\@m\else
      \Gm@magtooffset
      \divide\paperwidth\@m
      \multiply\paperwidth\the\mag
      \divide\paperheight\@m
      \multiply\paperheight\the\mag
    \fi
  \fi
%    \end{macrocode}
%    Checking the driver options.
%    \begin{macrocode}
  \Gm@checkdrivers
  \ifx\Gm@driver\relax
    \typeout{*geometry detected driver: <none>*}%
  \else
    \typeout{*geometry detected driver: \Gm@driver*}%
  \fi
%    \end{macrocode}
%    If |pdftex| is set to |true|, pdf-commands are set properly.
%    To avoid |pdftex| magnification problem, \cs{pdfhorigin} and
%    \cs{pdfvorigin} are adjusted for \cs{mag}.
%    \begin{macrocode}
  \ifx\Gm@driver\Gm@pdftex
    \setlength\pdfpagewidth{\Gm@pw}%
    \setlength\pdfpageheight{\Gm@ph}%
    \ifnum\mag=\@m\else
      \@tempdima=\mag sp%
      \divide\pdfhorigin\@tempdima
      \multiply\pdfhorigin\@m
      \divide\pdfvorigin\@tempdima
      \multiply\pdfvorigin\@m
      \ifx\Gm@truedimen\Gm@true
        \setlength\paperwidth{\Gm@pw}%
        \setlength\paperheight{\Gm@ph}%
      \fi
    \fi
  \fi
%    \end{macrocode}
%    With V\TeX{} environment, V\TeX{} variables are set here.
%    \begin{macrocode}
  \ifx\Gm@driver\Gm@vtex
    \mediawidth=\paperwidth
    \mediaheight=\paperheight
    \ifvtexdvi
      \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
    \fi
  \fi
%    \end{macrocode}
%    If |dvips| or |dvipdfm| is set to |true|, paper size is embedded in dvi
%    file with \cs{special}. For dvips, a landscape correction is added
%    because a landscape document converted by dvips is upside-down in
%    PostScript viewers.
%    \begin{macrocode}
  \ifx\Gm@driver\Gm@dvips
    \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
    \ifx\Gm@driver\Gm@dvips\ifGm@landscape
      \AtBeginDvi{\special{! /landplus90 true store}}%
    \fi\fi
%    \end{macrocode}
%    When |dvipdfm| option is set and \textsf{atbegshi} package in
%    `oberdiek' bundle is loaded, \cs{AtBeginShipoutFirst} is used
%    instead of \cs{AtBeginDvi} for compatibility with \textsf{hyperref}
%    and |dvipdfm| program.
%    \begin{macrocode}
  \else\ifx\Gm@driver\Gm@dvipdfm
    \ifcase\ifx\AtBeginShipoutFirst\relax\@ne\else
        \ifx\AtBeginShipoutFirst\@undefined\@ne\else\z@\fi\fi
      \AtBeginShipoutFirst{\special{papersize=\the\paperwidth,\the\paperheight}}%
    \or 
      \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
    \fi
  \fi\fi
%    \end{macrocode}
%    If |showframe=true|, page frames and lines are showed
%    on the first page.
%    \begin{macrocode}
  \ifGm@showframe
    \AtBeginDvi{%
      \moveright\@themargin%
      \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
      \vskip\topmargin\vbox to\z@{\vss\hrule width\textwidth}%
      \vskip\headheight\vbox to\z@{\vss\hrule width\textwidth}%
      \vskip\headsep\vbox to\z@{\vss\hrule width\textwidth}%
      \hbox to\textwidth{\llap{\vrule height\textheight}\hfil% 
      \vrule height\textheight}%
      \vbox to\z@{\vss\hrule width\textwidth}%
      \vskip\footskip\vbox to\z@{\vss\hrule width\textwidth}%
      \vss}}%
    \AtBeginDvi{%
      \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
      \vskip-1\Gm@truedimen in\rlap{\hskip-1\Gm@truedimen in%
      \vbox to\z@{\vbox to\z@{\vss\hrule width\paperwidth}%
      \hbox to \paperwidth{\llap{\vrule height\paperheight}\hfil%
      \vrule height\paperheight}%
      \vbox to\z@{\vss\hrule width\paperwidth}%
      \vss}}\vss}}%
  \fi
%    \end{macrocode}
%    If |verbose=true| and |pass=false|, the system checks
%    if marginpars fall off the page.
%    \begin{macrocode}
  \ifGm@verbose\ifGm@pass\else\Gm@checkmp\fi\fi
%    \end{macrocode}
% If |verbose=true| the parameter results are displayed on the terminal.
% |verbose=false| (default) still puts them into the log file.
%    \begin{macrocode}
  \ifGm@verbose\expandafter\typeout\else\expandafter\wlog\fi
  {\Gm@showparams}%
%    \end{macrocode}
% save memory.
%    \begin{macrocode}
  \let\Gm@cnth\relax
  \let\Gm@cntv\relax
  \let\c@Gm@tempcnt\relax
  \let\Gm@bindingoffset\relax
  \let\Gm@wd@mp\relax
  \let\Gm@odd@mp\relax
  \let\Gm@even@mp\relax
  \let\Gm@orgpw\relax
  \let\Gm@orgph\relax
  \let\Gm@pw\relax
  \let\Gm@ph\relax
  \let\Gm@dimlist\relax}%
%    \end{macrocode}
%
%    \begin{macro}{\geometry}
%    The user-interface macro \cs{geometry} is defined here.
%    This command should be used in the preamble.
%    \begin{macrocode}
\def\geometry#1{%
  \Gm@clean
  \setkeys{Gm}{#1}%
  \Gm@process}%
\@onlypreamble\geometry
%</package>
%    \end{macrocode}
%    \end{macro}
%
% \section{Config file}
%    In the configuration file |geometry.cfg|, one can use
%    \cs{ExecuteOptions} to set the site or user default settings.
%    \begin{macrocode}
%<*config>
%<<SAVE_INTACT

%  Uncomment and edit the line below to set default options.
%\ExecuteOptions{a4paper}

%SAVE_INTACT
%</config>
%    \end{macrocode}
%
% \section{Sample file}
%    Here is an executable sample tex file.
%    \begin{macrocode}
%<*samples>
%<<SAVE_INTACT
\documentclass{article}% uses letterpaper by default
% \documentclass[a4paper]{article}% for A4 paper
%---------------------------------------------------------------
% Edit and uncomment one of the settings below
%---------------------------------------------------------------
% \usepackage{geometry}
% \usepackage[centering]{geometry}
% \usepackage[width=10cm,vscale=.7]{geometry}
% \usepackage[margin=1cm, papersize={12cm,19cm}, resetpaper]{geometry}
% \usepackage[margin=1cm,includeheadfoot]{geometry}
\usepackage[margin=1cm,includeheadfoot,includemp]{geometry}
% \usepackage[margin=1cm,bindingoffset=1cm,twoside]{geometry}
% \usepackage[hmarginratio=2:1, vmargin=2cm]{geometry}
% \usepackage[hscale=0.5,twoside]{geometry}
% \usepackage[hscale=0.5,asymmetric]{geometry}
% \usepackage[hscale=0.5,heightrounded]{geometry}
% \usepackage[left=1cm,right=4cm,top=2cm,includefoot]{geometry}
% \usepackage[lines=20,left=2cm,right=6cm,top=2cm,twoside]{geometry}
% \usepackage[width=15cm, marginparwidth=3cm, includemp]{geometry}
% \usepackage[hdivide={1cm,,2cm}, vdivide={3cm,8in,}, nohead]{geometry}
% \usepackage[headsep=20pt, head=40pt,foot=20pt,includeheadfoot]{geometry}
% \usepackage[text={6in,8in}, top=2cm, left=2cm]{geometry}
% \usepackage[centering,includemp,twoside,landscape]{geometry}
% \usepackage[mag=1414,margin=2cm]{geometry}
% \usepackage[mag=1414,margin=2truecm,truedimen]{geometry}
% \usepackage[compat2,marginpar=50pt,twosideshift=50pt]{geometry}
% \usepackage[a5paper, landscape, twocolumn, twoside,
%    left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
%    bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
%    columnsep=1cm,verbose]{geometry}
%---------------------------------------------------------------
% No need to change below
%---------------------------------------------------------------
\geometry{verbose,showframe}% options appended.
\newcommand\mynote{\marginpar%
[\raggedright\rule{\marginparwidth}{.7pt}\\A left side note.]%
{\raggedright\rule{\marginparwidth}{.7pt}\\A side note.}}%
\def\fox{A quick brown fox jumps over the lazy dog. }
\def\fivefoxes{\fox\fox\fox\fox\fox}
\def\manyfoxes{\fivefoxes\mynote\fivefoxes\par\fivefoxes\fivefoxes\par}
% \let\mynote\relax % removes marginal notes.
\begin{document}
\manyfoxes\manyfoxes\manyfoxes\manyfoxes
\manyfoxes\manyfoxes\manyfoxes\manyfoxes
\manyfoxes\manyfoxes\manyfoxes\manyfoxes
\end{document}
%SAVE_INTACT
%</samples>
%    \end{macrocode}
%
% \Finale
%
\endinput