File: reftex.texi

package info (click to toggle)
xemacs20 20.4-13
  • links: PTS
  • area: main
  • in suites: slink
  • size: 67,324 kB
  • ctags: 57,643
  • sloc: lisp: 586,197; ansic: 184,662; sh: 4,296; asm: 3,179; makefile: 2,021; perl: 1,059; csh: 96; sed: 22
file content (2729 lines) | stat: -rw-r--r-- 101,771 bytes parent folder | download | duplicates (2)
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
\input texinfo  @c -*-texinfo-*-
@c %**start of header
@c $Id: reftex.texinfo,v 1.17 1998/01/29 13:07:11 dominik Exp dominik $
@setfilename reftex
@settitle RefTeX User User Manual
@synindex ky cp
@syncodeindex vr cp
@syncodeindex fn cp
@c %**end of header
@finalout


@ifinfo
This file documents @b{RefTeX}, a package to do labels, references and
citations for LaTeX documents with Emacs.@refill

This is edition 1.17 of the @b{RefTeX} User Manual for @b{RefTeX} 3.17

Copyright (c) 1997, 1998 Carsten Dominik <dominik@@strw.LeidenUniv.nl>
@end ifinfo

@titlepage
@title RefTeX User Manual
@subtitle Support for LaTeX labels, references, and citations with GNU Emacs
@subtitle Edition 1.17, January 1997

@author by Carsten Dominik
@page
Copyright @copyright{} 1997, 1998 Carsten Dominik @t{<dominik@@strw.LeidenUniv.nl>}

@sp 2
This is edition 1.17 of the @cite{RefTeX User Manual} for @b{RefTeX}
version 3.17, January 1998.@refill

@sp 2

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on  all copies.@refill

Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.@refill

Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the author.@refill

@end titlepage
@page

@ifinfo
@node Top,,,(xemacs20)

@b{RefTeX} is a package for managing Labels, References and Citations
with GNU Emacs.@refill

Don't be discouraged by the size of this manual, which covers @b{RefTeX}
in great depth.  All you need to know to use @b{RefTeX} can be
summarized on a single page (@pxref{RefTeX in a Nutshell}).  You can go
back later to other parts of this document when needed.@refill


@menu
* Introduction::                     Quick-Start information.

* Labels and References::            Creating and referencing labels.
* Citations::                        Creating Citations.
* Table of Contents::                A Tool to move around quickly.

* Keybindings::                      The default keybindings.
* Social Matters::                   Cooperation with other Emacs packages.
* Multifile Documents::              Document spread over many files.
* Optimizations::                    When RefTeX is too slow.
* Problems and Work-Arounds::        First Aid.
* Imprint::                          Author, Web-site, Thanks

* Commands::                         Which are the available commands.
* Options::                          How to extend and configure RefTeX.
* Keymaps::                          Where to put new key bindings.
* Hooks::                            Available hooks for customization.

The Index

* Index::                            The full index.

 --- The Detailed Node Listing ---

Introduction

* Installation::                     How to install and activate RefTeX.
* RefTeX in a Nutshell::             A brief summary and quick guide.

Labels and References

* Creating Labels::
* Referencing Labels::
* Builtin Label Environments::       The environments RefTeX knows about.
* Defining Label Environments::        ... and environments it doesn't.
* Displaying Cross References::      View the label corresponding to a \ref.
* xr (LaTeX package)::               References to external documents.
* varioref (LaTeX package)::         How to create \vref instead of \ref.

Defining Label Environments

* Theorem and Axiom::                Defined with @code{\newenvironment}.
* Quick Equation::                   When a macro sets the label type.
* Figure Wrapper::                   When a macro argument is a label.
* Adding Magic Words::               Other words for other languages.
* Using \eqref::                     How to switch to this AMS-LaTeX macro.
* Putting it Together::              How to combine many entries.

Citations

* Creating Citations::               How to create them.
* Citation Styles::                  Harvard, Chicago, Natbib and CO.
* Displaying Citations::             View the corresponding database entry.
* Chapterbib and Bibunits::          Multiple bibliographies in a Document.
* Citations Outside LaTeX::          How to make citations in Emails etc.

Social Matters

* AUCTeX::                           The ultimate TeX/LaTeX mode for GNU Emacs.
* Bib-Cite::                         Another package dealing with Citations.

Options, Keymaps, Hooks

* Options (Defining Label Environments)::
* Options (Creating Labels)::
* Options (Referencing Labels)::
* Options (Creating Citations)::
* Options (Table of Contents)::
* Options (Optimizations)::
* Options (Misc)::

@end menu

@end ifinfo

@node Introduction, Labels and References, , Top
@chapter Introduction
@cindex Introduction

@b{RefTeX} is a specialized package for support of labels, references,
and citations in LaTeX.  @b{RefTeX} wraps itself round 3 LaTeX macros:
@code{\label}, @code{\ref}, and @code{\cite}.  Using these macros
usually requires looking up different parts of the document and
searching through BibTeX database files.  @b{RefTeX} automates these
time--consuming tasks almost entirely.  It also provides functions to
display the structure of a document and to move around in this structure
quickly.@refill

@iftex
Don't be discouraged by the size of this manual, which covers @b{RefTeX}
in great depth.  All you need to know to use @b{RefTeX} can be
summarized on a single page (@pxref{RefTeX in a Nutshell}).  You can go
back later to other parts of this document when needed.
@end iftex

@menu
* Installation::                     How to install and activate RefTeX.
* RefTeX in a Nutshell::             A brief summary and quick guide.
@end menu

@node Installation, RefTeX in a Nutshell, , Introduction
@section Installation
@cindex Installation

If you are using Emacs 20.2 and later or XEmacs 19.16 or 20.2 and
later, @b{RefTeX} is installed already.@refill

You may also have retrieved your own copy of the @b{RefTeX}
distribution, because you use an older version of Emacs, or because new
features have been added to @b{RefTeX} in the mean time (@pxref{Imprint}
for information on how to obtain the @b{RefTeX} distribution).  In order
to install, the following steps are necessary.

