Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Obsolete LaTeX Commands and Packages: A Warning List, Papers of Microbiology

Outdated and superseded latex commands, classes, and packages, along with their alternatives. It also includes a warning system that alerts users when these obsolete elements are used in their latex documents.

Typology: Papers

Pre 2010

Uploaded on 08/31/2009

koofers-user-sqe
koofers-user-sqe 🇺🇸

10 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The nag package
Ulrich Michael Schwarz
July 30, 2009
Abstract
Old habits die hard. All the same, there are commands, classes and packages
which are outdated and superseded. 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 l2tabu.
Contents
1 User-sideconsiderations. 2
1.1 Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Known bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 nag-l2tabu.cfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 nag-orthodox.cfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 nag-abort.cfg .................................. 7
1.7 nag-experimental.cfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Author-side considerations and implementation. 10
2.1 Low-level tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Obsoletifying commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Obsoletifying packages and classes. . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Common float errors and no-nos. . . . . . . . . . . . . . . . . . . . . . . . 13
3 Switch vs. Environment 16
4 Compatibility issues 18
4.1 The caption package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2 The subfig package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 The float package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4 The topcapt package and the subfig package . . . . . . . . . . . . . . . . . 22
4.5 The rotating package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.6 Version control packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
This document corresponds to nag 0.61, dated 2008/02/10. Other versions can be found at
http://absatzen.de/
ulmi@absatzen.de
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Obsolete LaTeX Commands and Packages: A Warning List and more Papers Microbiology in PDF only on Docsity!

The nag package

Ulrich Michael Schwarz†

July 30, 2009

Abstract Old habits die hard. All the same, there are commands, classes and packages

which are outdated and superseded. 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 l2tabu.

Contents

1 User-side considerations. 2

1.1 Installation..................................... 2

1.2 Usage......................................... 2

1.3 Known bugs.................................... 2

1.4 nag-l2tabu.cfg................................. 2

1.5 nag-orthodox.cfg............................... 7

1.6 nag-abort.cfg.................................. 7

1.7 nag-experimental.cfg............................ 8

2 Author-side considerations and implementation. 10

2.1 Low-level tools................................... 10

2.2 Obsoletifying commands............................. 11

2.3 Obsoletifying packages and classes....................... 12

2.4 Common float errors and no-nos........................ 13

3 Switch vs. Environment 16

4 Compatibility issues 18

4.1 The caption package............................... 18 4.2 The subfig package................................ 18 4.3 The float package................................. 22 4.4 The topcapt package and the subfig package................. 22 4.5 The rotating package............................... 23

4.6 Version control packages............................ 23

∗This document corresponds to nag 0.61, dated 2008/02/10. Other versions can be found at

http://absatzen.de/ †ulmi@absatzen.de

5 Loading extensions 23

1 User-side considerations.

1.1 Installation.

Process nag.ins with LATEX to obtain some files: nag.sty and 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 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 nag.dtx to obtain this documentation, including the implemena-

tion docs. (This is recommended if you plan to extend nag to handle your own pack-

ages.) nagdemo.tex is a horrible document that will show you many of the warnings

that nag can generate.

1.2 Usage.

Add the following to the beginning your main document (Comments and \listfiles

can be safely left before it, though):

\RequirePackage[l2tabu, orthodox]{nag}

This will check for many common mistakes, and give some hints on what to use in-

stead. 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.

1.3 Known bugs

currently none.

1.4 nag-l2tabu.cfg

In a nutshell, nag-l2tabu.cfg detects the following:

  • Usage of the 2.09-style font commands \it, \bf, \rm, \sc, \sl, \tt and \cal.
  • Usage of \centerline.
  • Usage of the outdated packages epsfig, psfig, epsf, doublespace, fancyheadings, scrpage, umlaut, isolatin, isolatin1, t1enc, caption2, psfonts, mathptm, times, palatino, mathpple, euler and utopia, and of the outdated class scrlttr.
  • Figures and tables without caption (this is not technically in l2tabu, but the peo-

ple who have floats without captions tend to ask “Why is LATEX moving my pic-

tures away from where I put them?”), labels within floats that do not reference

the caption, and usage of the center environment within floats.

35 \nag@singledollar}% 36 }% 37 }{% 38 %% in pdf context, just be a math shift. This creates the "math 39 %% shift not allowed" warnings we all love. 40 \nag@singledollar 41 }% 42 }

