summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/apxproof
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/apxproof
Initial commit
Diffstat (limited to 'macros/latex/contrib/apxproof')
-rw-r--r--macros/latex/contrib/apxproof/LICENSE415
-rw-r--r--macros/latex/contrib/apxproof/Makefile20
-rw-r--r--macros/latex/contrib/apxproof/README.md52
-rw-r--r--macros/latex/contrib/apxproof/apxproof.bib13
-rw-r--r--macros/latex/contrib/apxproof/apxproof.dtx1510
-rw-r--r--macros/latex/contrib/apxproof/apxproof.ins67
-rw-r--r--macros/latex/contrib/apxproof/apxproof.pdfbin0 -> 559200 bytes
7 files changed, 2077 insertions, 0 deletions
diff --git a/macros/latex/contrib/apxproof/LICENSE b/macros/latex/contrib/apxproof/LICENSE
new file mode 100644
index 0000000000..4db9b5af29
--- /dev/null
+++ b/macros/latex/contrib/apxproof/LICENSE
@@ -0,0 +1,415 @@
+The LaTeX Project Public License
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+LPPL Version 1.3c 2008-05-04
+
+Copyright 1999 2002-2008 LaTeX3 Project
+ Everyone is allowed to distribute verbatim copies of this
+ license document, but modification of it is not allowed.
+
+
+PREAMBLE
+========
+
+The LaTeX Project Public License (LPPL) is the primary license under
+which the LaTeX kernel and the base LaTeX packages are distributed.
+
+You may use this license for any work of which you hold the copyright
+and which you wish to distribute. This license may be particularly
+suitable if your work is TeX-related (such as a LaTeX package), but
+it is written in such a way that you can use it even if your work is
+unrelated to TeX.
+
+The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE',
+below, gives instructions, examples, and recommendations for authors
+who are considering distributing their works under this license.
+
+This license gives conditions under which a work may be distributed
+and modified, as well as conditions under which modified versions of
+that work may be distributed.
+
+We, the LaTeX3 Project, believe that the conditions below give you
+the freedom to make and distribute modified versions of your work
+that conform with whatever technical specifications you wish while
+maintaining the availability, integrity, and reliability of
+that work. If you do not see how to achieve your goal while
+meeting these conditions, then read the document `cfgguide.tex'
+and `modguide.tex' in the base LaTeX distribution for suggestions.
+
+
+DEFINITIONS
+===========
+
+In this license document the following terms are used:
+
+ `Work'
+ Any work being distributed under this License.
+
+ `Derived Work'
+ Any work that under any applicable law is derived from the Work.
+
+ `Modification'
+ Any procedure that produces a Derived Work under any applicable
+ law -- for example, the production of a file containing an
+ original file associated with the Work or a significant portion of
+ such a file, either verbatim or with modifications and/or
+ translated into another language.
+
+ `Modify'
+ To apply any procedure that produces a Derived Work under any
+ applicable law.
+
+ `Distribution'
+ Making copies of the Work available from one person to another, in
+ whole or in part. Distribution includes (but is not limited to)
+ making any electronic components of the Work accessible by
+ file transfer protocols such as FTP or HTTP or by shared file
+ systems such as Sun's Network File System (NFS).
+
+ `Compiled Work'
+ A version of the Work that has been processed into a form where it
+ is directly usable on a computer system. This processing may
+ include using installation facilities provided by the Work,
+ transformations of the Work, copying of components of the Work, or
+ other activities. Note that modification of any installation
+ facilities provided by the Work constitutes modification of the Work.
+
+ `Current Maintainer'
+ A person or persons nominated as such within the Work. If there is
+ no such explicit nomination then it is the `Copyright Holder' under
+ any applicable law.
+
+ `Base Interpreter'
+ A program or process that is normally needed for running or
+ interpreting a part or the whole of the Work.
+
+ A Base Interpreter may depend on external components but these
+ are not considered part of the Base Interpreter provided that each
+ external component clearly identifies itself whenever it is used
+ interactively. Unless explicitly specified when applying the
+ license to the Work, the only applicable Base Interpreter is a
+ `LaTeX-Format' or in the case of files belonging to the
+ `LaTeX-format' a program implementing the `TeX language'.
+
+
+
+CONDITIONS ON DISTRIBUTION AND MODIFICATION
+===========================================
+
+1. Activities other than distribution and/or modification of the Work
+are not covered by this license; they are outside its scope. In
+particular, the act of running the Work is not restricted and no
+requirements are made concerning any offers of support for the Work.
+
+2. You may distribute a complete, unmodified copy of the Work as you
+received it. Distribution of only part of the Work is considered
+modification of the Work, and no right to distribute such a Derived
+Work may be assumed under the terms of this clause.
+
+3. You may distribute a Compiled Work that has been generated from a
+complete, unmodified copy of the Work as distributed under Clause 2
+above, as long as that Compiled Work is distributed in such a way that
+the recipients may install the Compiled Work on their system exactly
+as it would have been installed if they generated a Compiled Work
+directly from the Work.
+
+4. If you are the Current Maintainer of the Work, you may, without
+restriction, modify the Work, thus creating a Derived Work. You may
+also distribute the Derived Work without restriction, including
+Compiled Works generated from the Derived Work. Derived Works
+distributed in this manner by the Current Maintainer are considered to
+be updated versions of the Work.
+
+5. If you are not the Current Maintainer of the Work, you may modify
+your copy of the Work, thus creating a Derived Work based on the Work,
+and compile this Derived Work, thus creating a Compiled Work based on
+the Derived Work.
+
+6. If you are not the Current Maintainer of the Work, you may
+distribute a Derived Work provided the following conditions are met
+for every component of the Work unless that component clearly states
+in the copyright notice that it is exempt from that condition. Only
+the Current Maintainer is allowed to add such statements of exemption
+to a component of the Work.
+
+ a. If a component of this Derived Work can be a direct replacement
+ for a component of the Work when that component is used with the
+ Base Interpreter, then, wherever this component of the Work
+ identifies itself to the user when used interactively with that
+ Base Interpreter, the replacement component of this Derived Work
+ clearly and unambiguously identifies itself as a modified version
+ of this component to the user when used interactively with that
+ Base Interpreter.
+
+ b. Every component of the Derived Work contains prominent notices
+ detailing the nature of the changes to that component, or a
+ prominent reference to another file that is distributed as part
+ of the Derived Work and that contains a complete and accurate log
+ of the changes.
+
+ c. No information in the Derived Work implies that any persons,
+ including (but not limited to) the authors of the original version
+ of the Work, provide any support, including (but not limited to)
+ the reporting and handling of errors, to recipients of the
+ Derived Work unless those persons have stated explicitly that
+ they do provide such support for the Derived Work.
+
+ d. You distribute at least one of the following with the Derived Work:
+
+ 1. A complete, unmodified copy of the Work;
+ if your distribution of a modified component is made by
+ offering access to copy the modified component from a
+ designated place, then offering equivalent access to copy
+ the Work from the same or some similar place meets this
+ condition, even though third parties are not compelled to
+ copy the Work along with the modified component;
+
+ 2. Information that is sufficient to obtain a complete,
+ unmodified copy of the Work.
+
+7. If you are not the Current Maintainer of the Work, you may
+distribute a Compiled Work generated from a Derived Work, as long as
+the Derived Work is distributed to all recipients of the Compiled
+Work, and as long as the conditions of Clause 6, above, are met with
+regard to the Derived Work.
+
+8. The conditions above are not intended to prohibit, and hence do not
+apply to, the modification, by any method, of any component so that it
+becomes identical to an updated version of that component of the Work as
+it is distributed by the Current Maintainer under Clause 4, above.
+
+9. Distribution of the Work or any Derived Work in an alternative
+format, where the Work or that Derived Work (in whole or in part) is
+then produced by applying some process to that format, does not relax or
+nullify any sections of this license as they pertain to the results of
+applying that process.
+
+10. a. A Derived Work may be distributed under a different license
+ provided that license itself honors the conditions listed in
+ Clause 6 above, in regard to the Work, though it does not have
+ to honor the rest of the conditions in this license.
+
+ b. If a Derived Work is distributed under a different license, that
+ Derived Work must provide sufficient documentation as part of
+ itself to allow each recipient of that Derived Work to honor the
+ restrictions in Clause 6 above, concerning changes from the Work.
+
+11. This license places no restrictions on works that are unrelated to
+the Work, nor does this license place any restrictions on aggregating
+such works with the Work by any means.
+
+12. Nothing in this license is intended to, or may be used to, prevent
+complete compliance by all parties with all applicable laws.
+
+
+NO WARRANTY
+===========
+
+There is no warranty for the Work. Except when otherwise stated in
+writing, the Copyright Holder provides the Work `as is', without
+warranty of any kind, either expressed or implied, including, but not
+limited to, the implied warranties of merchantability and fitness for a
+particular purpose. The entire risk as to the quality and performance
+of the Work is with you. Should the Work prove defective, you assume
+the cost of all necessary servicing, repair, or correction.
+
+In no event unless required by applicable law or agreed to in writing
+will The Copyright Holder, or any author named in the components of the
+Work, or any other party who may distribute and/or modify the Work as
+permitted above, be liable to you for damages, including any general,
+special, incidental or consequential damages arising out of any use of
+the Work or out of inability to use the Work (including, but not limited
+to, loss of data, data being rendered inaccurate, or losses sustained by
+anyone as a result of any failure of the Work to operate with any other
+programs), even if the Copyright Holder or said author or said other
+party has been advised of the possibility of such damages.
+
+
+MAINTENANCE OF THE WORK
+=======================
+
+The Work has the status `author-maintained' if the Copyright Holder
+explicitly and prominently states near the primary copyright notice in
+the Work that the Work can only be maintained by the Copyright Holder
+or simply that it is `author-maintained'.
+
+The Work has the status `maintained' if there is a Current Maintainer
+who has indicated in the Work that they are willing to receive error
+reports for the Work (for example, by supplying a valid e-mail
+address). It is not required for the Current Maintainer to acknowledge
+or act upon these error reports.
+
+The Work changes from status `maintained' to `unmaintained' if there
+is no Current Maintainer, or the person stated to be Current
+Maintainer of the work cannot be reached through the indicated means
+of communication for a period of six months, and there are no other
+significant signs of active maintenance.
+
+You can become the Current Maintainer of the Work by agreement with
+any existing Current Maintainer to take over this role.
+
+If the Work is unmaintained, you can become the Current Maintainer of
+the Work through the following steps:
+
+ 1. Make a reasonable attempt to trace the Current Maintainer (and
+ the Copyright Holder, if the two differ) through the means of
+ an Internet or similar search.
+
+ 2. If this search is successful, then enquire whether the Work
+ is still maintained.
+
+ a. If it is being maintained, then ask the Current Maintainer
+ to update their communication data within one month.
+
+ b. If the search is unsuccessful or no action to resume active
+ maintenance is taken by the Current Maintainer, then announce
+ within the pertinent community your intention to take over
+ maintenance. (If the Work is a LaTeX work, this could be
+ done, for example, by posting to comp.text.tex.)
+
+ 3a. If the Current Maintainer is reachable and agrees to pass
+ maintenance of the Work to you, then this takes effect
+ immediately upon announcement.
+
+ b. If the Current Maintainer is not reachable and the Copyright
+ Holder agrees that maintenance of the Work be passed to you,
+ then this takes effect immediately upon announcement.
+
+ 4. If you make an `intention announcement' as described in 2b. above
+ and after three months your intention is challenged neither by
+ the Current Maintainer nor by the Copyright Holder nor by other
+ people, then you may arrange for the Work to be changed so as
+ to name you as the (new) Current Maintainer.
+
+ 5. If the previously unreachable Current Maintainer becomes
+ reachable once more within three months of a change completed
+ under the terms of 3b) or 4), then that Current Maintainer must
+ become or remain the Current Maintainer upon request provided
+ they then update their communication data within one month.
+
+A change in the Current Maintainer does not, of itself, alter the fact
+that the Work is distributed under the LPPL license.
+
+If you become the Current Maintainer of the Work, you should
+immediately provide, within the Work, a prominent and unambiguous
+statement of your status as Current Maintainer. You should also
+announce your new status to the same pertinent community as
+in 2b) above.
+
+
+WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE
+======================================================
+
+This section contains important instructions, examples, and
+recommendations for authors who are considering distributing their
+works under this license. These authors are addressed as `you' in
+this section.
+
+Choosing This License or Another License
+----------------------------------------
+
+If for any part of your work you want or need to use *distribution*
+conditions that differ significantly from those in this license, then
+do not refer to this license anywhere in your work but, instead,
+distribute your work under a different license. You may use the text
+of this license as a model for your own license, but your license
+should not refer to the LPPL or otherwise give the impression that
+your work is distributed under the LPPL.
+
+The document `modguide.tex' in the base LaTeX distribution explains
+the motivation behind the conditions of this license. It explains,
+for example, why distributing LaTeX under the GNU General Public
+License (GPL) was considered inappropriate. Even if your work is
+unrelated to LaTeX, the discussion in `modguide.tex' may still be
+relevant, and authors intending to distribute their works under any
+license are encouraged to read it.
+
+A Recommendation on Modification Without Distribution
+-----------------------------------------------------
+
+It is wise never to modify a component of the Work, even for your own
+personal use, without also meeting the above conditions for
+distributing the modified component. While you might intend that such
+modifications will never be distributed, often this will happen by
+accident -- you may forget that you have modified that component; or
+it may not occur to you when allowing others to access the modified
+version that you are thus distributing it and violating the conditions
+of this license in ways that could have legal implications and, worse,
+cause problems for the community. It is therefore usually in your
+best interest to keep your copy of the Work identical with the public
+one. Many works provide ways to control the behavior of that work
+without altering any of its licensed components.
+
+How to Use This License
+-----------------------
+
+To use this license, place in each of the components of your work both
+an explicit copyright notice including your name and the year the work
+was authored and/or last substantially modified. Include also a
+statement that the distribution and/or modification of that
+component is constrained by the conditions in this license.
+
+Here is an example of such a notice and statement:
+
+ %% pig.dtx
+ %% Copyright 2005 M. Y. Name
+ %
+ % 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 your option) any later version.
+ % The latest version of this license is in
+ % http://www.latex-project.org/lppl.txt
+ % and version 1.3 or later is part of all distributions of LaTeX
+ % version 2005/12/01 or later.
+ %
+ % This work has the LPPL maintenance status `maintained'.
+ %
+ % The Current Maintainer of this work is M. Y. Name.
+ %
+ % This work consists of the files pig.dtx and pig.ins
+ % and the derived file pig.sty.
+
+Given such a notice and statement in a file, the conditions
+given in this license document would apply, with the `Work' referring
+to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being
+generated from `pig.dtx' using `pig.ins'), the `Base Interpreter'
+referring to any `LaTeX-Format', and both `Copyright Holder' and
+`Current Maintainer' referring to the person `M. Y. Name'.
+
+If you do not want the Maintenance section of LPPL to apply to your
+Work, change `maintained' above into `author-maintained'.
+However, we recommend that you use `maintained', as the Maintenance
+section was added in order to ensure that your Work remains useful to
+the community even when you can no longer maintain and support it
+yourself.
+
+Derived Works That Are Not Replacements
+---------------------------------------
+
+Several clauses of the LPPL specify means to provide reliability and
+stability for the user community. They therefore concern themselves
+with the case that a Derived Work is intended to be used as a
+(compatible or incompatible) replacement of the original Work. If
+this is not the case (e.g., if a few lines of code are reused for a
+completely different task), then clauses 6b and 6d shall not apply.
+
+
+Important Recommendations
+-------------------------
+
+ Defining What Constitutes the Work
+
+ The LPPL requires that distributions of the Work contain all the
+ files of the Work. It is therefore important that you provide a
+ way for the licensee to determine which files constitute the Work.
+ This could, for example, be achieved by explicitly listing all the
+ files of the Work near the copyright notice of each file or by
+ using a line such as:
+
+ % This work consists of all files listed in manifest.txt.
+
+ in that place. In the absence of an unequivocal list it might be
+ impossible for the licensee to determine what is considered by you
+ to comprise the Work and, in such a case, the licensee would be
+ entitled to make reasonable conjectures as to which files comprise
+ the Work.
diff --git a/macros/latex/contrib/apxproof/Makefile b/macros/latex/contrib/apxproof/Makefile
new file mode 100644
index 0000000000..d24336a7d7
--- /dev/null
+++ b/macros/latex/contrib/apxproof/Makefile
@@ -0,0 +1,20 @@
+all: apxproof.pdf apxproof.sty
+
+clean:
+ -rm -f *.aux *.log *.gl? *.idx *.ilg *.fls *.ind *.axp *.bbl *.blg *.hd *.out
+
+ctan:
+ git archive --format zip master --prefix=apxproof/ --output apxproof.zip
+
+%.pdf: %.dtx %.sty
+ pdflatex $<
+ makeindex -s gind.ist $(patsubst %.pdf,%.idx,$@)
+ makeindex -s gglo.ist -o $(patsubst %.pdf,%.gls,$@) $(patsubst %.pdf,%.glo,$@)
+ bibtex $(patsubst %.pdf,%,$@)
+ bibtex bu1
+ pdflatex $<
+ pdflatex $<
+
+%.sty: %.ins %.dtx
+ -rm $@
+ latex $<
diff --git a/macros/latex/contrib/apxproof/README.md b/macros/latex/contrib/apxproof/README.md
new file mode 100644
index 0000000000..512574166a
--- /dev/null
+++ b/macros/latex/contrib/apxproof/README.md
@@ -0,0 +1,52 @@
+# `apxproof`: Proofs in Appendix
+
+## About
+
+The `apxproof` package makes it easier to write articles where proofs and
+other material are deferred to the appendix. The appendix material is
+written in the LaTeX code along with the main text which it naturally
+complements, and it is automatically deferred. The package can
+automatically send proofs to the appendix, can repeat in the appendix the
+theorem environments stated in the main text, can section the appendix
+automatically based on the sectioning of the main text, and supports a
+separate bibliography for the appendix material.
+
+The documentation of this package is provided in the
+[apxproof.pdf](apxproof.pdf) file.
+
+## Prerequisites
+
+In addition to a working installation of LaTeX2e, `apxproof` relies on a
+few other packages, which should be provided by all reasonable LaTeX
+distributions:
+ - `amsthm`
+ - `bibunits`
+ - `environ`
+ - `etoolbox`
+ - `fancyvrb`
+ - `ifthen`
+ - `kvoptions`
+
+## Manual installation
+
+Simply copy the file [apxproof.sty](apxproof.sty) in your LaTeX working directory, or
+in any other directory where LaTeX searches for packages.
+
+## License
+
+Copyright © 2016-2019 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
+your option) any later version. The latest version of this license is in
+http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
+all distributions of LaTeX version 2005/12/01 or later.
+
+## Contact
+
+https://github.com/PierreSenellart/apxproof
+
+Pierre Senellart <pierre@senellart.com>
+
+Bug reports and feature requests should
+preferably be submitted through the *Issues* feature of GitHub.
diff --git a/macros/latex/contrib/apxproof/apxproof.bib b/macros/latex/contrib/apxproof/apxproof.bib
new file mode 100644
index 0000000000..f0ae357682
--- /dev/null
+++ b/macros/latex/contrib/apxproof/apxproof.bib
@@ -0,0 +1,13 @@
+@book{ lamport86 ,
+ author = "Leslie Lamport" ,
+ title = "\LaTeX: A Document Preparation System" ,
+ publisher = "Addison--Wesley Pub.\ Co." ,
+ year = "1986" ,
+ address = "Reading, MA"
+}
+
+@misc{ proofsAreHard ,
+ author = "Unknown" ,
+ title = "Proofs are Hard" ,
+ year = "2016" ,
+}
diff --git a/macros/latex/contrib/apxproof/apxproof.dtx b/macros/latex/contrib/apxproof/apxproof.dtx
new file mode 100644
index 0000000000..25de2a7dcb
--- /dev/null
+++ b/macros/latex/contrib/apxproof/apxproof.dtx
@@ -0,0 +1,1510 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2016-2019 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 your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Pierre Senellart
+% <pierre@senellart.com> and a version control system for this work
+% is available at http://github.com/PierreSenellart/apxproof
+%
+% This work consists of the files apxproof.dtx and apxproof.ins
+% and the derived file apxproof.sty.
+%
+% \fi
+%
+% \iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
+%<package>\ProvidesPackage{apxproof}
+%<package> [2019/01/28 v1.1.1 Automatic proofs in appendix]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{apxproof}
+\usepackage{hypdoc}
+\usepackage{textcomp}
+\usepackage[TS1,T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{microtype}
+\newtheorem{example}{Example}
+\newtheoremrep{foobar}{Foobar}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{apxproof.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{729}
+%
+% \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
+% Lower-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
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \changes{v1.0.4}{2017/03/02}{Show options commented on in margin and index}
+%\iffalse
+% Taken from xkeyval.dtx
+%\fi
+%\makeatletter
+%\def\DescribeOption#1{\leavevmode\@bsphack
+% \marginpar{\raggedleft\PrintDescribeOption{#1}}%
+% \SpecialOptionIndex{#1}\@esphack\ignorespaces}
+%\def\PrintDescribeOption#1{\strut\emph{option}\\\MacroFont #1\ }
+%\def\SpecialOptionIndex#1{\@bsphack
+% \index{#1\actualchar{\protect\ttfamily#1}
+% (option)\encapchar usage}%
+% \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
+% usage}\@esphack}
+%\def\DescribeOptions#1{\leavevmode\@bsphack
+% \marginpar{\raggedleft\strut\emph{options}%
+% \@for\@tempa:=#1\do{%
+% \\\strut\MacroFont\@tempa\SpecialOptionIndex\@tempa
+% }}\@esphack\ignorespaces}
+%\makeatother
+%
+% \changes{v1.0.0}{2016/10/31}{Initial released version}
+% \changes{v1.0.1}{2016/11/07}{Prevent empty bibliography environment;
+% fix typos}
+%
+% \GetFileInfo{apxproof.sty}
+%
+% \makeatletter\c@IndexColumns=2\makeatother
+% \DoNotIndex{
+% \newcommand,\newenvironment,\end,\begin,\edef,\if,\else,\fi,\def,
+% \begingroup,\endgroup,\csname,\let,\noexpand,\protect,\expandafter,
+% \ifthenelse,\equal,\endcsname,\@empty,\@ifnotempty,\immediate,
+% \addtocounter,\newcounter,\newtoggle,\global,\ifdefined,\iftoggle,
+% \ifx,\jobname,\makeatletter,\makeatother,\newwrite,\NewEnviron,
+% \patchcmd,\relax,\renewcommand,\renewenvironment,\RequirePackage,
+% \roman,\space,\undefined,\unexpanded
+% }
+%
+% \title{The \textsf{apxproof} package}
+%
+% \author{Pierre Senellart \\ \texttt{pierre@senellart.com} \\
+% \url{http://github.com/PierreSenellart/apxproof}}
+% \date{\filedate \quad \fileversion}
+%
+% \maketitle
+%
+% \begin{abstract}
+% This package makes it easier to write articles where proofs and other material
+% are deferred to the appendix. The appendix material is written in the \LaTeX{}
+% code along with the main text which it naturally complements, and it is
+% automatically deferred. The package can automatically send proofs to the
+% appendix, can repeat in the appendix the theorem environments stated in the
+% main text, can section the appendix automatically based on the sectioning of
+% the main text, and supports a separate bibliography for the appendix material.
+% \end{abstract}
+%
+% \section{Usage}
+% The \textsf{apxproof} package is intended to simplify the writing of articles where some of
+% the content needs to be deferred to an appendix. This is in particular
+% useful for the submission of scientific articles to conferences or
+% journals that limit the number of pages in the main text but allow an
+% extra appendix, where proofs of theorems and other material can be added.
+%
+% \subsection{Basics}
+% To use \textsf{apxproof}, first load it in the header of your document:
+% \begin{quote}|\usepackage{apxproof}|\end{quote}
+% On its own, this does not do anything and should not change the
+% appearance of your document. To add an appendix with some material from
+% your document, use the |toappendix| environment:
+% \begin{quote}
+% |\begin{toappendix}|\DescribeEnv{toappendix}\\
+% \hspace*{1em}\dots\\
+% |\end{toappendix}|
+% \end{quote}
+% The content will appear at the end of your document, in an
+% automatically generated section that refers to the current section in the main
+% text.
+% \begin{example}
+% Throughout this documentation, all examples produce content
+% deferred to the appendix, at the very end of this document.
+% \begin{verbatim}
+% \begin{toappendix}
+% This content is in the appendix.
+% \end{toappendix}
+% \end{verbatim}
+% \begin{toappendix}
+%<*driver>
+This content is in the appendix.
+%</driver>
+% \end{toappendix}
+% \end{example}
+% \changes{v1.0.3}{2017/01/10}{Note on entire sections in appendix}
+% When the content to put in appendix is an entire section, make sure
+% that \verb|\section| is the very first command that appears within the
+% \verb|toappendix| environment. It will disable the automatic production
+% of a section heading.
+% \subsection{Repeated Theorems and Proofs}
+% In some scientific papers that include proofs, it is common to defer
+% proofs to the appendix. This can easily be achieved using the
+% |appendixproof| environment:
+% \begin{quote}
+% |\begin{appendixproof}|\DescribeEnv{appendixproof}\\
+% \hspace*{1em}\dots\\
+% |\end{appendixproof}|
+% \end{quote}
+% This behaves like the |toappendix| environment, except that
+% a proof environment is generated.
+% \begin{example}We now send a proof to the appendix:
+% \begin{verbatim}
+% \begin{appendixproof}
+% This proof is in the appendix.
+% \end{appendixproof}
+% \end{verbatim}
+% \begin{appendixproof}
+%<*driver>
+This proof is in the appendix.
+%</driver>
+% \end{appendixproof}
+% \end{example}
+%
+% When deferring proofs to the appendix, an annoying problem is that the
+% statement of the theorem remains in the main text; it is hard to read a
+% proof that is far away from the statement it proves. \textsf{apxproof}
+% solves this issue by allowing statements of theorems to be \emph{repeated}:
+% once in the main text, and once in the appendix before the proof of
+% the statement. To use this feature, you can define a new
+% \emph{repeated theorem} environment using the |\newtheoremrep| command:
+% \changes{v1.0.5}{2017/05/31}{Ability to specify a sectioning counter in newtheoremrep}
+% \begin{quote}
+% |\newtheoremrep|\marg{name}\oarg{counter}\marg{title}\oarg{countersec}\DescribeMacro{\newtheoremrep}
+% \end{quote}
+% Usage is exactly the same as that of AMS \LaTeX{}'s |\newtheorem|
+% macro:
+% \begin{itemize}
+% \item \meta{name} (e.g., |theorem|) is the name of an environment that is created for this kind of
+% theorem;
+% \item \meta{counter} (e.g., |definition|) is an optional counter describing
+% from which kind of environment should the numbering of these environments be
+% inherited;
+% \item \meta{title}
+% (e.g., |Theorem|) is
+% the title that will be used to display this theorem environment;
+% \item \meta{countersec} (e.g., |section|) is an optional counter of a
+% sectioning command indicating that counters for this theorem should
+% be prefixed by this counter (and reset at each occurrence of the
+% sectioning command).
+% \end{itemize}
+% \meta{counter} and \meta{countersec} should not be used together.
+% What
+% differs from |\newtheorem| is that, when the following is written:
+% \begin{quote}
+% |\newtheoremrep{foobar}{Foobar}|
+% \end{quote}
+% then \emph{two} environments are defined: the \verb|foobar|
+% environment, which behaves as if |\newtheorem| had been used, and the
+% |foobarrep| environment, which results in the statement of this
+% environment being repeated in the appendix.
+%
+% One interesting feature of \textsf{apxproof} is that in most
+% situations, there is no need to use the |appendixproof| environment.
+% Indeed, the |proof| \DescribeEnv{proof} environment is redefined by \textsf{apxproof} to
+% automatically put the proof either in the main text (if it follows a
+% regular theorem) or in the appendix (if it follows a repeated
+% theorem).
+% \begin{example}
+% Assume we have first defined a repeated theorem environment |foobar| as
+% above.
+% We can now use this theorem environment, first for a regular theorem in
+% the main text, then for a theorem repeated in the main text and in the
+% appendix:
+% \begin{quote}
+% \begin{verbatim}
+% \begin{foobar}
+% This foobar is a regular one, in the main text.
+% \end{foobar}
+% \begin{proof}
+% This is the proof of the regular foobar.
+% \end{proof}
+% \end{verbatim}
+% \end{quote}
+% We obtain:
+% \begin{foobar}
+% This foobar is a regular one, in the main text.
+% \end{foobar}
+% \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}
+% This foobar is repeated in the appendix.
+% \end{foobarrep}
+% \begin{proof}
+% This is the proof of the repeated foobar.
+% \end{proof}
+% \end{verbatim}
+% \end{quote}
+% We now obtain:
+% \begin{foobarrep}
+% This foobar is repeated in the appendix.
+% \end{foobarrep}
+% \begin{proof}
+%<*driver>
+This is the proof of the repeated foobar.
+%</driver>
+% \end{proof}
+% 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
+% add a proof sketch in the main text. \textsf{apxproof} defines a simple
+% |proofsketch| environment for this purpose:
+% \changes{v1.0.5}{2017/05/31}{Fix compilation of proofsketch environment in inline mode}
+% \begin{quote}
+% |\begin{proofsketch}|\DescribeEnv{proofsketch}\\
+% \hspace*{1em}\dots\\
+% |\end{proofsketch}|
+% \end{quote}
+% 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 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
+% proofs:
+% \begin{verbatim}
+% \begin{proofsketch}
+% This is a proof sketch.
+% \end{proofsketch}
+% \end{verbatim}
+% \begin{proofsketch}
+% This is a proof sketch.
+% \end{proofsketch}
+% \begin{verbatim}
+% \begin{inlineproof}
+% This is an inline proof.
+% \end{inlineproof}
+% \end{verbatim}
+% \begin{inlineproof}
+% This is an inline proof.
+% \end{inlineproof}
+% \end{example}
+%
+% \subsection{Bibliography}
+% By default, \textsf{apxproof} automatically adds a bibliography in the appendix
+% with only the references cited in the appendix material. This allows for a
+% clean separation of references used solely in the main text, and those
+% used in the appendix.
+% \begin{example}
+% Assume we have citations both in the main text and in the appendix.
+% \begin{verbatim}
+% This is a citation in the main text~\cite{lamport86}.
+% \begin{toappendix}
+% This is a citation in the appendix~\cite{proofsAreHard}.
+% \end{toappendix}
+% \end{verbatim}
+% This is a citation in the main text~\cite{lamport86}.
+% \begin{toappendix}
+%<*driver>
+This is a citation in the appendix~\cite{proofsAreHard}.
+%</driver>
+% \end{toappendix}
+% \end{example}
+% The bibliography in the appendix can use
+% a different style and heading than the bibliography in the main text (and, by
+% default, it does). See
+% Section~\ref{sec:customization} for how to configure the appearance of
+% that bibliography.
+%
+% \DescribeOption{bibliography}
+% In order to use a single appendix for the main text and the
+% bibliography, one can specify the
+% value |common| to the |bibliography| option when loading the package.
+% (By default this option is set to |separate|.)
+% \subsection{Mode}
+% \DescribeOption{appendix}
+% An optional \meta{mode} can be specified when loading the package:
+% \begin{quote}|\usepackage[appendix=|\meta{mode}|]{apxproof}|\end{quote}
+% \meta{mode} can take one of the following three values:
+% \begin{description}
+% \item[|append|] This is the default.
+% Appendix material gathered by \textsf{apxproof} is appended to
+% the main text.
+% \item[|inline|] In this mode, \textsf{apxproof} simply inline the
+% content along with the main text.
+% \item[|strip|] This mode functions similarly to |append| except that
+% the appendix is not appended at the end of the document. All appendix
+% material is therefore removed.
+% \end{description}
+%
+% \subsection{Customization}
+% \label{sec:customization}
+% \textsf{apxproof} provides a few macros that can be redefined (using
+% |\renewcommand|) to customize the appearance of the appendix:
+% \begin{description}
+% \item[\textbackslash|appendixsectionformat|\marg{number}\marg{title}]\DescribeMacro{\appendixsectionformat} is a macro
+% that indicates how to format the section titles in the Appendix, given
+% the number and title of the section in the main text. By
+% default, they appear as ``Proofs for Section~\meta{number}
+% (\meta{title})''.
+% \item[\textbackslash|appendixrefname|]\DescribeMacro{\appendixrefname} contains the heading that is displayed before
+% the bibliography. By default, this is ``References for the
+% Appendix''.
+% \item[\textbackslash|appendixbibliographystyle|]\DescribeMacro{\appendixbibliographystyle} contains the |.bst| bibliography
+% style that is used in the bibliography in appendix. By default, this is
+% |alpha|.
+% \item[\textbackslash|appendixbibliographyprelim|]\DescribeMacro{\appendixbibliographyprelim} contains arbitrary code that is executed
+% just before the production of the bibliography in appendix, which can
+% be used to configure the way it is displayed.
+% \item[\textbackslash|appendixprelim|]\DescribeMacro{\appendixprelim} contains arbitrary code that is executed
+% just before the production of the appendix, which can
+% be used to configure the way it is displayed. By default, this command
+% contains |\clearpage\onecolumn| (the appendix is typeset on a new page
+% 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
+% special cases:
+% \begin{description}
+% \item[|nestedproof|]\DescribeEnv{nestedproof} is an environment that
+% can be used within a |proof| environment deferred in the appendix; this
+% is required because, for technical reasons, no |proof| environment can
+% be nested within a deferred |proof| environment.
+% \item[\textbackslash|noproofinappendix|]\DescribeMacro{\noproofinappendix}
+% can be used inside repeated theorems that are not followed by a
+% |proof| or |appendixproof| theorem; the point is to ensure that a further
+% |proof| environment cannot be mistakenly understood as a proof of the repeated
+% theorem. It should not be needed in most situations as
+% \textsf{apxproof} tries figuring out when a proof follows a repeated
+% theorem automatically, but may occasionally be needed in complex
+% scenarios.
+% \item[\textbackslash|nosectionappendix|]\DescribeMacro{\nosectionappendix}
+% is to be used inside a section that \emph{does} contain appendix material, but
+% for which a section in the appendix should not be created. This should
+% be rarely needed. When this command is present, appendix material is
+% appended to the end of the previously created section.
+% \end{description}
+% \section{Supported Document Classes}
+% Because \textsf{apxproof} modifies sectioning commands, bibliographies,
+% and proofs, it may not work straight away with arbitrary document classes.
+% It has currently been tested with and is supported for the following
+% document classes:
+% \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|, |scrbook.cls|)
+% \item \href{https://www.acm.org/publications/proceedings-template}{ACM
+% 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|, |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
+% author of this package.
+% \section{Known Issues and Limitations}
+% We report here some issues we are currently aware of:
+% \begin{itemize}
+% \item When using \textsf{hyperref}, the appendix in the bibliography is
+% not hyperlinked. This is to avoid possible issues with multiply defined
+% bibliography entries.
+% \item |appendixproof|, |proof|, |toappendix| environments cannot be nested. This is a limitation of
+% the \textsf{fancyvrb} package that \textsf{apxproof} relies on. Note
+% the existence of the |nestedproof| environment for nested proofs.
+% \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--2019 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
+% your option) any later version. The latest version of this license is in
+% \url{http://www.latex-project.org/lppl.txt} and version 1.3 or later is part of
+% all distributions of \LaTeX{} version 2005/12/01 or later.
+%
+% \section{Contact}
+% \begin{itemize}
+% \item \url{https://github.com/PierreSenellart/apxproof}
+% \item
+% Pierre Senellart
+% \href{mailto:pierre@senellart.com}{<pierre@senellart.com>}
+% \end{itemize}
+% Bug reports and feature requests should
+% preferably be submitted through the \emph{Issues} feature of GitHub.
+%
+% \section{Acknowledgments}
+% 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
+% \PrintIndex
+% }
+%
+% \section{Implementation}
+% We now describe the entire code of the package, in a literate programming
+% fashion. Throughout the package, we use the |axp@| prefix to identify
+% local macros and environment names, which are not meant to be used by the final
+% user.
+% \subsection{Dependencies}
+% We first load a few package dependencies:
+% \begin{itemize}
+% \item \textsf{bibunits} to add a second bibliography for the appendix
+% material.
+% \begin{macrocode}
+\RequirePackage{bibunits}
+% \end{macrocode}
+% \item \textsf{environ} to easily define the repeated theorem
+% environments.
+% \begin{macrocode}
+\RequirePackage{environ}
+% \end{macrocode}
+% \item \textsf{etoolbox} to define simple toggles.
+% \begin{macrocode}
+\RequirePackage{etoolbox}
+% \end{macrocode}
+% \item \textsf{fancyvrb} for the bulk of the work of exporting appendix
+% material in an auxiliary file.
+% \begin{macrocode}
+\RequirePackage{fancyvrb}
+% \end{macrocode}
+% \item \textsf{ifthen} for easier comparison of character strings.
+% \begin{macrocode}
+\RequirePackage{ifthen}
+% \end{macrocode}
+% \item \textsf{kvoptions} to manage options passed to the package.
+% \begin{macrocode}
+\RequirePackage{kvoptions}
+% \end{macrocode}
+% \item \textsf{amsthm} for its |\newteorem| macro.
+% Some document classes (e.g., \textsf{lipics})
+% preload \textsf{amsthm}: this is fine, |\RequirePackage{amsthm}|
+% will simply have no effect. On the other hand, some other document
+% classes (e.g., \textsf{llncs} or \textsf{sig-alternate}) define a
+% |proof| environment that conflicts with \textsf{amsthm}, so we have to
+% undefine this environment before loading \textsf{amsthm}. In that case,
+% we reestablish the existing proof environments, in case they had been
+% customized (e.g., \textsf{sig-alternate})
+% \changes{v1.0.4}{2017/03/08}{Re-establish custom proof environments}
+% \begin{macrocode}
+\@ifpackageloaded{amsthm}{
+ }{
+ \let\apx@oldamsthmproof\proof
+ \let\apx@oldamsthmendproof\endproof
+ \let\proof\undefined
+ \let\endproof\undefined
+ }
+\RequirePackage{amsthm}
+\ifdefined\apx@oldamsthmproof
+ \let\proof\apx@oldamsthmproof
+ \let\endproof\apx@oldamsthmendproof
+\fi
+% \end{macrocode}
+% \end{itemize}
+% \subsection{Option Processing}
+% Many names throughout the package use an arobase (|@|) to avoid name
+% conflict with user-defined names. To simplify the compilation of the
+% documentation, we simply make it a regular character in all the rest.
+% \begin{macrocode}
+\makeatletter
+% \end{macrocode}
+% We setup the processing of options using \textsf{keyval} facilities.
+% \begin{macrocode}
+\SetupKeyvalOptions{
+ family=axp,
+ prefix=axp@
+}
+% \end{macrocode}
+% We declare the following options:
+% \begin{itemize}
+% \item |appendix|, with a default value of |append| (other possible
+% 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}
+\DeclareStringOption[append]{appendix}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\axp@bibliography}
+% \changes{v1.0.4}{2017/03/02}{\texttt{bibliography} option}
+% \begin{macrocode}
+\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 options are valid, and add a
+% message to the compilation log.
+% \begin{macrocode}
+\ifthenelse{\equal{\axp@appendix}{append}}{
+ \message{apxproof: Appendix material appended to the document}
+}{\ifthenelse{\equal{\axp@appendix}{strip}}{
+ \message{apxproof: Appendix material stripped}
+}{\ifthenelse{\equal{\axp@appendix}{inline}}{
+ \message{apxproof: Appendix material inlined within the document}
+}{
+ \errmessage{Error: unsupported option appendix=\axp@appendix\ for
+ package apxproof}
+}}}
+\ifthenelse{\equal{\axp@bibliography}{separate}}{
+ \message{apxproof: Separate bibliography for appendix material}
+}{\ifthenelse{\equal{\axp@bibliography}{common}}{
+ \message{apxproof: Common bibliography for appendix and main text}
+}{
+ \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}
+% \subsection{Macros Common to All Compilation Modes}
+% \begin{macro}{\axp@newtheorem}
+% \changes{v1.0.6}{2018/05/10}{Introduce intermediary command for theorem
+% macro}
+% \begin{macro}{\@axp@newtheorem}
+% \begin{macro}{\@@axp@newtheorem}
+% We introduce an intermediate |\axp@newtheorem| command to define a new
+% theorem, differently depending on whether there is a section counter or
+% not. This will be useful, in particular to allow changing this
+% definition depending on the document class. This command uses two
+% intermediary commands, |\@axp@newtheorem| and |\@@axp@newtheorem|, for
+% the non-starred and starred versions.
+\def\axp@newtheorem{\@ifstar\@@axp@newtheorem\@axp@newtheorem}
+\def\@axp@newtheorem#1#2#3#4{%
+ \ifx\relax#4\relax
+ \newtheorem{#1}[#2]{#3}%
+ \else
+ \newtheorem{#1}{#3}[#4]%
+ \fi
+}
+\def\@@axp@newtheorem#1#2{%
+ \newtheorem*{#1}{#2}%
+}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\newtheoremrep}
+% \begin{macro}{\axp@newtheoremreptmp}
+% We define the high-level |\newtheoremrep| to have the same syntax as
+% \textsf{amsthm}'s |\newtheorem|. For this purpose, we need a little
+% trick to deal with the second and fourth optional arguments, which is what
+% |\@oparg| and |\axp@newtheoremreptmp| are
+% used for. |\axp@newtheoremrep| is defined differently
+% depending on the compilation mode.
+% \begin{macrocode}
+\newcommand\newtheoremrep[1]{%
+ \@oparg{\axp@newtheoremreptmp{#1}}[]%
+}
+\def\axp@newtheoremreptmp#1[#2]#3{%
+ \@oparg{\axp@newtheoremrep{#1}[#2]{#3}}[]%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{environment}{proofsketch}
+% Simple |proofsketch| environment.
+% \changes{v1.0.3}{2016/12/16}{Ignore spaces after beginning of Proof sketch}
+% \begin{macrocode}
+ \newenvironment{proofsketch}{\begin{axp@oldproof}[Proof sketch]}{\end{axp@oldproof}}
+% \end{macrocode}
+% \end{environment}
+% \begin{macro}{\thmhead}
+% \changes{v1.0.2}{2016/12/13}{Fix display of repeated theorem counter in
+% some document classes}
+% We redefine AMS-\LaTeX{}'s |\thmhead| to use a format where the
+% repeated version of a theorem, using a theorem note, can look exactly
+% like the original version of the theorem and its theorem counter.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \def\thmhead#1#2#3{%
+ \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
+ \thmnote{ #3}}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\appendixrefname}
+% \begin{macro}{\appendixbibliographystyle}
+% \begin{macro}{\appendixbibliographyprelim}
+% \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.
+% \begin{macrocode}
+\newcommand{\appendixrefname}{References for the Appendix}
+\newcommand{\appendixbibliographystyle}{alpha}
+\newcommand{\appendixbibliographyprelim}{}
+\newcommand{\appendixprelim}{\clearpage\onecolumn}
+\newcommand{\appendixsectionformat}[2]{Proofs for Section~#1\ (#2)}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{environment}{axp@oldproof}
+% We save the definition of the existing |proof| environment.
+% \begin{macrocode}
+ \let\axp@oldproof\proof
+ \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}
+% \changes{v1.0.6}{2018/05/10}{Better support of Springer document
+% classes}
+% \begin{macrocode}
+ \ifdefined\spnewtheorem
+% \end{macrocode}
+% \begin{macro}{\@axp@newtheorem}
+% \begin{macro}{\@@axp@newtheorem}
+% It is necessary to use |\spnewtheorem| instead of |\newtheorem| in
+% Springer document classes to obtain standard formatting.
+% \begin{macrocode}
+\def\@axp@newtheorem#1#2#3#4{%
+ \ifx\relax#4\relax
+ \ifx\relax#2\relax
+ \spnewtheorem{#1}{#3}{\bfseries}{\itshape}%
+ \else
+ \spnewtheorem{#1}[#2]{#3}{\bfseries}{\itshape}%
+ \fi
+ \else
+ \spnewtheorem{#1}{#3}[#4]{\bfseries}{\itshape}%
+ \fi
+}
+\def\@@axp@newtheorem#1#2{%
+ \spnewtheorem*{#1}{#2}{\upshape\bfseries}{\itshape}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% We have to redefine the macro |\@thmcountersep| for proper sectioned
+% counters.
+% \begin{macrocode}
+\def\@thmcountersep{.}
+% \end{macrocode}
+% We remove the parentheses added by default for theorem notes, which are
+% not compatible with the use of theorem notes by \textsf{apxproof}.
+% \begin{macrocode}
+\def\@Opargbegintheorem#1#2#3#4{#4\trivlist
+ \item[\hskip\labelsep{#3#1}]{#3 #2\@thmcounterend\ }}
+\def\@spopargbegintheorem#1#2#3#4#5{\trivlist
+ \item[\hskip\labelsep{#4#1\ #2}]{#4 #3\@thmcounterend\ }#5}
+% \end{macrocode}
+% \begin{macrocode}
+ \fi
+% \end{macrocode}
+% \subsection{Inline Compilation Mode}
+% \begin{macrocode}
+\ifthenelse{\equal{\axp@appendix}{inline}}{
+% \end{macrocode}
+% \begin{macro}{\axp@newtheoremrep}
+% 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,
+% 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]\axp@redefinelabels\BODY\end{#1}%
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{inlineproof}
+% \begin{environment}{nestedproof}
+% \begin{environment}{appendixproof}
+% In inline mode, these environments behave like the regular |proof|
+% environment.
+% \begin{macrocode}
+ \let\inlineproof\proof
+ \let\endinlineproof\endproof
+ \let\nestedproof\proof
+ \let\endnestedproof\endproof
+ \let\appendixproof\proof
+ \let\endappendixproof\endproof
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \begin{environment}{toappendix}
+% \begin{macro}{\noproofinappendix}
+% \begin{macro}{\nosectionappendix}
+% In inline mode, this environment and these macros are no-ops.
+% \begin{macrocode}
+ \newenvironment{toappendix}{}{}
+ \let\noproofinappendix\relax
+ \let\nosectionappendix\relax
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{environment}
+% \begin{macrocode}
+}
+% \end{macrocode}
+% \subsection{Append or Strip Compilation Modes}
+% \begin{macrocode}
+{
+% \end{macrocode}
+% We now deal with the case where \textsf{apxproof} really does something
+% useful: either append the appendix material to the document, or strip
+% it entirely.
+% \bigskip
+% \subsubsection{Auxiliary File for the Appendix}
+% \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}
+ \AtBeginDocument{
+ \newwrite\axp@proofsfile
+ \immediate\openout\axp@proofsfile=\jobname.axp
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{proof}
+% \begin{macro}{\section}
+% At the beginning of this file, we make |@| a regular character (since
+% 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}
+ \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}
+% \end{environment}
+% \begin{macro}{\axp@unactivateeightbit}
+% \changes{v1.1.0-dev}{2019/01/28}{Fix compilation of non-ASCII
+% characters with \texttt{\textbackslash usepackage[utf8]\{inputenc\}}}
+% We need an auxiliary macro to disable active characters that have the
+% high bit set when writing to the |.axp| file. See
+% \url{https://tex.stackexchange.com/a/145361/166858}
+% \begin{macrocode}
+ \def\axp@unactivateeightbit{%
+ \count@=128%
+ \loop
+ \catcode\count@=12%
+ \ifnum\count@<255%
+ \advance\count@\@ne
+ \repeat}
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{axp@VerbatimOut}
+% \begin{macro}{\FVB@axp@VerbatimOut}
+% \begin{macro}{\FVE@axp@VerbatimOut}
+% \changes{v1.1.0-dev}{2018/10/02}{Make \textsf{apxproof} compatible with
+% independent use of \textsf{fancyvrb}}
+% Using the functionalities of the \textsf{fancyvrb} package, we define a
+% custom verbatim environment |axp@VerbatimOut| that writes every line
+% to the |\axp@proofsfile|. We also use the previous macro to disable active
+% characters with the eighth bit set.
+% \begin{macrocode}
+ \DefineVerbatimEnvironment{axp@VerbatimOut}{axp@VerbatimOut}{}
+ \def\FVB@axp@VerbatimOut{%
+ \@bsphack
+ \begingroup
+ \axp@unactivateeightbit
+ \FV@DefineWhiteSpace
+ \def\FV@Space{\space}%
+ \FV@DefineTabOut
+ \def\FV@ProcessLine{\immediate\write\axp@proofsfile}%
+ \let\FV@FontScanPrep\relax
+ \let\@noligs\relax
+ \FV@Scan}
+ \def\FVE@axp@VerbatimOut{\endgroup\@esphack}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{environment}
+% \begin{environment}{toappendix}
+% The entire content of this environment is put in appendix,
+% starting a new appendix section beforehand if needed.
+% \begin{macrocode}
+ \newenvironment{toappendix}
+ {\axp@writesection\axp@VerbatimOut}
+ {\endaxp@VerbatimOut}
+% \end{macrocode}
+% \end{environment}
+% \subsubsection{Definition of New Theorems}
+% \begin{macro}{axp@seenreptheorem}
+% Used to indicate whether a repeated theorem was just typeset, without
+% its proof.
+% \begin{macrocode}
+ \newtoggle{axp@seenreptheorem}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{axp@rpcounter}
+% Sequentially incremented for every repeated theorem, used to create labels.
+% \begin{macrocode}
+ \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
+% document class), then invoke |\newtheorem| for the regular version
+% of the theorem |foobar| (patching the |\begin{foobar}| so as not to
+% expect a proof in the appendix) and |\newtheorem*| for an internal version |axp@foobarrp| that
+% will be used in the appendix to restate the existing theorem.
+% \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}%
+ \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
+% derived from the counter. We distinguish the case when the theorem
+% argument has a note and when it does not.
+% \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}
+% 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
+ \axp@with@forward{#1}{\begin{#1}}\label{axp@r\roman{axp@rpcounter}}\BODY\end{#1}%
+ \else
+ \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
+% for the proof of the theorem, then store in a macro the content of the
+% theorem's body.
+% \begin{macrocode}
+ \global\toggletrue{axp@seenreptheorem}%
+ \global\expandafter\let\csname rplet\roman{axp@rpcounter}%
+ \endcsname
+ \BODY
+% \end{macrocode}
+% 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 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}
+% \changes{v1.0.6}{2018/05/10}{Fix incorrect use of \texttt{\textbackslash noexpand}
+% 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\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{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.
+% \begin{macrocode}
+ \newcommand\noproofinappendix{%
+ \global\togglefalse{axp@seenreptheorem}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{appendixproof}
+% We dump the content of this in appendix, within an original |proof|
+% environment, possibly after creating a new appendix section.
+% \begin{macrocode}
+ \newenvironment{appendixproof}
+ {%
+ \axp@writesection
+ \immediate\write\axp@proofsfile{%
+ \noexpand\begin{axp@oldproof}%
+ }%
+ \axp@VerbatimOut
+ }
+ {%
+ \endaxp@VerbatimOut
+ \immediate\write\axp@proofsfile{%
+ \noexpand\end{axp@oldproof}%
+ }%
+ \noproofinappendix
+ }
+% \end{macrocode}
+% \end{environment}
+% \begin{environment}{proof}
+% This environment either puts the proof in appendix, if we are after a repeated
+% theorem without its proof, or inlines it otherwise.
+% \begin{macrocode}
+ \renewenvironment{proof}
+ {%
+ \iftoggle{axp@seenreptheorem}{%
+ \appendixproof
+ }{%
+ \axp@oldproof
+ }%
+ }
+ {%
+ \iftoggle{axp@seenreptheorem}{%
+ \endappendixproof
+ }{%
+ \endaxp@oldproof
+ }%
+ }
+% \end{macrocode}
+% \end{environment}
+% \begin{environment}{inlineproof}
+% \begin{environment}{nestedproof}
+% These two environments are synonyms for the original |proof|
+% environment.
+% \begin{macrocode}
+ \let\inlineproof\axp@oldproof
+ \let\endinlineproof\endaxp@oldproof
+ \let\nestedproof\axp@oldproof
+ \let\endnestedproof\endaxp@oldproof
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \subsubsection{Section Management}
+% \begin{macro}{axp@seccounter}
+% Sequentially incremented for every section, used to create labels.
+% \begin{macrocode}
+ \newcounter{axp@seccounter}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\axp@sectitle}
+% Saves the title of the last encountered section.
+% \begin{macrocode}
+ \def\axp@sectitle{}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\axp@section}
+% \begin{macro}{\axp@@ssection}
+% \begin{macro}{\axp@@section}
+% This command behaves similarly to |\axp@oldsection|, except that it first
+% tests whether a |\section| follows, and if so, does not produce
+% anything. This is useful to avoid producing empty sections in the
+% appendix. As usual, we have to process starred and unstarred version
+% separately.
+% \begin{macrocode}
+ \def\axp@section{\@ifstar\axp@@ssection\axp@@section}
+ \def\axp@@ssection#1{%
+ \@ifnextchar\section{}{\axp@oldsection*{#1}}%
+ }
+ \def\axp@@section#1{%
+ \@ifnextchar\section{}{\axp@oldsection{#1}}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \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|.
+% 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}
+ \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}}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\nosectionappendix}
+% We remove the current section title, to indicate no section should be
+% created in the appendix.
+% \begin{macrocode}
+ \newcommand{\nosectionappendix}{
+ \global\def\axp@sectitle{}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \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
+ \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
+ \expandonce{\csname axp@protectref@\roman{axp@seccounter}\endcsname}%
+ }{\expandonce\axp@sectitle}%
+ }%
+ }%
+ \nosectionappendix
+ \fi
+ }
+% \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}}{
+% \end{macrocode}
+% \begin{macro}{\axp@oldbibliography}
+% \begin{macro}{\bibliography}
+% Thanks to \textsf{bibunits}'s |\defaultbibliography| macro, we set the appendix
+% bibliography source to be the same as that of the main text.
+% \begin{macrocode}
+ \let\axp@oldbibliography\bibliography
+ \renewcommand\bibliography[1]{%
+ \defaultbibliography{#1}%
+ \axp@oldbibliography{#1}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% After the end of the main text, we add the appendix (after the command
+% |\appendixprelim| is issued)
+% within a |bibunit| environment so as to typeset
+% a separate bibliography for the appendix (unless the |bibliography|
+% option is set to |common|). There is an extra test to
+% ensure an empty bibliography environment is not produced.
+% The name of the bibliography is changed to |\appendixrefname|; in most
+% document classes, it is called |\refname| but it is occasionally
+% (|scrartcl|, |scrreprt|) called |\bibname|.
+% \changes{v1.0.6}{2018/05/10}{Deal with document classes where the
+% bibliography is called \texttt{\textbackslash bibname}}
+% \begin{macrocode}
+ \AtEndDocument{
+ \appendixprelim
+ \appendix
+ \ifthenelse{\equal{\axp@bibliography}{separate}}{
+ \begin{bibunit}[\appendixbibliographystyle]
+ }{}
+ \immediate\closeout\axp@proofsfile
+ \input{\jobname.axp}
+ \ifthenelse{\equal{\axp@bibliography}{separate}}{
+ \ifdefined\refname
+ \renewcommand{\refname}{\appendixrefname}
+ \else\ifdefined\bibname
+ \renewcommand{\bibname}{\appendixrefname}
+ \fi\fi
+ \let\axp@oldthebibliography\thebibliography
+ \renewcommand\thebibliography[1]{%
+ \ifx\relax#1\relax\else\axp@oldthebibliography{#1}\fi}
+ \appendixbibliographyprelim
+ \putbib
+ \end{bibunit}
+ }{}
+ }
+% \end{macrocode}
+% \begin{macrocode}
+ }{}
+% \end{macrocode}
+% \subsubsection{Class-Specific Behavior}
+% We conclude with some class-specific behavior.
+% \paragraph{ACM Document Classes (old versions, till 2017)}
+% \changes{v1.0.4}{2017/03/08}{More faithful theorem style for ACM templates}
+% \changes{v1.0.4}{2017/03/08}{More robust coherent styling of proof sketches}
+% \begin{macrocode}
+ \ifdefined\@acmtitlebox
+% \end{macrocode}
+% We first redefine the |proofsketch| environment, which is used
+% differently in the base class.
+% \begin{macrocode}
+ \renewenvironment{proofsketch}{\begin{axp@oldproof}[sketch]}{\end{axp@oldproof}}
+% \end{macrocode}
+% We adjust the styling of theorems for the needs of \textsf{apxproof}.
+% \begin{macrocode}
+ \newtheoremstyle{mystyle}
+ {6pt}
+ {6pt}
+ {\itshape}
+ {10pt}
+ {\scshape}
+ {.}
+ {.5em}
+ {}
+ \theoremstyle{mystyle}
+% \end{macrocode}
+% \begin{macro}{\thebibliography}
+% \begin{macro}{\refname}
+% \begin{macro}{\appendixrefname}
+% The section title of the bibliography is in uppercase in these document
+% classes. In addition, the |\thebibliography| macro hard-codes twice
+% the section title, so we un-hardcode it so that it can be modified
+% in the appendix.
+% \begin{macrocode}
+ \patchcmd{\thebibliography}{References}{\protect\refname}{}{}
+ \patchcmd{\thebibliography}{References}{\protect\refname}{}{}
+ \newcommand{\refname}{REFERENCES}
+ \renewcommand{\appendixrefname}{REFERENCES FOR THE APPENDIX}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
+ \fi
+% \end{macrocode}
+% \paragraph{ACM Document Classes (new version)}
+% \changes{v1.0.6}{2018/05/10}{Support of new ACM document class
+% (\texttt{acmart.cls})}
+% Again, we adjust the styling of theorems for the needs of \textsf{apxproof}.
+% \begin{macrocode}
+ \@ifclassloaded{acmart}{
+% \end{macrocode}
+% \begin{macrocode}
+ \newtheoremstyle{mystyle}
+ {.5\baselineskip\@plus.2\baselineskip
+ \@minus.2\baselineskip}
+ {.5\baselineskip\@plus.2\baselineskip
+ \@minus.2\baselineskip}
+ {\@acmplainbodyfont}
+ {\@acmplainindent}
+ {\@acmplainheadfont}
+ {.}
+ {.5em}
+ {\thmname{#1}\thmnumber{ #2}\thmnote{ {\@acmplainheadfont #3}}}
+ \theoremstyle{mystyle}
+% \end{macrocode}
+% \begin{macrocode}
+ }{}
+% \end{macrocode}
+% \paragraph{\textsf{lipcs}}
+% \begin{macrocode}
+ \ifdefined\lipics@opterrshort
+% \end{macrocode}
+% \begin{macro}{\appendixbibliographyprelim}
+% \changes{v1.0.3}{2017/02/06}{Support for lipics-v2016}
+% The default bibliography in the \textsf{lipics} document class
+% formatting is not compatible with the
+% \textsf{alpha} bibliography style. We fix this here.
+% \begin{macrocode}
+ \renewcommand{\appendixbibliographyprelim}{%
+ \global\let\@oldbiblabel\@biblabel
+ \def\@biblabel{\hspace*{-2em}\small\@oldbiblabel}%
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+ \fi
+% \end{macrocode}
+% \paragraph{\textsf{llncs}}
+% \begin{macrocode}
+ \@ifclassloaded{llncs}{
+% \end{macrocode}
+% \begin{macro}{proofsketch}
+% We redefine the |proofsketch| environment, which is used
+% differently in the base class.
+% \begin{macrocode}
+ \renewenvironment{proofsketch}{\begin{axp@oldproof}[sketch]}{\end{axp@oldproof}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+ }{}
+% \end{macrocode}
+% \begin{macrocode}
+}
+% \end{macrocode}
+% \Finale
+% \bibliographystyle{plain}
+% \bibliography{apxproof}
diff --git a/macros/latex/contrib/apxproof/apxproof.ins b/macros/latex/contrib/apxproof/apxproof.ins
new file mode 100644
index 0000000000..77e0ce981b
--- /dev/null
+++ b/macros/latex/contrib/apxproof/apxproof.ins
@@ -0,0 +1,67 @@
+%%
+%% Copyright (C) 2016-2017 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 your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Pierre Senellart
+%% <pierre@senellart.com> and a version control system for this work
+%% is available at http://github.com/PierreSenellart/apxproof
+%%
+%% This work consists of the files apxproof.dtx and apxproof.ins
+%% and the derived file apxproof.sty.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/apxproof}
+
+\preamble
+
+Copyright (C) 2016-2017 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 your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is Pierre Senellart
+<pierre@senellart.com> and a version control system for this work
+is available at http://github.com/PierreSenellart/apxproof
+
+This work consists of the files apxproof.dtx and apxproof.ins
+and the derived file apxproof.sty.
+
+\endpreamble
+
+\generate{\file{apxproof.sty}{\from{apxproof.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* apxproof.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file apxproof.dtx *}
+\Msg{* through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/apxproof/apxproof.pdf b/macros/latex/contrib/apxproof/apxproof.pdf
new file mode 100644
index 0000000000..0a0de8d3ee
--- /dev/null
+++ b/macros/latex/contrib/apxproof/apxproof.pdf
Binary files differ