diff options
author | Karl Berry <karl@freefriends.org> | 2013-06-27 16:31:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-06-27 16:31:37 +0000 |
commit | ed725d5c234420505cc81dafaf4dd600a0c4b000 (patch) | |
tree | 5fe64908bd05b097e50bbc7dccc9c6e93b249912 /Master/texmf-dist/source/latex/autonum/autonum.dtx | |
parent | 82c37dcf73b52a88faef522a2f1a294351deea1a (diff) |
autonum (16jun13)
git-svn-id: svn://tug.org/texlive/trunk@30979 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/autonum/autonum.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/autonum/autonum.dtx | 122 |
1 files changed, 110 insertions, 12 deletions
diff --git a/Master/texmf-dist/source/latex/autonum/autonum.dtx b/Master/texmf-dist/source/latex/autonum/autonum.dtx index 531ae202394..b1424f0cbd8 100644 --- a/Master/texmf-dist/source/latex/autonum/autonum.dtx +++ b/Master/texmf-dist/source/latex/autonum/autonum.dtx @@ -43,7 +43,7 @@ See http://www.latex-project.org/lppl.txt \endpreamble \postamble -Copyright (C) 2012 by Patrick Häcker <pat_h@web.de> +Copyright (C) 2012, 2013 by Patrick Häcker <pat_h@web.de> This work may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either @@ -85,11 +85,12 @@ and the derived files autonum.ins, %</internal> %<*package> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{autonum}[2013/04/28 v0.3.4 autonum LaTeX package] +\ProvidesPackage{autonum}[2013/06/15 v0.3.5 autonum LaTeX package] \PassOptionsToPackage{hypertexnames=false}{hyperref} \RequirePackage{etoolbox} \RequirePackage{amsmath} \RequirePackage[absolute]{textpos} +\RequirePackage{letltxmacro} %</package> %<*driver> \documentclass{ltxdoc} @@ -131,6 +132,7 @@ and the derived files autonum.ins, %\changes{v0.3.2}{2012/09/03}{Fix using reference inside caption.} %\changes{v0.3.3}{2013/04/20}{Fix using cleveref inside section.} %\changes{v0.3.4}{2013/04/28}{Gracefully handle deactivating the package.} +%\changes{v0.3.5}{2013/06/15}{Support reference commands with optional arguments or stars.} % % \section{Introduction} % With \LaTeX, the user has to decide manually to not number an equation by adding a star in the math environment. Authors who do not want to think about the numbering during the writing (and maybe they should not), often use the environments without stars. As default, these users get all equations numbered, although there are \href{http://tex.stackexchange.com/q/29267/7323}{different opinions} about what should be numbered. @@ -318,6 +320,10 @@ and the derived files autonum.ins, % \begin{itemize} % \item found a bug when using \cmd{\cref} inside the \cmd{\section} command when hyperref is loaded which lead to its fix % \end{itemize} +% \item Michel Voßkuhle +% \begin{itemize} +% \item found a bug when using autonum together with the subcaption package due to the missing support of starred reference commands in autonum which lead to its fix +% \end{itemize} % \end{itemize} % % @@ -359,6 +365,41 @@ and the derived files autonum.ins, % \end{macrocode} %\end{macro} +%\begin{macro}{\csLetLtxMacro} +% This command simply combines the functionality from \cmd{\cslet} and \cmd{\LetLtxMacro}. This command would be a candidate for inclusion into letltxmacro or possibly etoolbox. +% \begin{macrocode} +\newrobustcmd{\csLetLtxMacro}[2]{% + \expandafter\LetLtxMacro\csname#1\endcsname#2% +} +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\LetcsLtxMacro} +% This command simply combines the functionality from \cmd{\letcs} and \cmd{\LetLtxMacro}. This command would be a candidate for inclusion into letltxmacro or possibly etoolbox. +% \begin{macrocode} +\newrobustcmd{\LetcsLtxMacro}[2]{% + \ifcsdef{#2}{% + \expandafter\LetLtxMacro\expandafter#1\csname#2\endcsname + }{% + \undef#1% + }% +} +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\csLetcsLtxMacro} +% This command simply combines the functionality from \cmd{\csletcs} and \cmd{\LetLtxMacro}. This command would be a candidate for inclusion into letltxmacro or possibly etoolbox. +% \begin{macrocode} +\newrobustcmd*{\csLetcsLtxMacro}[2]{% + \ifcsdef{#2}{% + \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname + }{% + \csundef{#1}% + }% +} +% \end{macrocode} +%\end{macro} + %\begin{macro}{\vanishprotect} % This \href{http://tex.stackexchange.com/a/110782}{command} encapsulates content to not appear in the table-of-contents or similar lists. The content is shown in normal text (captions or section headings and so on). The macro uses one arguments in spite of its parameterless definition. % \begin{macrocode} @@ -373,7 +414,7 @@ and the derived files autonum.ins, %\end{macro} %\begin{macro}{\ifcsedef} -% This command is similar to the \cmd{\ifcsdef} test from the package etoolbox, but the command sequence gets fully expanded before it is evaluated.. This command would be a candidate for inclusion into etoolbox. +% This command is similar to the \cmd{\ifcsdef} test from the package etoolbox, but the command sequence gets fully expanded before it is evaluated. This command would be a candidate for inclusion into etoolbox. % \begin{macrocode} \def\ifcsedef#1#2#3{% \edef\autonum@ifcsedefTemp{#1}% @@ -383,6 +424,34 @@ and the derived files autonum.ins, % \end{macrocode} %\end{macro} +%\begin{macro}{\ifstar} +% This command is similar to the \cmd{\@ifstar} command from LaTeX, but it absorbs a token instead of peeking ahead. This command would be a candidate for inclusion into etoolbox. +% \begin{macrocode} +% \def\ifstar#1#2#3{% +% \ifstrequal{#1}{*}{#2}{#3}% +% } +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\csDeclareDocumentCommand} +% This command is a mixture of the \cmd{\csdef} command from the etoolbox package and the \cmd{\DeclareDocumentCommand} from the xparse package. This command would be a candidate for inclusion into xparse. +% \begin{macrocode} +% \def\csDeclareDocumentCommand#1#2#3{% +% \expandafter\DeclareDocumentCommand\csname #1\endcsname{#2}{#3}% +% } +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\autonum@debug} +% Activate and deactivate debugging by commenting and uncommenting the folowing code. +% \begin{macrocode} +% \def\autonum@debug#1{% +% \PackageWarning{autonum}{#1}% +% } +% \def\autonum@debug#1{}% +% \end{macrocode} +%\end{macro} + % This is needed to not get overwritten by other packages. The package autonum only overwrites some commands whose name start with \cmd{\autonum}. Other commands are only patched, so the currently valid command gets called, too. So although not very polite, this behavior seems reasonable. % \begin{macrocode} \AtBeginDocument{% @@ -688,22 +757,51 @@ and the derived files autonum.ins, % This command can patch arbitrary reference commands. The patch logic can be different to patching the label command, as the references have to be patched only once, so optimizing for speed is counter-productive. % \begin{macrocode} \def\autonum@generatePatchedReferenceGeneral#1#2{% - \csletcs{autonum@reference#1Old}{#1}% % \end{macrocode} - % Mark label as referenced and call the old reference command. Do not write in the PDF's TOC, as this would lead to a write inside of a write when, e.g., calling \cmd{\cref} inside of a section command. Also use \cmd{\vanishprotect} to avoid writing \cmd{\autonum@markLabelAsReferenced} into the aux file or similar files. This avoids errors after deactivating the autonum package. + % There might be reference commands, which have an optional argument. To support these, use \cmd{\csLetcsLtxMacro} instead of \cmd{\csletcs}. % \begin{macrocode} - \csdef{#1}##1{% - \skipInPDFTOC{% - \vanishprotect{% - \csuse{#2}{\protect\autonum@markLabelAsReferenced}{##1}% - }% - }% - \csuse{autonum@reference#1Old}{##1}% + \csLetcsLtxMacro{autonum@reference#1Old}{#1}% +% \end{macrocode} + % Do not absorb any arguments, yet, because every further processing must be protected and this is the simplest way to achieve protected processing. Something like using \cmd{\@ifstar} inside of a moving argument would otherwise be very hard or impossible. Unfortunately, a simple approach like \cmd{\csDeclareDocumentCommand\{\#1\}\{sm\}} does produce a not yet understood infinite recursion. +% \begin{macrocode} + \csdef{#1}{% +% \end{macrocode} + % Use protect, to avoid problems with sections and captions. This is the same trick that hyperref uses, which can be seen by executing \cmd{\show}\cmd{\ref}. +% \begin{macrocode} + \protect\autonum@processReference{autonum@reference#1Old}{#2}% }% } % \end{macrocode} %\end{macro} +%\begin{macro}{\autonum@processReference} + % If the reference command supports a starred call, as \cmd{\ref} when loading hyperref does for example, the star must be supported, as well. This macro separates calls using a star from those not using one. +% \begin{macrocode} +\def\autonum@processReference#1#2{% + \@ifstar{% + \autonum@processReferenceHelper{#1}{#2}{*}% + }{% + \autonum@processReferenceHelper{#1}{#2}{}% + }% +}% +% \end{macrocode} +%\end{macro} + +%\begin{macro}{\autonum@processReference} + % Mark label as referenced and call the old reference command. Do not write in the PDF's TOC, as this would lead to a write inside of a write when, e.g., calling \cmd{\cref} inside of a section command. Also use \cmd{\vanishprotect} to avoid writing \cmd{\autonum@markLabelAsReferenced} into the aux file or similar files. This avoids errors after deactivating the autonum package. +% \begin{macrocode} +% \autonum@processReferenceHelper{reference command name}{extraction command name}{star or empty}{label} +\def\autonum@processReferenceHelper#1#2#3#4{% + \skipInPDFTOC{% + \vanishprotect{% + \csuse{#2}{\protect\autonum@markLabelAsReferenced}{#4}% + }% + }% + \csuse{#1}#3{#4}% +}% +% \end{macrocode} +%\end{macro} + %\begin{macro}{\autonum@markLabelAsReferenced} % This is a simple helper macro to mark a label as referenced. The reference information is stored into a variable (for the current run) and into the aux file (for the next run), so it does not matter if the reference is used before or after the definition of the label. Saving into a variable saves one compilation run, although still up to three are needed to get everything right. % \begin{macrocode} |