If the user doesn’t load hyperref, we have to fake its \texorpdfstring command. Note that this will break any package that is foolish enough to detect hyperref by testing for

definedness of \texorpdfstring.

43 \AtBeginDocument{\providecommand\texorpdfstring{@firstoftwo}} 44 \AtBeginDocument{\catcode‘$\active}%$

Now, the proper testing. (Yes, the above is just the technicalities.) We use the kernel’s

@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\letting @sptoken to something that cannot legally appear in

the source.

45 \bgroup 46 \catcode‘$\active%$ 47 \gdef\nag@maybe@dispmath{% 48 \bgroup 49 \let@sptoken\nag@quark% prevent skipping of spaces 50 @ifnextchar${%$% 51 \ifmmode 52 % we already warned upon entering. 53 \else 54 \nag@warn{% 55 \nag@doubledollar...\nag@doubledollar\space is obsolete.\MessageBreak 56 Use \string[...\string] et al. instead}% 57 \fi 58 \egroup\expandafter\nag@doubledollar@gobble 59 }{% 60 \egroup\nag@singledollar 61 }% 62 } 63 % we do the assignment here, which means any package that redefines 64 % $ as well will silently disable us. This is a feature. 65 \global\let$\nag@maybedispmath%$ 66 \egroup

new in 2.1alpha1: more compat testing. Version control keywords are dollar-delimited.

all five implementations get it wrong.

67 \AtBeginDocument{% 68 @ifpackageloaded{rcs}{% 69 % this redefinition is functionally equivalent, 70 % but does not share actual code. 71 \renewcommand\RCS{\bgroup%

72 \catcode‘_ =\active 73 \catcode‘$=3 % this line added for compatibility. 74 \csname RCS_get_argument\endcsname 75 } 76 \PackageInfo{nag}{rcs.sty hack applied}% 77 }{}% 78 @ifpackageloaded{svninfo}{% 79 \g@addto@macro@svnBeginRead{\catcode‘$ 3 }% 80 \PackageInfo{nag}{svninfo.sty hack applied}% 81 }{}% 82 @ifpackageloaded{svn}{% 83 \PackageInfo{nag}{svn.sty is broken: disabling dollar check}% 84 \catcode‘$ 3 85 }{}% 86 @ifpackageloaded{rcsinfo}{% 87 \PackageInfo{nag}{rcsinfo.sty is broken: disabling dollar check}% 88 \catcode‘$ 3 89 }{}% 90 @ifpackageloaded{pgf}{% 91 \PackageInfo{nag}{pgf.sty is broken: disabling dollar check}% 92 \catcode‘$ 3 93 }{}% 94 } 95 96 97 %% \S 1.7 cannot reasonably be checked programmatically 98 %% \S 1.8 \sloppy is called by parbox, among others, and would 99 %% give many spurious warnings. 100 %% \S 2.1. 101 \ObsoleteCS[an old LaTeX 2.09 command]{bf} 102 {\protect\bfseries\space or \protect\textbf} 103 \ObsoleteCS[an old LaTeX 2.09 command]{it} 104 {\protect\itshape\space or \protect\textit} 105 \ObsoleteCS[an old LaTeX 2.09 command]{rm} 106 {\protect\rmfamily\space or \protect\textrm} 107 \ObsoleteCS[an old LaTeX 2.09 command]{sc} 108 {\protect\scshape\space or \protect\textsc} 109 \ObsoleteCS[an old LaTeX 2.09 command]{sf} 110 {\protect\sffamily\space or \protect\textsf} 111 \ObsoleteCS[an old LaTeX 2.09 command]{sl} 112 {\protect\slshape\space or \protect\textsl} 113 \ObsoleteCS[an old LaTeX 2.09 command]{tt} 114 {\protect\ttfamily\space or \protect\texttt} 115 \ObsoleteCS[an old LaTeX 2.09 command]{cal} 116 {\protect\mathcal}% Hmm, this is not in l2tabu? 117 %% \S 2.1. 118 %% Gone with 1.8 because this never worked for the kernel \frac anyway. 119 %% \ObsoleteCS[TeX]{over}{\protect\frac} 120 %% \ObsoleteCS[TeX]{choose}{\protect\frac\space or amsmath’s \protect\binom} 121 %% \S 2.1.