@enumerate
@item 
Unpack the tarfile.
@item
Edit the header of the @file{Makefile} to contain the correct
installation paths for Lisp and Info files, as well as the correct name
for the Emacs executable.@refill
@item
Type
@example
make
make install
@end example
@noindent
in order to compile the code and install it along with the online Info
documentation.
@item
Copy the following lines into your @file{.emacs} file:@refill
@cindex .emacs
@cindex @code{autoload} forms, required
@example
(autoload 'reftex-mode    "reftex" "RefTeX Minor Mode" t)
(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
@end example
@end enumerate

In order to produce a printed version of the documentation, use
@code{make dvi} or @code{make ps}.  This will create the files
@file{reftex.dvi} and @file{reftex.ps}, respectively.  The command
@code{make html} will transform the documentation into HTML format (file
@file{reftex.html}).

@section Entering RefTeX Minor Mode
@findex turn-on-reftex
@findex reftex-mode
To turn @b{RefTeX} Minor Mode on and off in a particular buffer, use
@kbd{M-x reftex-mode}.  To turn on @b{RefTeX} Minor Mode for all LaTeX
files, add the following lines to your @file{.emacs} file:@refill

@example
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
@end example

@page
@node RefTeX in a Nutshell, , Installation, Introduction
@section RefTeX in a Nutshell
@cindex Quick-Start
@cindex Getting Started
@cindex RefTeX in a Nutshell
@cindex Nutshell, RefTeX in a

@enumerate
@item
@b{Labels and References}@* 
@b{RefTeX} distinguishes labels for different environments.  It always
knows if a certain label references a figure, table etc..  You can
configure @b{RefTeX} to recognize any additional labeled environments
you have defined yourself (variable @var{reftex-label-alist}).@refill
@itemize @bullet

@item
@b{Creating Labels}@* 
Type @kbd{C-c (} (@code{reftex-label}) to insert a label at point.
@b{RefTeX} will either
@itemize @minus
@item
derive a label from context (default for section labels)
@item
insert a simple label consisting of a prefix and a number
(default for equations, enumerate items, and footnotes) or@refill
@item
prompt for a label string (figures and tables).
@end itemize
@noindent
Which labels are created how is configurable (variable
@var{reftex-insert-label-flags}).@refill

@item
@b{Referencing Labels}@* 
Referencing labels is a snap and I promise you'll love it.  In order to
make a reference, type @kbd{C-c )} (@code{reftex-reference}).  This
shows an outline of the document with all labels of a certain type
(figure, equation,...) and context of the label definition.  Selecting
one of the labels inserts a @code{\ref} macro into the original buffer.
Online help during the selection is available with @kbd{?}.@refill
@end itemize

@item
@b{Citations}@* After typing @kbd{C-c [} (@code{reftex-citation}),
@b{RefTeX} will let you specify a regular expression to search in
current BibTeX database files (as specified in the @code{\bibliography}
command) and pull out a list of matches for you to choose from.  The
list is @emph{formatted} and sorted, thus much easier to read than the
raw database entries.  The text inserted into the buffer is by default
just @samp{\cite@{KEY@}}, but can also contain author names and the year
in a configurable way (variable @var{reftex-cite-format}).@refill

@item
@b{Viewing Cross References}@*
With point on or anywhere before a @code{\ref} or @code{\cite} macro,
press @kbd{C-c &} (@code{reftex-view-crossref}).  This will display the
corresponding label definition or BibTeX database entry in another
window.@refill

@item
@b{Table of Contents}@* 
Typing @kbd{C-c =} (@code{reftex-toc}) will show a table of contents of
the document.  From that buffer, you can jump quickly to every part of
your document.@refill

@item
@b{Multifile Documents}@* 
Multifile Documents are fully supported. @b{RefTeX} will provide cross
referencing information from all files which are part of the
document. You may also use it to reference labels in external documents
(in cooperation with the LaTeX package @code{xr}).@refill

@item
@b{Document Parsing}@*
@b{RefTeX} needs to parse the document in order to find labels and other
information.  It will do it automatically once, when you start working
with a document.  Re-parsing should not be necessary too often since
@b{RefTeX} updates its lists internally when you make a new label with
@code{reftex-label}.  To enforce reparsing, call any of the commands
described above with a raw @kbd{C-u} prefix, or press the @kbd{r} key in
the label selection buffer or the table of contents buffer.@refill
@end enumerate

@node Labels and References, Citations, Introduction, Top
@chapter Labels and References
@cindex Labels in LaTeX
@cindex References in LaTeX
@cindex Label category
@cindex Label environment
@cindex @code{\label}

LaTeX provides a powerful mechanism to deal with cross references in a
file.  When writing a document, any part of it can be marked with a
label, like @samp{\label@{mark@}}.  LaTeX records the current value of a
certain counter when a label is defined.  Later references to this label
(like @samp{\ref@{mark@}}) will produce the recorded value of the
counter.@refill

Labels can be used to mark sections, figures, tables, equations,
footnotes, items in enumerate lists etc.  LaTeX is context sensitive in
doing this: A label defined in a figure environment automatically
records the figure counter, not the section counter.@refill

Several different environments can share a common counter and therefore
a common label category.  E.g.  labels in both @code{equation} and
@code{eqnarray} environments record the value of the same counter - the
equation counter.@refill

@menu
* Creating Labels::
* Referencing Labels::
* Builtin Label Environments::       The environments RefTeX knows about.
* Defining Label Environments::        ... and environments it doesn't.
* Displaying Cross References::      View the label corresponding to a \ref.
* xr (LaTeX package)::               References to external documents.
* varioref (LaTeX package)::         How to create \vref instead of \ref.
@end menu

@node Creating Labels, Referencing Labels, , Labels and References
@section Creating Labels
@cindex Creating labels
@cindex Labels, creating
@cindex Labels, deriving from context
@kindex C-c (
@findex reftex-label

In order to create a label in a LaTeX document, press @kbd{C-c (}
(@code{reftex-label}).  Just like LaTeX, @b{RefTeX} is context sensitive
and will figure out the environment it currently is in and adapt the
label to that environment.  A label usually consists of a short prefix
indicating the type of the label and a unique mark.  @b{RefTeX} has
3 different modes to create this mark.@refill

@enumerate
@item
A label can be derived from context.  This means, @b{RefTeX} takes
the context of the label definition and construct a label from that.
This works best for section labels, where the section heading is used to
construct a label.  In fact, @b{RefTeX}'s default settings use this
method only for section labels.  You will be asked to confirm the
derived label, or edit it.@refill

@item
We may also use a simple unique number to identify a label.  This is
mostly useful for labels where it is difficult to come up with a very
good descriptive name.  @b{RefTeX}'s default settings use this method
for equations, enumerate items and footnotes.  The author of @b{RefTeX}
tends to write documents with many equations and finds it impossible
to come up with good names for each of them.  These simple labels are
inserted without query, and are therefore very fast.  Good descriptive
names are not really necessary as @b{RefTeX} will provide context to
reference a label (@pxref{Referencing Labels}).@refill

@item
The third method is to ask the user for a label.  This is most
useful for things which are easy to describe briefly and do not turn up
too frequently in a document.  @b{RefTeX} uses this for figures and
tables.  Of course, one can enter the label directly by typing the full
@samp{\label@{mark@}}.  The advantage of using @code{reftex-label}
anyway is that @b{RefTeX} will know that a new label has been defined.
It will then not be necessary to rescan the document in order to access
this label later.@refill
@end enumerate

If you want to change the way certain labels are created, check out the
variable @var{reftex-insert-label-flags} (@pxref{Options (Creating
Labels)}).@refill

@node Referencing Labels, Builtin Label Environments, Creating Labels, Labels and References
@section Referencing Labels
@cindex Referencing labels
@cindex Labels, referencing
@cindex Selection buffer, labels
@cindex Selection process
@cindex @code{\ref}
@kindex C-c )
@findex reftex-reference

Referencing Labels is really at the heart of @b{RefTeX}.  Press @kbd{C-c
)} in order to reference a label (reftex-reference).  This will start a
selection process and finally insert the complete @samp{\ref@{label@}}
into the buffer.@refill

First, @b{RefTeX} will determine the label category which is required.
Often that can be figured out from context.  For example, if you
write @samp{As shown in eq.} and the press @kbd{C-c )}, @b{RefTeX} knows
that an equation label is going to be referenced.  If it cannot figure
out what label category is needed, it will query for one.@refill

You will then be presented with a label selection menu.  This is a
special buffer which contains an outline of the document along with all
labels of the given label category.  In addition, next to the label
there will be one line of context of the label definition, which is some
text in the buffer near the label definition.  Usually this is
sufficient to identify the label.  If you are unsure about a certain
label, pressing @kbd{SPC} will show the label definition point in
another window.@refill

In order to reference a label, move to cursor to the correct label
and press @kbd{RET}.@*
Here is a list of commands available in the selection buffer.  A summary
of this information is always available from the selection process by
pressing @kbd{?}.@refill

@table @kbd
@item Cursor
All normal cursor motions are available to move through the buffer.
This includes scrolling and @code{beginning-of-buffer},
@code{end-of-buffer}.@refill

@item b
Jump back to the position where you last left the selection buffer.
Normally this should get you back to the last referenced label.@refill

@item c
Toggle the display of the one-line label definition context in the
selection buffer.@refill

@item f
Toggle follow mode.  When follow mode is active, the other window will
always display the full context of the current label.  This is
equivalent to pressing @key{SPC} after each cursor motion.@refill

@item g
Update the menu.  This will rebuilt the menu from the internal label
list, but not reparse the document (see @kbd{r}).@refill

@item i
Toggle the display of the file borders of a multifile document in the
selection buffer.@refill

@item l
Use the last referenced label again.  This is equivalent to moving to
that label again and pressing @kbd{RET}.@refill

@item n
Go to next label.

@item p
Go to previous label.

@item q
Exit the selection process without inserting any reference into the
buffer.@refill

@item r
Reparse the document to update the information on all labels and rebuild
the menu.  If the variable @var{reftex-enable-partial-scans} is
non-@code{nil} and your document is a multifile document, this will
reparse only a a part of the document (the file the label at point was
defined in).@refill

@item R
Reparse the @emph{entire} document.

@item s
Switch the label category.  After prompting for another label category,
a menu for that category will be shown.@refill

@item t
Toggle the display of the table of contents in the selection buffer.@refill

@item v
Toggle between @code{\ref} and @code{\vref} macro for references.  The
@code{\vref} macro is defined in the @code{varioref} LaTeX package.
With this key you can force @b{RefTeX} to insert a @code{\vref} macro.  The
current state of this flag is displayed in the mode line of the
selection buffer.@refill

@item x
Reference a label from an external document.  With the LaTeX package
@code{xr} it is possible to reference labels defined in another
document.  This key will switch to the label menu of an external
document and let you select a label from there (@pxref{xr (LaTeX
package),,xr}).@refill

@item TAB
Enter a label with completion.  This may also be a label which does not
yet exist in the document.

@item SPC
Show the surroundings of the definition of the current label in another
window.  See also the @kbd{f} key.  The usual bindings to scroll the other
window are also available.@refill

@item RET
Insert a reference to the label at point into the buffer from which the
selection process was started.@refill

@item #
Toggle the display of a label counter in the selection buffer.@refill

@item %
Toggle the display of labels hidden in comments in the selection
buffers.  Sometimes, you may have commented out parts of your document.
If these parts contain label definitions, @b{RefTeX} can still display
and reference these labels.@refill

@item ?
Show a summary of the available keys.

@item C-c C-n
Goto next section heading (like outline mode).

@item C-c C-p
Goto next section heading (like outline mode).

@item C-s / C-r
Search forward/backward.  This works almost like incremental search -
subsequent @kbd{C-s}/@kbd{C-r} will find other occurrences of the same
search string.@refill

@end table

Several of these keys toggle certain settings.  The default value for
these flags can be preset by configuring the variable
@var{reftex-label-menu-flags} (@pxref{Options (Referencing Labels)}).
In order to define additional commands for the selection process, the
keymap @var{reftex-select-label-map} may be used
(@pxref{Keymaps}).@refill

@node Builtin Label Environments, Defining Label Environments, Referencing Labels, Labels and References
@section Builtin Label Environments
@cindex Builtin label environments
@cindex Label environments, builtin
@cindex Environments, builtin
@vindex reftex-label-alist
@vindex reftex-label-alist-builtin

@b{RefTeX} needs to be aware of the environments which can be referenced
with a label (i.e. which carry their own counters).  By default, @b{RefTeX}
recognizes all labeled environments and macros discussed in @cite{The
LaTeX Companion by Goossens, Mittelbach & Samarin, Addison-Wesley
1994.}.  These are:@refill

@itemize @minus
@item
@cindex @code{figure}, LaTeX environment
@cindex @code{figure*}, LaTeX environment
@cindex @code{table}, LaTeX environment
@cindex @code{table*}, LaTeX environment
@cindex @code{equation}, LaTeX environment
@cindex @code{eqnarray}, LaTeX environment
@cindex @code{enumerate}, LaTeX environment
@cindex @code{\footnote}, LaTeX macro
@cindex LaTeX macro @code{footnote}
@cindex LaTeX core
@code{figure}, @code{figure*}, @code{table}, @code{table*}, @code{equation},
@code{eqnarray}, @code{enumerate}, the @code{\footnote} macro (this is
the LaTeX core stuff)@refill
@item
@cindex AMS-LaTeX
@cindex @code{amsmath}, LaTeX package
@cindex LaTeX packages, @code{amsmath}
@cindex @code{align}, AMS-LaTeX environment
@cindex @code{gather}, AMS-LaTeX environment
@cindex @code{multline}, AMS-LaTeX environment
@cindex @code{flalign}, AMS-LaTeX environment
@cindex @code{alignat}, AMS-LaTeX environment
@cindex @code{xalignat}, AMS-LaTeX environment
@cindex @code{xxalignat}, AMS-LaTeX environment
@cindex @code{subequations}, AMS-LaTeX environment
@code{align}, @code{gather}, @code{multline}, @code{flalign},
@code{alignat}, @code{xalignat}, @code{xxalignat}, @code{subequations}
(from AMS-LaTeX's @file{amsmath.sty} package)@refill
@item
@cindex @code{endnote}, LaTeX package
@cindex LaTeX packages, @code{endnote}
@cindex @code{\endnote}, LaTeX macro
the @code{\endnote} macro (from @file{endnotes.sty})
@item
@cindex @code{fancybox}, LaTeX package
@cindex LaTeX packages, @code{fancybox}
@cindex @code{Beqnarray}, LaTeX environment
@code{Beqnarray} (@file{fancybox.sty})
@item
@cindex @code{floatfig}, LaTeX package
@cindex LaTeX packages, @code{floatfig}
@cindex @code{floatingfig}, LaTeX environment
@code{floatingfig} (@file{floatfig.sty})
@item
@cindex @code{longtable}, LaTeX package
@cindex LaTeX packages, @code{longtable}
@cindex @code{longtable}, LaTeX environment
@code{longtable} (@file{longtable.sty})
@item
@cindex @code{picinpar}, LaTeX package
@cindex LaTeX packages, picinpar
@cindex @code{figwindow}, LaTeX environment
@cindex @code{tabwindow}, LaTeX environment
@code{figwindow}, @code{tabwindow} (@file{picinpar.sty})
@item
@cindex @code{rotating}, LaTeX package
@cindex LaTeX packages, @code{rotating}
@cindex @code{sidewaysfigure}, LaTeX environment
@cindex @code{sidewaystable}, LaTeX environment
@code{sidewaysfigure}, @code{sidewaystable} (@file{rotating.sty})
@item
@cindex @code{subfig}, LaTeX package
@cindex LaTeX packages, @code{subfigure}
@cindex @code{subfigure}, LaTeX environment
@cindex @code{subfigure*}, LaTeX environment
@code{subfigure}, @code{subfigure*}, the @code{\subfigure} macro
(@file{subfigure.sty})@refill
@item
@cindex @code{supertab}, LaTeX package
@cindex LaTeX packages, @code{supertab}
@cindex @code{supertabular}, LaTeX environment
@code{supertabular} (@file{supertab.sty})
@item
@cindex @code{wrapfig}, LaTeX package
@cindex LaTeX packages, @code{wrapfig}
@cindex @code{wrapfigure}, LaTeX environment
@code{wrapfigure} (@file{wrapfig.sty})
@end itemize

If you want to use other labeled environments, for example some defined
with @code{\newtheorem}, @b{RefTeX} needs to be configured to recognize them
(@pxref{Defining Label Environments}).@refill

@node Defining Label Environments, Displaying Cross References, Builtin Label Environments, Labels and References
@section Defining Label Environments
@cindex Label environments, defining
@vindex reftex-label-alist

@b{RefTeX} can be configured to recognize additional labeled
environments and macros.  This is done with the variable
@var{reftex-label-alist} (@pxref{Options (Defining Label
Environments)}).  If you are not familiar with Lisp, you should use the
@code{custom} library to configure this rather complex variable.  To do
this, use

@example
@kbd{M-x customize-variable @key{RET} reftex-label-alist @key{RET}}
@end example

Here we will discuss a few examples, in order to make things clearer.
It can also be instructive to look at the constant
@var{reftex-label-alist-builtin} which contains the entries for
all the builtin environments and macros (@pxref{Builtin Label
Environments}).@refill

@menu
* Theorem and Axiom::                Defined with @code{\newenvironment}.
* Quick Equation::                   When a macro sets the label type.
* Figure Wrapper::                   When a macro argument is a label.
* Adding Magic Words::               Other words for other languages.
* Using \eqref::                     How to switch to this AMS-LaTeX macro.
* Putting it Together::              How to combine many entries.
@end menu

@node Theorem and Axiom, Quick Equation, , Defining Label Environments
@subsection Theorem and Axiom Environments
@cindex @code{theorem}, newtheorem
@cindex @code{axiom}, newtheorem
@cindex @code{\newtheorem}

Suppose you are using @code{\newtheorem} in LaTeX in order to define two
new environments, @code{theorem} and @code{axiom}@refill

@example
\newtheorem@{axiom@}@{Axiom@}
\newtheorem@{theorem@}@{Theorem@}
@end example

@noindent
to be used like this:

@example
\begin@{axiom@}
\label@{ax:first@}
  ....
\end@{axiom@}
@end example

So we need to tell @b{RefTeX} that @code{theorem} and @code{axiom} are new
labeled environments which define their own label categories.  We can
either use Lisp to do this (e.g. in @file{.emacs}) or use the custom
library.  With lisp it would look like this

@lisp
(setq reftex-label-alist
   '(("axiom"   ?a "ax:"  "~\\ref@{%s@}" nil ("Axiom"   "Ax."))
     ("theorem" ?h "thr:" "~\\ref@{%s@}" t   ("Theorem" "Theor." "Th."))))
@end lisp

The type indicator characters @code{?a} and @code{?h} are used for
prompts when @b{RefTeX} queries for a label type.  Note that @code{?h}
was chosen for @code{theorem} since @code{?t} is already taken by
@code{table}.  Note that also @code{?s}, @code{?f}, @code{?e},
@code{?i}, @code{?n} are already used for standard environments.@refill

@noindent
The automatic labels for Axioms and Theorems will look like @samp{ax:23} or
@samp{thr:24}.@refill

@noindent
The @samp{~\ref@{%s@}} is a format string indicating how to insert
references to these labels.@refill

@noindent
The next item indicates how to grab context of the label definition.@refill
@itemize @minus
@item
@code{t} means to get it from a default location (from the beginning of
a @code{\macro} or after the @code{\begin} statement).  @code{t} is
@emph{not} a good choice for eqnarray and similar environments.@refill
@item
@code{nil} means to use the text right after the label definition.@refill
@item
For more complex ways of getting context, see the variable
@var{reftex-label-alist} (@pxref{Options (Defining Label
Environments)}).@refill
@end itemize

The strings at the end of each entry are used to guess the correct label
type from the word before point when creating a reference.  E.g. if you
write: @samp{As we have shown in Theorem} and then press @kbd{C-c )},
@b{RefTeX} will know that you are looking for a theorem label and restrict
the menu to only these labels without even asking.@refill

To do the same configuration with @code{customize}, you need to click on
the @code{[INS]} button twice to create two templates and fill them in
like this:@refill

@example
Reftex Label Alist: [Hide]
[INS] [DEL] Choice: [Value Menu] Detailed label alist entry:
            Environment or \macro : [Value Menu] String: axiom
            Typekey character     : a 
            Label prefix string   : [Value Menu] String: ax:
            Label reference format: [Value Menu] String: ~\ref@{%s@}
            Context: [Value Menu] 1 method: [Value Menu] After label
            List of Magic Words:
            [INS] [DEL] String: Axiom
            [INS] [DEL] String: Ax.
            [INS]
[INS] [DEL] Choice: [Value Menu] Detailed label alist entry:
            Environment or \macro : [Value Menu] String: theorem
            Typekey character     : h
            Label prefix string   : [Value Menu] String: thr:
            Label reference format: [Value Menu] String: ~\ref@{%s@}
            Context: [Value Menu] 1 method: [Value Menu] Default position
            List of Magic Words:
            [INS] [DEL] String: Theorem
            [INS] [DEL] String: Theor.
            [INS] [DEL] String: Th.
            [INS]
@end example

Depending on how you would like the label insertion and selection for
the new environments to work, you might want to add the letters @samp{a}
and @samp{h} to some of the flags in the variables
@var{reftex-insert-label-flags} (@pxref{Options (Creating Labels)})
and @var{reftex-label-menu-flags} (@pxref{Options (Referencing
Labels)}).@refill


@node Quick Equation, Figure Wrapper, Theorem and Axiom , Defining Label Environments
@subsection Quick Equation Macro
@cindex Quick equation macro
@cindex Macros as environment wrappers

Suppose you would like to have a macro for quick equations.  It
could be defined like this:

@example
\newcommand@{\quickeq@}[1]@{\begin@{equation@} #1 \end@{equation@}@}
@end example

@noindent
and used like this:

@example
Einstein's equation is \quickeq@{E=mc^2 \label@{eq:einstein@}@}.
@end example

We need to tell @b{RefTeX} that any label defined in the argument of the
@code{\quickeq} is an equation label.  Here is how to do this with lisp:

@lisp
(setq reftex-label-alist '(("\\quickeq@{@}" ?e nil nil 1 nil)))
@end lisp

The first element in this list is now the macro with empty braces as an
@emph{image} of the macro arguments.  @code{?e} indicates that this is
an equation label, the different @code{nil} elements indicate to use the
default values for equations.  The @samp{1} as the fifth element
indicates that the context of the label definition should be the 1st
argument of the macro.@refill

Here is again how this would look in the customization buffer:

@example
Reftex Label Alist: [Hide]
[INS] [DEL] Choice: [Value Menu] Detailed label alist entry:
            Environment or \macro : [Value Menu] String: \quickeq@{@}
            Typekey character     : e 
            Label prefix string   : [Value Menu] Default
            Label reference format: [Value Menu] Default
            Context: [Value Menu] 1 method: [Value Menu] Macro arg nr: 1
            List of Magic Words:
            [INS]
@end example

@node Figure Wrapper, Adding Magic Words, Quick Equation, Defining Label Environments
@subsection Figure Wrapping Macro
@cindex Macros as environment wrappers
@cindex Figure wrapping macro

Suppose you want to make figures not directly with the figure
environment, but with a macro like

@example
\newcommand@{\myfig@}[5][tbp]@{%
  \begin@{figure@}[#1]
    \epsimp[#5]@{#2@}
    \caption@{#3@}
    \label@{#4@}
  \end@{figure@}@}
@end example

@noindent
which would be called like

@example
\myfig[htp]@{filename@}@{caption text@}@{label@}@{1@}
@end example

Now we need to tell @b{RefTeX} that the 4th argument of the
@code{\myfig} macro @emph{is itself} a figure label, and where to find
the context.@refill

@lisp
(setq reftex-label-alist
      '(("\\myfig[]@{@}@{@}@{*@}@{@}" ?f nil nil 3)))
@end lisp

The empty pairs of brackets indicate the different arguments of the
@code{\myfig} macro. The @samp{*} marks the label argument.  @code{?f}
indicates that this is a figure label which will be listed together with
labels from normal figure environments.  The @code{nil} entries for
prefix and reference format mean to use the defaults for figure labels.
The @samp{3} for the context method means to grab the 3rd macro argument
- the caption.@refill

As a side effect of this configuration, @code{reftex-label} will now
insert the required naked label (without the @code{\label} macro) when
point is directly after the opening parenthesis of a @code{\myfig} macro
argument.@refill

Again, here the configuration in the customization buffer:

@example
[INS] [DEL] Choice: [Value Menu] Detailed label alist entry:
            Environment or \macro : [Value Menu] String: \myfig[]@{@}@{@}@{*@}@{@}
            Typekey character     : f 
            Label prefix string   : [Value Menu] Default
            Label reference format: [Value Menu] Default
            Context: [Value Menu] 1 method: [Value Menu] Macro arg nr: 3
            List of Magic Words:
            [INS]
@end example

@node Adding Magic Words, Using \eqref, Figure Wrapper, Defining Label Environments
@subsection Adding Magic Words
@cindex Magic words
@cindex German magic words
@cindex Label category

Sometimes you don't want to define a new label environment or macro, but
just change the information associated with a label category.  Maybe you
want to add some magic words, for another language.  Changing only the
information associated with a label category is done by giving
@code{nil} for the environment name and then specify the items you want
to define.  Here is an example which adds German magic words to all
predefined label categories.@refill

@lisp
(setq reftex-label-alist
  '((nil ?s nil nil nil ("Kapitel" "Kap." "Abschnitt" "Teil"))
    (nil ?e nil nil nil ("Gleichung" "Gl."))
    (nil ?t nil nil nil ("Tabelle"))
    (nil ?f nil nil nil ("Figur" "Abbildung" "Abb."))
    (nil ?n nil nil nil ("Anmerkung" "Anm."))
    (nil ?i nil nil nil ("Punkt"))))
@end lisp

@node Using \eqref, Putting it Together, Adding Magic Words, Defining Label Environments
@subsection Using @code{\eqref}
@cindex @code{\eqref}, AMS-LaTeX macro
@cindex AMS-LaTeX
@cindex Label category

Another case where one only wants to change the information associated
with the label category is to change the macro which is used for
referencing the label.  When working with the AMS-LaTeX stuff, you might
prefer the @code{\eqref} for doing equation references.  Here is how to
do this:

@lisp
(setq reftex-label-alist '((nil ?e nil "~\\eqref@{%s@}" nil nil)))
@end lisp

@b{RefTeX} has also a predefined symbol for this special purpose.  The
following is equivalent to the line above.@refill

@lisp
(setq reftex-label-alist '(AMSTeX))
@end lisp

@node Putting it Together, , Using \eqref, Defining Label Environments
@subsection Putting it all together

When you have to put several entries into @var{reftex-label-alist}, just
put them after each other in a list, or create that many templates in
the customization buffer.  Here is a lisp example which uses several of
the entries described above:

@lisp
(setq reftex-label-alist
  '(("axiom"   ?a "ax:"  "~\\ref@{%s@}" nil ("Axiom"   "Ax."))
    ("theorem" ?h "thr:" "~\\ref@{%s@}" t   ("Theorem" "Theor." "Th."))
    ("\\quickeq@{@}" ?e nil nil 1 nil)
    AMSTeX
    ("\\myfig[]@{@}@{@}@{*@}@{@}" ?f nil nil 3)))
@end lisp

@node Displaying Cross References, xr (LaTeX package), Defining Label Environments, Labels and References
@section Displaying Cross References
@findex reftex-view-crossref
@findex reftex-mouse-view-crossref
@cindex Cross references, displaying
@cindex Displaying cross references
@cindex Viewing cross references
@kindex C-c &

@b{RefTeX} can display the definition site of a label which is
referenced in the text.  With the cursor on or anywhere before a
@code{\ref} macro, type @kbd{C-c &}.  @b{RefTeX} will then display the
definition of the label in another window.  This works also with
references to external labels (@pxref{xr (LaTeX package)}).@refill

See also @ref{Displaying Citations}.

@node xr (LaTeX package), varioref (LaTeX package), Displaying Cross References, Labels and References
@section @code{xr}: Cross-Document References
@cindex @code{xr}, LaTeX package
@cindex LaTeX packages, @code{xr}
@cindex @code{\externaldocument}
@cindex External documents
@cindex References to external documents
@cindex Cross-document references

The LaTeX package @code{xr} makes it possible to create references to
labels defined in external documents.  The preamble of a document using
@code{xr} will contain something like this:@refill

@example
\usepackage@{xr@}
\externaldocument[V1-]@{volume1@}
\externaldocument[V3-]@{volume3@}
@end example

@noindent
and we can make references to any labels defined in these
external documents by using the prefixes @samp{V1-} and @samp{V3-},
respectively.@refill

@b{RefTeX} can be used to create such labels as well.  Start the
referencing process normally, by pressing @kbd{C-c )}.  Select a label
type if necessary.  When you see the label selection buffer, pressing
@kbd{x} will switch to the label selection buffer of one of the external
documents.  You may then select a label as before and @b{RefTeX} will
insert it along with the required prefix.@refill

For this kind of inter-document cross references, saving of parsing
information and the use of multiple selection buffers can mean a large
speed-up (@pxref{Optimizations}).@refill

@node varioref (LaTeX package), , xr (LaTeX package), Labels and References
@section @code{varioref}: Variable Page References
@cindex @code{varioref}, LaTeX package
@cindex @code{\vref}
@cindex LaTeX packages, @code{varioref}

@code{varioref} is a frequently used LaTeX package to create cross
references with page information.  When you want to make a reference
with the @code{\vref} macro, just press the @kbd{v} key in the selection
buffer to toggle between the @code{\ref} and @code{\vref}
(@pxref{Referencing Labels}.  The mode line of the selection buffer
shows the current status of this switch.  If you find that you almost
always use @code{\vref}, you may want to make it the default by
customizing the variable @var{reftex-vref-is-default}@refill

@node Citations, Table of Contents, Labels and References, Top
@chapter Citations
@cindex Citations

Citations in LaTeX are done with the @code{\cite} macro or variations of
it.  The argument of the macro is a citation key which identifies a piece
literature in either a BibTeX database file or in an explicit
@code{thebibliography} environment in the document.  @b{RefTeX}'s support
for citations helps to select the correct key quickly.@refill

@menu
* Creating Citations::               How to create them.
* Citation Styles::                  Harvard, Chicago, Natbib and CO.
* Displaying Citations::             View the corresponding database entry.
* Chapterbib and Bibunits::          Multiple bibliographies in a Document.
* Citations Outside LaTeX::          How to make citations in Emails etc.
@end menu

@node Creating Citations, Citation Styles, , Citations
@section Creating Citations
@cindex Creating citations
@cindex Citations, creating
@findex reftex-citation
@kindex C-c [
@cindex Selection buffer, citations
@cindex Selection process

In order to create a citation, press @kbd{C-c [}.  @b{RefTeX} then
prompts for a regular expression which will be used to search through
the database and present the list of matches to choose from in a
selection process similar to that for selecting labels
(@pxref{Referencing Labels}).@refill

The regular expression uses an extended syntax: @samp{&&} defines a
logic @code{and} for regular expressions. For example
@samp{Einstein&&Bose} will match all articles which mention
Bose-Einstein condensation, or which are co-authored by Bose and
Einstein.@refill

@cindex @code{\bibliography}
@cindex @code{thebibliography}, LaTeX environment
@b{RefTeX} prefers to use BibTeX database files specified with a
@code{\bibliography} macro to collect its information.  However, if you
have an explicit @code{thebibliography} environment in your document, it
will be scanned instead.  Note that in this case the information
presented in the selection buffer will just be a copy of relevant
@code{\bibitems}, not the structured listing available with BibTeX
database files.@refill

In the selection buffer, the following keys are available to find and
select an article.  A summary of this information is always
available from the selection process by pressing @kbd{?}.@refill

@table @kbd
@item Cursor
All normal cursor motions are available to move through the buffer.
This includes scrolling and @code{beginning-of-buffer},
@code{end-of-buffer}.@refill

@item a
Accept all entries in the selection buffer and create @code{\cite}
macros referring to them.@refill

@item e
Start a recursive edit in the other window (which usually displays the
full database entry when using this).  See @key{SPC} and @kbd{f}
keys.@refill

@item f
Toggle follow mode.  When follow mode is active, the other window will
always display the full database entry of the current article.  This is
equivalent to pressing SPC after each cursor motion.  With BibTeX
entries, follow mode can be rather slow.@refill

@item g
Start over with a new regular expression.  The full database will be
rescanned with the new expression (see also @kbd{r}).@refill

@item n
Go to next article.

@item p
Go to previous article.

@item q
Exit the selection process without inserting any citation into the
buffer.@refill

@item r
Refine the current selection with another regular expression.  This will
@emph{not} rescan the entire database, but just the already selected
entries.@refill

@item TAB
Enter a citation key with completion.  This may also be a key which does
not yet exist.

@item SPC
Show the database entry corresponding to the article at point, in
another window.  See also the @kbd{f} key.  The usual bindings to scroll
the other window are also available.@refill

@item RET
Insert a citation to the article at point into the buffer from which the
selection process was started.@refill

@item C-s / C-r
Search forward/backward.  This works almost like incremental search -
subsequent @kbd{C-s}/@kbd{C-r} will find other occurrences of the same
search string.@refill

@item ?
Show a summary of the available keys.
@end table

In order to define additional commands for this selection process, the
keymap @var{reftex-select-bib-map} may be used (@pxref{Keymaps}).@refill

@node Citation Styles, Displaying Citations, Creating Citations, Citations
@section Citation Styles
@cindex Citation styles
@cindex Citation styles, @code{harvard}
@cindex Citation styles, @code{chicago}
@cindex Citation styles, @code{natbib}
@cindex @code{harvard}, citation style
@cindex @code{chicago}, citation style
@cindex @code{natbib}, citation style

The standard LaTeX macro @code{\cite} works well with numeric or simple
key citations.  To deal with the more complex task of author-year
citations as used in many natural sciences, a variety of packages has
been developed which define derived forms of the @code{\cite} macro.
@b{RefTeX} can be configured to produce these citation macros as well by
setting the variable @var{reftex-cite-format}.  For the most commonly
used packages (@code{natbib}, @code{harvard}, @code{chicago}) this may
be done from the menu, under @code{Ref/Citation Options}.  Since there
are usually several macros to create the citations, executing
@code{reftex-citation} (@kbd{C-c [}) starts by prompting for the correct
macro.  For the Harvard style, this looks like this:

@example
SELECT A CITATION FORMAT

[^M]   \cite@{%l@}
[p]    \cite@{%l@}
[t]    \citeasnoun@{%l@}
[n]    \citeasnoun@{%l@}
[s]    \possessivecite@{%l@}
[e]    \citeaffixed@{%l@}@{?@}
[y]    \citeyear@{%l@}
[a]    \citename@{%l@}
@end example

Following the most generic of these packages, @code{natbib}, the builtin
citation packages always accept the @kbd{t} for a @emph{textual}
citation (like: @code{Jones et al. (1997) have shown...})  as well as
the @kbd{p} key for a parenthetical citation (like: @code{As shown
earlier (Jones et al, 1997)}).@refill

To make one of these styles the default, customize the variable
@var{reftex-cite-format} or put into @file{.emacs}:

@lisp
(setq reftex-cite-format 'harvard)
@end lisp

@node Displaying Citations, Chapterbib and Bibunits, Citation Styles, Citations, Top
@section Displaying Citations
@cindex Displaying citations
@cindex Citations, displaying
@cindex Viewing citations
@kindex C-c &
@findex reftex-view-crossref
@findex reftex-mouse-view-crossref

@b{RefTeX} can display the full database entry for any citation key used
in the document.  With the cursor on or anywhere before a @code{\cite}
macro, type @kbd{C-c &}. @b{RefTeX} will show the full database entry in
another window.  If you press @kbd{C-c &} immediately again, @b{RefTeX}
will move to the next following citation key - so this can be used to
display the database entries for several keys in a single @code{\cite}
macro, or in subsequent macros.@refill

See also @ref{Displaying Cross References}.

@node Chapterbib and Bibunits, Citations Outside LaTeX, Displaying Citations, Citations
@section Chapterbib and Bibunits
@cindex @code{chapterbib}, LaTeX package
@cindex @code{bibunits}, LaTeX package
@cindex Bibliographies, multiple

@code{chapterbib} and @code{bibunits} are two LaTeX packages which
produce multiple bibliographies in a document.  This is no problem for
@b{RefTeX} as long as all bibliographies use the same BibTeX database
files.  If they do not, it is best to have each document part in a
separate file (as it is required for @code{chapterbib} anyway).  Then
@b{RefTeX} will still scan the locally relevant databases correctly.  If
you have multiple bibliographies within a @emph{single file}, this may
or may not be the case.

@node  Citations Outside LaTeX, , Chapterbib and Bibunits, Citations
@section Citations outside LaTeX
@cindex Citations outside LaTeX

The command @code{reftex-citations} can also be executed outside a LaTeX
buffer.  This can be useful to reference articles in Emails and other
documents.  The list of BibTeX files will in this case be taken from the
variable @var{reftex-default-bibliography}.  Setting the variable
@var{reftex-cite-format} to the symbol 'locally does a decent job of
putting all relevant information about a citation directly into the
buffer.  Here is the lisp code to add the @kbd{C-c [} binding to the
mail buffer.  It also provides a local binding for
@var{reftex-cite-format}.@refill

@lisp
(add-hook
 'mail-setup-hook
 (lambda ()
   (define-key mail-mode-map "\C-c["
     (lambda ()
       (interactive)
       (require 'reftex)
       (let ((reftex-cite-format 'locally))
         (reftex-citation))))))
@end lisp
    

@node Table of Contents, Keybindings, Citations, Top
@chapter Table of Contents
@cindex @code{*toc*} buffer
@cindex Table of contents buffer
@findex reftex-toc
@kindex C-c =

When you press @kbd{C-c =}, @b{RefTeX} will pop up a buffer showing the
table of contents of the document.  With the cursor in any of the lines
denoting a section, simple key strokes will jump to that section or
perform other actions.  Here is a list of available commands.  A summary
of this information is always available by pressing @kbd{?}.@refill

@table @kbd

@item 0-9, -
Prefix argument.

@item f
Toggle follow mode on and of.  When follow mode is active, the other
window will always show the section corresponding to the line in the
@samp{*toc*} buffer at point.  This is equivalent to pressing @key{SPC}
after each cursor motion.  The default for this flag can be set with
the variable @var{reftex-toc-follow-mode}.@refill

@item g
Rebuild the @samp{*toc*} buffer.  This does @emph{not} rescan the
document.@refill

@item n
Goto next line.

@item p
Goto previous line.

@item q
Hide the @samp{*toc*} buffer, return to the position where
@code{reftex-toc} was last called.@refill

@item Q
Kill the @samp{*toc*} buffer, return to the position where
@code{reftex-toc} was last called.@refill

@item r
Reparse the LaTeX document and rebuild the @samp{*toc*} buffer.  When
@var{reftex-enable-partial-scans} is non-nil, rescan only the file this
section is defined in, not the entire document.@refill

@item R
Reparse the @emph{entire} LaTeX document and rebuild the @samp{*toc*}
buffer.@refill

@item x
Switch to the @samp{*toc*} buffer of an external document.  When the
current document is using the @code{xr} package (@pxref{xr (LaTeX
package)}), @b{RefTeX} will switch to one of these external
documents.@refill

@item SPC
Show the corresponding section in another window.  This command does
@emph{not} select that other window.@refill

@item TAB
Goto the section in another window.

@item RET
Go to the section and hide the @samp{*toc*} buffer.  This will restore
the window configuration before @code{reftex-toc} (@kbd{C-c =}) was
called. @refill
@end table

In order to define additional commands for the @samp{*toc*} buffer, the
keymap @var{reftex-toc-map} may be used (@pxref{Keymaps}).@refill

@iftex
@chapter All the Rest
@end iftex

@node Keybindings, Social Matters, Table of Contents, Top
@section Default Keybindings
@cindex Keybindings, summary

All @b{RefTeX} commands can be reached from its menu, which is installed
as @code{Ref} menu in the menu bar.  Here is a summary of the available
keybindings.

@example
@kbd{C-c =}    @code{reftex-toc}
@kbd{C-c (}    @code{reftex-label}
@kbd{C-c )}    @code{reftex-reference}
@kbd{C-c [}    @code{reftex-view-crossref}
@end example

These keys were chosen to avoid interfering with AUCTeX's settings.
Personally, I also bind some functions in the @kbd{C-c @key{letter}} map
for easier access:

@kindex C-c t
@kindex C-c l
@kindex C-c r
@kindex C-c c
@kindex C-c v
@kindex C-c s
@kindex C-c g
@example
@kbd{C-c t}    @code{reftex-toc}
@kbd{C-c l}    @code{reftex-label}
@kbd{C-c r}    @code{reftex-reference}
@kbd{C-c c}    @code{reftex-citation}
@kbd{C-c v}    @code{reftex-view-crossref}
@kbd{C-c s}    @code{reftex-search-document}
@kbd{C-c g}    @code{reftex-grep-document}
@end example

@noindent
If you want to copy these as well, set in your @file{.emacs} file:

@vindex reftex-extra-bindings
@lisp
(setq reftex-extra-bindings t)
@end lisp

It is also possible to bind the function for viewing cross references
and citations (@code{reftex-view-crossref}) to a mouse event.  Something
like the following will do the trick:

@findex reftex-mouse-view-crossref
@lisp
(add-hook 'reftex-load-hook
   (lambda ()
     (define-key reftex-mode-map [(shift mouse-2)]
       'reftex-mouse-view-crossref)))
@end lisp


@node Social Matters, Multifile Documents, Keybindings, Top
@section Social Matters

There are two Emacs packages related to @b{RefTeX}.  @b{RefTeX} can
interact with both of them.@refill

@menu
* AUCTeX::                           The ultimate TeX/LaTeX mode for GNU Emacs.
* Bib-Cite::                         Another package dealing with Citations.
@end menu

@node AUCTeX, Bib-Cite, , Social Matters
@subsection AUCTeX
@cindex @code{AUCTeX}, Emacs package
@cindex Emacs packages, @code{AUCTeX}

If you are writing TeX or LaTeX documents with Emacs, you should have
a look at AUCTeX, the definitive package to work with TeX and LaTeX.
Information on AUCTeX can be found here:@refill

@example
http://www.sunsite.auc.dk/auctex/
@end example

Instead of using the @b{RefTeX} functions described above directly, you
can also use them indirectly, through AUCTeX (version 9.8a or later).
@b{RefTeX} provides several interface functions which can be used as
replacement for corresponding AUCTeX functions dealing with labels and
citations.  In this way you can work normally with AUCTeX and use
@b{RefTeX} internals to create and complete labels and citation
keys.@refill

@itemize @bullet
@item
@findex reftex-label
@vindex LaTeX-label-function
@code{reftex-label} can be used as the @var{LaTeX-label-function} which
does label insertion when new environments are created with @kbd{C-c
C-e}.@refill

@item
@findex reftex-arg-label
@findex TeX-arg-label, AUCTeX function
@findex reftex-arg-ref
@findex TeX-arg-ref, AUCTeX function
@findex reftex-arg-cite
@findex TeX-arg-cite, AUCTeX function
@code{reftex-arg-label}, @code{reftex-arg-ref} and
@code{reftex-arg-cite} can replace the corresponding @code{TeX-arg-...}
functions.  E.g. when you insert a label macro with @kbd{C-c @key{RET}
label @key{RET}}, @b{RefTeX} will be transparently used to create the
label.@refill
@end itemize

@noindent
In order to plug all 4 functions into AUCTeX, use:

@vindex reftex-plug-into-AUCTeX
@lisp
(setq reftex-plug-into-AUCTeX t)
@end lisp

@noindent
You may also choose to plug in only some of these functions.  Try
@kbd{M-x customize-variable @key{RET} reftex-plug-into-AUCTeX @key{RET}}
to find out more about this.@refill

@findex reftex-add-to-label-alist
@cindex Style files, AUCTeX
AUCTeX can support @b{RefTeX} via style files.  A style file may contain
calls to @code{reftex-add-to-label-alist} which defines additions to
@var{reftex-label-alist}.  The argument taken by this function must have
the same format as @var{reftex-label-alist}.  The @file{amsmath.el}
style file of AUCTeX (>9.7p) for example contains the following:

@lisp
(TeX-add-style-hook "amsmath"
   (function
     (lambda ()
       (if (featurep 'reftex)
           (reftex-add-to-label-alist '(AMSTeX))))))
@end lisp

@noindent
while a package @code{myprop} defining a proposition environment with
@code{\newtheorem} might use

@lisp
(TeX-add-style-hook "myprop"
  (function
   (lambda ()
     (if (featurep 'reftex)
         (reftex-add-to-label-alist
          '(("proposition" ?p "prop:"  "~\\ref@{%s@}" t
                           ("Proposition" "Prop."))))))))
@end lisp

Similarly, the style file @file{harvard.el} for the Harvard citation
style could switch @b{RefTeX}'s citation format to @code{harvard} like
this:

@lisp
(TeX-add-style-hook "myprop"
  (function
   (lambda ()
     (if (featurep 'reftex)
         (setq reftex-cite-format 'harvard)))))
@end lisp

@node Bib-Cite, , AUCTeX, Social Matters
@subsection Bib-Cite
@cindex @code{bib-cite}, Emacs package
@cindex Emacs packages, @code{bib-cite}

Once you have written a document with labels, references and citations,
it can be nice to read it like a hypertext document.  @b{RefTeX} has
some support for that (@code{reftex-view-crossref},
@code{reftex-search-document}).  A more elegant interface with mouse
support is provided (among other things) by Peter S. Galbraith's
@file{bib-cite.el}.  There is some overlap in the functionalities of
Bib-cite and @b{RefTeX}.  Bib-cite.el comes bundled with AUCTeX.  You
can also get the latest version from@refill

@example
ftp://ftp.phys.ocean.dal.ca/users/rhogee/elisp/bib-cite.el
@end example

Bib-cite versions 3.06 and later can be configured so that bib-cite's
mouse functions use @b{RefTeX} for displaying references and citations.
This can be useful in particular when working with the LaTeX @code{xr}
package or with an explicit @code{thebibliography} environment (rather
than BibTeX).  Bib-cite cannot handle those, but @b{RefTeX} does.  To
make use of this feature, try@refill

@vindex bib-cite-use-reftex-view-crossref
@lisp
(setq bib-cite-use-reftex-view-crossref t)
@end lisp

@node Multifile Documents, Optimizations, Social Matters, Top
@section Multifile Documents
@cindex Multifile documents
@cindex Documents, spread over files

@b{RefTeX} will work smoothly with documents spread over many files
(so-called multifile documents).  The following is relevant when using
@b{RefTeX} for multi-file documents:@refill

@itemize @bullet
@item
@b{RefTeX} has full support for multifile documents.  You can edit parts of
several (multifile) documents at the same time without conflicts.
@b{RefTeX} provides functions to run @code{grep}, @code{search} and
@code{query-replace} on all files which are part of a multifile
document.@refill

@item
@vindex tex-main-file
@vindex TeX-master
All files belonging to a multifile document should have a File Variable
(@var{TeX-master} for AUCTeX or @var{tex-main-file} for the standard
Emacs LaTeX mode) set to the name of the master file.  See the
documentation of your (La)TeX mode and @ref{File Variables,,,emacs, The GNU
Emacs Manual}.@refill

@item
The context of a label definition must be found in the same file as the
label itself in order to be processed correctly by @b{RefTeX}.  The only
exception is that section labels referring to a section statement
outside the current file can still use that section title as
context.@refill
@end itemize

@node Optimizations, Problems and Work-Arounds, Multifile Documents, Top
@section Optimizations
@cindex Optimizations

The default settings of @b{RefTeX} ensure a safe ride for beginners and
casual users.  However, when using @b{RefTeX} for a large project and/or on
a small computer, there are ways to improve speed or memory usage.@refill

@itemize @bullet
@item
@b{Removing Lookup Buffers}@*
@cindex Removing lookup buffers
@b{RefTeX} will load other parts of a multifile document as well as BibTeX
database files for lookup purposes.  These buffers are kept, so that
subsequent use of the same files is fast.  If you can't afford keeping
these buffers around, and if you can live with a speed penalty, try

@vindex reftex-keep-temporary-buffers
@lisp
(setq reftex-keep-temporary-buffers nil)
@end lisp

@item
@b{Files Visited with Follow Mode}@*
Follow--mode in the selection and @code{*toc*} buffers shows the context
of the current line in another window.  If the context is in an
unvisited file, @b{RefTeX} normally visits the file.  The setting

@vindex reftex-revisit-to-follow
@lisp
(setq reftex-revisit-to-follow nil)
@end lisp

disables follow mode for such cases, so that only context in live
buffers is displayed.  However, pressing @key{SPC} will always visit the
file to show the context.

@item
@b{Partial Document Scans}@*
@cindex Partial documents scans
@cindex Document scanning, partial
A @kbd{C-u} prefix on the major @b{RefTeX} commands @code{reftex-label}
(@kbd{C-u C-c (}), @code{reftex-reference} (@kbd{C-u C-c )}),
@code{reftex-citation} (@kbd{C-u C-c [}), @code{reftex-toc} (@kbd{C-u C-c
=}), and @code{reftex-view-crossref} (@kbd{C-u C-c &}) initiates
re-parsing of the entire document in order to update the parsing
information.  For a large document this can be unnecessary, in
particular if only one file has changed.  @b{RefTeX} can be configured
to do partial scans instead of full ones.  @kbd{C-u} re-parsing then
does apply only to the current buffer and files included from it.
Likewise, the @kbd{r} key in both the label selection buffer and the
table-of-contents buffer will only prompt scanning of the file in which
the label or section macro near the cursor was defined.  Re-parsing of
the entire document is still available by using @kbd{C-u C-u} as a
prefix, or the capital @kbd{R} key in the menus.  To use this feature,
try@refill

@vindex reftex-enable-partial-scans
@lisp
(setq reftex-enable-partial-scans t)
@end lisp

@item
@b{Saving Parser Information}@*
@cindex Saving parser information
@cindex Parse information, saving to a file
Even with partial scans enabled, @b{RefTeX} still has to make one full
scan, when you start working with a document.  To avoid this, parsing
information can be stored in a file.  The file @file{MASTER.rel} is used
for storing information about a document with master file
@file{MASTER.tex}.  It is written each time @b{RefTeX} parses (part of)
the document, and restored when you begin working with a document in a
new editing session.  To use this feature, put into
@file{.emacs}:@refill

@vindex reftex-save-parse-info
@lisp
(setq reftex-save-parse-info t)
@end lisp

@item
@b{Automatic Document Scans}@*
@cindex Automatic document scans
@cindex Document scanning, automatic
At rare occasions, @b{RefTeX} will automatically rescan a part of the
document.  If this gets into your way, it can be turned off with

@vindex reftex-allow-automatic-rescan
@lisp
(setq reftex-allow-automatic-rescan nil)
@end lisp

@b{RefTeX} will then occasionally annotate new labels in the selection
buffer, saying that their position in the label list in uncertain.  I
manual document scan will fix this.

@item
@b{Multiple Selection Buffers}@*
@cindex Multiple selection buffers
@cindex Selection buffers, multiple
Normally, the selection buffer @code{*RefTeX Select*} is re-created
newly for every selection process.  In documents with very many labels
this can take several seconds - in particular with context
refontification turned on.  @b{RefTeX} provides an option to create a
separate selection buffer for each label type and to keep this buffer
from one selection to the next.  These buffers are updated automatically
only when a new label has been added in the buffers category with
@code{reftex-label}.  Updating the buffer takes as long as recreating it
- so the time saving is limited to cases where no new labels of that
category have been added.  To turn on this feature, use@refill

@vindex reftex-use-multiple-selection-buffers
@lisp
(setq reftex-use-multiple-selection-buffers t)
@end lisp

@noindent
@cindex Selection buffers, updating
You can also inhibit the automatic updating entirely.  Then the
selection buffer will always pop up very fast, but may not contain the
most recently defined labels.  You can always update the buffer hand,
with the @kbd{g} key.  To get this behavior, use instead@refill

@vindex reftex-auto-update-selection-buffers
@lisp
(setq reftex-use-multiple-selection-buffers t
      reftex-auto-update-selection-buffers nil)
@end lisp
@end itemize

@noindent
@b{As a summary}, here are the settings I recommend for heavy use of
@b{RefTeX} with large documents:

@lisp
(setq reftex-enable-partial-scans t
      reftex-save-parse-info t
      reftex-use-multiple-selection-buffers t
      reftex-revisit-to-follow nil)
@end lisp


@node Problems and Work-Arounds, Imprint, Optimizations, Top
@section Problems and Work-arounds
@cindex Problems and work-arounds

@itemize @bullet
@item
@code{\input}, @code{\include}, @code{\bibliography} and @code{\section}
(etc.) statements have to be first on a line (except for white space).@refill

@item
@cindex Labels, commented out
@b{RefTeX} sees also labels in regions commented out and will refuse to
make duplicates of such a label.  This is considered to be a feature.@refill

@item
When using partial scans (@var{reftex-enable-partial-scans}), the section
numbers in the table of contents may eventually become wrong.  A full
scan will fix this.@refill

@item
@b{RefTeX} keeps only a global copy of the configuration variables.
Also, any additions from style files go into a global variable.
Practically, this should not be a problem.  Theoretically, it could
give conflicts if two documents used environments with identical
names, but different associated label types.@refill

@item 
When using AUCTeX and AMS-LaTeX, the @file{amsmath.el} style file will
automatically cause @b{RefTeX} to use the macro @code{\eqref} for
equation references.  This will take effect for @emph{all} current
documents, not only for the one actually using AMS-LaTeX.  The best
work--around is to use AMS-LaTeX in @emph{all} documents.  The other
possibility is to enforce the use of the @code{\ref} macro for all
documents with

@lisp
(setq reftex-label-alist '((nil ?e nil "~(\\ref@{%s@})" nil nil)))
@end lisp

@item
@cindex @code{x-symbol}, Emacs package
@cindex Emacs packages, @code{x-symbol}
@cindex @code{isotex}, Emacs package
@cindex Emacs packages, @code{isotex}
@cindex @code{iso-cvt}, Emacs package
@cindex Emacs packages, @code{iso-cvt}
When using packages which make the buffer representation of a file
different from its disk representation (e.g. x-symbol, isotex,
iso-cvt) you may find that @b{RefTeX}'s parsing information sometimes
reflects the disk state of a file.  This happens only in @emph{unvisited}
parts of a multifile document, because @b{RefTeX} visits these files
literally for speed reasons.  Then both short context and section
headings may look different from what you usually see on your screen.
In rare cases @code{reftex-toc} may have problems to jump to an affected
section heading.  There are three possible ways to deal with
this:@refill 
@itemize @minus
@item
@vindex reftex-keep-temporary-buffers
@code{(setq reftex-keep-temporary-buffers t)}@*
This implies that @b{RefTeX} will load all parts of a multifile
document into Emacs (i.e. there will be no temporary buffers).@refill
@item
@vindex reftex-initialize-temporary-buffers
@code{(setq reftex-initialize-temporary-buffers t)}@*
This means full initialization of temporary buffers.  It involves
a penalty when the same unvisited file is used for lookup often.@refill
@item
Set @code{reftex-initialize-temporary-buffers} to a list of hook
functions doing a minimal initialization.@refill
@end itemize
@vindex reftex-refontify-context
See also the variable @var{reftex-refontify-context}.

@item
@cindex @code{pf}, LaTeX package
@cindex LaTeX packages, @code{pf}
Some packages use an additional argument to a @code{\begin} macro
to specify a label.  E.g. Lamport's @file{pf.sty} uses both

@example
\step@{LABEL@}@{CLAIM@}   and      \begin@{step+@}@{LABEL@}
                                  CLAIM
                               \end@{step+@}
@end example

@noindent
We need to trick @b{RefTeX} into swallowing this:

@lisp
;; Configuration for Lamport's pf.sty
(setq reftex-label-alist
    '(("\\step@{*@}@{@}"       ?p "st:" "~\\stepref@{%s@}" 2 ("Step" "St."))
      ("\\begin@{step+@}@{*@}" ?p "st:" "~\\stepref@{%s@}" 1000)))
@end lisp

@noindent
The first line is just a normal configuration for a macro.  For the
@code{step+} environment we actually tell @b{RefTeX} to look for the
@emph{macro} @samp{\begin@{step+@}} and interpret the @emph{first}
argument (which really is a second argument to the macro @code{\begin})
as a label of type @code{?p}.  Argument count for this macro starts only
after the @samp{@{step+@}}, also when specifying how to get
context.@refill 

@item
@cindex Overlays, problems with XEmacs 19.15
In XEmacs 19.15, the overlay library has a bug.  @b{RefTeX} does not
suffer from it, but since it loads the library, other packages like
GNUS will switch from extents to overlays and hit the bug.  Upgrade
to XEmacs 20, or fix the overlay library (in line 180 of overlay.el,
change @code{(list before after)} to @code{(cons before after)}).@refill

@item
@cindex Viper mode
@cindex Keybindings, problems with Viper mode
@findex viper-harness-minor-mode
If you use @i{Viper} mode, you need to protect @b{RefTeX}'s keymaps
with@refill

@lisp
(viper-harness-minor-mode "reftex")
@end lisp

@end itemize

@page

@node Imprint, Commands, Problems and Work-Arounds, Top
@section Imprint
@cindex Imprint
@cindex Maintainer
@cindex Acknowledgments
@cindex Thanks
@cindex Bug reports
@cindex @code{http}, @b{RefTeX} home page
@cindex @code{ftp}, @b{RefTeX} site

@b{RefTeX} was written by @i{Carsten Dominik}
@t{<dominik@@strw.LeidenUniv.nl>}, with contributions by @i{Stephen
Eglen}.  @b{RefTeX} is currently maintained by @refill

@example
Carsten Dominik <dominik@@strw.LeidenUniv.nl>
@end example

If you find a bug in @b{RefTeX} or its documentation, or if you want to
contribute code or ideas, please contact the maintainer.  Remember to
provide all necessary information such as version numbers of Emacs and
@b{RefTeX}, and the relevant part of your configuration in @file{.emacs}.
When reporting a bug, please include a backtrace if you know how to
produce one.

@b{RefTeX} is distributed with Emacs (version 20.2 and later) and XEmacs
(version 19.16 and 20.2 and later).  The newest version of @b{RefTeX}
is available at@refill

@example
http://www.strw.leidenuniv.nl/~dominik/Tools/
ftp://strw.leidenuniv.nl/pub/dominik/
@end example

@noindent
The version at this site is actually compatible with Emacs 19 - the
versions of @b{RefTeX} distributed with Emacs 20 are not.@refill

Thanks to the people on the Net who have used @b{RefTeX} and helped
developing it with their reports.  In particular thanks to
@i{F. Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, Karl
Eichwalder, Peter Galbraith, Dieter Kraft, Adrian Lanz, Rory Molinari,
Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, Robin Socha, Richard
Stanton, Allan Strand, Jan Vroonhof, Christoph Wedler}.@refill

The view crossref feature was inspired by the similar function in
@i{Peter Galbraith's} @file{bib-cite.el}.@refill

Finally thanks to @i{Uwe Bolick} who first got me (some years ago) into
supporting LaTeX labels and references with an Editor (which was
MicroEmacs at the time).@refill

@node Commands, Options, Imprint, Top
@chapter Commands
@cindex Commands, list of

Here is a summary of @b{RefTeX}'s commands.  All commands are available
from the @code{Ref} menu.  For keybindings, @pxref{Keybindings}.

@deffn Command reftex-label
Insert a unique label.  With one or two @kbd{C-u} prefixes, enforce
document rescan first.
@end deffn

@deffn Command reftex-reference
Start a selection process to select a label, and insert a reference to
it.  With one or two @kbd{C-u} prefixes, enforce document rescan first.
@end deffn

@deffn Command reftex-citation
Make a citation using BibTeX database files.  After asking for a Regular
Expression, it scans the buffers with BibTeX entries (taken from the
@code{\bibliography} command or a @code{thebibliography} environment)
and offers the matching entries for selection.  The selected entry is
formated according to @var{reftex-cite-format} and inserted into the
buffer.@refill @*
When called with one or two @kbd{C-u} prefixes, first rescans the document.
When called with a numeric prefix, make that many citations.  When
called with point inside the braces of a @code{\cite} command, it will
add another key, ignoring the value of @var{reftex-cite-format}.@refill @*
The regular expression uses an expanded syntax: @samp{&&} is interpreted as
@code{and}.  Thus, @samp{aaaa&&bbb} matches entries which contain both
@samp{aaaa} and @samp{bbb}.@refill
@end deffn

@deffn Command reftex-view-crossref
View cross reference of @code{\ref} or @code{\cite} macro at point.  If
the macro at point is a @code{\ref}, show the corresponding label
definition.  If it is a @code{\cite}, show the BibTeX database entry or the
@code{\bibitem}.  If there is no such macro at point, search forward to find
one.  When you call this function several times in direct succession,
point will move to view subsequent cross references further down in the
buffer.  To cope with the plethora of variations in packages, this
function assumes any macro either starting with or ending in @samp{ref} or
@samp{cite} to contain cross references.  When the LaTeX package @code{xr} is
being used, this command will also view cross-references in external
documents.  However, this works correctly only when the
@code{\externaldocument} macros are used with the optional label prefix
argument.@*@refill
With one or two @kbd{C-u} prefixes, enforce rescanning of the
document.  With argument t or 1, select the window showing the cross
reference.@refill
@end deffn

@deffn Command reftex-toc
Show the table of contents for the current document.  When called with
one ore two @kbd{C-u} prefixes, rescan the document first.@refill
@end deffn


@deffn Command reftex-create-tags-file
Create TAGS file by running @code{etags} on the current document.  The
TAGS file is also immediately visited with
@code{visit-tags-table}.@refill
@end deffn

@deffn Command reftex-grep-document
Run grep query through all files related to this document.
With prefix arg, force to rescan document.
This works also without an active TAGS table.@refill
@end deffn

@deffn Command reftex-search-document
Regexp search through all files of the current TeX document.
Starts always in the master file.  Stops when a match is found.
This works also without an active TAGS table.@refill
@end deffn

@deffn Command reftex-query-replace-document
Run a query-replace-regexp of FROM with TO over the entire TeX document.
With prefix arg, replace only word-delimited matches.
This works also without an active TAGS table.@refill
@end deffn

@deffn Command reftex-change-label
Query replace FROM with TO in all @code{\label} and @code{\ref} commands.
Works on the entire multifile document.
This works also without an active TAGS table.@refill
@end deffn

@deffn Command reftex-find-duplicate-labels
Produce a list of all duplicate labels in the document.@refill
@end deffn

@deffn Command reftex-customize
Run the customize browser on the @b{RefTeX} group.
@end deffn
@deffn Command reftex-show-commentary
Show the commentary section from @file{reftex.el}.
@end deffn
@deffn Command reftex-info
Run info on the top @b{RefTeX} node.
@end deffn
@deffn Command reftex-parse-document
Parse the entire document in order to update the parsing information.
@end deffn
@deffn Command reftex-reset-mode
Enforce rebuilding of several internal lists and variables.
@end deffn

@node Options, Keymaps, Commands, Top
@chapter Options, Keymaps, Hooks
@cindex Options, list of

Here is a complete list of @b{RefTeX}'s configuration variables.  All
variables have customize support - so if you are not familiar with Emacs
Lisp (and even if you are) you might find it more comfortable to use
@code{customize} to look at and change these variables. @kbd{M-x
reftex-customize} will get you there.@refill

@menu
* Options (Defining Label Environments)::
* Options (Creating Labels)::
* Options (Referencing Labels)::
* Options (Creating Citations)::
* Options (Table of Contents)::
* Options (Optimizations)::
* Options (Misc)::
@end menu

@node Options (Defining Label Environments), Options (Creating Labels), , Options
@section Defining Label Environments
@cindex Options, defining label environments

@defopt reftex-default-label-alist-entries
Default label alist specifications.  It is a list of symbols with
associations in the constant @var{reftex-label-alist-builtin}.
@code{LaTeX} should always be the last entry.@refill
@end defopt

@defopt reftex-label-alist
Set this variable to define additions and changes to the default.  The
only things you @emph{must not} change is that @code{?s} is the type
indicator for section labels, and @key{SPC} for the @code{any} label
type.  These are hard-coded at other places in the code.@refill

The value of the variable must be a list of items.  Each item is a list
itself and has the following structure:

@example
 (ENV-OR-MACRO  TYPE-KEY  LABEL-PREFIX  REFERENCE-FORMAT
    CONTEXT-METHOD  (MAGIC-WORD ... ))
@end example

Each list entry describes either an environment carrying a counter for
use with @code{\label} and @code{\ref}, or a LaTeX macro defining a
label as (or inside) one of its arguments.  The elements of each list
entry are:@refill

@table @asis
@item ENV-OR-MACRO
Name of the environment (like @samp{table}) or macro (like
@samp{\myfig}).  For macros, indicate the arguments, as in
@samp{\myfig[]@{@}@{@}@{*@}@{@}}.  Use square brackets for optional
arguments, a star to mark the label argument, if any.  The macro does
not have to have a label argument - you could also use
@samp{\label@{...@}} inside one of its arguments.@refill

Special names: @code{section} for section labels, @code{any} to define a
group which contains all labels.@refill

This may also be @code{nil} if the entry is only meant to change some
settings associated with the type indicator character (see
below).@refill

@item TYPE-KEY
Type indicator character, like @code{?t}, must be a printable ASCII
character.  The type indicator is a single character which defines a
label type.  Any label inside the environment or macro is assumed to
belong to this type.  The same character may occur several times in this
list, to cover cases in which different environments carry the same
label type (like @code{equation} and @code{eqnarray}).@refill

@item LABEL-PREFIX
Label prefix string, like @samp{tab:}.  The prefix is a short string
used as the start of a label.  It may be the empty string.  The prefix
may contain the following @samp{%} escapes:@refill

@example
%f Current file name, directory and extension stripped.
%F Current file name relative to master file directory.
%u User login name, on systems which support this.
@end example

@noindent
Example: In a file @file{intro.tex}, @samp{eq:%f:} will become
@samp{eq:intro:}.@refill

@item REFERENCE-FORMAT
Format string for reference insert in buffer.  @samp{%s} will be
replaced by the label.  When the format starts with @samp{~}, this
@samp{~} will only be inserted when the character before point is
@emph{not} a whitespace.@refill

@item CONTEXT-METHOD
Indication on how to find the short context.
@itemize @minus
@item
If @code{nil}, use the text following the @samp{\label@{...@}} macro.@refill
@item
If @code{t}, use
@itemize @minus
@item
the section heading for section labels.
@item
text following the @samp{\begin@{...@}} statement of environments (not
a good choice for environments like eqnarray or enumerate, where one has
several labels in a single environment).@refill
@item
text after the macro name (starting with the first arg) for
macros.@refill
@end itemize
@item
If an integer, use the nth argument of the macro.  As a special case,
1000 means to get text after the last macro argument.@refill
@item
If a string, use as regexp to search @emph{backward} from the label.
Context is then the text following the end of the match.  E.g. putting
this to @samp{\\caption[@{]]} will use the caption in a figure or table
environment.  @samp{\\begin@{eqnarray@}\\|\\\\} works for
eqnarrays.@refill
@item
If any of @code{caption}, @code{item}, @code{eqnarray-like},
@code{alignat-like}, this symbol will internally be translated into an
appropriate regexp (see also the variable
@var{reftex-default-context-regexps}).@refill
@item
If a function, call this function with the name of the environment/macro
as argument.  On call, point will be just after the @code{\label} macro.
The function is expected to return a suitable context string.  It should
throw an exception (error) when failing to find context.  As an example,
here is a function returning the 10 chars following the label macro as
context:@refill

@example
(defun my-context-function (env-or-mac)
   (if (> (point-max) (+ 10 (point)))
       (buffer-substring (point) (+ 10 (point)))
     (error "Buffer too small")))
@end example
@end itemize

Label context is used in two ways by @b{RefTeX}: For display in the label
menu, and to derive a label string.  If you want to use a different
method for each of these, specify them as a dotted pair.
E.g. @code{(nil . t)} uses the text after the label (@code{nil}) for
display, and text from the default position (@code{t}) to derive a label
string.  This is actually used for section labels.@refill

Setting the variable @var{reftex-use-text-after-label-as-context} to
@code{t} overrides the setting here.@refill

@item MAGIC-WORD-LIST
List of magic words which identify a reference to be of this type.  If
the word before point is equal to one of these words when calling
@code{reftex-reference}, the label list offered will be automatically
restricted to labels of the correct type.  If the first element of this
word--list is the symbol `regexp', the strings are interpreted as regular
expressions@footnote{Careful:  @b{RefTeX} will add stuff to the
beginning and end of these regular expressions.}.@refill
@end table

If the type indicator characters of two or more entries are the same,
@b{RefTeX} will use@refill
@itemize @minus
@item
the first non-@code{nil} format and prefix
@item
the magic words of all involved entries.
@end itemize

Any list entry may also be a symbol.  If that has an association in
@var{reftex-label-alist-builtin}, the @code{cddr} of that association is
spliced into the list.  However, builtin defaults should normally be set
with the variable @var{reftex-default-label-alist-entries}.@refill
@end defopt

@defopt reftex-section-levels
Commands and levels used for defining sections in the document.  The car
of each cons cell is the name of the section macro.  The cdr is a number
indicating its level.@refill
@end defopt

@defopt reftex-default-context-regexps
Alist with default regular expressions for finding context.  The emacs
lisp form @w{@code{(format regexp (regexp-quote environment))}} is used
to calculate the final regular expression - so @samp{%s} will be
replaced with the environment or macro.@refill
@end defopt
  
@defopt reftex-use-text-after-label-as-context
Non-@code{nil} means, grab context from directly after the
@samp{\label@{...@}} macro.  This is the fastest method for obtaining
context of the label definition, but requires discipline when placing
labels.  Setting this variable to @code{t} takes precedence over the
individual settings in @var{reftex-label-alist}.  This variable may be
set to @code{t}, @code{nil}, or a string of label type letters
indicating the label types for which it should be true.@refill
@end defopt

@node Options (Creating Labels), Options (Referencing Labels), Options (Defining Label Environments), Options
@section Creating Labels
@cindex Options, creating labels

@defopt reftex-insert-label-flags
Flags governing label insertion.  The value has the form

@example
(DERIVE PROMPT)
@end example

If DERIVE is @code{t}, @b{RefTeX} will try to derive a sensible label
from context.  A section label for example will be derived from the
section heading.  The conversion of the context to a legal label is
governed by the specifications given in
@var{reftex-derive-label-parameters}.  If DERIVE is @code{nil}, the
default label will consist of the prefix and a unique number, like
@samp{eq:23}.@refill

If PROMPT is @code{t}, the user will be prompted for a label string.
When PROMPT is @code{nil}, the default label will be inserted without
query.@refill

So the combination of DERIVE and PROMPT controls label insertion.  Here
is a table describing all four possibilities:@refill

@example
@group
DERIVE PROMPT ACTION
-----------------------------------------------------------
nil    nil    @r{Insert simple label, like @samp{eq:22} or @samp{sec:13}. No query.}
nil    t      @r{Prompt for label.}
t      nil    @r{Derive a label from context and insert. No query.}
t      t      @r{Derive a label from context, prompt for confirmation.}
@end group
@end example

Each flag may be set to @code{t}, @code{nil}, or a string of label type
letters indicating the label types for which it should be true.  Thus,
the combination may be set differently for each label type.  The default
settings @samp{"s"} and @samp{"sft"} mean: Derive section labels from
headings (with confirmation).  Prompt for figure and table labels.  Use
simple labels without confirmation for everything else.@refill

The available label types are: @code{s} (section), @code{f} (figure),
@code{t} (table), @code{i} (item), @code{e} (equation), @code{n}
(footnote), plus any definitions in @var{reftex-label-alist}.@refill
@end defopt

@deffn Hook reftex-format-label-function
If non-@code{nil}, should be a function which produces the string to
insert as a label definition.  The function will be called with two
arguments, the LABEL and the DEFAULT FORMAT (usually
@samp{\label@{%s@}}).  It should return the string to insert into the
buffer.@refill
@end deffn

@defopt reftex-derive-label-parameters
Parameters for converting a string into a label.  This variable is a
list of the following items:@refill
@table @asis
@item NWORDS
Number of words to use.
@item MAXCHAR
Maximum number of characters in a label string.
@item ILLEGAL
@code{nil}: Throw away any words containing characters illegal in labels.@*
@code{t}:   Throw away only the illegal characters, not the whole word.
@item ABBREV
@code{nil}: Never abbreviate words.@*
@code{t}:   Always abbreviate words (see @var{reftex-abbrev-parameters}).@*
@code{1}:   Abbreviate words if necessary to shorten label string.
@item SEPARATOR
String separating different words in the label.
@item IGNOREWORDS
List of words which should not be part of labels.
@end table
@end defopt

@defopt reftex-label-illegal-re
Regexp matching characters not legal in labels.  For historic reasons,
this character class comes @emph{with} the @code{[]} brackets.@refill
@end defopt

@defopt reftex-abbrev-parameters
Parameters for abbreviation of words.  A list of four parameters.@refill
@table @asis
@item MIN-CHARS
Minimum number of characters remaining after abbreviation.
@item MIN-KILL
Minimum number of characters to remove when abbreviating words.@refill
@item BEFORE
Character class before abbrev point in word.@refill
@item AFTER
Character class after  abbrev point in word.@refill
@end table
@end defopt

@node Options (Referencing Labels), Options (Creating Citations), Options (Creating Labels), Options
@section Referencing Labels
@cindex Options, referencing labels

@defopt reftex-label-menu-flags
List of flags governing the label menu makeup. The flags are:
@table @asis
@item TABLE-OF-CONTENTS
Show the labels embedded in a table of context.@refill
@item SECTION-NUMBERS
Include section numbers (like 4.1.3) in table of contents.@refill
@item COUNTERS
Show counters.  These are just numbers the labels in the menu.@refill
@item NO-CONTEXT
Non-@code{nil} means do NOT show the short context.@refill
@item FOLLOW
Follow full context in other window.@refill
@item SHOW-COMMENTED
Show labels from regions which are commented out.@refill
@item MATCH-EVERYWHERE
Searches in label menu will also match in toc lines etc.@refill
@item SHOW FILES
Show Begin and end of included files.@refill
@end table

Each of these flags can be set to @code{t} or @code{nil}, or to a string
of type letters indicating the label types for which it should be true.
These strings work like character classes in regular expressions.  Thus,
setting one of the flags to @samp{"sf"} makes the flag true for section
and figure labels, @code{nil} for everything else.  Setting it to
@samp{"^ft"} makes it the other way round.@refill

The available label types are: @code{s} (section), @code{f} (figure),
@code{t} (table), @code{i} (item), @code{e} (equation), @code{n}
(footnote), plus any definitions in @var{reftex-label-alist}.@refill

Most options can also be switched from the label menu itself - so if you
decide here to not have a table of contents in the label menu, you can
still get one interactively during selection from the label menu.@refill
@end defopt

@deffn Hook reftex-format-ref-function
If non-@code{nil}, should be a function which produces the string to
insert as a reference.  Note that the insertion format can also be
changed with @var{reftex-label-alist}.  The function will be called with
two arguments, the LABEL and the DEFAULT FORMAT (usually
@samp{~\ref@{%s@}}).  It should return the string to insert into the
buffer.@refill
@end deffn

@defopt reftex-vref-is-default
Non-@code{nil} means, the varioref macro @code{\vref} is used as
default.  In the selection buffer, the @kbd{v} key toggles the reference
macro between @code{\ref} and @code{\vref}.  The value of this variable
determines the default which is active when entering the selection
process.  Instead of @code{nil} or @code{t}, this may also be a string
of type letters indicating the label types for which it should be
true.@refill
@end defopt

@defopt reftex-level-indent
Number of spaces to be used for indentation per section level.@refill
@end defopt

@defopt reftex-refontify-context
Non-@code{nil} means, re-fontify the context in the label menu with
font-lock.  This slightly slows down the creation of the label menu.  It
is only necessary when you definitely want the context fontified.@refill

This option may have 3 different values:
@table @code
@item nil
Never refontify.
@item t
Always refontify.
@item 1
Refontify when necessary, e.g. with the x-symbol package.@refill
@end table
The option is ignored when @var{reftex-use-fonts} is @code{nil}.@refill
@end defopt

@defopt reftex-guess-label-type
Non-@code{nil} means, @code{reftex-reference} will try to guess the
label type.  To do that, @b{RefTeX} will look at the word before the
cursor and compare it with the magic words given in
@var{reftex-label-alist}.  When it finds a match, @b{RefTeX} will
immediately offer the correct label menu - otherwise it will prompt you
for a label type.  If you set this variable to @code{nil}, @b{RefTeX}
will always prompt.@refill
@end defopt

@node Options (Creating Citations), Options (Table of Contents), Options (Referencing Labels), Options
@section Creating Citations
@cindex Options, creating citations

@defopt reftex-bibpath-environment-variables
List of environment variables which might contain the path to BibTeX
database files.@refill
@end defopt

@defopt reftex-bibfile-ignore-list
List of files in @code{\bibliography@{...@}} @b{RefTeX} should not parse.
The file names have to be in the exact same form as in the bibliography
macro - i.e. without the @file{.bib} extension.  Intended for files
which contain only @code{@@string} macro definitions and the like, which
are ignored by @b{RefTeX} anyway.@refill
@end defopt

@defopt reftex-default-bibliography
List of BibTeX database file which should be used if none are specified.
When @code{reftex-citation} is called from a document which has neither
a @samp{\bibliography@{...@}} statement nor a @code{thebibliography}
environment, @b{RefTeX} will scan these files instead.  Intended for
using @code{reftex-citation} in non-LaTeX files.
@end defopt

@defopt reftex-sort-bibtex-matches
Sorting of the entries found in BibTeX databases by reftex-citation.
Possible values:@refill
@example
nil          @r{Do not sort entries.}
author       @r{Sort entries by author name.}
year         @r{Sort entries by increasing year.}
reverse-year @r{Sort entries by decreasing year.}
@end example
@end defopt

@defopt reftex-cite-format
The format of citations to be inserted into the buffer.  It can be a
string or an alist.  In the simplest case this is just the string
@samp{\cite@{%l@}}, which is also the default.  See the definition of
@var{reftex-cite-format-builtin} for more complex examples.@refill

If @var{reftex-cite-format} is a string, it will be used as the format.
In the format, the following percent escapes will be expanded.@refill

@table @code
@item %l
The BibTeX label of the citation.
@item %a
List of author names, see also @var{reftex-cite-punctuation}.
@item %2a
Like %a, but abbreviate more than 2 authors like Jones et al.
@item %A
First author name only.
@item %e
Works like @samp{%a}, but on list of editor names. (@samp{%2e} and
@samp{%E} work a well).@refill
@end table

It is also possible to access all other BibTeX database fields:

@example
%b booktitle     %c chapter        %d edition    %h howpublished
%i institution   %j journal        %k key        %m month
%n number        %o organization   %p pages      %P first page
%r address       %s school         %u publisher  %t title
%v volume        %y year
@end example

@noindent
Usually, only @samp{%l} is needed.  Try, however, @code{(setq
reftex-comment-citations t)}.@refill

Beware that all this only works when using BibTeX database files.  When
citations are made from the @code{\bibitems} in an explicit
@code{thebibliography} environment, only @samp{%l} is available.@refill

If @var{reftex-cite-format} is an alist of characters and strings, the
user will be prompted for a character to select one of the possible
format strings.@refill

In order to configure this variable, you can either set
@var{reftex-cite-format} directly yourself or set it to the
@emph{symbol} of one of the predefined styles (see
@var{reftex-cite-format-builtin}).  E.g.: @code{(setq reftex-cite-format
'harvard)}.@refill
@end defopt

@deffn Hook reftex-format-cite-function
If non-@code{nil}, should be a function which produces the string to
insert as a citation.  Note that the citation format can also be changed
with the variable @var{reftex-cite-format}.  The function will be called
with two arguments, the CITATION KEY and the DEFAULT FORMAT (taken from
@var{reftex-cite-format}).  It should return the string to insert into
the buffer.
@end deffn

@defopt reftex-comment-citations
Non-@code{nil} means add a comment for each citation describing the full
entry.  The comment is formatted according to
@var{reftex-cite-comment-format}.@refill
@end defopt

@defopt reftex-cite-comment-format
Citation format used for commented citations.  Must @emph{not} contain
@samp{%l}.@refill
@end defopt

@defopt reftex-cite-punctuation
Punctuation for formatting of name lists in citations.  This is a list
of 3 strings.@refill
@enumerate
@item
normal names separator, like @samp{, } in Jones, Brown and Miller
@item
final names separator, like @samp{ and }  in Jones, Brown and Miller
@item
The @samp{et al.} string, like @samp{ @{\it et al.@}} in 
Jones @{\it et al.@}
@end enumerate
@end defopt

@node Options (Table of Contents), Options (Optimizations), Options (Creating Citations),  Options
@section Table of Contents
@cindex Options, table of contents

@defopt reftex-toc-follow-mode
Non-@code{nil} means, point in @code{*toc*} buffer (the
table-of-contents buffer) will cause other window to follow.  The other
window will show the corresponding part of the document.  This flag can
be toggled from within the @code{*toc*} buffer with the @kbd{f}
key.@refill
@end defopt

@node Options (Optimizations), Options (Misc), Options (Table of Contents), Options
@section Optimizations
@cindex Options, optimizations

@defopt reftex-keep-temporary-buffers
Non-@code{nil} means, keep buffers created for parsing and lookup.
@b{RefTeX} sometimes needs to visit files related to the current
document.  We distinguish files visited for@refill
@table @asis
@item PARSING
Parts of a multifile document loaded when (re)-parsing the
document.@refill
@item LOOKUP
BibTeX database files and TeX files loaded to find a reference, to
display label context, etc.@refill
@end table
The created buffers can be kept for later use, or be thrown away
immediately after use, depending on the value of this variable:@refill

@table @code
@item nil
Throw away as much as possible.
@item t
Keep everything.
@item 1
Throw away buffers created for parsing, but keep the ones created for
lookup.@refill
@end table

If a buffer is to be kept, the file is visited normally (which is
potentially slow but will happen only once). If a buffer is to be thrown
away, the initialization of the buffer depends upon the variable
@var{reftex-initialize-temporary-buffers}.@refill
@end defopt

@defopt reftex-initialize-temporary-buffers
Non-@code{nil} means do initializations even when visiting file
temporarily.  When @code{nil}, @b{RefTeX} may turn off find-file hooks and
other stuff to briefly visit a file. When @code{t}, the full default
initializations are done (@code{find-file-hook} etc.).  Instead of
@code{t} or @code{nil}, this variable may also be a list of hook
functions to do a minimal initialization.@refill
@end defopt

@defopt reftex-no-include-regexps
List of regular expressions to exclude certain input files from parsing.
If the name of a file included via @code{\include} or @code{\input} is
matched by any of the regular expressions in this list, that file is not
parsed by @b{RefTeX}.
@end defopt

@defopt reftex-enable-partial-scans
Non-@code{nil} means, re-parse only 1 file when asked to re-parse.
Re-parsing is normally requested with a @kbd{C-u} prefix to many @b{RefTeX}
commands, or with the @kbd{r} key in menus.  When this option is
@code{t} in a multifile document, we will only parse the current buffer,
or the file associated with the label or section heading near point in a
menu.  Requesting re-parsing of an entire multifile document then
requires a @kbd{C-u C-u} prefix or the capital @kbd{R} key in
menus.@refill
@end defopt

@defopt reftex-save-parse-info
Non-@code{nil} means, save information gathered with parsing in a file.
The file @file{MASTER.rel} in the same directory as @file{MASTER.tex} is
used to save the information.  When this variable is @code{t},
@itemize @minus
@item
accessing the parsing information for the first time in an editing
session will read that file (if available) instead of parsing the
document.@refill
@item
each time (part of) the document is rescanned, a new version of the file
is written.@refill
@end itemize
@end defopt

@defopt reftex-allow-automatic-rescan
Non-@code{nil} means, RefTeX may rescan the document when this seems
necessary.  Applies (currently) only in rare cases, when a new label
cannot be placed with certainty into the internal label list.
@end defopt

@defopt reftex-use-multiple-selection-buffers
Non-@code{nil} means use a separate selection buffer for each label
type.  These buffers are kept from one selection to the next and need
not to be created for each use - so the menu generally comes up faster.
The selection buffers will be erased (and therefore updated)
automatically when new labels in its category are added.  See the
variable @var{reftex-auto-update-selection-buffers}.@refill
@end defopt

@defopt reftex-auto-update-selection-buffers
Non-@code{nil} means, selection buffers will be updated automatically.
When a new label is defined with @code{reftex-label}, all selection
buffers associated with that label category are emptied, in order to
force an update upon next use.  When @code{nil}, the buffers are left
alone and have to be updated by hand, with the @kbd{g} key from the
label selection process.  The value of this variable will only have any
effect when @var{reftex-use-multiple-selection-buffers} is
non-@code{nil}.@refill
@end defopt

@node Options (Misc), , Options (Optimizations), Options
@section Miscellaneous
@cindex Options, misc

@defopt reftex-extra-bindings
Non-@code{nil} means, make additional key bindings on startup.  These
extra bindings are located in the users @samp{C-c letter}
map. @xref{Keybindings}.@refill
@end defopt

@defopt reftex-plug-into-AUCTeX
Plug-in flags for AUCTeX interface.  This variable is a list of 4
boolean flags.  When a flag is non-@code{nil}, it means:@refill

@example
Flag 1:  use @code{reftex-label}     as @code{LaTeX-label-function}.
Flag 2:  use @code{reftex-arg-label} as @code{TeX-arg-label}
Flag 3:  use @code{reftex-arg-ref}   as @code{TeX-arg-ref}
Flag 4:  use @code{reftex-arg-cite}  as @code{TeX-arg-cite}
@end example

You may also set the variable itself to @code{t} or @code{nil} in order
to turn all plug-ins on or off, respectively.  The value of
@var{LaTeX-label-function} is the function used for label insertion when
you enter a new environment in AUCTeX.  The @code{TeX-arg-label}
etc. functions are for entering macro arguments during macro insertion
with AUCTeX.  See the AUCTeX documentation for more information.
@b{RefTeX} uses @code{fset} to take over the function calls.  Changing
the variable may require a restart of Emacs in order to become
effective.@refill
@end defopt

@defopt reftex-use-fonts
Non-@code{nil} means, use fonts in label menu and on-the-fly help.
Font-lock must be loaded as well to actually get fontified
display.@refill
@end defopt

@defopt reftex-auto-show-entry
Non-@code{nil} means, do something when context in other window is
hidden.  Some modes like @code{outline-mode} or @code{folding-mode} hide
parts of buffers.  When @b{RefTeX} is asked to show context for a label
definition, and the context is invisible, it can unhide that section
permanently (value @code{t}), or copy the context to a temporary buffer
(value 'copy).@refill
@end defopt

@defopt reftex-revisit-to-follow
Non-@code{nil} means, follow-mode will revisit files if necessary.
When nil, follow-mode will be suspended for stuff in unvisited files.
@end defopt

@node Keymaps, Hooks, Options, Top
@section Keymaps
@cindex Keymaps

@defvar reftex-mode-map
The keymap for @b{RefTeX} minor mode.
@end defvar

@defvar reftex-select-label-map
The keymap which is active in the labels selection process
(@pxref{Referencing Labels}).  Commands added to this map must return to
the selection buffer after any excursion.@refill
@end defvar

@defvar reftex-select-bib-map
The keymap which is active in the citation-key selection process
(@pxref{Creating Citations}).  Commands added to this map must return to
the selection buffer after any excursion.@refill
@end defvar

@defvar reftex-toc-map
The keymap which is active in the @code{*toc*} buffer.
(@pxref{Table of Contents}).@refill
@end defvar

@node Hooks, , Keymaps, Top
@section Hooks
@cindex Hooks

@deffn {Normal Hook} reftex-load-hook
Normal hook which is being run when loading @file{reftex.el}.
@end deffn

@deffn {Normal Hook} reftex-mode-hook
Normal hook which is being run when turning on @b{RefTeX} mode.@refill
@end deffn

See also the following variables which have hook properties as well:

@itemize @bullet
@item
@var{reftex-format-label-function} (@ref{Options (Creating
Labels)})@refill
@item
@var{reftex-format-ref-function} (@ref{Options (Referencing
Labels)})@refill
@item
@var{reftex-format-cite-function} (@ref{Options (Creating
Citations)})@refill
@item
@var{reftex-initialize-temporary-buffers} (@ref{Options
(Optimizations)})@refill 
@end itemize


@node Index,  , , Top
@unnumbered Index
@printindex cp

@summarycontents
@contents
@bye