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

\typeout{Next: not-an-env complaints}
\begin{Large}
  \begin{sffamily}
    Large and sans.
  \end{sffamily}
\end{Large}

\typeout{Next: center in float complaint}
\begin{figure}
  \begin{center}
    Center in float.
  \end{center}
  \caption{\label{fig}Figs and dates.}
\end{figure}

\typeout{Next: no complaints: manually fake caption}
\begin{figure}
    I have a caption, you just can't see it.
\makeatletter\nag@hascaptiontrue\makeatother
  \label{date}
\end{figure}

\typeout{Next: no complaing about label outside float not preceded by caption}
\section{More Tests}\label{sec:tests2}

\typeout{Next: put-label-after-caption complaint}
\begin{figure}
  \label{coconut}\caption{Preceded, not followed, by label.}
\end{figure}

\typeout{Next: no-caption complaint}
\begin{figure}
    No caption, even a fake one.
    But too big, this should get bottom-of-page warning.
    \rule{1pt}{0.4\textheight}
\end{figure}

\typeout{Next: no complaint about subfloat and topcapt}
\typeout{also: complaint about it in caption.}
\begin{figure}
  \subfloat{\label{sf:1}Subfig number~\ref{sf:1}  with label.}
  \subfloat[\label{sf:17}Strange subfig]{Subfig~\ref{sf:17} with label elsewhere.}
  \caption{Figure: \it's a sin!}
\end{figure}

\begin{figure}
  \topcaption{A topcaption.}
  \subfloat{\label{sf:2}Subfig~\ref{sf:2} with label, but no caption.}
\end{figure}

\typeout{Next: no robustness issues}
\begin{minipage}{5cm}
  foo\footnote{bar}
\end{minipage}

\typeout{Shouldn't cause trouble to have dollars in headings.}
\section{Maths tests, like if $1+1=2$}

\typeout{Next: three complaints in total concerning $$ and eqnarray}

A \TeX-style displayed equation:
$$ 1+1=2 $$

Not an equation at all:
$ $ 1+1=2 $ $

An in line equation:
$1+1=2$

Two inline equations, double dollar is dollar dollar in resticted
horizontal mode (onlyamsmath gets this wrong):
$a+b=c$$1+1=2$

An eqnarray:
\begin{eqnarray}
1+1 &=& 2
\end{eqnarray}

A bracket-style equation:
\[1+1=2\]

A starred eqnarray:
\begin{eqnarray*}
1+1 &=& 2
\end{eqnarray*}

A double-dollar in a hbox:
\hbox{$$}

\typeout{Next: appendix complaints}
\begin{appendix}
  \begin{center}
    It's a center environment.
  \end{center}
\typeout{Next: no over complaint, centerline complaint, no frac complaint}
  Over etc. warning removed for compatibility with \LaTeX\ without amsmath.

  \centerline{Furthermore, $4\over 2=2$.}
  $\frac 42$
\end{appendix}
\typeout{Next: unmatched endflushright}
This is not flushright, in spite of a endflushright coming up.
\endflushright
\typeout{Next: unclosed center}
{\center Smack in the middle, but center used as a switch\par}
\typeout{Next: mismatched endflushright}

Another endflushright, this is brace-mismatched and otherwise totally
unsuited for closing the center command above.
\endflushright

\typeout{Next: a warning that is not uppercased.}
\MakeUppercase{\it's a sin!}

\typeout{Next: another warning about it in a caption, in the LoF this time.}
\listoffigures
\AtEndDocument{\typeout{You should get 25 warnings and one info in the log.}}
\end{document}
%</nagdemo>
%
%\fi
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%\CheckSum{624}
%
%\DoNotIndex{\if,\else,\fi,\PackageWarning,\PackageWarningNoLine,\typeout}
%\DoNotIndex{\@for,\addtocounter,\arabic,\centering,\csname,\CurrentOption}
%\DoNotIndex{\DeclareOption,\def,\do,\endcsname,\expandafter,\ifnum,\ifx}
%\DoNotIndex{\InputIfFileExists,\let,\lq,\rq,\MessageBreak,\protect}
%\DoNotIndex{\space,\stepcounter,\the,\value,\relax,\ProcessOptions}
%\DoNotIndex{\ifcsname,\@ifundefined,\flo,\begingroup,\endgroup}
%\DoNotIndex{\or,\vbox,\vskip,\z@,\wd,\vtop,\tmp@a,\tmp@b,\tw@}
%\DoNotIndex{\@nil,\@nx,\@ne,\@tempcnta,\@tempcntb,\@tempdima,\@tempskipb}
%\DoNotIndex{\foo,\endfoo,\ht,\dp,\wd,\hrule,\ifcase,\ifdim}
%
%\changes{0.1}{2005/03/29}{First official version.}
%\changes{0.2}{2005/05/08}{Rephrased umlaut.sty warning, suggested by
%Patrick Happel.}
%\changes{0.2}{2005/05/08}{Added abort.nag, suggested by Michael Zedler}
%\changes{0.3}{2005/07/07}{New ifdefined that won't relax the commands}
%\changes{0.4}{2006/04/19}{Handling command vs. environment; bugfixes}
% \changes{0.5}{2006/07/08}{Handle the case that somebody else relaxes
% the ver@-commands. Stack-based NotASwitch.}
%\changes{0.55}{2007/03/31}{Some spaces crept in in 0.5}
%\changes{0.60alpha}{2007/04/03}{ changes the way label/caption is handled,
%  this eliminates the current limit of some thousand floats you can have in
%  your document. (I wonder why nobody noticed). }
%\changes{0.60alpha2}{2007/04/08}{ is more careful around commands that
%  aren't there. }
%\changes{0.60alpha4}{2007/04/23}{ handles eqnarray itself and has code in
%  nag-experimental.cfg to handle double-dollar in a more robust way that
%  onlyamsmath.}
%\changes{0.60alpha4}{2007/04/23}{ tarballs now unpack into a subdirectory
%  like proper citizens should.}
%\changes{0.60alpha5}{2007/05/10}{ improves compatibility with subfig.}
%\changes{0.60}{2007/05/10}{ fixes double-dollar in conjunction with
%  hyperref; documents incompatiblity with rotating.}
%\changes{0.61alpha1}{2007/11/10}{ fixes warnings in toc/lof/lot and
%  unsightly uppercasing. }
%\changes{0.61alpha2}{2007/11/26}{ fixes the warnings, without generating
%  too many duplicates.}
%\changes{0.61alpha3}{2007/12/21}{ warns about inputs that fail (in
%  particular includes that fail) and notes if a float has position t/b but is
%  too large to ever go into such a position (log only). }
%\changes{0.61alpha4}{2008/01/04}{ exempts the complaints counter from
%  include trickery. (Previously, nag would get confused if you includeonly
%  only some chapters.) }
%\changes{0.61alpha5}{2008/01/27}{ introduces compatibility hacks with
%  version control packages which rely on dollar having constant catcode.
%  (Workaround for svninfo and rcs, all other packages now disable
%  double-dollar
%  checking.) }
%\changes{0.61}{2008/02/10}{ is 0.61alpha5 with some typos in the docs
%  fixed.}
%\changes{0.62}{2007/07/30}{ fixes a bug in the float placement code and
%  adds more compatibility with the caption package.}
%\changes{0.621}{2010/04/05}{Bugfix concerning unknown command in math mode}
%\changes{0.622}{2010/05/17}{Bugfix: math in captions catcode issue}
%\changes{0.623}{2010/08/15}{Tracing code in experimental: nofiles}
%\changes{0.623}{2010/08/15}{Tracing code in experimental: changing labels}
%\changes{0.623}{2010/08/15}{New error message: no room for a ... and eTeX}
%\changes{0.7}{2011/11/25}{IncompatiblePackages,RecommendPackage,BadFileLoadOrder}
%
%\GetFileInfo{nag.sty}
%\newcommand\pkg[1]{\textsf{#1}} 
%\title{The \pkg{nag} package\ignorespaces%
%      \thanks{This document corresponds to \pkg{nag}~\fileversion,
%        dated~\filedate. Other versions can be found at http://absatzen.de/}} 
%    \author{Dr. Ulrich Michael Schwarz\ignorespaces%
%      \thanks{\texttt{ulmi@absatzen.de}}}
%
%    \maketitle
%
% \begin{abstract}
%   Old habits die hard. All the same, there are commands, classes and
%   packages which are outdated and superseded. \pkg{nag} provides
%   routines to warn the user about the use of those. As an example, we
%   provide an extension that detects many of the ``sins'' described in
%   \pkg{l2tabu}.
% \end{abstract}
%
% \tableofcontents
%
% \section{User-side considerations.}
%
% \subsection{Installation.}
%
% Process \texttt{nag.ins} with \LaTeX\ to obtain some files:
% \texttt{nag.sty} and \texttt{nag-l2tabu.cfg} et al. must go to a place where
% \LaTeX\ will find them, like the local TEXMF tree. (If all else fails and
% you need it to work \emph{right now}, having them in the same
% directory as the \LaTeX\ file you want to use them on may work under
% many circumstances.) You can, as usual, run \LaTeX\ on
% \texttt{nag.dtx} to obtain this documentation, including the
% implemenation docs. (This is recommended if you plan to extend
% \pkg{nag} to handle your own packages.) \texttt{nagdemo.tex} is
% a horrible document that will show you many of the warnings that
% \pkg{nag} can generate. 
%
% \subsection{Usage.}
%
% Add the following to the beginning your main document (Comments and
% |\listfiles| can be safely left before it, though):
% \begin{verbatim}
%   \RequirePackage[l2tabu, orthodox]{nag}\end{verbatim}
% This will check for many common mistakes, and give some hints on what
% to use instead. However, you should always refer to l2tabu for a more
% detailed explanation of the whats and whys: it gives more information
% than can be possibly pressed into two lines of error message.
% Orthodox checks for pitfalls that are not technically incorrect. If
% you know what you're doing, omit orthodox.
%
% \subsection{Known bugs}
% currently none.
%
% \subsection{\texttt{nag-l2tabu.cfg}}
%
% In a nutshell, \texttt{nag-l2tabu.cfg} detects the following:
% \begin{itemize}  
% \item Usage of the 2.09-style font commands |\it|, |\bf|, |\rm|,
% |\sc|, |\sl|, |\tt| and |\cal|.
% \item Usage of |\centerline|.
% \item Usage of the outdated packages \pkg{epsfig}, \pkg{psfig},
% \pkg{epsf}, \pkg{doublespace}, \pkg{fancyheadings}, \pkg{scrpage},
% \pkg{umlaut}, \pkg{isolatin}, \pkg{isolatin1}, \pkg{t1enc},
% \pkg{caption2}, \pkg{psfonts}, \pkg{mathptm}, \pkg{times},
% \pkg{palatino}, \pkg{mathpple}, \pkg{euler} and \pkg{utopia}, and of
% the outdated class \pkg{scrlttr}.
% \item Figures and tables without caption (this is not technically
%      in l2tabu, but the people who have floats without captions tend
%      to ask ``Why is \LaTeX\ moving my pictures away from where I
%      put them?''), labels within floats
% that do not reference the caption, and usage of the center
% environment within floats.
%\end{itemize}
%
% It is beyond the possibilities of this package to detect things like
% use of \TeX\ assignment syntax, or direct change of paper
% parameters, or reliable detection of user-issued |\sloppy|. 
% eqnarray is handled as of 0.60alpha4, and there is code for \$\$ in
% experimental since 0.60alpha4, which has been moved to l2tabu in 0.60.
%
% {\bfseries\label{disclaimer} Be warned, that this package will possibly balk at
% legitimate use, and not find illegitimate use in all cases. It is a
% tool, not a replacement for study of \pkg{l2tabu}.}
%
% \iffalse
%<*l2tabunag>
% \fi
%    \begin{macrocode}
\ProvidesFile{nag-l2tabu.cfg}
             [2010/05/17 v2.11 l2tabu rules for nag.sty (ulmi)]
%%
%% The sins.
%%
%% Section numbers refer to l2tabuen 1.7 revised/enlarged dated 2004OCT24
%% \S 1.1
\ObsoletePackage{a4wide}{the \lq a4paper\rq\space class option}
\ObsoletePackage{a4}{the \lq a4paper\rq\space class option}
%% \S 1.2--1.5 cannot reasonably be checked programmatically
%% \S 1.6 
%    \end{macrocode}
% Hacking galore ahead! We will make the dollar active. Since unlike
% \pkg{onlyamsmath}, we do not change the user's command to \LaTeX\ or
% \pkg{amsmath} commands, we need to store the old double dollar
% sequence as well as the single dollar.
%    \begin{macrocode}
\def\nag@doubledollar{$$}%$$
\def\nag@singledollar{$}%$
%    \end{macrocode}
% This is used to hide our redefinition in unprotected expanding
% context. This should not happen: you are expected to \emph{always}
% use protected means of expansion in \LaTeX, but fecal matter
% happens. See below for a good trick to distinguish expansion from
% executing context.
%    \begin{macrocode}
\def\nag@expanding@voodoo#1#2#3{\relax\relax\nag@singledollar}

\def\nag@maybedispmath{%
  \texorpdfstring{%
    %% in TeX context, do tricky stuff.
    \ifinner\expandafter\@firstoftwo
    \else\expandafter\@secondoftwo\fi
    {%% in inner mode, $$ is an empty formula, so no testing wanted.
      \nag@singledollar}%
    {%%
      \ifx\protect\@typeset@protect\expandafter\@firstoftwo
      \else\expandafter\@secondoftwo\fi
      {%% normal case: looks like typesetting
        %% protect against strictly expanding context
        %% like TeX' \message: the first expanding voodoo will expand,
        %% removing the rest, inserting \relax\relax$ instead. This is
        %% not totally transparent, but \let\relax\relax is as close
        %% to a no-op as we can get.
        \let\nag@expanding@voodoo\nag@expanding@voodoo
        \protect\nag@maybe@dispmath}%
      {%% some other case, hide ourselves
        \nag@singledollar}%
    }%
  }{%
    %% in pdf context, just be a math shift. This creates the "math
    %% shift not allowed" warnings we all love.
    \nag@singledollar
  }%
}
%    \end{macrocode}
% If the user doesn't load \pkg{hyperref}, we have to fake its
% \cmd{\texorpdfstring} command. Note that this will break any package that
% is foolish enough to detect \pkg{hyperref} by testing for
% definedness of \cmd{\texorpdfstring}.
%    \begin{macrocode}
\AtBeginDocument{\providecommand\texorpdfstring{\@firstoftwo}}
\AtBeginDocument{\catcode`$\active}%$
\AtEndDocument{\catcode`$=3\relax}
%    \end{macrocode}
% Now, the proper testing. (Yes, the above is just the
% technicalities.) We use the kernel's \cmd{\@ifnextchar} to look for
% a possible second dollar. Note however, this would allow skipping of
% spaces between them, and \$\_\$ is not a displayed equation start in
% \TeX. We work around this by re\cmd{\let}ting \cmd{\@sptoken} to
% something that cannot legally appear in the source.
%    \begin{macrocode}
\def\nag@quark{\nag@quark}
\bgroup
  \catcode`$\active%$
  \gdef\nag@maybe@dispmath{%
    \bgroup
    \let\@sptoken\nag@quark% prevent skipping of spaces
    \@ifnextchar${%$%
      \ifmmode
      % we already warned upon entering.
      \else
      \nag@warn{%
        \nag@doubledollar...\nag@doubledollar\space is obsolete.\MessageBreak
        Use \string\[...\string\] et al. instead}%
      \fi
      \egroup\expandafter\nag@doubledollar\@gobble
    }{%
     \egroup\nag@singledollar
    }%
  }
  % we do the assignment here, which means any package that redefines
  % \$ as well will silently disable us. This is a feature.
  \global\let$\nag@maybedispmath%$
\egroup
%    \end{macrocode}
%    \changes{0.61alpha6}{2008/01/27}{Compatibility w/ VCS packages, pgf}
%% new in 2.1alpha1: more compat testing. Version control keywords are dollar-delimited.
%% all five implementations get it wrong.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{rcs}{%
    % this redefinition is functionally equivalent,
    % but does not share actual code.
    \renewcommand\RCS{\bgroup%
      \catcode`\_ =\active
      \catcode`\$=3 % this line added for compatibility.
      \csname RCS_get_argument\endcsname
    }
    \PackageInfo{nag}{rcs.sty hack applied}%
  }{}%
  \@ifpackageloaded{svninfo}{%
    \g@addto@macro\@svnBeginRead{\catcode`\$ 3 }%
    \PackageInfo{nag}{svninfo.sty hack applied}%
  }{}%
  \@ifpackageloaded{svn}{%
    \PackageInfo{nag}{svn.sty is broken: disabling dollar check}%
    \catcode`\$ 3
  }{}%
  \@ifpackageloaded{rcsinfo}{%
    \PackageInfo{nag}{rcsinfo.sty is broken: disabling dollar check}%
    \catcode`\$ 3
  }{}%
  \@ifpackageloaded{pgf}{%
    \PackageInfo{nag}{pgf.sty is broken: disabling dollar check}%
    \catcode`\$ 3
  }{}%
}


%% \S 1.7 cannot reasonably be checked programmatically
%% \S 1.8 \sloppy is called by parbox, among others, and would
%% give many spurious warnings.
%% \S 2.1.1
\ObsoleteCS[an old LaTeX 2.09 command]{bf}
           {\protect\bfseries\space or \protect\textbf}
\ObsoleteCS[an old LaTeX 2.09 command]{it}
           {\protect\itshape\space or \protect\textit}
\ObsoleteCS[an old LaTeX 2.09 command]{rm}
           {\protect\rmfamily\space or \protect\textrm}
\ObsoleteCS[an old LaTeX 2.09 command]{sc}
           {\protect\scshape\space or \protect\textsc}
\ObsoleteCS[an old LaTeX 2.09 command]{sf}
           {\protect\sffamily\space or \protect\textsf}
\ObsoleteCS[an old LaTeX 2.09 command]{sl}
           {\protect\slshape\space or \protect\textsl}
\ObsoleteCS[an old LaTeX 2.09 command]{tt}
           {\protect\ttfamily\space or \protect\texttt}
\ObsoleteCS[an old LaTeX 2.09 command]{cal}
           {\protect\mathcal}% Hmm, this is not in l2tabu?
%% \S 2.1.2
%% Gone with 1.8 because this never worked for the kernel \frac anyway.
%% \ObsoleteCS[TeX]{over}{\protect\frac}
%% \ObsoleteCS[TeX]{choose}{\protect\frac\space or amsmath's \protect\binom}
%% \S 2.1.3
\ObsoleteCS[TeX]{centerline}{\protect\centering\space or center environment}
%% \S 2.2.1
\ObsoleteClass{scrlettr}{the scrlttr2 package}
%% \S 2.2.2
\ObsoletePackage{epsf}{the graphicx package}
\ObsoletePackage{psfig}{the graphicx package}
\ObsoletePackage[deprecated]{epsfig}{the graphicx package directly}
%% \S 2.2.3
\ObsoletePackage{doublespace}{the setspace package}
%% \S 2.2.4
\ObsoletePackage{fancyheadings}{the fancyhdr or scrpage2 packages}
\ObsoletePackage{scrpage}{the scrpage2 package}
%% \S 2.2.5
\ObsoletePackage{isolatin}{the inputenc package with option latin1}
\ObsoletePackage{umlaut}{the inputenc package with suitable option
  (latin1, utf8 ...)}
\ObsoletePackage{isolatin1}{the inputenc package with option latin1}
%% \S 2.2.6
\ObsoletePackage{t1enc}{the fontenc package with option T1}
%% \S 2.2.7 we don't check for bst yet.
%% (This is in l2tabu 1.8)
\ObsoletePackage{caption2}{the caption package v3.0 or later}
%% \S 2.3.1-3
\ObsoletePackage{times}
                {the mathptmx, helvet (option scaled=.9), courier packages}
\ObsoletePackage{pslatex}
                {the mathptmx, helvet (option scaled=.9), courier packages}
\ObsoletePackage{mathptm}
                {the mathptmx package}
%% \S 2.3.4-5
\ObsoletePackage{palatino}
                {the mathpazo, helvet (option scaled=.95), courier packages}
\ObsoletePackage{mathpple}{the mathpazo package}
%% \S 2.3.6 can't be checked
%% \S 2.3.7
\ObsoletePackage{euler}{the eulervm package}
\ObsoletePackage{utopia}{the fourier package}
%% \S 3.1
\NagDeclareFloat{figure}\NagDeclareFloat{table}%
\g@addto@macro\nag@labels{,label,caption@xlabel}%
% \changes{0.60}{2007/03/31}{alternate center-in-float check, doesn't
% take up as many macro names}
\nag@prepend{endcenter}{%
  \ifx\@captype\@undefined\else
    \nag@warn{\lq center\rq\space environment in \@captype.\MessageBreak
	      Maybe you want \protect\centering\space instead}%
  \fi
}%
%% The latter two are used by KOMA-Script, the last by hypcap.
% \changes{0.53}{2007/03/21}{hypcap support. (H.G.Krauth\"auser)}
% \changes{0.53}{2007/03/21}{topcapt support.}
\g@addto@macro\nag@captions{,caption,captionabove,captionbelow,hc@caption,topcaption}%

%% \S 3.2
\NotAnEnvironment{appendix}%
%% In the same vein:
\@for\sectioning:=frontmatter,mainmatter,backmatter\do{%
  \expandafter\NotAnEnvironment\expandafter{\sectioning}%
}
%% \S 3.3
%% It's more trouble than it's worth to have another warning for
%% align*, since it passes through align.
\ObsoleteEnv{eqnarray}{amsmath's align}
%% \S 3.4 -- nothing to be done --
%    \end{macrocode}
% \iffalse
%</l2tabunag>
% \fi
%
% \subsection{\texttt{nag-orthodox.cfg}}
% \texttt{nag-orthodox.cfg} warns about usage that is not technically
% incorrect, but will mostly do things an unwary user may not expect.
% This includes in particular the usage of font size and style switches
% as environments (line spacing will be off if the environment does not
% contain a trailing \string\par, spurious spaces might occur since the
% switches don't \string\ignorespaces), and, conversely, the usage of
% center etc. environments as unclosed switches. (Detection of the
% latter might still be somewhat brittle.)
% \iffalse
%<*orthodoxnag>
% \fi
%    \begin{macrocode}
\ProvidesFile{nag-orthodox.cfg}
             [2006/04/19 v1.8 strict rules for nag.sty (ulmi)]
\@for\fontcmd:=tiny,small,footnotesize,normalsize,large,Large,%
               LARGE,huge,Huge\do{%
  \expandafter\NotAnEnvironment\expandafter{\fontcmd}%
}%
\@for\fontcmd:=sffamily,rmfamily,ttfamily,%
               bfseries,mdseries,scshape,%
               itshape,upshape\do{%
  \expandafter\NotAnEnvironment\expandafter{\fontcmd}%
}%
\@for\justsw:=centering,raggedleft,raggedright,%
              RaggedLeft,RaggedRight\do{%
  \expandafter\NotAnEnvironment\expandafter{\justsw}%
}
\@for\justenv:=center,flushleft,flushright\do{%
 \expandafter\NotASwitch\expandafter{\justenv}%
}
%    \end{macrocode}
%\iffalse
%</orthodoxnag>
%\fi
%
% \subsection{\texttt{nag-abort.cfg}}
% Requesting this nag file will turn all complaints into errors.
%
% \iffalse
%<*abortnag>
%\fi
%    \begin{macrocode}
\ProvidesFile{nag-abort.cfg}
             [2007/11/10 v0.2 treat complaints as errors (ulmi)]
\DeclareRobustCommand\nag@warn[1]{%
  \addtocounter{nag@sins}{1}%
  \PackageError{nag}{#1}{#1}%
}
\DeclareRobustCommand\nag@warnNoLine[1]{%
  \addtocounter{nag@sins}{1}%
  \PackageError{nag}{#1}{#1}%
}
%    \end{macrocode}
%\iffalse
%</abortnag>
%<*experimentalnag>
%\fi
%\subsection{\texttt{nag-experimental.cfg}}
% Functionality that needs more testing.
%    \begin{macrocode}
\ProvidesFile{nag-experimental.cfg}
             [2009/07/04 v0.62alpha2 experimental additions to nag (ulmi)]
%    \end{macrocode}
%
% Patch handling of nofiles: suppressed lines give an
% Info-level message in the logfile now. The message
% doesn't quite give the original line, but a sanitized
% version. Reason: otherwise, we might need to execute
% the setup code \#2.
%
%    \begin{macrocode}
\long\def\nag@protected@dontwrite#1#2#3%
  {\write\m@ne{}%
   \def\nag@line{#3}%
   \@onelevel@sanitize\nag@line
   \PackageInfo{nag}{%
    \string\nofiles\space in effect.
    Did not write line \MessageBreak
    `\nag@line'
   }%
   \if@nobreak\ifvmode\nobreak\fi\fi}%

\if@filesw
  \def\nofiles{%
    \@fileswfalse
    \typeout{No auxiliary output files.^^J}%
    \global\let\protected@write=\nag@protected@dontwrite
    \let\makeindex\relax
    \let\makeglossary\relax}
\else
  % already \nofiles.
  \global\let\protected@write=\nag@protected@dontwrite
\fi
%    \end{macrocode}
%
% Amend ``no space for a new foo'' message to point out
% e\TeX\ alleviates some problems in that area.
%    \begin{macrocode}
\gdef\ch@ck#1#2#3{%
  \ifnum\count1#1<#2\else
    \errhelp{%
      eTeX has more counters, dimens, etc., maybe
      that will help.
    }
    \errmessage{No room for a new #3}%
\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@testdef #1#2#3{%
  \def\reserved@a{#3}%
  \expandafter \ifx \csname #1@#2\endcsname\reserved@a 
  \else 
    \@tempswatrue
    \begingroup
    \@onelevel@sanitize\reserved@a
    \expandafter\let\expandafter\nag@tmpb\csname #1@#2\endcsname
    \ifx\nag@tmpb\relax
      \let\nag@tmpb\@empty
    \else
      \@onelevel@sanitize\nag@tmpb
    \fi
    \PackageInfo{nag}{%
      Label `#2' appears to have changed from\MessageBreak
      `\nag@tmpb'\MessageBreak
      to `\reserved@a'
    }%
    \endgroup
  \fi}
%    \end{macrocode}
%
%
% Check if a float that may be positioned b is actually small
% enough for bottomfraction etc.
%    \changes{0.62alpha1}{2008/03/19}{Bigger warning if all float positions fail}
%    \changes{0.62alpha2}{2009/07/04}{Fix for marginpar etc which don't have fps}
%    \begin{macrocode}
\let\@xa\expandafter
\newif\ifnag@dofloatsizecheck
\newif\ifnag@allfloatpositionsfailed
\newcommand\nag@allfloatsizechecks{}%
\newcommand\nag@onefloatsizecheck[2]{%
  % #1 is size fraction of textheight,
  % #2 is position to say in warning.
  \ifdim \ht\@currbox>#1\textheight
    \@tempdima -#1\textheight
    \advance \@tempdima \ht\@currbox
    \PackageInfo{nag}{Float too large for #2 by \the\@tempdima}%
    % note we do not truncate.
    % also, it's too late to add "p" now.
  \else
    \nag@allfloatpositionsfailedfalse
  \fi
}
% \@currbox is current float box,
% \@fps is the current list of float specifiers.
\renewcommand\@largefloatcheck{%
  \ifdim \ht\@currbox>\textheight
    \@tempdima -\textheight
    \advance \@tempdima \ht\@currbox
    \@latex@warning {Float too large for page by \the\@tempdima}%
    \ht\@currbox \textheight
  \fi
  %% the preceding is the original check.
  \nag@dofloatsizechecktrue
  \nag@allfloatpositionsfailedtrue
  \def\nag@allfloatsizechecks{}%
  \@xa\@xa\@xa\@tfor\@xa\@xa\@xa\nag@fltsz@tmp\@xa\@xa\@xa:\@xa\@xa\@xa=\csname @fps\endcsname\do{%
    \ifx\nag@fltsz@tmp\relax
      \nag@dofloatsizecheckfalse
    \fi
    \if\nag@fltsz@tmp !
      \nag@dofloatsizecheckfalse
    \else
      \if\nag@fltsz@tmp t
        \g@addto@macro\nag@allfloatsizechecks
          {\nag@onefloatsizecheck{\topfraction}{top of page}}%
      \else
        \if\nag@fltsz@tmp b
          \g@addto@macro\nag@allfloatsizechecks
            {\nag@onefloatsizecheck{\bottomfraction}{bottom of page}}%
        \else
          \if\nag@fltsz@tmp p
            \nag@allfloatpositionsfailedfalse
          \fi
        \fi
      \fi
    \fi
  }%
  \ifnag@dofloatsizecheck
    \nag@allfloatsizechecks
    \ifnag@allfloatpositionsfailed
      \nag@warn{All float specifiers `\@fps' won't work}%
    \fi
  \fi
}%
%    \end{macrocode}
% More experimental code: warning about files that were
% requested but not there. The really important one would
% be a check for include (this is just a typeout in the kernel?!).
% But as it is, we get warnings that point out missing ToC, LoF etc.
%    \begin{macrocode}
\def\@input#1{%
  \IfFileExists{#1}{\@@input\@filef@und}{%
  \typeout{No file #1.}
  \@latex@warning{File `#1' not found}
  %{The file `#1' was requested but not found }
  \protected@edef\nag@nofile{File `#1' requested, but not found}%
  \@xa\AtEndDocument\@xa{%
    \@xa\@latex@info@no@line\@xa{%
      \nag@nofile
    }%
  }%
}}%
%
\def\@input@#1{\InputIfFileExists{#1}{}{%
  \typeout{No file #1.}
  \@latex@warning{File `#1' not found}
  {The file `#1' was requested but not found }
  \edef\nag@nofile{File `#1' requested, but not found}%
  \@xa\AtEndDocument\@xa{%
    \@xa\@latex@info@no@line\@xa{%
      \nag@nofile
    }%
  }%
}}%
%
%    \end{macrocode}
%\iffalse
%</experimentalnag>
%
%<*nag>
%\fi
%    \section{Author-side considerations and implementation.}
%    If you are a package or class author and want to extend the range
%    of \pkg{nag} (or prevent \pkg{nag} from criticizing
%    your macros), please see the description below, in
%    sections~\ref{sec:obsol-cmds} and following. It is
%    probably wise to group new rules in a seperate nag file:
%    users can request nag files by passing their name as a package
%    parameter, as shown above for the example of l2tabu.
%
%    \subsection{Low-level tools.}
%    Identify ourselves.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nag}[2011/11/25 0.7 warning about old commands (ulmi)]
\let\@xa\expandafter
\let\@nx\noexpand
%    \end{macrocode}
%    First of all, two counters we need. The first is used to
%    generate running numbers for replacement macros, the latter is
%    stepped for each complaint we have, so that the user gets a
%    frighteningly high number, showing how sinful he or she is.
%    \changes{0.61alpha1}{2007/11/10}{roman counter (external file issue)}
%    \changes{0.61alpha4}{2008/01/01}{sin counter should not be saved by include}
%    \begin{macrocode}
\newcounter{nag@c}
\renewcommand\thenag@c{\roman{nag@c}}%
\setcounter{nag@c}{1}%
\begingroup
  \let\@addtoreset\@gobbletwo
  \newcounter{nag@sins}%
\endgroup
%    \end{macrocode}
%
%    \begin{macro}{\nag@prepend}
%     |\nag@prepend|\marg{cs}\marg{something}:
%     Prepend \meta{something} to the macro definition of |\|\meta{cs}.
%
%     In reality, we do call indirection: save old macro away,
%     redefine macro to do the something, call old macro.
%     (With thanks to Juergen Goebel, Heiko Oberdiek and Rolf Niepraschk
%     (\pkg{savesym}))
%
%    From $0.60\alpha_2$ on, nag is more robust about not defining
%    commands that are not there. Now, they're not even relaxed.
%    \begin{macrocode}
\newcommand\nag@ifundefined[1]{%
  \begingroup
  \@ifundefined{#1}{\endgroup\@firstoftwo}{\endgroup\@secondoftwo}%
}
%    \end{macrocode}
%    \changes{0.51}{2006/10/21}{bugfix}
%    Don't define the macro if it's not there. This confuses caption,
%    which loads ragged2e AtBeginDocument, at which point, RaggedLeft
%    et al. were already defined by us.
%    \changes{0.52}{2007/02/25}{info}
%    \changes{0.60alpha2}{2007/04/08}{don't even relax unknown
%    commands (J.Sommer)}
%    \dots but \emph{do} log a message.
%    \changes{0.61alpha1}{2007/11/10}{Extra indirection of warnings
%    for robustness (uppercasing/LoF issues)}
%    \changes{0.61alpha2}{2007/11/26}{Creep under existing robust cover}
%    \begin{macrocode}
\newcommand\nag@prepend[2]{%
  \nag@ifundefined{#1}{%
    % if it doesn't exist, don't do anything.
    \PackageInfo{nag}{%
      Command \@backslashchar#1\space not defined, skipping amendment%
    }%
  }{%
    \nag@ifundefined{#1 }{%
      \let\nag@maybespace\@empty
    }{%
      \let\nag@maybespace\space
      %\PackageInfo{nag}{%
      %  Command \@backslashchar#1\space appears robust\MessageBreak
      %  Modifying `\@backslashchar#1\space' instead.
      %}%
    }%
    \@xa\let
    \csname nag@@#1@\thenag@c\@xa\endcsname
    \csname #1\nag@maybespace\endcsname
    \@xa\DeclareRobustCommand\csname nag@@warning@\thenag@c\@xa\endcsname{%
      #2%
    }%
    \@xa\nag@pr@p@nd\csname #1\nag@maybespace\@xa\endcsname
    \csname nag@@#1@\thenag@c\@xa\endcsname
    \csname nag@@warning@\thenag@c\@xa\endcsname
%    \end{macrocode}
% Fun with scoping: one might think we can get away with a (non-local)
% |\advance\c@nag@c 1\relax| here. This would lead to less hashtable
% usage. Problem: if a nag@@foo@17 macro ever escapes its scope, it
% might be bound to something else entirely. This might occur with
% some of the fancier table packages which use external files?
%    \begin{macrocode}
    \stepcounter{nag@c}%
  }%
}
\newcommand\nag@pr@p@nd[3]{%
  \def#1{#3#2}%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\nag@warn}
%    All complaints to the user run through one of these two macros,
%    with or without source line.
%    \changes{0.61alpha1}{2007/11/10}{Made robust.}
%    \begin{macrocode}
\DeclareRobustCommand\nag@warn{%
  \addtocounter{nag@sins}{1}%
  \PackageWarning{nag}%
}
\DeclareRobustCommand\nag@warnNoLine{%
  \addtocounter{nag@sins}{1}%
  \PackageWarningNoLine{nag}%
}
\providecommand\PackageInfoNoLine[2]{%
  \PackageInfo{#1}{#2\@gobble}%
}
\DeclareRobustCommand\nag@suggestNoLine[1]{%
  \PackageInfoNoLine{nag}{#1}%
}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Obsoletifying commands.}\label{sec:obsol-cmds} 
%
%    (No, I do not think that is a proper word either.)
%
%    \begin{macro}{\ObsoleteCS}
%    Usage: |\ObsoleteCS|\oarg{reason}\marg{CS}\marg{suggestions}
%    Mark |\|\meta{CS} as obsolete. \meta{reason} defaults to
%    obsolete. When the macro is used anyway, the following
%    warning is logged:
%    
%    \noindent|Command \|\meta{CS}| is |\meta{reason}|. Use |\meta{suggestions}| instead.|
%    \begin{macrocode}
\newcommand\ObsoleteCS[3][obsolete]{%
  \AtBeginDocument{%
    \nag@prepend{#2}{%
      \nag@warn{%
	Command \@backslashchar#2 is #1.
	\MessageBreak 
	Use #3 instead}%
    }%
  }%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\ObsoleteEnv}
%    \changes{0.60alpha4}{2007/04/23}{There was no ObsoleteEnv?!}
%    \begin{macrocode}
\newcommand\ObsoleteEnv[3][obsolete]{%
  \AtBeginDocument{%
    \nag@prepend{#2}{%
      \nag@warn{%
	Environment #2 is #1.
	\MessageBreak 
	Use #3 instead}%
    }%
  }%
}
%    \end{macrocode}
%     \end{macro}
%
%    \subsection{Obsoletifying packages and classes.}
%
%    Checking for packages and classes is done by looking for
%    |ver@foo.sty|, which holds the version information that is also
%    displayed by |\listfiles|. This means that we're out of luck if
%    fontenc ever becomes obsolete, because that won't be detected.
%
%    First, define a macro to check if a control sequence is defined.
%    Unlike |\@ifundefined|, this will not define the control sequence
%    to |\relax|, but the arguments will be executed in a group. For
%    our purposes, this doesn't matter, because we only give a warning
%    (and |\addtocounter| already is |\global|).
%    \begin{macrocode}
\newcommand\nag@ifcsname[3]{%
  \begingroup\@ifundefined{#1}{#3}{#2}\endgroup
}
%    \end{macrocode}
%    Just because we can, use $\epsilon$\TeX' |\ifcsname| if we can. This
%    bootstrapping gives me a big grin\dots Note we add an extra group
%    for compatibility with the non-$\epsilon$ case.
%    \changes{0.52}{2007/02/25}{made eTeX-ifcsname more robust}
%    \begin{macrocode}
\nag@ifcsname{ifcsname}{%
  \renewcommand*\nag@ifcsname[3]{%
    \begingroup
      % assume it won't be there.
      \let\tmp@a\@secondoftwo
      \ifcsname #1\endcsname 
    % It still might be relax from some other test. Thanks to J\"org
    % Sommer for finding this bug.
      \expandafter\ifx\csname #1\endcsname\relax
      \else
        % it's there after all
        \let\tmp@a\@firstoftwo
      \fi
    \fi
    \tmp@a{#2}{#3}%
    \endgroup
  }%
%    \end{macrocode}
%    This way of escaping the grouping gives me an even
%    bigger grin.
%    \begin{macrocode}
  \global\let\nag@ifcsname\nag@ifcsname
}{}
%    \end{macrocode}
%
%    \begin{macro}{\ObsoletePackage}
%    Usage: |\ObsoletePackage|\oarg{reason}\marg{package}\marg{%
%    alternative}. Mark \meta{package} as obsolete. \meta{reason} defaults
%    to obsolete. If the \meta{package} is used anyway, at the end of
%    the compilation, the following warning will be displayed:
%
%    \noindent|Package |\meta{package}| is |\meta{reason}|. Use |
%    \meta{alternative}| instead.|
%    \begin{macrocode}
\newcommand\ObsoletePackage[3][obsolete]{%
  \AtEndDocument{%
% |\@clsextension| is onlypreamble, for some reason.
    \nag@ifcsname{ver@#2.sty}{%
    \nag@warnNoLine{%
      Package #2 is #1.\MessageBreak
      Use #3 instead}%
    }{}%
  }%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\SuggestedPackage}
%    Usage: |\SuggestedPackage|\oarg{reason}\marg{package}
%    \begin{macrocode}
\newcommand\SuggestedPackage[2][might be useful to you]{%
  \AtEndDocument{%
    \nag@ifcsname{ver@#2.sty}{%
     % Attaboy!
    }{%
    \nag@suggestNoLine{%
      Not loaded: Package #2 #1}%
    }%
  }%
}%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\IncompatiblePackages}
%    Usage: |\IncompatiblePackages|\oarg{reason}\marg{package}\marg{package}\marg{hint}
%    \begin{macrocode}
\newcommand\IncompatiblePackages[4][are incompatible]{%
  \AtEndDocument{%
    \nag@ifcsname{ver@#2.sty}{%
      \nag@ifcsname{ver@#3.sty}{%
        \nag@warnNoLine{%
          Packages #2 and #3 #1.\MessageBreak
          #4}%
      }{}%
    }{}
  }%
}%
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\ObsoleteClass}
%    Usage: |\ObsoleteClass|\oarg{reason}\marg{class}\marg{%
%    alternative}. Mark \meta{class} as obsolete. \meta{reason} defaults
%    to obsolete. If the \meta{class} is used anyway, at the end of
%    the compilation, the following warning will be displayed:
%
%    \noindent|Class |\meta{class}| is |\meta{reason}|. Use |
%    \meta{alternative}| instead.|
%    \begin{macrocode}
\newcommand\ObsoleteClass[3][obsolete]{%
  \AtEndDocument{%
% |\@clsextension| is onlypreamble, for some reason.
    \nag@ifcsname{ver@#2.cls}{%
    \nag@warnNoLine{%
      Class #2 is #1.\MessageBreak
      Use #3 instead}%
    }{}%
  }%
}
%    \end{macrocode} 
%    \end{macro}
%
%    \begin{macro}{\BadFileLoadOrder}
%    \begin{macrocode}
\def\nag@quark{\nag@quark}
\ifx\@listfiles\@undefined
  % emulate a silent listfiles
  \def\@listfiles#1\@@{}%
\fi
\newcommand\BadFileLoadOrder[3][This might cause problems]{%
  \AtEndDocument{%
    \nag@ifLoadOrder{#2}{#3}{%
      \nag@warnNoLine{%
        `#3' loaded after `#2'.\MessageBreak
        #1}%
    }%
  }%
}
\def\nag@ifLoadOrder#1#2{%
  \def\nag@tmporder@a ##1#1##2\relax{%
    \ifx\nag@quark##2\nag@quark
      \noexpand\@gobble
    \else
      \nag@tmporder@b ##2,#2\relax
    \fi
  }%
  \def\nag@tmporder@b ##1#2##2\relax{%
    \ifx\nag@quark##2\nag@quark
      \noexpand\@gobble
    \else
      \noexpand\@firstofone
    \fi
  }%
  \@xa\protected@edef\@xa\nag@tmporder\@xa{\@xa\nag@tmporder@a\@filelist,,#1\relax}%
  \nag@tmporder
}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Common float errors and no-nos.}
%
%    We do the following: 
%    \begin{itemize}
%      \item check for presence of a caption 
%      \item check for absence of the center environment
%      \item check that a label comes only after a caption 
%    \end{itemize}
%
%    First of all, we define two ifs to memorize whether we have a
%    label and/or a caption in the float already. Package writers may
%    want to set these manually behind \pkg{nag}'s back. In this
%    way, they can suppress possible warnings if they know what
%    they're doing -- we only check at the end of the float
%    environment, which gives them plenty of time to call 
%    |\csname nag@haslabeltrue\endcsname| et al. 
%    (Thanks to Markus Kohm for pointing out this need.)
%    We initialize |\nag@hascaption| to be true because since 0.60,
%    |\label| always checks if it's after a caption, even outside of
%    floats.
%    \begin{macrocode}
\newif\ifnag@haslabel 
\newif\ifnag@hascaption\nag@hascaptiontrue
%    \end{macrocode}
%    Now, to the work proper: as of 0.60, it is sufficient to set the
%    label and caption flags to false. |\endcenter| now always checks
%    if it is inside a float (looking at |\@captype|). The label and
%    caption commands are amended only once. This should be
%    sufficient: captions are not handled by letting |\caption| to the
%    proper command upon float entry, so we assume nobody redefines
%    |\caption| at runtime, or they provide more entries to
%    |\nag@captions|. Similar for |\label|, and we do not care about
%    the flag setting outside of floats.
%    \begin{macrocode}
\newcommand\nag@hackfloat[1]{%
  \nag@prepend{#1}{%
    \global\nag@haslabelfalse\global\nag@hascaptionfalse
  }%
  \nag@prepend{end#1}{%
    \ifnag@hascaption\relax\else
      \nag@warn%
	  {#1 with no \protect\caption}%
    \fi
    % labels outside floats shouldn't complain:
    \global\nag@hascaptiontrue
    % (we do this always because it needs to be global)
  }%  
}
%    \end{macrocode}
%    Add checks to all macros named by |\nag@labels|
%    and |\nag@captions|, respectively.    
%    \changes{0.3}{2005/07/07}{Fixed missing globals}
%    Scoping of presence-of-caption information:
%    \changes{0.4}{2006/04/19}{bugfix}
%    Well, maybe I should do it the way the kernel does, which means
%    a label is just as local as |\refstepcounter|'s |\@currentlabel|
%    information as of v0.4. I think we can leave captions global.
%    \changes{0.60}{2007/03/31}{Captions/Labels now done only once, and not every time
%    we enter a float}
%    \changes{0.60}{2007/03/31}{@preamblecmds}
%    Big old hack: we do this at |\@preamblecmds|-time, which is after
%    |\AtBeginDocument|, since hyperref loads nameref ABD, and nameref
%    steps all over label. \emph{Note:} We cannot use |\nag@prepend|
%    for this, since it would break the pkgindoc package, which nobody
%    has ever heard of, but it's in the kernel and relies on certain
%    tokens being present in the expansion of |\@preamblecmds|. Now,
%    you pretty much cannot get any later than this.
%
%    \emph{Note:} we cannot exchange the order of the for loops here:
%    if a cs generates both a label and a caption, it shouldn't get
%    complained about.
%    \begin{macrocode}
\AtBeginDocument{%
\g@addto@macro{\@preamblecmds}{%
  \@for\labelprovider:=\nag@labels\do{%
    \ifx\labelprovider\@empty\else
    \nag@prepend{\labelprovider}%
	        {\nag@captioncheck\nag@haslabeltrue}%
    \fi                       
  }%
  \@for\captionprovider:=\nag@captions\do{%
    \ifx\captionprovider\@empty\else
      \nag@prepend{\captionprovider}{\global\nag@hascaptiontrue}%
    \fi
  }%
}%
}
\newcommand\nag@captioncheck{%
  \ifnag@hascaption\else
  \nag@warn{\protect\label\space in float, but not after
    \protect\caption}%
  \fi
}
%    \end{macrocode}
%    Define the lists of commands that are floats, generate labels,
%    and generate captions, respectively. We don't start with defined
%    floats (that is for nag-l2tabu.cfg to set up). Since v0.52, we handle
%    an empty name, so the lists may be empty. Also, no labels and
%    captions are provided by default since v0.52. This has been moved
%    to nag-l2tabu.cfg. 
%    See also
%    |\NagDeclareFloat|, which is the user-level wrapper for new
%    floats. Since there are no packages to define new 
%    caption or label commands on an user level, there is no wrapper
%    for those.
%    \begin{macrocode}
\def\nag@floats{} 
\def\nag@labels{}
\def\nag@captions{}
%    \end{macrocode}
%
%    We call the above for each float environment named via
%    |\nag@floats|:
%    \begin{macrocode}
\newcommand\nag@floatsetup{%
  \@for\flo:=\nag@floats\do{%
    \ifx\flo\@empty\else
      \@xa\nag@hackfloat\@xa{\flo}%
    \fi
  }%
}
%    \end{macrocode}
%    but only after all other packages get their chance to add to the
%    list:
%    \begin{macrocode}
\AtBeginDocument{% 
  \nag@floatsetup
}
%    \end{macrocode}
%
%     At the very end, we will display a running total of complaints.
%    \begin{macrocode}
\AtBeginDocument{%
  \AtEndDocument{%
    \ifnum\value{nag@sins}>0%
    \PackageWarningNoLine{nag}{\arabic{nag@sins} complaints
      in total}%
    \else
    \typeout{No complaints by nag.}%
    \fi
  }%
}
%    \end{macrocode}
%
%    \section{Switch vs. Environment}
%    
%    People often use switches as environments and vice versa. This is
%    dangerous in because it tends to \emph{almost} work.
%    (Consider font size commands in particular, but also |\centering|
%    vs. |center| environment.) As usual, ``it's not an error if you
%    know what you're doing''. In particular, it is perfectly valid
%    code to use the |\foo|\dots|\endfoo| syntax. So, |\NotASwitch|
%    needs to trace the calls to |\foo| and see if they match with
%    corresponding |\endfoo|s with its own stack. This might still be
%    brittle. Fortunately, it is currently only needed for
%    nag-orthodox, where it checks for the justification environments.
%
%    First of all, a helper macro we hinge upon:
%    \changes{0.53}{2007/03/20}{bugfix: more Robustness. (J\"org Sommer)}
%    \begin{macrocode}
\DeclareRobustCommand\nag@ifCurrentEnvironment[3]{%
  \bgroup
  \def\tmp@a{#1}%
  \ifx\@currenvir\tmp@a
    #2%
  \else
    #3%
  \fi
  \egroup
}
%    \end{macrocode}
%    And now, the two variations there are:
%    \begin{macro}{\NotAnEnvironment}
%    Usage:|\NotAnEnvironment|\marg{command}
%    Issue an error if the user calls |\begin{command}| and not
%    |\command| directly.
%    \begin{macrocode}
\newcommand\NotAnEnvironment[1]{%
  \AtBeginDocument{%
    \nag@prepend{#1}{%
      \nag@ifCurrentEnvironment{#1}{%
        \nag@warn{%
          There is no environment ``#1''.\MessageBreak
          Maybe you want a grouped \@backslashchar#1
        }%
      }{% OK case.
      }%
    }%
  }%
}
%    \end{macrocode}
%     \end{macro}
%    |\NotASwitch| is a bit more involved:
%    \begin{macro}{\NotASwitch}
%    Usage:|\NotASwitch|\marg{command}
%    Issue an error if the user calls |\command| and not
%    |\begin{command}| and mis-nests calls or doesn't call
%    |\endcommand| at all.
%    \changes{0.54}{2007/03/27}{bugfix: can't get around the token register. (J\"org Sommer)}
%    \begin{macrocode}
% we need to maintain a stack of environments that are used in the
% \foo...\endfoo way.
\newcommand\nag@envstack{\relax}

\DeclareRobustCommand\nag@beginenv[1]{%
  % push a begin-entry onto the stack. Form is
  % |{\foo{lineno}}| for environment foo.
  \bgroup
    \@xa\toks@\@xa{\nag@envstack}%
    \xdef\nag@envstack{%
    \@nx{%
    \@xa\@nx\csname #1\endcsname
      \@nx{\the\inputlineno\@nx}%
    \@nx}%
    \the\toks@
    }%
  \egroup
}
\DeclareRobustCommand\nag@endenv[1]{%
  % extract the first entry.
  \@xa\nag@end@nv\nag@envstack\@nil #1\@nil
}

\def\nag@end@nv#1#2\@nil #3\@nil{%
  \def\tmp@a{#1}%
  \def\tmp@b{\relax}%
  \ifx\tmp@a\tmp@b
  % This was the end-of-stack flag.
  \nag@warn{``\@backslashchar end#3'' without matching
    ``\@backslashchar #3''}
  \else
    % We may assume this is a proper entry. See if the begin-token on
    % the stack matches what |\nag@endenv| was passed.
    \@xa\ifx\csname #3\@xa\endcsname\@firstoftwo #1%
      %OK case, just pop the entry.
      \gdef\nag@envstack{#2}%
    \else
    % error case
    \nag@warn{%
      You cannot close ``\@xa\string\@firstoftwo #1'' on line
      \@secondoftwo #1 with ``\@backslashchar end#3''%
    }%
    % leave it on the stack. Some case of misnesting will always cause
    % horrible amounts of follow-up errors. Also, scare them!
    \fi
  \fi
}
%    \end{macrocode}
%    At the end, we complain about all the entries that are still on
%    the stack. 
%    \begin{macrocode}
\AtEndDocument{%
  \@xa\@tfor\@xa\looseends\@xa:\@xa=\nag@envstack\do{%
    \@xa\ifx\looseends\relax\else
      \nag@warnNoLine{Unmatched 
        ``\@xa\@xa\@xa\string\@xa\@firstoftwo\looseends'' 
        command on line
        \@xa\@xa\@xa\string\@xa\@secondoftwo\looseends%
      }%
    \fi
  }%
}
%    \end{macrocode}
%      \end{macro}
% Now, the user-side command is easy.
%    \begin{macrocode}
\newcommand\NotASwitch[1]{%
  \AtBeginDocument{%
    \nag@prepend{#1}{%
      \nag@beginenv{#1}%
    }%
    \nag@prepend{end#1}{%
      \nag@endenv{#1}%
    }%
  }%
}
%    \end{macrocode}
%
%    \section{Compatibility issues}
%    \subsection{The \pkg{caption} package}
%    Axel Sommerfeldt's \pkg{caption} package loads the \pkg{ragged2e}
%    package AtBeginDocument (regardless of whether it is needed).
%    This is too late for us to amend the |\RaggedFoo| commands with
%    |\NotAnEnvironment|. Since v0.51 of \pkg{nag}, they will then be
%    skipped (with information in the log). Earlier versions would
%    fail because by time \pkg{ragged2e} was loaded, the commands were
%    already defined by the amendment process. To make sure the
%    commands \emph{are} amended, load \pkg{ragged2e} explicitly
%    yourself. 
%
%    \subsection{The \pkg{subfig} package}
%    Starting with v0.52 of \pkg{nag}, we recognize the fact that the
%    |\subfloat| command from Steven D. Cochran's \pkg{subfig} package
%    is a caption-provider for its fourth argument. Earlier versions
%    would flag use of |\label| as inappropriate. The current
%    implementation works with versions close enough to v1.3 of
%    \pkg{subfig}. Since the change is a one-liner, I hope it will be
%    integrated into future versions of \pkg{subfig}.
%    \changes{0.52}{2007/02/25}{twiddle subfig's bowels}
%    \begin{macrocode}
\AtBeginDocument{%
  \nag@ifcsname{ver@subfig.sty}{%
    \PackageInfo{nag}{Attempting subfig hack\@gobble}%
    \nag@maybehacksubfig
  }{%
  }%
}
\def\nag@maybehacksubfig{%
  %
  % of course, i need to touch the single longest definition in
  % subfig.sty, to amend one single command...
  %
  % The definition is taken from subfig.sty 1.3 dated 2005/07/05 by
  % S.D. Chochran, where it is called sf@@@subfloat, and appears here
  % under the conditions of section 6 of the LPPL 1.3. The subfig
  % package is available on a CTAN mirror near you.
  %
  \long\def\nag@@original@@sf@@@subfloat##1[##2][##3]##4{%
    \@ifundefined{FBsc@max}{%
    }{%
      \FB@readaux{\let\FBsuboheight\relax}%
    }%
    \@tempcnta=\@ne
    \if@minipage
      \@tempcnta=\z@
    \else\ifdim \lastskip=\z@ \else
        \@tempcnta=\tw@
    \fi\fi
    \ifmaincaptiontop
      \sf@top=\sf@nearskip
      \sf@bottom=\sf@farskip
    \else
      \sf@top=\sf@farskip
      \sf@bottom=\sf@nearskip
    \fi
    \leavevmode
    \setbox\@tempboxa \hbox{%
      ##4}%
    \@tempdima=\wd\@tempboxa
    \@ifundefined{FBsc@max}{%
    }{%
      \global\advance\Xhsize-\wd\@tempboxa
      \dimen@=\ht\@tempboxa
      \advance\dimen@\dp\@tempboxa
      \ifdim\dimen@>\FBso@max
      \global\FBso@max\dimen@
      \fi
    }%
    \vtop\bgroup
      \vbox\bgroup
        \ifcase\@tempcnta
        \@minipagefalse
        \or
          \vskip\sf@top
        \or
          \ifdim \lastskip=\z@ \else
            \@tempskipb\sf@top\relax\@xaddvskip
          \fi
        \fi
        \sf@ifpositiontop{%
          \ifx \@empty##3\relax \else
            \sf@subcaption{##1}{##2}{##3}%
            \vskip\sf@capskip
            \vskip\sf@captopadj
          \fi\egroup
          \hrule width0pt height0pt depth0pt
          \box\@tempboxa
        }{%
          \@ifundefined{FBsc@max}{%
            \box\@tempboxa
          }{%
            \ifx\FBsuboheight\relax
              \box\@tempboxa
            \else
              \vbox to \FBsuboheight{\FBafil\box\@tempboxa\FBbfil}%
            \fi}%
          \egroup
        \ifx \@empty##3\relax \else
          \vskip\sf@capskip
          \hrule width0pt height0pt depth0pt
          \sf@subcaption{##1}{##2}{##3}%
        \fi
        }%
        \vskip\sf@bottom
      \egroup
      \@ifundefined{FBsc@max}{%
      }{%
        \addtocounter{FRobj}{-1}%
        \ifnum\c@FRobj=0\else
          \subfloatrowsep
        \fi
      }%
      \ifmaincaptiontop\else
        \global\advance\@nameuse{c@\@captype}\m@ne
      \fi
      \endgroup\ignorespaces}%
  %
  \expandafter\ifx\csname sf@@@subfloat\endcsname\nag@@original@@sf@@@subfloat
    % yup, that's it.
    \PackageInfo{nag}{OK, equivalent to subfig 1.3, redefining
      \@backslashchar sf@@@subfloat\@gobble}%
    \global\long\def\sf@@@subfloat##1[##2][##3]##4{%
      \@ifundefined{FBsc@max}{%
    }{%
      \FB@readaux{\let\FBsuboheight\relax}%
    }%
    \@tempcnta=\@ne
    \if@minipage
      \@tempcnta=\z@
    \else\ifdim \lastskip=\z@ \else
        \@tempcnta=\tw@
    \fi\fi
    \ifmaincaptiontop
      \sf@top=\sf@nearskip
      \sf@bottom=\sf@farskip
    \else
      \sf@top=\sf@farskip
      \sf@bottom=\sf@nearskip
    \fi
    \leavevmode
    \setbox\@tempboxa \hbox{%
      %% ulmi: new 2007/02/25: #4 may contain label command
      \csname nag@hascaptiontrue\endcsname
      %% and that was it.
      ##4}%
    \@tempdima=\wd\@tempboxa
    \@ifundefined{FBsc@max}{%
    }{%
      \global\advance\Xhsize-\wd\@tempboxa
      \dimen@=\ht\@tempboxa
      \advance\dimen@\dp\@tempboxa
      \ifdim\dimen@>\FBso@max
      \global\FBso@max\dimen@
      \fi
    }%
    \vtop\bgroup
      %% ulmi: new 2007/05/10: #2, #3 may contain label command
      \csname nag@hascaptiontrue\endcsname
      %% and that was it.
      \vbox\bgroup
        \ifcase\@tempcnta
        \@minipagefalse
        \or
          \vskip\sf@top
        \or
          \ifdim \lastskip=\z@ \else
            \@tempskipb\sf@top\relax\@xaddvskip
          \fi
        \fi
        \sf@ifpositiontop{%
          \ifx \@empty##3\relax \else
            \sf@subcaption{##1}{##2}{##3}%
            \vskip\sf@capskip
            \vskip\sf@captopadj
          \fi\egroup
          \hrule width0pt height0pt depth0pt
          \box\@tempboxa
        }{%
          \@ifundefined{FBsc@max}{%
            \box\@tempboxa
          }{%
            \ifx\FBsuboheight\relax
              \box\@tempboxa
            \else
              \vbox to \FBsuboheight{\FBafil\box\@tempboxa\FBbfil}%
            \fi}%
          \egroup
        \ifx \@empty##3\relax \else
          \vskip\sf@capskip
          \hrule width0pt height0pt depth0pt
          \sf@subcaption{##1}{##2}{##3}%
        \fi
        }%
        \vskip\sf@bottom
      \egroup
      \@ifundefined{FBsc@max}{%
      }{%
        \addtocounter{FRobj}{-1}%
        \ifnum\c@FRobj=0\else
          \subfloatrowsep
        \fi
      }%
      \ifmaincaptiontop\else
        \global\advance\@nameuse{c@\@captype}\m@ne
      \fi
      \endgroup\ignorespaces}%
    \else
        \PackageInfo{nag}{Not redefining sf@@@subfloat, it looks odd\@gobble}
    \fi
}
%    \end{macrocode}
%
%    \subsection{The \pkg{float} package}
%    Sorry, there is no way for \pkg{nag} to automatically add new
%    float types to check them for captions. However, since v0.52,
%    there is an user-level command |\NagDeclareFloat| that will do
%    the bookkeeping for you, i.e. after your call to |\newfloat|, you
%    call |\NagDeclareFloat| with the first argument to |\newfloat|.
%    \changes{0.52}{2007/02/25}{Command NagDeclareFloat added}
%    \begin{macrocode}
\newcommand*\NagDeclareFloat[1]{\g@addto@macro\nag@floats{,#1}}
%    \end{macrocode}
%
%    \subsection{The \pkg{topcapt} package and the \pkg{subfig} package}
%    nagdemo exhibits an error when topcapt and subfig are used
%    together, i.e. \pkg{subfig} thinks the caption has not been
%    stepped already. This is not a bug in \pkg{nag}.
%
%    \subsection{The \pkg{rotating} package}
%    \pkg{rotating} uses \cmd{\centerline} to place rotated floats. As
%    far as I can see, the usage is legitimate there, and using
%    \cmd{\centering} instead would change behaviour when the float's
%    dimension are larger than the text body. (Currently, the height
%    of the figure may exceed \cmd{\textwidth} without warning.) If this
%    bothers you, go read the warning on p.~\pageref{disclaimer} again.
%   
%    \subsection{Version control packages}
%    Common version control systems like rcs, cvs, svn insert their keywords
%    between dollar signs. Packages that parse these keywords define their
%    commands and usually assume catcode 3, which is not true if either
%    \pkg{onlyamsmath} or \pkg{nag} is loaded. Special handling is
%    introduced for \pkg{rcs} and \pkg{svninfo}. In case of \pkg{rcsinfo},
%    \pkg{svn} and \pkg{pgf} (yes, it's got internal VC handling that fails
%    when \cmd{\pgfuselibrary} is used outside the preamble -- thanks to 
%    Ralf Th\"ole for spotting this one), dollar checking is disabled.
%
%    \section{Loading extensions}
%    Finally, we deal with package options.
%    This is simple: just try to input appropriate nag files.
%    \changes{0.4}{2006/04/19}{config file names changed to free extension}
%    \begin{macrocode}
\DeclareOption*{%
  \InputIfFileExists{nag-\CurrentOption.cfg}{%
    \PackageInfo{nag}{%
      Loaded nag-\CurrentOption.cfg
    }
  }{%
    \InputIfFileExists{\CurrentOption.nag}{%
      \PackageWarningNoLine{nag}{%
        Loaded old-style config file \CurrentOption.nag.\MessageBreak
        Consider renaming the file to nag-\CurrentOption.cfg
      }%
    }{%
      \PackageWarningNoLine{nag}{Required ruleset
        \CurrentOption, and it wasn't there}
    }%
  }
}
\ProcessOptions*
%    \end{macrocode}
%\iffalse
%</nag>
%\fi
% \PrintChanges
%\PrintIndex
%\Finale
%\iffalse
%%X Local Variables:
%%X mode: latex
%%X End:
%\fi