172 % \changes{0.53}{2007/03/21}{topcapt support.} 173 \g@addto@macro\nag@captions{,caption,captionabove,captionbelow,hc@caption,topcaption}% 174 175 %% \S 3. 176 \NotAnEnvironment{appendix}% 177 %% In the same vein: 178 @for\sectioning:=frontmatter,mainmatter,backmatter\do{% 179 \expandafter\NotAnEnvironment\expandafter{\sectioning}% 180 } 181 %% \S 3. 182 %% It’s more trouble than it’s worth to have another warning for 183 %% align*, since it passes through align. 184 \ObsoleteEnv{eqnarray}{amsmath’s align} 185 %% \S 3.4 -- nothing to be done --

1.5 nag-orthodox.cfg

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 \par, spurious spaces might occur since the switches don’t

\ignorespaces), and, conversely, the usage of center etc. environments as unclosed

switches. (Detection of the latter might still be somewhat brittle.)

186 \ProvidesFile{nag-orthodox.cfg} 187 [2006/04/19 v1.8 strict rules for nag.sty (ulmi)] 188 @for\fontcmd:=tiny,small,footnotesize,normalsize,large,Large,% 189 LARGE,huge,Huge\do{% 190 \expandafter\NotAnEnvironment\expandafter{\fontcmd}% 191 }% 192 @for\fontcmd:=sffamily,rmfamily,ttfamily,% 193 bfseries,mdseries,scshape,% 194 itshape,upshape\do{% 195 \expandafter\NotAnEnvironment\expandafter{\fontcmd}% 196 }% 197 @for\justsw:=centering,raggedleft,raggedright,% 198 RaggedLeft,RaggedRight\do{% 199 \expandafter\NotAnEnvironment\expandafter{\justsw}% 200 } 201 @for\justenv:=center,flushleft,flushright\do{% 202 \expandafter\NotASwitch\expandafter{\justenv}% 203 }

1.6 nag-abort.cfg

Requesting this nag file will turn all complaints into errors.

