diff options
author | Karl Berry <karl@freefriends.org> | 2007-02-28 01:32:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-02-28 01:32:05 +0000 |
commit | ee05abb32cef8f23b3eef73769b7dc6abd4313a3 (patch) | |
tree | c80da70bf412ff8a338e7acc3d47995d3138d290 /Master/texmf-dist/source/latex | |
parent | 6fc4926b8b360e85e414b3cce37ca44b76d582c3 (diff) |
nag update (26feb07)
git-svn-id: svn://tug.org/texlive/trunk@3996 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/nag/nag.dtx | 310 |
1 files changed, 284 insertions, 26 deletions
diff --git a/Master/texmf-dist/source/latex/nag/nag.dtx b/Master/texmf-dist/source/latex/nag/nag.dtx index 73b41b15b40..c24f400190e 100644 --- a/Master/texmf-dist/source/latex/nag/nag.dtx +++ b/Master/texmf-dist/source/latex/nag/nag.dtx @@ -108,7 +108,7 @@ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} -%\CheckSum{298} +%\CheckSum{624} % %\DoNotIndex{\if,\else,\fi,\PackageWarning,\PackageWarningNoLine,\typeout} %\DoNotIndex{\@for,\addtocounter,\arabic,\centering,\csname,\CurrentOption} @@ -126,12 +126,13 @@ % \changes{0.5}{2006/07/08}{Handle the case that somebody else relaxes % the ver@-commands. Stack-based NotASwitch.} % +%\GetFileInfo{nag.sty} %\newcommand\pkg[1]{\textsf{#1}} %\title{The \pkg{nag} package\ignorespaces% % \thanks{This document corresponds to \pkg{nag}~\fileversion, % dated~\filedate.}} % \author{Ulrich Michael Schwarz\ignorespaces% -% \thanks{\texttt{ulmi@users.sarovar.org}}} +% \thanks{\texttt{ulmi@absatzen.de}}} % % \maketitle % @@ -281,7 +282,11 @@ \ObsoletePackage{euler}{the eulervm package} \ObsoletePackage{utopia}{the fourier package} %% \S 3.1 -\g@addto@macro\nag@floats{,figure,table}% +\NagDeclareFloat{figure}\NagDeclareFloat{table}% +\g@addto@macro\nag@labels{,label}% +%% The latter two are used by KOMA-Script. +\g@addto@macro\nag@captions{,caption,captionabove,captionbelow}% + %% \S 3.2 \NotAnEnvironment{appendix}% %% In the same vein: @@ -342,7 +347,7 @@ } %</abortnag> % \end{macrocode} -%\StopEventually{\PrintChanges} +% %<*nag> % \section{Author-side considerations and implementation.} % If you are a package or class author and want to extend the range @@ -357,7 +362,7 @@ % Identify ourselves. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{nag}[2006/07/08 0.5 warning about old commands (ulmi)] +\ProvidesPackage{nag}[2007/02/25 0.52 warning about old commands (ulmi)] \let\@xa\expandafter \let\@nx\noexpand % \end{macrocode} @@ -379,14 +384,27 @@ % (With thanks to Juergen Goebel, Heiko Oberdiek and Rolf Niepraschk % (\pkg{savesym})) % +% \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} +% \dots but \emph{do} log a message. % \begin{macrocode} - \newcommand\nag@prepend[2]{% - \@xa\let +\newcommand\nag@prepend[2]{% + \@ifundefined{#1}{% + % if it doesn't exist, don't do anything. + \PackageInfo{nag}{% + Command \@backslashchar#1\space not defined, skipping amendment + } + }{% + \@xa\let \csname nag@@#1@\thenag@c\@xa\endcsname \csname #1\endcsname - \@xa\nag@pr@p@nd\csname #1\@xa\endcsname + \@xa\nag@pr@p@nd\csname #1\@xa\endcsname \csname nag@@#1@\thenag@c\endcsname{#2}% \stepcounter{nag@c}% + } } \newcommand\nag@pr@p@nd[3]{% \def#1{#3#2}% @@ -453,15 +471,23 @@ % 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 - \ifcsname #1\endcsname + % 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. - \@ifundefined{#1}{#3}{#2}% - \else #3\fi + \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} @@ -554,25 +580,26 @@ % Add checks to all macros named by |\nag@labels| % and |\nag@captions|, respectively. % \changes{0.3}{2005/07/07}{Fixed missing globals} -% The hascounter etc. information is now global. I don't think -% those should be hidden by groups. In particular, a center or -% minipage environment would hide the caption inside from a label -% outside. +% 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. I think we can leave captions global. +% information as of v0.4. I think we can leave captions global. % % \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} \@for\labelprovider:=\nag@labels\do{% + \ifx\labelprovider\@empty\else \nag@prepend{\labelprovider}% {\nag@captioncheck\nag@haslabeltrue} + \fi }% \@for\captionprovider:=\nag@captions\do{% - \nag@prepend{\captionprovider}{\global\nag@hascaptiontrue}% + \ifx\captionprovider\@empty\else + \nag@prepend{\captionprovider}{\global\nag@hascaptiontrue}% + \fi }% \global\nag@haslabelfalse\global\nag@hascaptionfalse }% @@ -592,14 +619,19 @@ % \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 l2tabu.obs to set up), but keep the list -% non-empty, so that we can always add to it with -% |\g@addto@macro|\marg{list}|{,|\meta{things}|}|. +% 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{nag@dummy} -\def\nag@labels{label} -%% The latter two are used by KOMA-Script. -\def\nag@captions{caption,captionabove,captionbelow} +\def\nag@floats{} +\def\nag@labels{} +\def\nag@captions{} % \end{macrocode} % % We call the above for each float environment named via @@ -607,7 +639,9 @@ % \begin{macrocode} \newcommand\nag@floatsetup{% \@for\flo:=\nag@floats\do{% - \@xa\nag@hackfloat\@xa{\flo}% + \ifx\flo\@empty\else + \@xa\nag@hackfloat\@xa{\flo}% + \fi }% } % \end{macrocode} @@ -620,7 +654,6 @@ % \end{macrocode} % % At the very end, we will display a running total of complaints. -% This feature was more-or-less suggested by David Kastrup. % \begin{macrocode} \AtBeginDocument{% \AtEndDocument{% @@ -763,6 +796,230 @@ } % \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 + \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} +% +% +% \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} @@ -787,6 +1044,7 @@ \ProcessOptions* % \end{macrocode} %</nag> +% \PrintChanges %\PrintIndex %\Finale %\iffalse |