diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-08 21:06:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-08 21:06:12 +0000 |
commit | 6bb20d05915a6075a51a761e5b4d1bf33b7f5f78 (patch) | |
tree | 1c47a3d57c0c9819a9251a3e5cf7e999b7a61995 | |
parent | 9b57e6101d0ce5e78a61572e72d8476e0ddf9272 (diff) |
apxproof (8aug18)
git-svn-id: svn://tug.org/texlive/trunk@48377 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/apxproof/apxproof.pdf | bin | 449831 -> 555226 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/apxproof/apxproof.dtx | 376 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/apxproof/apxproof.sty | 169 |
3 files changed, 437 insertions, 108 deletions
diff --git a/Master/texmf-dist/doc/latex/apxproof/apxproof.pdf b/Master/texmf-dist/doc/latex/apxproof/apxproof.pdf Binary files differindex 57d28fbd810..db2e8fd35f7 100644 --- a/Master/texmf-dist/doc/latex/apxproof/apxproof.pdf +++ b/Master/texmf-dist/doc/latex/apxproof/apxproof.pdf diff --git a/Master/texmf-dist/source/latex/apxproof/apxproof.dtx b/Master/texmf-dist/source/latex/apxproof/apxproof.dtx index c1942cc2f26..9c7bdb81c2c 100644 --- a/Master/texmf-dist/source/latex/apxproof/apxproof.dtx +++ b/Master/texmf-dist/source/latex/apxproof/apxproof.dtx @@ -24,7 +24,7 @@ % \iffalse %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01] %<package>\ProvidesPackage{apxproof} -%<package> [2018/05/10 v1.0.6 Automatic proofs in appendix] +%<package> [2018/08/08 v1.1.0 Automatic proofs in appendix] % %<*driver> \documentclass{ltxdoc} @@ -32,6 +32,7 @@ \usepackage{hypdoc} \usepackage{textcomp} \usepackage[TS1,T1]{fontenc} +\usepackage{lmodern} \usepackage{microtype} \newtheorem{example}{Example} \newtheoremrep{foobar}{Foobar} @@ -44,7 +45,7 @@ %</driver> % \fi % -% \CheckSum{562} +% \CheckSum{716} % % \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 @@ -249,6 +250,7 @@ This proof is in the appendix. % \begin{proof} % This is the proof of the regular foobar. % \end{proof} +% Now, if we use a repeated theorem: % \begin{quote} % \begin{verbatim} % \begin{foobarrep} @@ -268,9 +270,9 @@ This proof is in the appendix. This is the proof of the repeated foobar. %</driver> % \end{proof} -% Note that, since |hyperref| is loaded, there is a hyperlink -% created from the statement of the theorem in the appendix to that in -% the main text. +% Note that, since |hyperref| is loaded, there are hyperlinks +% created between the statements of the theorems in the main text and in +% the appendix. % \end{example} % % When the proof is deferred to the appendix, it is common practice to @@ -285,7 +287,7 @@ This is the proof of the repeated foobar. % The proof sketch is typeset similarly to a proof, but is always in the % main text. Similarly, an |inlineproof| \DescribeEnv{inlineproof} % environment is provided so as to -% be able to have both a proof in the appendix (using the regualr |proof| +% be able to have both a proof in the appendix (using the regular |proof| % environment, or alternatively the |appendixproof| environment) and a % different proof in the main text (using the |inlineproof| environment). % \begin{example} Here are simple examples of proof sketches and inline @@ -381,6 +383,17 @@ This is a citation in the appendix~\cite{proofsAreHard}. % in single-column mode) but redefining this option allows changing this % behavior. % \end{description} +% \DescribeOption{repeqn} +% Another customization capability concerns \emph{numbered equations} that are present +% within repeated theorems. An optional |repeqn| option can be specified +% when loading the package, which controls whether +% equation numbers should be as in the same text (by setting this option +% to |same|, the default) or independently +% numbered (by setting this option to |independent|). In the latter case, +% whenever a referenceable counter is set with |\label{|\meta{counter}|}|, +% |\ref{|\meta{counter}|}| references the counter in the main text, while +% |\ref{|\meta{counter}|-apx}| references the counter in the appendix +% (except in |inline| mode, where both have the same effect). % % \subsection{Advanced Features} % We now describe a few advanced macros and environments, whose usage is limited to @@ -412,16 +425,16 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \begin{itemize} % \item \LaTeX{} standard document classes (e.g., |article.cls|) % \item \href{https://www.ctan.org/pkg/koma-script}{KOMA-Script} -% (e.g., |scrartcl.cls|) +% (e.g., |scrartcl.cls|, |scrbook.cls|) % \item \href{https://www.acm.org/publications/proceedings-template}{ACM -% SIG Proceedings} (e.g., |sig-alternate.cls|) +% SIG Proceedings} (e.g., |sig-alternate.cls|, |acmart.cls|) % \item \href{https://www.springer.com/computer/lncs/lncs+authors}{ % Springer's Lecture Notes in Computer Science} (e.g., % |llncs.cls|) % \item % \href{https://www.dagstuhl.de/en/publications/lipics}{Schlo\ss{} % Dagstuhl's Leibniz International Proceedings in Informatics} (e.g., -% |lipics.cls|) +% |lipics.cls|, |lipcs-v2016.cls|) % \end{itemize} % Other classes may work out of the box. Adding support for specific % classes is possible and can be requested from the @@ -438,12 +451,16 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \item \textsf{apxproof} is incompatible with a separate use of the % \textsf{fancyvrb} package. This is because \textsf{apxproof} redefines % some internal mechanisms of \textsf{fancyvrb}. +% \item \textsf{apxproof} poorly interacts with Sync\TeX: identifying +% which source line has produced which box does not work for appendix +% content managed by \textsf{apxproof} or repeated theorems. No obvious +% fix is known, though this issue will be investigated in the long term. % \end{itemize} % % Issues not listed here should be reported to the author. % % \section{License} -% Copyright \textcopyright{} 2016--2017 by Pierre Senellart. +% Copyright \textcopyright{} 2016--2018 by Pierre Senellart. % % This work may be distributed and/or modified under the conditions of the % \LaTeX{} Project Public License, either version 1.3 of this license or (at @@ -462,7 +479,9 @@ This is a citation in the appendix~\cite{proofsAreHard}. % preferably be submitted through the \emph{Issues} feature of GitHub. % % \section{Acknowledgments} -% Thanks to Antoine Amarilli for feedback and proofreading. +% Thanks to Antoine Amarilli for feedback and proofreading. Thanks to K.~D. +% Bauer for the implementation of the forward-linking mechanism, and +% for various bugfixes. % % \StopEventually{ % \PrintChanges @@ -549,6 +568,8 @@ This is a citation in the appendix~\cite{proofsAreHard}. % values: |strip|, |inline|); % \item |bibliography|, with a default value of |separate| (other % possible value: |common|); +% \item |repeqn|, with a default value of |same| (other possible value: +% |independent|). % \end{itemize} % \begin{macro}{\axp@appendix} % \begin{macrocode} @@ -561,11 +582,16 @@ This is a citation in the appendix~\cite{proofsAreHard}. \DeclareStringOption[separate]{bibliography} % \end{macrocode} % \end{macro} +% \begin{macro}{\axp@repeqn} +% \changes{v1.1.0}{2018/07/20}{\texttt{repeqn} option} +% \begin{macrocode} +\DeclareStringOption[same]{repeqn} +% \end{macrocode} +% \end{macro} % \begin{macrocode} \ProcessLocalKeyvalOptions* % \end{macrocode} -% We check that the value of the |appendix| and -% |bibliography| options are valid, and add a +% We check that the value of the options are valid, and add a % message to the compilation log. % \begin{macrocode} \ifthenelse{\equal{\axp@appendix}{append}}{ @@ -575,7 +601,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. }{\ifthenelse{\equal{\axp@appendix}{inline}}{ \message{apxproof: Appendix material inlined within the document} }{ - \errmessage{Error: unsupported option appendix=\axp@appendix for + \errmessage{Error: unsupported option appendix=\axp@appendix\ for package apxproof} }}} \ifthenelse{\equal{\axp@bibliography}{separate}}{ @@ -583,7 +609,15 @@ This is a citation in the appendix~\cite{proofsAreHard}. }{\ifthenelse{\equal{\axp@bibliography}{common}}{ \message{apxproof: Common bibliography for appendix and main text} }{ - \errmessage{Error: unsupported option bibliography=\axp@bibliography for + \errmessage{Error: unsupported option bibliography=\axp@bibliography\ for + package apxproof} +}} +\ifthenelse{\equal{\axp@repeqn}{same}}{ + \message{apxproof: Repeated equations keep the same numbering} +}{\ifthenelse{\equal{\axp@repeqn}{independent}}{ + \message{apxproof: Repeated equations are independently numbered} +}{ + \errmessage{Error: unsupported option repeqn=\axp@repeqn\ for package apxproof} }} % \end{macrocode} @@ -658,6 +692,8 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \begin{macro}{\appendixprelim} % \changes{v1.0.4}{2017/03/03}{Configurable appendix style} % \begin{macro}{\appendixsectionformat} +% \changes{v1.1.0}{2018/07/17}{Fix missing space in default +% \cs{appendixsectionformat}} % We provide sensible defaults for these four user-customizable macros. % Even though they are only useful in append mode, we define them for % all modes so that a |\renewcommand| works in all cases. @@ -666,7 +702,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. \newcommand{\appendixbibliographystyle}{alpha} \newcommand{\appendixbibliographyprelim}{} \newcommand{\appendixprelim}{\clearpage\onecolumn} -\newcommand{\appendixsectionformat}[2]{Proofs for Section~#1 (#2)} +\newcommand{\appendixsectionformat}[2]{Proofs for Section~#1\ (#2)} % \end{macrocode} % \end{macro} % \end{macro} @@ -680,6 +716,37 @@ This is a citation in the appendix~\cite{proofsAreHard}. \let\endaxp@oldproof\endproof % \end{macrocode} % \end{environment} +% We define a utility macro that will be used to properly set the +% |\label| command (and its \textsf{amsmath} counterpart, +% |\label@in@display|) for equations within repeated theorems, depending on the +% compilation mode. +% \begin{macro}{\axp@redefinelabels} +% \changes{v1.1.0}{2018/07/04}{Fix \cs{label} not being disabled +% in \textsf{amsmath} environments, where \cs{label@in@display} is +% used instead (K. D. Bauer)} +% \begin{macrocode} + \newcommand{\axp@redefinelabels}{% + \providecommand\label@in@display{} + \ifthenelse{\equal{\axp@appendix}{inline}}{ + \let\axp@oldlabel\label + \let\axp@oldlabel@in@display\label@in@display + \renewcommand\label[1]{% + \axp@oldlabel{##1}% + \axp@oldlabel{##1-apx}% + }% + \renewcommand\label@in@display[1]{% + \axp@oldlabel@in@display{##1}% + \axp@oldlabel{##1-apx}% + }% + }{% + \let\axp@oldlabel\label + \let\axp@oldlabel@in@display\label@in@display + \renewcommand\label[1]{\axp@oldlabel{##1-apx}}% + \renewcommand\label@in@display[1]{\axp@oldlabel@in@display{##1-apx}}% + }% + } +% \end{macrocode} +% \end{macro} % \subsubsection{Class-Specific Behavior} % Finally, some class-specific behavior common to all compilation modes % \paragraph{\textsf{llncs} and other Springer document classes} @@ -734,14 +801,16 @@ This is a citation in the appendix~\cite{proofsAreHard}. % In inline mode, |\axp@newtheoremrep| undefines the existing % theorem environment if it has already been defined (e.g., by the % document class), invokes |\newtheorem| and creates a repeated theorem -% environment that behaves exactly as the regular theorem environment. +% environment that behaves exactly as the regular theorem environment, +% while calling |\axp@redefinelabels| to make sure that |-axp| variants +% of equation counters are defined. % \begin{macrocode} \def\axp@newtheoremrep#1[#2]#3[#4]{% \expandafter\let\csname #1\endcsname\undefined \expandafter\let\csname c@#1\endcsname\undefined \axp@newtheorem{#1}{#2}{#3}{#4}% \NewEnviron{#1rep}[1][]{% - \begin{#1}[##1]\BODY\end{#1}% + \begin{#1}[##1]\axp@redefinelabels\BODY\end{#1}% } } % \end{macrocode} @@ -789,9 +858,14 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \begin{macro}{\axp@proofsfile} % We open a new auxiliary file, with extension |.axp|, where the appendix % material will be dumped. +% \changes{v1.1.0}{2018/07/11}{Initialization deferred to \cs{AtBeginDocument} +% for compatibility with \cs{dump}ed precompiled preambles (K. D. +% Bauer)} % \begin{macrocode} - \newwrite\axp@proofsfile - \immediate\openout\axp@proofsfile=\jobname.axp + \AtBeginDocument{ + \newwrite\axp@proofsfile + \immediate\openout\axp@proofsfile=\jobname.axp + } % \end{macrocode} % \end{macro} % \begin{environment}{proof} @@ -800,11 +874,13 @@ This is a citation in the appendix~\cite{proofsAreHard}. % it will be used in several places for internal names) and reestablish the original definition of % the |proof| environment and the |\section| macro. % \begin{macrocode} - \immediate\write\axp@proofsfile{% - \noexpand\makeatletter - \noexpand\let\noexpand\proof\noexpand\axp@oldproof - \noexpand\let\noexpand\endproof\noexpand\endaxp@oldproof - \noexpand\let\noexpand\section\noexpand\axp@oldsection + \AtBeginDocument{ + \immediate\write\axp@proofsfile{% + \noexpand\makeatletter + \noexpand\let\noexpand\proof\noexpand\axp@oldproof + \noexpand\let\noexpand\endproof\noexpand\endaxp@oldproof + \noexpand\let\noexpand\section\noexpand\axp@oldsection + } } % \end{macrocode} % \end{macro} @@ -853,6 +929,16 @@ This is a citation in the appendix~\cite{proofsAreHard}. \newcounter{axp@rpcounter} % \end{macrocode} % \end{macro} +% \begin{macro}{axp@equation} +% \begin{macro}{axp@equationx} +% Used to save the value of the |equation| counter, when |repeqn| is set +% to |same|. +% \begin{macrocode} + \newcounter{axp@equation} + \newcounter{axp@equationx} +% \end{macrocode} +% \end{macro} +% \end{macro} % \begin{macro}{axp@newtheoremrep} % When called with first argument |foobar|, we first undefine the existing % |foobar| environment (and its counter) if it has already been defined (e.g., by the @@ -867,6 +953,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. \axp@newtheorem{#1}{#2}{#3}{#4}% \expandafter\pretocmd\csname #1\endcsname{\noproofinappendix}{}{}% \axp@newtheorem*{axp@#1rp}{#3}% + \axp@forward@setup{#1}{#2}{#3}{#4}% % \end{macrocode} % We then define a |foobarrep| environment that increments the % |axp@rpcounter| and typeset the regular |foobar| theorem with a label @@ -875,13 +962,19 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \changes{v1.0.6}{2018/05/10}{Better handling of note-free theorems in % document classes that treat theorems differently when they have an % empty note} -% \begin{macrocode} +% We save the equation counter +% before typesetting the theorem environment, to reset it to the same +% value in the repeated environment when |repeqn| is set to |same|. +% \begin{macrocode} \NewEnviron{#1rep}[1][]{% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \setcounter{axp@equation}{\value{equation}}% + }{}% \addtocounter{axp@rpcounter}{1}% \ifx\relax##1\relax - \begin{#1}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% + \axp@with@forward{#1}{\begin{#1}}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% \else - \begin{#1}[##1]\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% + \axp@with@forward{#1}{\begin{#1}[##1]}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% \fi % \end{macrocode} % We set the |axp@seenreptheorem| toggle to indicate that we are looking @@ -896,7 +989,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. % Possibly after starting a new appendix section if needed, we typeset a % repeated version of the theorem using the |axp@foobarrp| environment % and a reference to the previously defined label. -% We ignore any use of |\label| in this environment to avoid multiply +% We use |\axp@redefinelabels| in this environment to avoid multiply % defined labels. % \changes{v1.0.2}{2016/12/13}{Fix missing space between repeated theorem % counter and theorem note} @@ -904,19 +997,140 @@ This is a citation in the appendix~\cite{proofsAreHard}. % in optional argument of macro environment} % \begin{macrocode} \axp@writesection% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \immediate\write\axp@proofsfile{% + \noexpand\setcounter{axp@equationx}{\value{equation}}% + \noexpand\setcounter{equation}{\theaxp@equation}% + }% + }{}% \immediate\write\axp@proofsfile{% \noexpand\begin{axp@#1rp} [\noexpand\ref{axp@r\roman{axp@rpcounter}}% \@ifnotempty{##1}{ \unexpanded{##1}}]% - \noexpand\let\noexpand\label\noexpand\@gobble% + \noexpand\axp@forward@target{axp@fw@r\roman{axp@rpcounter}}{}% + \noexpand\axp@redefinelabels \expandafter\noexpand\csname rplet\roman{axp@rpcounter}% \endcsname \noexpand\end{axp@#1rp} - } - } + }% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \immediate\write\axp@proofsfile{% + \noexpand\setcounter{equation}{\value{axp@equationx}}% + }% + }{}% + }% } -% \end{macrocode} +% \end{macrocode} % \end{macro} +% +% \subsubsection{Forward-Linking Mechanism} +% \changes{v1.1.0}{2018/07/02}{Added forward-link mechanism (K. D. Bauer)} +% +% When hyperref is loaded, |foobarrep| environments +% in the main text have their number link to their +% repetition in the appendix. +% +% + +% +% \begin{macro}{\axp@with@forward} +% In order to make the number of the |foobarrep| theorem a link +% to its repeated version, we temporarily redefine the +% |\thefoobar| command, or, if we inherited the counter +% from a |bazbar| environment, the |\thebazbar| command. +% This seems to be the only robust way, to make the number +% a |\hyperlink|, without adding extensive dependence +% on internals of |amsthm|, the builtin |\newtheorem| +% and possibly document-class specific definitions. +% +% In order to allow users to redefine |\thefoobar| without +% breaking this feature, we redefine |\thefoobar| only +% for the duration of the |\begin{foobar}| form, +% resetting it to the old value as soon as possible. +% +% Redefining |\thefoobar| has the side effect of changing |\newlabel| entries +% in the |.aux| file, so we need to to be able to disable +% addition of the hyperlink, which is why we use an +% intermediate |\axp@forward@link|\marg{target}\marg{text} macro, +% We also redefine |\theHfoobar| which is used by |hyperref| but not +% defined if |hyperref| was loaded after |\newtheoremrep| was used. +% and |\protect| it to output it verbatim into the |.aux| file. +% +% These hyperlinks are of course disabled in the |strip| compilation +% mode. +% \begin{macrocode} + \newcommand{\axp@with@forward}[2]{% + \ifthenelse{\equal{\axp@appendix}{strip}}{#2}{ + \global\booltrue{axp@forward}% + \ifcsundef{axp@old@the\csname axp@cn@#1\endcsname}{% + \csletcs{axp@old@the\csname axp@cn@#1\endcsname}{the\csname axp@cn@#1\endcsname}% + \csletcs{theH\csname axp@cn@#1\endcsname}{the\csname axp@cn@#1\endcsname}% + \csdef{the\csname axp@cn@#1\endcsname}{% + \protect\axp@forward@link{axp@fw@r\roman{axp@rpcounter}}% + {\csname axp@old@the\csname axp@cn@#1\endcsname\endcsname}% + }% + }{}% + #2% + \ifcsdef{axp@old@the\csname axp@cn@#1\endcsname}{% + \csletcs{the\csname axp@cn@#1\endcsname}{axp@old@the\csname axp@cn@#1\endcsname}% + }{}% + \global\boolfalse{axp@forward} + }}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\axp@forward@link} +% \begin{macro}{axp@forward} +% Dummy macro, for handling the unwanted change of +% the |\newlabel| entry in the |.aux| file caused by +% changing the definition of |\thefoobar|. +% +% \begin{macrocode} + \newbool{axp@forward} + \newcommand{\axp@forward@link}[2]{% + \ifbool{axp@forward}{% + \ifcsdef{hyperlink}{% + \hyperlink{#1}{#2}% + }{% + #2% + }% + }{% + #2% + }% + }% +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\axp@forward@target} +% Provides the needed |\hypertarget|. +% Intended to be written to the |.axp| file. +% \begin{macrocode} + \newcommand{\axp@forward@target}[2]{% + \ifcsname hypertarget\endcsname + \hypertarget{#1}{#2}% + \else + #2% + \fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\axp@forward@setup} +% In order to support counter inheritance with the first +% optional argument of |\newtheoremrep|, +% we need access to the name of the counter. +% For compliance with the behavior of |\@axp@newtheorem|, +% the first optional argument (|#2|) is ignored +% if the second optional argument (|#4|) is given. +% \begin{macrocode} + \newcommand{\axp@forward@setup}[4]{% + \csedef{axp@cn@#1}{\ifblank{#4}{\ifblank{#2}{#1}{#2}}{#1}}% + } +% \end{macrocode} +% \end{macro} +% +% % \subsubsection{Proof Environments} % \begin{macro}{\noproofinappendix} % Utility macro that toggles |axp@seenreptheorem| to false. @@ -924,7 +1138,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. \newcommand\noproofinappendix{% \global\togglefalse{axp@seenreptheorem}% } -% \end{macrocode} +% \end{macrocode} % \end{macro} % \begin{environment}{appendixproof} % We dump the content of this in appendix, within an original |proof| @@ -1015,25 +1229,29 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \end{macro} % \begin{macro}{\axp@oldsection} % \begin{macro}{\section} +% \changes{v1.1.0}{2018/07/25}{Rewrote definition of \cs{section} +% to enable optional argument. See \#23. (K. D. Bauer)} +% \changes{v1.1.0}{2018/07/25}{Fix handling of fragile macros within +% section headings. See \#22.} % \begin{macro}{\@section} % \begin{macro}{\@@section} % We redefine the |\section| command to create a label based on -% |axp@seccounter| and to store its title in |\axp@sectitle|. Two definitions are necessary to cover the -% starred and unstarred use of |\section|, though most likely the former -% is not going to be used (since no section number will appear to refer -% to that section in the appendix). +% |axp@seccounter| and to store its title in |\axp@sectitle|. +% In order to support starred and unstarred versions, as well +% as the optional short-title argument, the intermediate macros +% \cs{@section} and \cs{@@section} are needed. % \begin{macrocode} \let\axp@oldsection\section \def\section{\@ifstar\@section\@@section} - \def\@section#1{% - \global\edef\axp@sectitle{#1}% - \axp@oldsection*{#1}% - \addtocounter{axp@seccounter}{1}% - \label{axp@s\roman{axp@seccounter}}% - } - \def\@@section#1{% - \global\edef\axp@sectitle{#1}% - \axp@oldsection{#1}% + \newcommand{\@section}[2][\relax]{\axp@@@section{*}{#1}{#2}}% + \newcommand{\@@section}[2][\relax]{\axp@@@section{}{#1}{#2}}% + \newcommand{\axp@@@section}[3]{% + \global\def\axp@sectitle{#3}% + \ifx\relax#2\relax + \axp@oldsection#1{#3}% + \else + \axp@oldsection#1[{#2}]{#3}% + \fi \addtocounter{axp@seccounter}{1}% \label{axp@s\roman{axp@seccounter}}% } @@ -1054,19 +1272,38 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \begin{macro}{\axp@writesection} % If |\axp@sectitle| is not empty, we create % a new section in the appendix, referring to the main text section. +% +% Here, we wrap |\ref{axp@si}| into |\axp@protectref@i|, in order +% to protect the label name from wrongly being converted to uppercase, +% e.g., in \textsf{fancyhdr} with |\pagestyle{fancy}|. +% +% This macro is defined both in the |.aux| file (in order to ensure availability +% when typesetting the |\tableofcontents|), and immediately before typesetting +% the appendix section (to ensure availability in the |\section| command). +% % \changes{v1.0.6}{2018/05/10}{Fix extraneous space after section number % in appendix titles} +% \changes{v1.1.0}{2018/07/09}{Make \cs{axp@tmp} wrapper more robust. +% Resolves issues from use of section title in \textsf{fancyhdr}, +% and in \cs{tableofcontents} (K. D. Bauer).} % \begin{macrocode} \newcommand\axp@writesection{% \ifx\axp@sectitle\@empty \else - \immediate\write\axp@proofsfile{% - \noexpand\def\noexpand\axp@tmp{% + \edef\axp@tmp{% + \noexpand\global\noexpand\def + \expandonce{\csname axp@protectref@\roman{axp@seccounter}\endcsname}{% \noexpand\ref{axp@s\roman{axp@seccounter}}% - } + }% + }% + \immediate\write\@auxout{\expandonce\axp@tmp} + \immediate\write\axp@proofsfile{% + \expandonce\axp@tmp^^J% \noexpand\axp@section{% - \noexpand\appendixsectionformat{\protect\noexpand\axp@tmp}% - {\axp@sectitle}% + \noexpand\appendixsectionformat{% + \protect + \expandonce{\csname axp@protectref@\roman{axp@seccounter}\endcsname}% + }{\expandonce\axp@sectitle}% }% }% \nosectionappendix @@ -1074,6 +1311,20 @@ This is a citation in the appendix~\cite{proofsAreHard}. } % \end{macrocode} % \end{macro} +% Finally, in a somewhat ad hoc manner, we disable the whole section management +% for \cs{tableofcontents}, which may be typeset using a section heading, +% but for which automatic section management does not make sense. +% +% \begin{macro}{\axp@oldtableofcontents} +% \begin{macro}{\tableofcontents} +% \changes{v1.1.0}{2018/07/09}{Disable section management for table +% of contents} +% \begin{macrocode} + \let\axp@oldtableofcontents\tableofcontents + \def\tableofcontents{{\let\section\axp@oldsection\axp@oldtableofcontents}} +% \end{macrocode} +% \end{macro} +% \end{macro} % \subsubsection{Append Compilation Mode} % \begin{macrocode} \ifthenelse{\equal{\axp@appendix}{append}}{ @@ -1171,22 +1422,7 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \end{macro} % \end{macro} % \end{macro} -% \begin{macro}{\section} -% \begin{macro}{\@@section} -% These document classes redefine |\section| in a weird way, adding -% the possibility of an optional argument. We redefine them in a sane -% way. -% \begin{macrocode} - \def\section{\@ifstar\@section{\@dblarg{\@@section}}} - \def\@@section[#1]#2{% - \global\edef\axp@sectitle{#2}% - \axp@oldsection{#2}% - \addtocounter{axp@seccounter}{1}% - \label{axp@s\roman{axp@seccounter}}% - } -% \end{macrocode} -% \end{macro} -% \end{macro} +% % \begin{macrocode} \fi % \end{macrocode} @@ -1233,12 +1469,12 @@ This is a citation in the appendix~\cite{proofsAreHard}. % \begin{macrocode} \fi % \end{macrocode} -% \paragraph{\textsf{llncs} and other Springer document classes} +% \paragraph{\textsf{llncs}} % \begin{macrocode} \@ifclassloaded{llncs}{ % \end{macrocode} % \begin{macro}{proofsketch} -% We first redefine the |proofsketch| environment, which is used +% We redefine the |proofsketch| environment, which is used % differently in the base class. % \begin{macrocode} \renewenvironment{proofsketch}{\begin{axp@oldproof}[sketch]}{\end{axp@oldproof}} diff --git a/Master/texmf-dist/tex/latex/apxproof/apxproof.sty b/Master/texmf-dist/tex/latex/apxproof/apxproof.sty index 1ca283ae346..5371853fc93 100644 --- a/Master/texmf-dist/tex/latex/apxproof/apxproof.sty +++ b/Master/texmf-dist/tex/latex/apxproof/apxproof.sty @@ -27,7 +27,7 @@ %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{apxproof} - [2018/05/10 v1.0.6 Automatic proofs in appendix] + [2018/08/08 v1.1.0 Automatic proofs in appendix] \RequirePackage{bibunits} \RequirePackage{environ} \RequirePackage{etoolbox} @@ -53,6 +53,7 @@ } \DeclareStringOption[append]{appendix} \DeclareStringOption[separate]{bibliography} +\DeclareStringOption[same]{repeqn} \ProcessLocalKeyvalOptions* \ifthenelse{\equal{\axp@appendix}{append}}{ \message{apxproof: Appendix material appended to the document} @@ -61,7 +62,7 @@ }{\ifthenelse{\equal{\axp@appendix}{inline}}{ \message{apxproof: Appendix material inlined within the document} }{ - \errmessage{Error: unsupported option appendix=\axp@appendix for + \errmessage{Error: unsupported option appendix=\axp@appendix\ for package apxproof} }}} \ifthenelse{\equal{\axp@bibliography}{separate}}{ @@ -69,7 +70,15 @@ }{\ifthenelse{\equal{\axp@bibliography}{common}}{ \message{apxproof: Common bibliography for appendix and main text} }{ - \errmessage{Error: unsupported option bibliography=\axp@bibliography for + \errmessage{Error: unsupported option bibliography=\axp@bibliography\ for + package apxproof} +}} +\ifthenelse{\equal{\axp@repeqn}{same}}{ + \message{apxproof: Repeated equations keep the same numbering} +}{\ifthenelse{\equal{\axp@repeqn}{independent}}{ + \message{apxproof: Repeated equations are independently numbered} +}{ + \errmessage{Error: unsupported option repeqn=\axp@repeqn\ for package apxproof} }} \def\axp@newtheorem{\@ifstar\@@axp@newtheorem\@axp@newtheorem} @@ -99,9 +108,29 @@ \newcommand{\appendixbibliographystyle}{alpha} \newcommand{\appendixbibliographyprelim}{} \newcommand{\appendixprelim}{\clearpage\onecolumn} -\newcommand{\appendixsectionformat}[2]{Proofs for Section~#1 (#2)} +\newcommand{\appendixsectionformat}[2]{Proofs for Section~#1\ (#2)} \let\axp@oldproof\proof \let\endaxp@oldproof\endproof + \newcommand{\axp@redefinelabels}{% + \providecommand\label@in@display{} + \ifthenelse{\equal{\axp@appendix}{inline}}{ + \let\axp@oldlabel\label + \let\axp@oldlabel@in@display\label@in@display + \renewcommand\label[1]{% + \axp@oldlabel{##1}% + \axp@oldlabel{##1-apx}% + }% + \renewcommand\label@in@display[1]{% + \axp@oldlabel@in@display{##1}% + \axp@oldlabel{##1-apx}% + }% + }{% + \let\axp@oldlabel\label + \let\axp@oldlabel@in@display\label@in@display + \renewcommand\label[1]{\axp@oldlabel{##1-apx}}% + \renewcommand\label@in@display[1]{\axp@oldlabel@in@display{##1-apx}}% + }% + } \ifdefined\spnewtheorem \def\@axp@newtheorem#1#2#3#4{% \ifx\relax#4\relax @@ -129,7 +158,7 @@ \expandafter\let\csname c@#1\endcsname\undefined \axp@newtheorem{#1}{#2}{#3}{#4}% \NewEnviron{#1rep}[1][]{% - \begin{#1}[##1]\BODY\end{#1}% + \begin{#1}[##1]\axp@redefinelabels\BODY\end{#1}% } } \let\inlineproof\proof @@ -143,13 +172,17 @@ \let\nosectionappendix\relax } { - \newwrite\axp@proofsfile - \immediate\openout\axp@proofsfile=\jobname.axp - \immediate\write\axp@proofsfile{% - \noexpand\makeatletter - \noexpand\let\noexpand\proof\noexpand\axp@oldproof - \noexpand\let\noexpand\endproof\noexpand\endaxp@oldproof - \noexpand\let\noexpand\section\noexpand\axp@oldsection + \AtBeginDocument{ + \newwrite\axp@proofsfile + \immediate\openout\axp@proofsfile=\jobname.axp + } + \AtBeginDocument{ + \immediate\write\axp@proofsfile{% + \noexpand\makeatletter + \noexpand\let\noexpand\proof\noexpand\axp@oldproof + \noexpand\let\noexpand\endproof\noexpand\endaxp@oldproof + \noexpand\let\noexpand\section\noexpand\axp@oldsection + } } \def\FVB@VerbatimOut{% \@bsphack @@ -168,34 +201,92 @@ {\endVerbatimOut} \newtoggle{axp@seenreptheorem} \newcounter{axp@rpcounter} + \newcounter{axp@equation} + \newcounter{axp@equationx} \def\axp@newtheoremrep#1[#2]#3[#4]{% \expandafter\let\csname #1\endcsname\undefined \expandafter\let\csname c@#1\endcsname\undefined \axp@newtheorem{#1}{#2}{#3}{#4}% \expandafter\pretocmd\csname #1\endcsname{\noproofinappendix}{}{}% \axp@newtheorem*{axp@#1rp}{#3}% + \axp@forward@setup{#1}{#2}{#3}{#4}% \NewEnviron{#1rep}[1][]{% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \setcounter{axp@equation}{\value{equation}}% + }{}% \addtocounter{axp@rpcounter}{1}% \ifx\relax##1\relax - \begin{#1}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% + \axp@with@forward{#1}{\begin{#1}}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% \else - \begin{#1}[##1]\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% + \axp@with@forward{#1}{\begin{#1}[##1]}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}% \fi \global\toggletrue{axp@seenreptheorem}% \global\expandafter\let\csname rplet\roman{axp@rpcounter}% \endcsname \BODY \axp@writesection% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \immediate\write\axp@proofsfile{% + \noexpand\setcounter{axp@equationx}{\value{equation}}% + \noexpand\setcounter{equation}{\theaxp@equation}% + }% + }{}% \immediate\write\axp@proofsfile{% \noexpand\begin{axp@#1rp} [\noexpand\ref{axp@r\roman{axp@rpcounter}}% \@ifnotempty{##1}{ \unexpanded{##1}}]% - \noexpand\let\noexpand\label\noexpand\@gobble% + \noexpand\axp@forward@target{axp@fw@r\roman{axp@rpcounter}}{}% + \noexpand\axp@redefinelabels \expandafter\noexpand\csname rplet\roman{axp@rpcounter}% \endcsname \noexpand\end{axp@#1rp} - } - } + }% + \ifthenelse{\equal{\axp@repeqn}{same}}{% + \immediate\write\axp@proofsfile{% + \noexpand\setcounter{equation}{\value{axp@equationx}}% + }% + }{}% + }% + } + + \newcommand{\axp@with@forward}[2]{% + \ifthenelse{\equal{\axp@appendix}{strip}}{#2}{ + \global\booltrue{axp@forward}% + \ifcsundef{axp@old@the\csname axp@cn@#1\endcsname}{% + \csletcs{axp@old@the\csname axp@cn@#1\endcsname}{the\csname axp@cn@#1\endcsname}% + \csletcs{theH\csname axp@cn@#1\endcsname}{the\csname axp@cn@#1\endcsname}% + \csdef{the\csname axp@cn@#1\endcsname}{% + \protect\axp@forward@link{axp@fw@r\roman{axp@rpcounter}}% + {\csname axp@old@the\csname axp@cn@#1\endcsname\endcsname}% + }% + }{}% + #2% + \ifcsdef{axp@old@the\csname axp@cn@#1\endcsname}{% + \csletcs{the\csname axp@cn@#1\endcsname}{axp@old@the\csname axp@cn@#1\endcsname}% + }{}% + \global\boolfalse{axp@forward} + }}% + \newbool{axp@forward} + \newcommand{\axp@forward@link}[2]{% + \ifbool{axp@forward}{% + \ifcsdef{hyperlink}{% + \hyperlink{#1}{#2}% + }{% + #2% + }% + }{% + #2% + }% + }% + \newcommand{\axp@forward@target}[2]{% + \ifcsname hypertarget\endcsname + \hypertarget{#1}{#2}% + \else + #2% + \fi + } + \newcommand{\axp@forward@setup}[4]{% + \csedef{axp@cn@#1}{\ifblank{#4}{\ifblank{#2}{#1}{#2}}{#1}}% } \newcommand\noproofinappendix{% \global\togglefalse{axp@seenreptheorem}% @@ -245,15 +336,15 @@ } \let\axp@oldsection\section \def\section{\@ifstar\@section\@@section} - \def\@section#1{% - \global\edef\axp@sectitle{#1}% - \axp@oldsection*{#1}% - \addtocounter{axp@seccounter}{1}% - \label{axp@s\roman{axp@seccounter}}% - } - \def\@@section#1{% - \global\edef\axp@sectitle{#1}% - \axp@oldsection{#1}% + \newcommand{\@section}[2][\relax]{\axp@@@section{*}{#1}{#2}}% + \newcommand{\@@section}[2][\relax]{\axp@@@section{}{#1}{#2}}% + \newcommand{\axp@@@section}[3]{% + \global\def\axp@sectitle{#3}% + \ifx\relax#2\relax + \axp@oldsection#1{#3}% + \else + \axp@oldsection#1[{#2}]{#3}% + \fi \addtocounter{axp@seccounter}{1}% \label{axp@s\roman{axp@seccounter}}% } @@ -263,18 +354,27 @@ \newcommand\axp@writesection{% \ifx\axp@sectitle\@empty \else - \immediate\write\axp@proofsfile{% - \noexpand\def\noexpand\axp@tmp{% + \edef\axp@tmp{% + \noexpand\global\noexpand\def + \expandonce{\csname axp@protectref@\roman{axp@seccounter}\endcsname}{% \noexpand\ref{axp@s\roman{axp@seccounter}}% - } + }% + }% + \immediate\write\@auxout{\expandonce\axp@tmp} + \immediate\write\axp@proofsfile{% + \expandonce\axp@tmp^^J% \noexpand\axp@section{% - \noexpand\appendixsectionformat{\protect\noexpand\axp@tmp}% - {\axp@sectitle}% + \noexpand\appendixsectionformat{% + \protect + \expandonce{\csname axp@protectref@\roman{axp@seccounter}\endcsname}% + }{\expandonce\axp@sectitle}% }% }% \nosectionappendix \fi } + \let\axp@oldtableofcontents\tableofcontents + \def\tableofcontents{{\let\section\axp@oldsection\axp@oldtableofcontents}} \ifthenelse{\equal{\axp@appendix}{append}}{ \let\axp@oldbibliography\bibliography \renewcommand\bibliography[1]{% @@ -320,13 +420,6 @@ \patchcmd{\thebibliography}{References}{\protect\refname}{}{} \newcommand{\refname}{REFERENCES} \renewcommand{\appendixrefname}{REFERENCES FOR THE APPENDIX} - \def\section{\@ifstar\@section{\@dblarg{\@@section}}} - \def\@@section[#1]#2{% - \global\edef\axp@sectitle{#2}% - \axp@oldsection{#2}% - \addtocounter{axp@seccounter}{1}% - \label{axp@s\roman{axp@seccounter}}% - } \fi \@ifclassloaded{acmart}{ \newtheoremstyle{mystyle} |