204 \ProvidesFile{nag-abort.cfg} 205 [2007/11/10 v0.2 treat complaints as errors (ulmi)] 206 \DeclareRobustCommand\nag@warn[1]{%

207 \addtocounter{nag@sins}{1}% 208 \PackageError{nag}{#1}{#1}% 209 } 210 \DeclareRobustCommand\nag@warnNoLine[1]{% 211 \addtocounter{nag@sins}{1}% 212 \PackageError{nag}{#1}{#1}% 213 }

1.7 nag-experimental.cfg

Functionality that needs more testing.

214 \ProvidesFile{nag-experimental.cfg} 215 [2009/07/04 v0.62alpha2 experimental additions to nag (ulmi)]

Check if a float that may be positioned b is actually small enough for bottomfraction

etc.

216 \let@xa\expandafter 217 \newif\ifnag@dofloatsizecheck 218 \newif\ifnag@allfloatpositionsfailed 219 \newcommand\nag@allfloatsizechecks{}% 220 \newcommand\nag@onefloatsizecheck[2]{% 221 % #1 is size fraction of textheight, 222 % #2 is position to say in warning. 223 \ifdim \ht@currbox>#1\textheight 224 @tempdima -#1\textheight 225 \advance @tempdima \ht@currbox 226 \PackageInfo{nag}{Float too large for #2 by \the@tempdima}% 227 % note we do not truncate. 228 % also, it’s too late to add "p" now. 229 \else 230 \nag@allfloatpositionsfailedfalse 231 \fi 232 } 233 % @currbox is current float box, 234 % @fps is the current list of float specifiers. 235 \renewcommand@largefloatcheck{% 236 \ifdim \ht@currbox>\textheight 237 @tempdima -\textheight 238 \advance @tempdima \ht@currbox 239 @latex@warning {Float too large for page by \the@tempdima}% 240 \ht@currbox \textheight 241 \fi 242 %% the preceding is the original check. 243 \nag@dofloatsizechecktrue 244 \nag@allfloatpositionsfailedtrue 245 \def\nag@allfloatsizechecks{}% 246 @xa@xa@xa@tfor@xa@xa@xa\nag@fltsz@tmp@xa@xa@xa:@xa@xa@xa=\csname @fps\endcsnam 247 \ifx\nag@fltsz@tmp\relax 248 \nag@dofloatsizecheckfalse 249 \fi

2 Author-side considerations and implementation.

If you are a package or class author and want to extend the range of nag (or prevent nag from criticizing your macros), please see the description below, in sections 2.

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.

2.1 Low-level tools.

Identify ourselves.

300 \NeedsTeXFormat{LaTeX2e} 301 \ProvidesPackage{nag}[2009/07/30 0.62 warning about old commands (ulmi)] 302 \let@xa\expandafter 303 \let@nx\noexpand

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.

304 \newcounter{nag@c} 305 \renewcommand\thenag@c{\roman{nag@c}}% 306 \setcounter{nag@c}{1}% 307 \begingroup 308 \let@addtoreset@gobbletwo 309 \newcounter{nag@sins}% 310 \endgroup

\nag@prepend \nag@prepend{〈 cs 〉}{〈 something 〉}: Prepend 〈 something 〉 to the macro definition of

\〈 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 (savesym))

From 0.60 α 2 on, nag is more robust about not defining commands that are not

there. Now, they’re not even relaxed.

311 \newcommand\nag@ifundefined[1]{% 312 \begingroup 313 @ifundefined{#1}{\endgroup@firstoftwo}{\endgroup@secondoftwo}% 314 }

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.... but

do log a message.

315 \newcommand\nag@prepend[2]{%

316 \nag@ifundefined{#1}{% 317 % if it doesn’t exist, don’t do anything. 318 \PackageInfo{nag}{% 319 Command @backslashchar#1\space not defined, skipping amendment% 320 }% 321 }{% 322 \nag@ifundefined{#1 }{% 323 \let\nag@maybespace@empty 324 }{% 325 \let\nag@maybespace\space 326 %\PackageInfo{nag}{% 327 % Command @backslashchar#1\space appears robust\MessageBreak 328 % Modifying ‘@backslashchar#1\space’ instead. 329 %}% 330 }% 331 @xa\let 332 \csname nag@@#1@\thenag@c@xa\endcsname 333 \csname #1\nag@maybespace\endcsname 334 @xa\DeclareRobustCommand\csname nag@@warning@\thenag@c@xa\endcsname{% 335 #2% 336 }% 337 @xa\nag@pr@p@nd\csname #1\nag@maybespace@xa\endcsname 338 \csname nag@@#1@\thenag@c@xa\endcsname 339 \csname nag@@warning@\thenag@c@xa\endcsname

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?

340 \stepcounter{nag@c}% 341 }% 342 } 343 \newcommand\nag@pr@p@nd[3]{% 344 \def#1{#3#2}% 345 }

\nag@warn All complaints to the user run through one of these two macros, with or without source

line.

346 \DeclareRobustCommand\nag@warn{% 347 \addtocounter{nag@sins}{1}% 348 \PackageWarning{nag}% 349 } 350 \DeclareRobustCommand\nag@warnNoLine{% 351 \addtocounter{nag@sins}{1}% 352 \PackageWarningNoLine{nag}% 353 }

2.2 Obsoletifying commands.

(No, I do not think that is a proper word either.)

384 % Sommer for finding this bug. 385 \expandafter\ifx\csname #1\endcsname\relax 386 \else 387 % it’s there after all 388 \let\tmp@a@firstoftwo 389 \fi 390 \fi 391 \tmp@a{#2}{#3}% 392 \endgroup 393 }%

This way of escaping the grouping gives me an even bigger grin.

394 \global\let\nag@ifcsname\nag@ifcsname 395 }{}

\ObsoletePackage Usage: \ObsoletePackage[〈 reason 〉]{〈 package 〉}{〈 alternative 〉}. Mark 〈 package 〉 as

obsolete. 〈 reason 〉 defaults to obsolete. If the 〈 package 〉 is used anyway, at the end of

the compilation, the following warning will be displayed:

Package 〈 package 〉 is 〈 reason 〉. Use 〈 alternative 〉 instead.

396 \newcommand\ObsoletePackage[3][obsolete]{% 397 \AtEndDocument{% 398 % |@clsextension| is onlypreamble, for some reason. 399 \nag@ifcsname{ver@#2.sty}{% 400 \nag@warnNoLine{% 401 Package #2 is #1.\MessageBreak 402 Use #3 instead}% 403 }{}% 404 }% 405 }

\ObsoleteClass Usage: \ObsoleteClass[〈 reason 〉]{〈 class 〉}{〈 alternative 〉}. Mark 〈 class 〉 as obsolete.

〈 reason 〉 defaults to obsolete. If the 〈 class 〉 is used anyway, at the end of the compila-

tion, the following warning will be displayed:

Class 〈 class 〉 is 〈 reason 〉. Use 〈 alternative 〉 instead.

406 \newcommand\ObsoleteClass[3][obsolete]{% 407 \AtEndDocument{% 408 % |@clsextension| is onlypreamble, for some reason. 409 \nag@ifcsname{ver@#2.cls}{% 410 \nag@warnNoLine{% 411 Class #2 is #1.\MessageBreak 412 Use #3 instead}% 413 }{}% 414 }% 415 }

2.4 Common float errors and no-nos.

We do the following:

  • check for presence of a caption
  • check for absence of the center environment
  • check that a label comes only after a caption

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 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.

416 \newif\ifnag@haslabel 417 \newif\ifnag@hascaption\nag@hascaptiontrue

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.

418 \newcommand\nag@hackfloat[1]{% 419 \nag@prepend{#1}{% 420 \global\nag@haslabelfalse\global\nag@hascaptionfalse 421 }% 422 \nag@prepend{end#1}{% 423 \ifnag@hascaption\relax\else 424 \nag@warn% 425 {#1 with no \protect\caption}% 426 \fi 427 % labels outside floats shouldn’t complain: 428 \global\nag@hascaptiontrue 429 % (we do this always because it needs to be global) 430 }% 431 }

Add checks to all macros named by \nag@labels and \nag@captions, respec-

tively. Scoping of presence-of-caption information: 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. Big old

hack: we do this at @preamblecmds-time, which is after \AtBeginDocument, since

hyperref loads nameref ABD, and nameref steps all over label. 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.

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.

432 \AtBeginDocument{% 433 \g@addto@macro{@preamblecmds}{%

471 \else 472 \typeout{No complaints by nag.}% 473 \fi 474 }% 475 }

3 Switch vs. Environment

People often use switches as environments and vice versa. This is dangerous in be-

cause it tends to 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... \endfoo syntax.

So, \NotASwitch needs to trace the calls to \foo and see if they match with corre-

sponding \endfoos with its own stack. This might still be brittle. Fortunately, it is

currently only needed for nag-orthodox, where it checks for the justification environ-

ments.

First of all, a helper macro we hinge upon:

476 \DeclareRobustCommand\nag@ifCurrentEnvironment[3]{% 477 \bgroup 478 \def\tmp@a{#1}% 479 \ifx@currenvir\tmp@a 480 #2% 481 \else 482 #3% 483 \fi 484 \egroup 485 }

And now, the two variations there are:

\NotAnEnvironment Usage:\NotAnEnvironment{〈 command 〉} Issue an error if the user calls \begin{command}

and not \command directly.

486 \newcommand\NotAnEnvironment[1]{% 487 \AtBeginDocument{% 488 \nag@prepend{#1}{% 489 \nag@ifCurrentEnvironment{#1}{% 490 \nag@warn{% 491 There is no environment ‘‘#1’’.\MessageBreak 492 Maybe you want a grouped @backslashchar# 493 }% 494 }{% OK case. 495 }% 496 }% 497 }% 498 }

\NotASwitch is a bit more involved:

\NotASwitch Usage:\NotASwitch{〈 command 〉} Issue an error if the user calls \command and not

\begin{command} and mis-nests calls or doesn’t call \endcommand at all.

499 % we need to maintain a stack of environments that are used in the 500 % \foo...\endfoo way. 501 \newcommand\nag@envstack{\relax} 502 503 \DeclareRobustCommand\nag@beginenv[1]{% 504 % push a begin-entry onto the stack. Form is 505 % |{\foo{lineno}}| for environment foo. 506 \bgroup 507 @xa\toks@@xa{\nag@envstack}% 508 \xdef\nag@envstack{% 509 @nx{% 510 @xa@nx\csname #1\endcsname 511 @nx{\the\inputlineno@nx}% 512 @nx}% 513 \the\toks@ 514 }% 515 \egroup 516 } 517 \DeclareRobustCommand\nag@endenv[1]{% 518 % extract the first entry. 519 @xa\nag@end@nv\nag@envstack@nil #1@nil 520 } 521 522 \def\nag@end@nv#1#2@nil #3@nil{% 523 \def\tmp@a{#1}% 524 \def\tmp@b{\relax}% 525 \ifx\tmp@a\tmp@b 526 % This was the end-of-stack flag. 527 \nag@warn{‘‘@backslashchar end#3’’ without matching 528 ‘‘@backslashchar #3’’} 529 \else 530 % We may assume this is a proper entry. See if the begin-token on 531 % the stack matches what |\nag@endenv| was passed. 532 @xa\ifx\csname #3@xa\endcsname@firstoftwo #1% 533 %OK case, just pop the entry. 534 \gdef\nag@envstack{#2}% 535 \else 536 % error case 537 \nag@warn{% 538 You cannot close ‘‘@xa\string@firstoftwo #1’’ on line 539 @secondoftwo #1 with ‘‘@backslashchar end#3’’% 540 }% 541 % leave it on the stack. Some case of misnesting will always cause 542 % horrible amounts of follow-up errors. Also, scare them! 543 \fi 544 \fi 545 }

574 \def\nag@maybehacksubfig{% 575 % 576 % of course, i need to touch the single longest definition in 577 % subfig.sty, to amend one single command... 578 % 579 % The definition is taken from subfig.sty 1.3 dated 2005/07/05 by 580 % S.D. Chochran, where it is called sf@@@subfloat, and appears here 581 % under the conditions of section 6 of the LPPL 1.3. The subfig 582 % package is available on a CTAN mirror near you. 583 % 584 \long\def\nag@@original@@sf@@@subfloat##1[##2][##3]##4{% 585 @ifundefined{FBsc@max}{% 586 }{% 587 \FB@readaux{\let\FBsuboheight\relax}% 588 }% 589 @tempcnta=@ne 590 \if@minipage 591 @tempcnta=\z@ 592 \else\ifdim \lastskip=\z@ \else 593 @tempcnta=\tw@ 594 \fi\fi 595 \ifmaincaptiontop 596 \sf@top=\sf@nearskip 597 \sf@bottom=\sf@farskip 598 \else 599 \sf@top=\sf@farskip 600 \sf@bottom=\sf@nearskip 601 \fi 602 \leavevmode 603 \setbox@tempboxa \hbox{% 604 ##4}% 605 @tempdima=\wd@tempboxa 606 @ifundefined{FBsc@max}{% 607 }{% 608 \global\advance\Xhsize-\wd@tempboxa 609 \dimen@=\ht@tempboxa 610 \advance\dimen@\dp@tempboxa 611 \ifdim\dimen@>\FBso@max 612 \global\FBso@max\dimen@ 613 \fi 614 }% 615 \vtop\bgroup 616 \vbox\bgroup 617 \ifcase@tempcnta 618 @minipagefalse 619 \or 620 \vskip\sf@top

621 \or 622 \ifdim \lastskip=\z@ \else 623 @tempskipb\sf@top\relax@xaddvskip 624 \fi 625 \fi 626 \sf@ifpositiontop{% 627 \ifx @empty##3\relax \else 628 \sf@subcaption{##1}{##2}{##3}% 629 \vskip\sf@capskip 630 \vskip\sf@captopadj 631 \fi\egroup 632 \hrule width0pt height0pt depth0pt 633 \box@tempboxa 634 }{% 635 @ifundefined{FBsc@max}{% 636 \box@tempboxa 637 }{% 638 \ifx\FBsuboheight\relax 639 \box@tempboxa 640 \else 641 \vbox to \FBsuboheight{\FBafil\box@tempboxa\FBbfil}% 642 \fi}% 643 \egroup 644 \ifx @empty##3\relax \else 645 \vskip\sf@capskip 646 \hrule width0pt height0pt depth0pt 647 \sf@subcaption{##1}{##2}{##3}% 648 \fi 649 }% 650 \vskip\sf@bottom 651 \egroup 652 @ifundefined{FBsc@max}{% 653 }{% 654 \addtocounter{FRobj}{-1}% 655 \ifnum\c@FRobj=0\else 656 \subfloatrowsep 657 \fi 658 }% 659 \ifmaincaptiontop\else 660 \global\advance@nameuse{c@@captype}\m@ne 661 \fi 662 \endgroup\ignorespaces}% 663 % 664 \expandafter\ifx\csname sf@@@subfloat\endcsname\nag@@original@@sf@@@subfloat 665 % yup, that’s it. 666 \PackageInfo{nag}{OK, equivalent to subfig 1.3, redefining 667 @backslashchar sf@@@subfloat@gobble}% 668 \global\long\def\sf@@@subfloat##1[##2][##3]##4{% 669 @ifundefined{FBsc@max}{% 670 }{%