summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nag/nag.sty
blob: a627c9b02929db60f2d410344db4ec9684ee9f42 (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
%%
%% This is file `nag.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nag.dtx  (with options: `nag')
%% This is a generated file.
%% 
%% This file is part of the `nag' package.
%% The `nag' package has the LPPL maintenance status: maintained.
%% Current Maintainer is Ulrich M. Schwarz, ulmi@absatzen.de
%% 
%% Copyright (C) 2005-8 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 of this license or (at your option) any later
%% version. The latest version of this license is in:
%% http://www.latex-project.org/lppl.txt
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nag}[2010/05/17 0.622 warning about old commands (ulmi)]
\let\@xa\expandafter
\let\@nx\noexpand
\newcounter{nag@c}
\renewcommand\thenag@c{\roman{nag@c}}%
\setcounter{nag@c}{1}%
\begingroup
  \let\@addtoreset\@gobbletwo
  \newcounter{nag@sins}%
\endgroup
\newcommand\nag@ifundefined[1]{%
  \begingroup
  \@ifundefined{#1}{\endgroup\@firstoftwo}{\endgroup\@secondoftwo}%
}
\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
    \stepcounter{nag@c}%
  }%
}
\newcommand\nag@pr@p@nd[3]{%
  \def#1{#3#2}%
}
\DeclareRobustCommand\nag@warn{%
  \addtocounter{nag@sins}{1}%
  \PackageWarning{nag}%
}
\DeclareRobustCommand\nag@warnNoLine{%
  \addtocounter{nag@sins}{1}%
  \PackageWarningNoLine{nag}%
}
\newcommand\ObsoleteCS[3][obsolete]{%
  \AtBeginDocument{%
    \nag@prepend{#2}{%
      \nag@warn{%
Command \@backslashchar#2 is #1.
\MessageBreak
Use #3 instead}%
    }%
  }%
}
\newcommand\ObsoleteEnv[3][obsolete]{%
  \AtBeginDocument{%
    \nag@prepend{#2}{%
      \nag@warn{%
Environment #2 is #1.
\MessageBreak
Use #3 instead}%
    }%
  }%
}
\newcommand\nag@ifcsname[3]{%
  \begingroup\@ifundefined{#1}{#3}{#2}\endgroup
}
\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
  }%
  \global\let\nag@ifcsname\nag@ifcsname
}{}
\newcommand\ObsoletePackage[3][obsolete]{%
  \AtEndDocument{%
    \nag@ifcsname{ver@#2.sty}{%
    \nag@warnNoLine{%
      Package #2 is #1.\MessageBreak
      Use #3 instead}%
    }{}%
  }%
}
\newcommand\ObsoleteClass[3][obsolete]{%
  \AtEndDocument{%
    \nag@ifcsname{ver@#2.cls}{%
    \nag@warnNoLine{%
      Class #2 is #1.\MessageBreak
      Use #3 instead}%
    }{}%
  }%
}
\newif\ifnag@haslabel
\newif\ifnag@hascaption\nag@hascaptiontrue
\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)
  }%
}
\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
}
\def\nag@floats{}
\def\nag@labels{}
\def\nag@captions{}
\newcommand\nag@floatsetup{%
  \@for\flo:=\nag@floats\do{%
    \ifx\flo\@empty\else
      \@xa\nag@hackfloat\@xa{\flo}%
    \fi
  }%
}
\AtBeginDocument{%
  \nag@floatsetup
}
\AtBeginDocument{%
  \AtEndDocument{%
    \ifnum\value{nag@sins}>0%
    \PackageWarningNoLine{nag}{\arabic{nag@sins} complaints
      in total}%
    \else
    \typeout{No complaints by nag.}%
    \fi
  }%
}
\DeclareRobustCommand\nag@ifCurrentEnvironment[3]{%
  \bgroup
  \def\tmp@a{#1}%
  \ifx\@currenvir\tmp@a
    #2%
  \else
    #3%
  \fi
  \egroup
}
\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.
      }%
    }%
  }%
}
\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
}
\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
  }%
}
\newcommand\NotASwitch[1]{%
  \AtBeginDocument{%
    \nag@prepend{#1}{%
      \nag@beginenv{#1}%
    }%
    \nag@prepend{end#1}{%
      \nag@endenv{#1}%
    }%
  }%
}
\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
}
\newcommand*\NagDeclareFloat[1]{\g@addto@macro\nag@floats{,#1}}
\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*
%%X Local Variables:
%%X mode: latex
%%X End:
\endinput
%%
%% End of file `nag.sty'.