texlive[61776] Master/texmf-dist: proof-at-the-end (28jan22)

commits+karl at tug.org commits+karl at tug.org
Fri Jan 28 23:24:21 CET 2022


Revision: 61776
          http://tug.org/svn/texlive?view=revision&revision=61776
Author:   karl
Date:     2022-01-28 23:24:21 +0100 (Fri, 28 Jan 2022)
Log Message:
-----------
proof-at-the-end (28jan22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/proof-at-the-end/README.md
    trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end.pdf
    trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.pdf
    trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.tex
    trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.dtx
    trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.ins
    trunk/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty

Modified: trunk/Master/texmf-dist/doc/latex/proof-at-the-end/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/proof-at-the-end/README.md	2022-01-28 22:24:07 UTC (rev 61775)
+++ trunk/Master/texmf-dist/doc/latex/proof-at-the-end/README.md	2022-01-28 22:24:21 UTC (rev 61776)
@@ -1,5 +1,7 @@
 # Proof-at-the-end, or how to move proofs in appendix in LaTeX
 
+WARNING: this package is definitely usable, but may not be as tested and stable as standard packages. Note also that it may change a bit in the future, but we will of course try to avoid as much as possible backward incompatibilities. To ensure your document won't change when the package get updates, it is always safer to copy the `proof-at-the-end.sty` file at the root of your project.
+
 ## Introduction
 
 This package aims to provide a way to easily move proofs in the appendix. You can:
@@ -34,28 +36,109 @@
 
 ## Quickstart ##
 
+### Super Quick QuickStart ###
+
+If `proof-at-the-end` it's not installed in your CTAN distribution, copy the [`proof-at-the-end.sty` file](https://github.com/leo-colisson/proof-at-the-end/) in your project. Then, in your project, create new theorem/lemma environments (using any tool you like, like asmthm, ntheorem and thmtools), load the library using `\usepackage[createShortEnv]{proof-at-the-end}` (note that you need the version 2022/01/28 to have `createShortEnv` defined, otherwise you need to use directly `theoremEnd`) and write your theorem using:
+
+```latex
+\begin{thmE}[My title][end, restate]
+  I am a restated theorem whose proof goes in appendix (compile me twice).
+\end{thmE}
+\begin{proofE}
+  And I am a proof.
+\end{proofE}
+```
+The options (here `restate` and `end`) tells what should go in appendix, how to configure the links... Here the proof should go in appendix, and the `restate` options states that the theorem should be restated before the proof.
+
+You can find below a full example to compile which should produce this output (sorry, this is a screenshot, that way I can export it easily in the github page). Just make sure to compile twice to get references.
+
+![Screenshot of the quickstart](screenshot.png)
+
+You can directly copy them (with a more complete demo) in the github page here https://github.com/leo-colisson/proof-at-the-end/.
+
+```latex
+\documentclass{article}
+
+\usepackage{xparse} % Not needed with recent LaTeX
+\usepackage{amsthm}
+
+% Create new theorems, or use ntheorem/thmtools/...
+\newtheorem{thm}{Theorem}[section]
+% Default uses autoref, but you can also use cleveref, see the documentation.
+% Say to autoref that "thm" are Theorems.
+\newcommand{\thmautorefname}{Theorem}
+
+%% Load the library. createShortEnv automatically creates the shortcuts
+%% thmE, theoremE, lemmaE, corrolaryE, proofE. See \newEndThm for more details.
+\usepackage[createShortEnv]{proof-at-the-end}
+
+\begin{document}
+
+\section{Theorems}
+
+\begin{thmE}[My title][end]
+  I am a theorem
+\end{thmE}
+\begin{proofE}
+  And I am a proof.
+\end{proofE}
+
+\section{Proofs}
+\printProofs
+
+\end{document}
+```
+
+
 ### Install ###
 
-If your CTAN distribution is recent enough, you have nothing to do. Otherwise if it's not yet in your CTAN distribution, first download the `proof-at-the-end.sty` file and insert it in the root of your project with the following commands on unix (you can also clone this repository if you prefer, or just manually download or copy/paste the files on Windows). It also requires a recent version of xparse, so for simplicity we included the sty file of xparse in this repository as well:
+If your CTAN distribution is recent enough, you have nothing to do (if you are using overleaf, note that you can configure your project to use a more recent TexLive distribution: this packages is included starting from TexLive 2019). Otherwise if it's not yet in your CTAN distribution, first download the `proof-at-the-end.sty` file and insert it in the root of your project with the following commands on unix (you can also clone this repository if you prefer, or just manually download or copy/paste the files on Windows).
 
-```bash
+``` bash
 cd <your project>
 repopratend="https://raw.githubusercontent.com/leo-colisson/proof-at-the-end"
 wget ${repopratend}/master/proof-at-the-end.sty
-wget ${repopratend}/master/xparse.sty
 ```
-If you have an old distribution of LaTeX (before 2018 basically, which is the case of Overleaf), you may also need a [more recent expl3](https://tex.stackexchange.com/questions/489646/expl3-and-recent-xparse-on-overleaf-no-expl3-loader-detected/489649?noredirect=1#comment1236409_489649). It is also very easy to install, just download the zip file [http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip](http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip), unzip, and copy the content of the directory `tex/latex/l3kernel/` into your project. On linux it's a matter of two commands in your project:
 
+It also requires a recent version of xparse (not present in TexLive 2018 and before basically), otherwise you will get an error like:
+
+```
+Unknown argument type 'b' replaced by 'm'
+```
+
+While [we used to provide](https://raw.githubusercontent.com/leo-colisson/proof-at-the-end/c2150f4feba4709d47e43c00e5f8eb93ce345cab/xparse.sty) for simplicity a `xparse.sty` file (version `2018-04-12`) in older versions of this repository, we removed it to [avoid license issues and conflicts with recent LaTeX distributions that already include xparse](https://github.com/leo-colisson/proof-at-the-end/issues/6). Nevertheless, if you are using an older distribution, you can also download `xparse` manually [here](http://mirrors.ctan.org/install/macros/latex/contrib/l3packages.tds.zip), unzip it, and copy the `.sty` files contained in `tex/latex/l3packages/xparse/` at the root of your project. On linux, you can do that via:
+
+``` bash
+cd <your project>
+wget http://mirrors.ctan.org/install/macros/latex/contrib/l3packages.tds.zip
+unzip -d . -j l3packages.tds.zip 'tex/latex/l3packages/xparse/*'
+rm -f l3packages.tds.zip xparse.ltx
+```
+
+If you have an old distribution of LaTeX (2017 or before basically), you may also need a [more recent expl3](https://tex.stackexchange.com/questions/489646/expl3-and-recent-xparse-on-overleaf-no-expl3-loader-detected/489649?noredirect=1#comment1236409_489649) or you will get an error like:
+
+```
+Package xparse Error: Support package l3kernel too old.
+```
+
+To install it, download the zip files [http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip](http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip) and [http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip](http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip) (`l3backend` is [since July 1st, 2019](https://tex.stackexchange.com/questions/499082/file-l3backend-pdfmode-def-not-found-when-loading-expl3) a dependency of l3kernel), unzip, and copy the content of the directories `tex/latex/l3kernel/` (first archive) and `tex/latex/l3backend/` (second archive) into your project. On linux it's a matter of two commands in your project:
+
 ```bash
+cd <your project>
 wget http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip
 unzip -d . -j l3kernel.tds.zip 'tex/latex/l3kernel/*'
 rm l3kernel.tds.zip
+wget http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip
+unzip -d . -j l3backend.tds.zip 'tex/latex/l3backend/*'
+rm l3backend.tds.zip
 ```
 
 If you don't want to pollute your main project with all these files, you may be interested to put them in a subfolder and update the environment variable `TEXINPUTS` or, if you use latexmk or overleaf, you can write instead a `latexmkrc` file as explained [here](https://www.overleaf.com/learn/latex/Questions/I_have_a_lot_of_.cls,_.sty,_.bst_files,_and_I_want_to_put_them_in_a_folder_to_keep_my_project_uncluttered._But_my_project_is_not_finding_them_to_compile_correctly). 
 
-That's all!
+If you still have errors, it's likely that your LaTeX distribution is just too old (LaTeX 2016 seems to be too old to install a recent l3exp). So just upgrade to a decent version, and you should not have any troubles anymore.
 
+You can test your install by compiling the `demo.tex` file present in the repository. When it compiles, you are ready to start!
+
 ### Use in your project ###
 
 Now, you can load the library in your project by simply using:
@@ -101,9 +184,20 @@
 \end{proofEnd}
 ```
 
-And put in the place where you would like to display the theorem the following code:
+Since `theoremEnd` may be a bit verbose to use, we provide since the version 2022/01/28, an option: if you load the program using `\usepackage[createShortEnv]{proof-at-the-end}`, you will automatically have the shortcut environments `proofE` (to replace `proof`), `thmE` (to replace `thm`), `theoremE` (to replace... ok you got the pattern), `lemmaE` and `corollaryE`. Note that it is your role to define the initial commands `thm`..., but you don't need to define them all, only those that you use. Then, you can use them like:
 
 ```latex
+\begin{thmE}[My title][end, restate]
+  I am a restated theorem whose proof goes in appendix (compile me twice).
+\end{thmE}
+\begin{proofE}
+  And I am a proof.
+\end{proofE}
+```
+
+Finally, to display the proofs, just use `\printProofs` where you like:
+
+```latex
 \printProofs
 ```
 
@@ -114,6 +208,16 @@
 
 Isn't it simple ?
 
+
+### A note on `hyperref`
+
+An older version of the package explicitely loaded `hyperref` with no option, and an option clash could occur if the user wanted to add options to `hyperref`. We now push the loading to the very end to avoid that issue, but if you want to load packages *after* `hyperref` (like `cleveref`), it is your job to include `hyperref`, for example by putting at the end of the preambule something like:
+
+```latex
+\usepackage[colorlinks]{hyperref}
+\usepackage{cleveref}
+```
+
 ## Use cases
 
 ### Configuration and how to use and create styles ###
@@ -177,23 +281,17 @@
 }
 ```
 
-Finally, it can be practical to define custom environments to avoid typing always `theoremEnd`:
+Finally, it can be practical to define custom environments to avoid typing always `theoremEnd` using something like that (`thmE` is the shortcut environment to create, and `thm` is the old one):
 
 ```latex
-\NewDocumentEnvironment{thmE}{O{}O{}+b}{%
-  \begin{theoremEnd}[normal,#2]{thm}[#1]%
-    #3%
-  \end{theoremEnd}%
-}{}
-% Do not forget the second parameter or you might get Missing \begin{document} error
-\NewDocumentEnvironment{proofE}{O{}+b}{%
-  \begin{proofEnd}[#1]%
-    #2%
-  \end{proofEnd}%
-}{}
+\newEndThm[normal]{thmE}{thm}
+\newEndProof{proofE}
 ```
-That you could use like that:
 
+By default, loading the package using the `createShortEnv` option automatically creates the shortcut environments `proofE` (to replace `proof`), `thmE` (to replace `thm`), `theoremE` (to replace... ok you got the pattern), `lemmaE` and `corollaryE`.
+
+Then you can use like that:
+
 ```latex
 \begin{thmE}[Title]
   Here is a normal theorem with the proof in the main text.
@@ -352,7 +450,7 @@
 - `text link`: text of the link to the proof, defaults to
 
   `{See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.}`
-- `text proof`: text displayed in place of "Proof" in the appendix. Defaults to `{Proof of \string\autoref{thm:prAtEnd\pratendcountercurrent}}`
+- `text proof`: text displayed in place of "Proof" in the appendix. Defaults to `{Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}}`
 - `restate command`: name of a unique macro (without backslash) that will be defined as an alias to restate the theorem wherever you want
 - `restated before`: if the theorems has been stated before (with `\theoremProofEndRestateBefore`), then we just need to put the restate command in place of the theorem, and enable this option
 - `both`/`no both`: only for `\textInAppendix`, specifies that the text must be present in both the main text and the appendix.
@@ -365,14 +463,14 @@
 - `proof at the end`: theorems whose proof need to go in the appendix contrary to `end` it does not make sure that there is a link to the proof.  Shorcut for `no proof here, no all end, proof end, no both`.
 - `debug`: make sure the proof is written in the main text as well (alias of `proof here, no opt all end`), it is quite practical to use when you write a proof to be able to use synctex features to move between the pdf and the file.
 - `no link to theorem`: Remove the link from the proof to the theorem, alias of `text proof={\proofname}`
-- `stared` (or `no number`): when you use the stared version of a theorem you don't have any number, so autoref fails to write a nice link to the theorem. This option changes the text of "Proof", by keeping the link but writting only `Proof`. Equivalent to `text proof={\string\mbox{\string\hyperref[thm:prAtEnd\pratendcountercurrent]{\proofname}}}`
+- `stared` (or `no number`): when you use the stared version of a theorem you don't have any number, so cref fails to write a nice link to the theorem. This option changes the text of "Proof", by keeping the link but writting only `Proof`. Equivalent to `text proof={\string\mbox{\string\hyperref[thm:prAtEnd\pratendcountercurrent]{\proofname}}}`
 - `see full proof`: useful when you want to write in the main text only a sketch of proof, this alias writes a link `See full proof on page X.`. Equivalent to `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.}`
 - `one big link`: instead of two links, one for page, one for proof, put just one link around everything. It can also accept an optional argument which will be the text of the link, like `one big link=Go to the proof`. The default value is `See proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent.}`.
 - `one big link translated`: This is like `one big link`, but automatically add the page at the end (and a big link around). Practical to quickly define a translation like `one big link translated=Voir preuve page`. See also `text proof translated`.
-- `text link section`: Put a link to the proof looking like "See proof in section X". Defaults to `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}`
-- `text link section full proof`: Put a link to the proof looking like "See full proof in section X". Defaults to `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}`
+- `text link section`: Put a link to the proof looking like "See proof in section X". Defaults to `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \pratendSectionlikeCref.}`
+- `text link section full proof`: Put a link to the proof looking like "See full proof in section X". Defaults to `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \pratendSectionlikeCref.}`
 - `default text link`: default text for the link to the proof, equivalent of `text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.}`
-- `default text proof`: default text for the proof in appendix, equivalent of `text proof={Proof of \string\autoref{thm:prAtEnd\pratendcountercurrent}}`
+- `default text proof`: default text for the proof in appendix, equivalent of `text proof={Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}}`
 - `text proof translated`: like `default text proof`, but takes one argument and use it instead of `Proof of`. Example: `text proof translated={Preuve du}`
 - `bare defaults`: default style that is loaded before anything else that configure by default a link to the proof, put the proof in appendix, use the category `defaultcategory`. It is an alias of `end, link to proof, no restate,category=defaultcategory, default text link,default text proof,restate command=pratenddummymacro`.
 - `configuration options`: style that contains the options used to load the package. It is called right after `bare defaults`. Note that you cannot insert macro in the options, overwrite `global custom defaults` instead
@@ -380,7 +478,63 @@
 - `local custom defaults`: empty style that you can overwrite to change the "local" defaults, like category
 - `all defaults`: all the defaults, equivalent of `bare defaults, configuration options, global custom defaults, local custom defaults`
 
+## Package options
 
+The package comes with multiple options:
+- The `conf={CONFIGURATION}` option is used to configure the default style. Usage: `\usepackage[conf={normal, text link section}]{proof-at-the-end}`
+- The `disablePatchSection` is useful to stop the library from patching the section-like commands and chapters (by default, we automatically add a `\label` at the end of the section which is used by `text link section` to find the Appendix). If you enable this option, you can manually add the label by using `\pratendAddLabel` after the appendix section (without any argument).
+- `commandRef=NAMECOMMAND`: By default, theorem are referenced to using `\autoref{}`. You can change the value of `NAMECOMMAND` to use another command, like `commandRef=Cref` to use `\Cref{}`. In that case, make sure to load both `hyperref` and `cleveref` (typically at the very end of your preambule) as `cleveref` needs to be loaded after `hyperref`. Internally, the library creates and uses `\pratendRef` instead of `\autoref`.
+- `createShortEnv`: creates (using `newEndThm` and `newEndProof`) the shortcut environments `proofE` (to replace `proof`), `thmE` (to replace `thm`), `theoremE` (to replace... ok you got the pattern), `lemmaE` and `corollaryE`. Note that it is still your job to define the `thm`, `lemma` environments.
+
+## Troubleshooting
+
+Here are some common issues you may have, with explainations to solve them.
+
+### The link after the proof does not mention the section, but something else (an equation, a figure, etc.)
+
+Sometimes, you may see something like `See proof in Equation A` instead of ``See proof in Appendix A`. This issue [was reported before](https://github.com/leo-colisson/proof-at-the-end/issues/2) and should be solved on newer versions (starting from 2022/01/27) by automatically patching sections. If you have this issue, just upgrade (for instance by copying the [`proof-at-the-end.sty` file](https://github.com/leo-colisson/proof-at-the-end) at the root of your project). We proceed by patching the `\chapter`, `\section`, `\subsection`, `subsubsection` and `\paragraph` commands to add `\pratendAddLabel` which will help the package to find the label of the current section. If you prefer the old behavior, you can disable it using the `disablePatchSection` option (more details in the package options).
+
+### I get an error `ERROR: File ended while scanning use of \@xverbatim.` when using verbatim inside a theorem
+
+I turns out that this library needs to use the `+b` option of environments in order to manipulate appropriately the theorem/proof. Unfortunately, it means that it is not possible to use verbatim environments inside. While [this answer](https://tex.stackexchange.com/questions/489435/use-environment-into-new-xparse-environment) suggests that it is impossible to avoid this issue, other people reported that it may be possible to use catcodes to capture the environment body verbatim, before using scantokens to reparse it, or to use [filecontentsdef](https://mirror.ibcp.fr/pub/CTAN/macros/latex/contrib/filecontentsdef/filecontentsdef.pdf) (see for instance [this comment](https://tex.stackexchange.com/questions/631810/create-a-newdocumentenvironment-programmatically?noredirect=1#comment1575605_631810)],  ). However, it may be possible that this make syntex unusable, so it may not worth the effort.
+
+In anycase, there exists some workarounds, some of the are for instance give in the [TeX FAQ](https://texfaq.org/FAQ-verbwithin). The simplest solution, if your code is simple/short enough, is to use `\texttt` (you can replace backslash with `\textbackslash` inside etc, and include it in a `verse` if you have multiple lines). If you have a longer text, you may also like `lrbox` to put your content inside a box, for instance like that:
+
+
+```latex
+%% Create the box
+\newsavebox{\myEndBox}
+
+\begin{lrbox}{\myEndBox}
+  \begin{minipage}{1.0\linewidth}
+\begin{verbatim}
+\newEndThm[normal]{thmE}{thm}
+\newEndProof{proofE}{proof}
+\end{verbatim}
+  \end{minipage}
+\end{lrbox}
+
+%% Create a theorem:
+\begin{thmE}
+  Insert the box:
+  
+  \begin{center}
+    \usebox{\myEndBox}
+  \end{center}
+\end{thmE}
+```
+
+
+## Changelog
+
+- 2022/01/28:
+  1. Fix the issue when using sharps in a proof https://github.com/leo-colisson/proof-at-the-end/issues/7.
+  2. Provide `\newEndThm`, `\newEndProof` and the option `createShortEnv` to quickly create environments.
+- 2022/01/27:
+  1. Patch chapters/sections/... to better detect the current section and fix [issue 2](https://github.com/leo-colisson/proof-at-the-end/issues/2). This can be disabled using the package option `disablePatchSection`.
+  2. Add an option `commandRef` to use other ref libraries, like `cleveref` instead of `autoref`.
+  3. Normal restatable theorem do not need to be restated. Fix [issue 8](https://github.com/leo-colisson/proof-at-the-end/issues/8).
+
 ## Contributions ##
 
 Feel free to contribute, report bugs, and send pull requests on the github repository  [https://github.com/leo-colisson/proof-at-the-end](https://github.com/leo-colisson/proof-at-the-end) !

Modified: trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.tex	2022-01-28 22:24:07 UTC (rev 61775)
+++ trunk/Master/texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.tex	2022-01-28 22:24:21 UTC (rev 61776)
@@ -1,7 +1,9 @@
 \documentclass{article}
 
 \usepackage{amssymb, amsthm, amsmath}
-\usepackage{hyperref}
+\usepackage{xparse}
+\usepackage{verbatim}
+
 % Load the package (put the proof-at-the-end.sty file in the working directory)
 \usepackage{proof-at-the-end} % with default options...
 % Or by putting in the 'conf' option the default configuration you want:
@@ -17,7 +19,7 @@
 %     text link={\hyperref[proof:prAtEnd\pratendcountercurrent]{See proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent}}}
 %   }
 % }
-%%% You can also easily modify the gloabl/locals defaults in other parts of the code using:
+%%% You can also easily modify the global/locals defaults in other parts of the code using:
 % \pgfkeys{/prAtEnd/local custom defaults/.style={
 %     category=greattheorem
 %   }
@@ -39,14 +41,17 @@
 \providecommand*\lemmaautorefname{Lemma}
 
 %% If you want you can define shortcuts:
-\usepackage{xparse}
-% And to define new shortcuts:
-\NewDocumentEnvironment{mynormalthm}{O{}O{}+b}{%
-  \begin{theoremEnd}[normal,#2]{thm}[#1]%
-    #3%
-  \end{theoremEnd}%
-}{}
+% And to define new shortcuts, in order to avoid typing:
+% \NewDocumentEnvironment{thmE}{O{}O{}+b}{%
+%   \begin{theoremEnd}[normal,#2]{thm}[#1]%
+%     #3%
+%   \end{theoremEnd}%
+% }{}
+% you can just type:
+\newEndThm[normal]{thmE}{thm}
+\newEndProof{proofE}
 
+\usepackage{hyperref}
 \begin{document}
 
 \section{Demo of proof-at-the-end}
@@ -94,6 +99,13 @@
   And keep the proof with you!  
 \end{proofEnd}
 
+\begin{theoremEnd}[normal,restate]{thm}[I am restatable but normal]
+  See, if you are both normal and restatable, then no need to restate the theorem at the end!
+\end{theoremEnd}
+\begin{proofEnd}
+  I am a proof of a restatable but normal theorem.  
+\end{proofEnd}
+
 You can also put comments that appear only in the appendix.
 
 \textEnd{See, I am a simple comments with math $\delta = b^2-ac$ and references \autoref{thm:mytheoremattheend}.}
@@ -168,33 +180,67 @@
 }{}
 \end{verbatim}
 
-\begin{mynormalthm}[My own environment]
-  You can then create your own environment from other styles using
-\end{mynormalthm}
+\newsavebox{\myEndBox}
+
+\begin{lrbox}{\myEndBox}
+  \begin{minipage}{1.0\linewidth}
+\begin{verbatim}
+\newEndThm[normal]{thmE}{thm}
+\newEndProof{proofE}
+\end{verbatim}
+  \end{minipage}
+\end{lrbox}
+
+\newsavebox{\myEndBoxB}
+
+\begin{lrbox}{\myEndBoxB}
+  \begin{minipage}{1.0\linewidth}
+\begin{verbatim}
+\begin{thmE}[Title][optional options]
+  Theorem
+\end{thmE}
+\begin{proofE}
+  Your proof
+\end{proofE}
+\end{verbatim}
+  \end{minipage}
+\end{lrbox}
+   
+\begin{thmE}[My own environment][normal]
+  You can then create a wrapper to avoid typing the full theoremEnd environment, and to add custom options by using:
+  
+  \begin{center}
+    \usebox{\myEndBox}
+  \end{center}
+  
+  \noindent (see that we need to use \texttt{\textbackslash textt} or \texttt{lrbox} to typeset verbatim inside theorem)
+
+  Then, you can simply use:
+\end{thmE}
 \begin{proofEnd}
   That's quicker :D
 \end{proofEnd}
 
-\begin{mynormalthm}[My own environment][end]
+\begin{thmE}[My own environment][end]
   You can use options also with your custom environments.
-\end{mynormalthm}
+\end{thmE}
 \begin{proofEnd}
   That's quicker with the proof at the end :D
 \end{proofEnd}
 
-\begin{mynormalthm}[][end]
+\begin{thmE}[][end]
   And you can remove the title and have options.
-\end{mynormalthm}
-\begin{proofEnd}
+\end{thmE}
+\begin{proofE}
   Just leave empty title.
-\end{proofEnd}
+\end{proofE}
 
-\begin{mynormalthm}[My second own environment][all end]
+\begin{thmE}[My second own environment][all end]
   My normal theorem is moved at the end!
-\end{mynormalthm}
-\begin{proofEnd}
+\end{thmE}
+\begin{proofE}
   Custom environments are practical no ;)
-\end{proofEnd}
+\end{proofE}
 
 \begin{theoremEnd}[]{thm}[Yes I can have no proof]
   Proof is useless. You can do do it. And see, I can include other environments inside me ;)\\
@@ -204,7 +250,6 @@
   \end{tabular}
 \end{theoremEnd}
 
-
 \begin{theoremEnd}[restate command=mymanualrestate]{thm}[Manual restate]
   A theorem can be manually restated  
 \end{theoremEnd}

Modified: trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.dtx	2022-01-28 22:24:07 UTC (rev 61775)
+++ trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.dtx	2022-01-28 22:24:21 UTC (rev 61776)
@@ -1,12 +1,12 @@
 %\iffalse
 % proof-at-the-end.dtx generated using makedtx version 1.2 (c) Nicola Talbot
 % Command line args:
+%   -dir "/home/leo/Documents/Informatique/Programmation/LaTeX/proof-at-the-end/"
 %   -doc "../doc/proof-at-the-end_doc.tex"
 %   -author "Léo Colisson"
-%   -dir "/tmp/pat/proof-at-the-end/"
 %   -src "proof-at-the-end\.sty=>proof-at-the-end.sty"
 %   proof-at-the-end
-% Created on 2019/5/22 12:52
+% Created on 2022/1/28 19:43
 %\fi
 %\iffalse
 %<*package>
@@ -29,28 +29,33 @@
 %\fi
 % \iffalse
 % Doc-Source file to use with LaTeX2e
-% Copyright (C) 2019 Léo Colisson, all rights reserved.
+% Copyright (C) 2022 Léo Colisson, all rights reserved.
 % \fi
 % \iffalse
 %<*driver>
-\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
+% Options for packages loaded elsewhere
+\PassOptionsToPackage{unicode}{hyperref}
 \PassOptionsToPackage{hyphens}{url}
 %
 \documentclass[
 ]{article}
+\title{Proof-at-the-end, or how to move proofs in appendix in LaTeX}
+\author{Léo Colisson}
+\date{}
+
+\usepackage{amsmath,amssymb}
 \usepackage{lmodern}
-\usepackage{amssymb,amsmath}
-\usepackage{ifxetex,ifluatex}
-\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+\usepackage{iftex}
+\ifPDFTeX
   \usepackage[T1]{fontenc}
   \usepackage[utf8]{inputenc}
-  \usepackage{textcomp} % provides euro and other symbols
-\else % if luatex or xelatex
+  \usepackage{textcomp} % provide euro and other symbols
+\else % if luatex or xetex
   \usepackage{unicode-math}
   \defaultfontfeatures{Scale=MatchLowercase}
   \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
 \fi
-% use upquote if available, for straight quotes in verbatim environments
+% Use upquote if available, for straight quotes in verbatim environments
 \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
 \IfFileExists{microtype.sty}{% use microtype if available
   \usepackage[]{microtype}
@@ -72,9 +77,9 @@
 \hypersetup{
   pdftitle={Proof-at-the-end, or how to move proofs in appendix in LaTeX},
   pdfauthor={Léo Colisson},
-  pdfborder={0 0 0},
-  breaklinks=true}
-\urlstyle{same}  % don't use monospace font for urls
+  hidelinks,
+  pdfcreator={LaTeX via pandoc}}
+\urlstyle{same} % disable monospaced font for URLs
 \usepackage{color}
 \usepackage{fancyvrb}
 \newcommand{\VerbBar}{|}
@@ -113,30 +118,27 @@
 \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
 \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
 \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
-\setlength{\emergencystretch}{3em}  % prevent overfull lines
+\usepackage{graphicx}
+\makeatletter
+\def\maxwidth{\ifdim\Gin at nat@width>\linewidth\linewidth\else\Gin at nat@width\fi}
+\def\maxheight{\ifdim\Gin at nat@height>\textheight\textheight\else\Gin at nat@height\fi}
+\makeatother
+% Scale images if necessary, so that they will not overflow the page
+% margins by default, and it is still possible to overwrite the defaults
+% using explicit options in \includegraphics[width, height, ...]{}
+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
+% Set default figure placement to htbp
+\makeatletter
+\def\fps at figure{htbp}
+\makeatother
+\setlength{\emergencystretch}{3em} % prevent overfull lines
 \providecommand{\tightlist}{%
   \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
 \setcounter{secnumdepth}{5}
-% Redefines (sub)paragraphs to behave more like sections
-\ifx\paragraph\undefined\else
-  \let\oldparagraph\paragraph
-  \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\ifLuaTeX
+  \usepackage{selnolig}  % disable illegal ligatures
 \fi
-\ifx\subparagraph\undefined\else
-  \let\oldsubparagraph\subparagraph
-  \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
-\fi
 
-% set default figure placement to htbp
-\makeatletter
-\def\fps at figure{htbp}
-\makeatother
-
-
-\title{Proof-at-the-end, or how to move proofs in appendix in LaTeX}
-\author{Léo Colisson}
-\date{}
-
 \begin{document}
 \DocInput{proof-at-the-end.dtx}
 \end{document}
@@ -148,6 +150,13 @@
 %\setcounter{tocdepth}{3}
 %\tableofcontents
 %}
+%WARNING: this package is definitely usable, but may not be as tested and
+%stable as standard packages. Note also that it may change a bit in the
+%future, but we will of course try to avoid as much as possible backward
+%incompatibilities. To ensure your document won't change when the package
+%get updates, it is always safer to copy the
+%\texttt{proof-at-the-end.sty} file at the root of your project.
+%
 %\hypertarget{introduction}{%
 %\section{Introduction}\label{introduction}}
 %
@@ -206,8 +215,8 @@
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\FunctionTok{git}\NormalTok{ clone https://github.com/leo-colisson/proof-at-the-end.git}
-%\ExtensionTok{pdflatex}\NormalTok{ demo.tex }\KeywordTok{&&} \ExtensionTok{pdflatex}\NormalTok{ demo.tex}
+%\FunctionTok{git}\NormalTok{ clone https://github.com/leo{-}colisson/proof{-}at{-}the{-}end.git}
+%\ExtensionTok{pdflatex}\NormalTok{ demo.tex }\KeywordTok{\&\&} \ExtensionTok{pdflatex}\NormalTok{ demo.tex}
 %\end{Highlighting}
 %\end{Shaded}
 %
@@ -214,42 +223,163 @@
 %\hypertarget{quickstart}{%
 %\section{Quickstart}\label{quickstart}}
 %
+%\hypertarget{super-quick-quickstart}{%
+%\subsection{Super Quick QuickStart}\label{super-quick-quickstart}}
+%
+%If \texttt{proof-at-the-end} it's not installed in your CTAN
+%distribution, copy the
+%\href{https://github.com/leo-colisson/proof-at-the-end/}{\texttt{proof-at-the-end.sty}
+%file} in your project. Then, in your project, create new theorem/lemma
+%environments (using any tool you like, like asmthm, ntheorem and
+%thmtools), load the library using
+%\texttt{\textbackslash{}usepackage{[}createShortEnv{]}\{proof-at-the-end\}}
+%(note that you need the version 2022/01/28 to have
+%\texttt{createShortEnv} defined, otherwise you need to use directly
+%\texttt{theoremEnd}) and write your theorem using:
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}[My title][end, restate]}
+%\NormalTok{  I am a restated theorem whose proof goes in appendix (compile me twice).}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%\NormalTok{  And I am a proof.}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%\end{Highlighting}
+%\end{Shaded}
+%
+%The options (here \texttt{restate} and \texttt{end}) tells what should
+%go in appendix, how to configure the links\ldots{} Here the proof should
+%go in appendix, and the \texttt{restate} options states that the theorem
+%should be restated before the proof.
+%
+%You can find below a full example to compile which should produce this
+%output (sorry, this is a screenshot, that way I can export it easily in
+%the github page). Just make sure to compile twice to get references.
+%
+%\begin{figure}
+%\centering
+%\includegraphics{screenshot.png}
+%\caption{Screenshot of the quickstart}
+%\end{figure}
+%
+%You can directly copy them (with a more complete demo) in the github
+%page here https://github.com/leo-colisson/proof-at-the-end/.
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
+%\BuiltInTok{\textbackslash{}documentclass}\NormalTok{\{}\ExtensionTok{article}\NormalTok{\}}
+%
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{xparse}\NormalTok{\} }\CommentTok{\% Not needed with recent LaTeX}
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{amsthm}\NormalTok{\}}
+%
+%\CommentTok{\% Create new theorems, or use ntheorem/thmtools/...}
+%\FunctionTok{\textbackslash{}newtheorem}\NormalTok{\{thm\}\{Theorem\}[section]}
+%\CommentTok{\% Default uses autoref, but you can also use cleveref, see the documentation.}
+%\CommentTok{\% Say to autoref that "thm" are Theorems.}
+%\FunctionTok{\textbackslash{}newcommand}\NormalTok{\{}\ExtensionTok{\textbackslash{}thmautorefname}\NormalTok{\}\{Theorem\}}
+%
+%\CommentTok{\%\% Load the library. createShortEnv automatically creates the shortcuts}
+%\CommentTok{\%\% thmE, theoremE, lemmaE, corrolaryE, proofE. See \textbackslash{}newEndThm for more details.}
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{[createShortEnv]\{}\ExtensionTok{proof{-}at{-}the{-}end}\NormalTok{\}}
+%
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{document}\NormalTok{\}}
+%
+%\KeywordTok{\textbackslash{}section}\NormalTok{\{Theorems\}}
+%
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}[My title][end]}
+%\NormalTok{  I am a theorem}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%\NormalTok{  And I am a proof.}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%
+%\KeywordTok{\textbackslash{}section}\NormalTok{\{Proofs\}}
+%\FunctionTok{\textbackslash{}printProofs}
+%
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{document}\NormalTok{\}}
+%\end{Highlighting}
+%\end{Shaded}
+%
 %\hypertarget{install}{%
 %\subsection{Install}\label{install}}
 %
-%If your CTAN distribution is recent enough, you have nothing to do.
-%Otherwise if it's not yet in your CTAN distribution, first download the
-%\texttt{proof-at-the-end.sty} file and insert it in the root of your
-%project with the following commands on unix (you can also clone this
-%repository if you prefer, or just manually download or copy/paste the
-%files on Windows). It also requires a recent version of xparse, so for
-%simplicity we included the sty file of xparse in this repository as
-%well:
+%If your CTAN distribution is recent enough, you have nothing to do (if
+%you are using overleaf, note that you can configure your project to use
+%a more recent TexLive distribution: this packages is included starting
+%from TexLive 2019). Otherwise if it's not yet in your CTAN distribution,
+%first download the \texttt{proof-at-the-end.sty} file and insert it in
+%the root of your project with the following commands on unix (you can
+%also clone this repository if you prefer, or just manually download or
+%copy/paste the files on Windows).
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\BuiltInTok{cd} \OperatorTok{<}\NormalTok{your project}\OperatorTok{>}
-%\VariableTok{repopratend=}\StringTok{"https://raw.githubusercontent.com/leo-colisson/proof-at-the-end"}
-%\FunctionTok{wget} \VariableTok{$\{repopratend\}}\NormalTok{/master/proof-at-the-end.sty}
-%\FunctionTok{wget} \VariableTok{$\{repopratend\}}\NormalTok{/master/xparse.sty}
+%\BuiltInTok{cd} \OperatorTok{\textless{}}\NormalTok{your project}\OperatorTok{\textgreater{}}
+%\VariableTok{repopratend}\OperatorTok{=}\StringTok{"https://raw.githubusercontent.com/leo{-}colisson/proof{-}at{-}the{-}end"}
+%\FunctionTok{wget} \VariableTok{$\{repopratend\}}\NormalTok{/master/proof{-}at{-}the{-}end.sty}
 %\end{Highlighting}
 %\end{Shaded}
 %
-%If you have an old distribution of LaTeX (before 2018 basically, which
-%is the case of Overleaf), you may also need a
+%It also requires a recent version of xparse (not present in TexLive 2018
+%and before basically), otherwise you will get an error like:
+%
+%\begin{verbatim}
+%Unknown argument type 'b' replaced by 'm'
+%\end{verbatim}
+%
+%While
+%\href{https://raw.githubusercontent.com/leo-colisson/proof-at-the-end/c2150f4feba4709d47e43c00e5f8eb93ce345cab/xparse.sty}{we
+%used to provide} for simplicity a \texttt{xparse.sty} file (version
+%\texttt{2018-04-12}) in older versions of this repository, we removed it
+%to
+%\href{https://github.com/leo-colisson/proof-at-the-end/issues/6}{avoid
+%license issues and conflicts with recent LaTeX distributions that
+%already include xparse}. Nevertheless, if you are using an older
+%distribution, you can also download \texttt{xparse} manually
+%\href{http://mirrors.ctan.org/install/macros/latex/contrib/l3packages.tds.zip}{here},
+%unzip it, and copy the \texttt{.sty} files contained in
+%\texttt{tex/latex/l3packages/xparse/} at the root of your project. On
+%linux, you can do that via:
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
+%\BuiltInTok{cd} \OperatorTok{\textless{}}\NormalTok{your project}\OperatorTok{\textgreater{}}
+%\FunctionTok{wget}\NormalTok{ http://mirrors.ctan.org/install/macros/latex/contrib/l3packages.tds.zip}
+%\FunctionTok{unzip} \AttributeTok{{-}d}\NormalTok{ . }\AttributeTok{{-}j}\NormalTok{ l3packages.tds.zip }\StringTok{\textquotesingle{}tex/latex/l3packages/xparse/*\textquotesingle{}}
+%\FunctionTok{rm} \AttributeTok{{-}f}\NormalTok{ l3packages.tds.zip xparse.ltx}
+%\end{Highlighting}
+%\end{Shaded}
+%
+%If you have an old distribution of LaTeX (2017 or before basically), you
+%may also need a
 %\href{https://tex.stackexchange.com/questions/489646/expl3-and-recent-xparse-on-overleaf-no-expl3-loader-detected/489649?noredirect=1\#comment1236409_489649}{more
-%recent expl3}. It is also very easy to install, just download the zip
-%file
-%\url{http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip},
-%unzip, and copy the content of the directory
-%\texttt{tex/latex/l3kernel/} into your project. On linux it's a matter
-%of two commands in your project:
+%recent expl3} or you will get an error like:
 %
+%\begin{verbatim}
+%Package xparse Error: Support package l3kernel too old.
+%\end{verbatim}
+%
+%To install it, download the zip files
+%\url{http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip}
+%and
+%\url{http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip}
+%(\texttt{l3backend} is
+%\href{https://tex.stackexchange.com/questions/499082/file-l3backend-pdfmode-def-not-found-when-loading-expl3}{since
+%July 1st, 2019} a dependency of l3kernel), unzip, and copy the content
+%of the directories \texttt{tex/latex/l3kernel/} (first archive) and
+%\texttt{tex/latex/l3backend/} (second archive) into your project. On
+%linux it's a matter of two commands in your project:
+%
 %\begin{Shaded}
 %\begin{Highlighting}[]
+%\BuiltInTok{cd} \OperatorTok{\textless{}}\NormalTok{your project}\OperatorTok{\textgreater{}}
 %\FunctionTok{wget}\NormalTok{ http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip}
-%\FunctionTok{unzip}\NormalTok{ -d . -j l3kernel.tds.zip }\StringTok{'tex/latex/l3kernel/*'}
+%\FunctionTok{unzip} \AttributeTok{{-}d}\NormalTok{ . }\AttributeTok{{-}j}\NormalTok{ l3kernel.tds.zip }\StringTok{\textquotesingle{}tex/latex/l3kernel/*\textquotesingle{}}
 %\FunctionTok{rm}\NormalTok{ l3kernel.tds.zip}
+%\FunctionTok{wget}\NormalTok{ http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip}
+%\FunctionTok{unzip} \AttributeTok{{-}d}\NormalTok{ . }\AttributeTok{{-}j}\NormalTok{ l3backend.tds.zip }\StringTok{\textquotesingle{}tex/latex/l3backend/*\textquotesingle{}}
+%\FunctionTok{rm}\NormalTok{ l3backend.tds.zip}
 %\end{Highlighting}
 %\end{Shaded}
 %
@@ -259,8 +389,14 @@
 %write instead a \texttt{latexmkrc} file as explained
 %\href{https://www.overleaf.com/learn/latex/Questions/I_have_a_lot_of_.cls,_.sty,_.bst_files,_and_I_want_to_put_them_in_a_folder_to_keep_my_project_uncluttered._But_my_project_is_not_finding_them_to_compile_correctly}{here}.
 %
-%That's all!
+%If you still have errors, it's likely that your LaTeX distribution is
+%just too old (LaTeX 2016 seems to be too old to install a recent l3exp).
+%So just upgrade to a decent version, and you should not have any
+%troubles anymore.
 %
+%You can test your install by compiling the \texttt{demo.tex} file
+%present in the repository. When it compiles, you are ready to start!
+%
 %\hypertarget{use-in-your-project}{%
 %\subsection{Use in your project}\label{use-in-your-project}}
 %
@@ -268,24 +404,24 @@
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{proof-at-the-end}\NormalTok{\}}
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{proof{-}at{-}the{-}end}\NormalTok{\}}
 %\end{Highlighting}
 %\end{Shaded}
 %
 %Then, you can configure your theorem/lemma/\ldots{} environments as
-%usual, by using any counter you like\ldots{}:
+%usual, by using any counter you like\ldots:
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
 %\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{amssymb, amsthm, amsmath}\NormalTok{\}}
-%\CommentTok{% Theorems}
+%\CommentTok{\% Theorems}
 %\FunctionTok{\textbackslash{}newtheorem}\NormalTok{\{thm\}\{Theorem\}[section]}
-%\FunctionTok{\textbackslash{}newtheorem}\NormalTok{*\{thm*\}\{Theorem\}}
-%\FunctionTok{\textbackslash{}providecommand}\NormalTok{*}\FunctionTok{\textbackslash{}thmautorefname}\NormalTok{\{Theorem\}}
-%\CommentTok{% Lemmata}
+%\FunctionTok{\textbackslash{}newtheorem*}\NormalTok{\{thm*\}\{Theorem\}}
+%\FunctionTok{\textbackslash{}providecommand*\textbackslash{}thmautorefname}\NormalTok{\{Theorem\}}
+%\CommentTok{\% Lemmata}
 %\FunctionTok{\textbackslash{}newtheorem}\NormalTok{\{lemma\}[thm]\{Lemma\}}
-%\FunctionTok{\textbackslash{}newtheorem}\NormalTok{*\{lemma*\}\{Lemma\}}
-%\FunctionTok{\textbackslash{}providecommand}\NormalTok{*}\FunctionTok{\textbackslash{}lemmaautorefname}\NormalTok{\{Lemma\}}
+%\FunctionTok{\textbackslash{}newtheorem*}\NormalTok{\{lemma*\}\{Lemma\}}
+%\FunctionTok{\textbackslash{}providecommand*\textbackslash{}lemmaautorefname}\NormalTok{\{Lemma\}}
 %\end{Highlighting}
 %\end{Shaded}
 %
@@ -297,7 +433,7 @@
 %\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{theoremEnd}\NormalTok{\}[OPTIONS]\{THEOREM ENVIRONMENT\}[OPTIONAL TITLE]}
 %\NormalTok{    YOUR THEOREM, with eventually labels like }\KeywordTok{\textbackslash{}label}\NormalTok{\{}\ExtensionTok{thm:OPTIONAL LABEL}\NormalTok{\}}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{theoremEnd}\NormalTok{\}}
-%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\} }\CommentTok{%% Optional environment}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\} }\CommentTok{\%\% Optional environment}
 %\NormalTok{    YOUR (OPTIONAL) PROOF}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}
 %\end{Highlighting}
@@ -317,11 +453,32 @@
 %\end{Highlighting}
 %\end{Shaded}
 %
-%And put in the place where you would like to display the theorem the
-%following code:
+%Since \texttt{theoremEnd} may be a bit verbose to use, we provide since
+%the version 2022/01/28, an option: if you load the program using
+%\texttt{\textbackslash{}usepackage{[}createShortEnv{]}\{proof-at-the-end\}},
+%you will automatically have the shortcut environments \texttt{proofE}
+%(to replace \texttt{proof}), \texttt{thmE} (to replace \texttt{thm}),
+%\texttt{theoremE} (to replace\ldots{} ok you got the pattern),
+%\texttt{lemmaE} and \texttt{corollaryE}. Note that it is your role to
+%define the initial commands \texttt{thm}\ldots, but you don't need to
+%define them all, only those that you use. Then, you can use them like:
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}[My title][end, restate]}
+%\NormalTok{  I am a restated theorem whose proof goes in appendix (compile me twice).}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%\NormalTok{  And I am a proof.}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofE}\NormalTok{\}}
+%\end{Highlighting}
+%\end{Shaded}
+%
+%Finally, to display the proofs, just use
+%\texttt{\textbackslash{}printProofs} where you like:
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
 %\FunctionTok{\textbackslash{}printProofs}
 %\end{Highlighting}
 %\end{Shaded}
@@ -335,6 +492,25 @@
 %
 %Isn't it simple ?
 %
+%\hypertarget{a-note-on-hyperref}{%
+%\subsection{\texorpdfstring{A note on
+%\texttt{hyperref}}{A note on hyperref}}\label{a-note-on-hyperref}}
+%
+%An older version of the package explicitely loaded \texttt{hyperref}
+%with no option, and an option clash could occur if the user wanted to
+%add options to \texttt{hyperref}. We now push the loading to the very
+%end to avoid that issue, but if you want to load packages \emph{after}
+%\texttt{hyperref} (like \texttt{cleveref}), it is your job to include
+%\texttt{hyperref}, for example by putting at the end of the preambule
+%something like:
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{[colorlinks]\{}\ExtensionTok{hyperref}\NormalTok{\}}
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{\{}\ExtensionTok{cleveref}\NormalTok{\}}
+%\end{Highlighting}
+%\end{Shaded}
+%
 %\hypertarget{use-cases}{%
 %\section{Use cases}\label{use-cases}}
 %
@@ -373,7 +549,7 @@
 %\NormalTok{  Each theorem can have a custom configuration!}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{theoremEnd}\NormalTok{\}}
 %\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}
-%\NormalTok{  Quite practical, isn't it?}
+%\NormalTok{  Quite practical, isn\textquotesingle{}t it?}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}
 %\end{Highlighting}
 %\end{Shaded}
@@ -396,7 +572,7 @@
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{[conf=\{normal, one big link\}]\{}\ExtensionTok{proof-at-the-end}\NormalTok{\}}
+%\BuiltInTok{\textbackslash{}usepackage}\NormalTok{[conf=\{normal, one big link\}]\{}\ExtensionTok{proof{-}at{-}the{-}end}\NormalTok{\}}
 %\end{Highlighting}
 %\end{Shaded}
 %
@@ -411,7 +587,7 @@
 %\begin{Shaded}
 %\begin{Highlighting}[]
 %\FunctionTok{\textbackslash{}pgfkeys}\NormalTok{\{/prAtEnd/global custom defaults/.style=\{}
-%\NormalTok{    one big link=\{Go to proof on page~}\KeywordTok{\textbackslash{}pageref}\ErrorTok{*}\NormalTok{\{}\ExtensionTok{proof:prAtEnd\textbackslash{}pratendcountercurrent}\NormalTok{\}\}}
+%\NormalTok{    one big link=\{Go to proof on page\textasciitilde{}}\FunctionTok{\textbackslash{}pageref*}\NormalTok{\{proof:prAtEnd}\FunctionTok{\textbackslash{}pratendcountercurrent}\NormalTok{\}\}}
 %\NormalTok{  \}}
 %\NormalTok{\}}
 %\end{Highlighting}
@@ -429,26 +605,25 @@
 %\end{Shaded}
 %
 %Finally, it can be practical to define custom environments to avoid
-%typing always \texttt{theoremEnd}:
+%typing always \texttt{theoremEnd} using something like that
+%(\texttt{thmE} is the shortcut environment to create, and \texttt{thm}
+%is the old one):
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\FunctionTok{\textbackslash{}NewDocumentEnvironment}\NormalTok{\{thmE\}\{O\{\}O\{\}+b\}\{}\CommentTok{%}
-%  \KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{theoremEnd}\NormalTok{\}[normal,#2]\{thm\}[#1]}\CommentTok{%}
-%\NormalTok{    #3}\CommentTok{%}
-%  \KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{theoremEnd}\NormalTok{\}}\CommentTok{%}
-%\NormalTok{\}\{\}}
-%\CommentTok{% Do not forget the second parameter or you might get Missing \textbackslash{}begin\{document\} error}
-%\FunctionTok{\textbackslash{}NewDocumentEnvironment}\NormalTok{\{proofE\}\{O\{\}+b\}\{}\CommentTok{%}
-%  \KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}[#1]}\CommentTok{%}
-%\NormalTok{    #2}\CommentTok{%}
-%  \KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}\CommentTok{%}
-%\NormalTok{\}\{\}}
+%\FunctionTok{\textbackslash{}newEndThm}\NormalTok{[normal]\{thmE\}\{thm\}}
+%\FunctionTok{\textbackslash{}newEndProof}\NormalTok{\{proofE\}}
 %\end{Highlighting}
 %\end{Shaded}
 %
-%That you could use like that:
+%By default, loading the package using the \texttt{createShortEnv} option
+%automatically creates the shortcut environments \texttt{proofE} (to
+%replace \texttt{proof}), \texttt{thmE} (to replace \texttt{thm}),
+%\texttt{theoremE} (to replace\ldots{} ok you got the pattern),
+%\texttt{lemmaE} and \texttt{corollaryE}.
 %
+%Then you can use like that:
+%
 %\begin{Shaded}
 %\begin{Highlighting}[]
 %\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}[Title]}
@@ -676,7 +851,7 @@
 %\NormalTok{  Hint: look at the alias options.}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proof}\NormalTok{\}}
 %\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}
-%\NormalTok{  You just use ``see full proof'' as an option}
+%\NormalTok{  You just use \textasciigrave{}\textasciigrave{}see full proof\textquotesingle{}\textquotesingle{} as an option}
 %\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{proofEnd}\NormalTok{\}}
 %\end{Highlighting}
 %\end{Shaded}
@@ -715,7 +890,7 @@
 %\item
 %  \texttt{text\ proof}: text displayed in place of ``Proof'' in the
 %  appendix. Defaults to
-%  \texttt{\{Proof\ of\ \textbackslash{}string\textbackslash{}autoref\{thm:prAtEnd\textbackslash{}pratendcountercurrent\}\}}
+%  \texttt{\{Proof\ of\ \textbackslash{}string\textbackslash{}pratendRef\{thm:prAtEnd\textbackslash{}pratendcountercurrent\}\}}
 %\item
 %  \texttt{restate\ command}: name of a unique macro (without backslash)
 %  that will be defined as an alias to restate the theorem wherever you
@@ -762,10 +937,9 @@
 %  theorem, alias of \texttt{text\ proof=\{\textbackslash{}proofname\}}
 %\item
 %  \texttt{stared} (or \texttt{no\ number}): when you use the stared
-%  version of a theorem you don't have any number, so autoref fails to
-%  write a nice link to the theorem. This option changes the text of
-%  ``Proof'', by keeping the link but writting only \texttt{Proof}.
-%  Equivalent to
+%  version of a theorem you don't have any number, so cref fails to write
+%  a nice link to the theorem. This option changes the text of ``Proof'',
+%  by keeping the link but writting only \texttt{Proof}. Equivalent to
 %  \texttt{text\ proof=\{\textbackslash{}string\textbackslash{}mbox\{\textbackslash{}string\textbackslash{}hyperref{[}thm:prAtEnd\textbackslash{}pratendcountercurrent{]}\{\textbackslash{}proofname\}\}\}}
 %\item
 %  \texttt{see\ full\ proof}: useful when you want to write in the main
@@ -787,11 +961,11 @@
 %\item
 %  \texttt{text\ link\ section}: Put a link to the proof looking like
 %  ``See proof in section X''. Defaults to
-%  \texttt{text\ link=\{See\ \textbackslash{}hyperref{[}proof:prAtEnd\textbackslash{}pratendcountercurrent{]}\{proof\}\ in\ \textbackslash{}autoref\{proofsection:prAtEnd\textbackslash{}pratendcountercurrent\}.\}}
+%  \texttt{text\ link=\{See\ \textbackslash{}hyperref{[}proof:prAtEnd\textbackslash{}pratendcountercurrent{]}\{proof\}\ in\ \textbackslash{}pratendSectionlikeCref.\}}
 %\item
 %  \texttt{text\ link\ section\ full\ proof}: Put a link to the proof
 %  looking like ``See full proof in section X''. Defaults to
-%  \texttt{text\ link=\{See\ \textbackslash{}hyperref{[}proof:prAtEnd\textbackslash{}pratendcountercurrent{]}\{full\ proof\}\ in\ \textbackslash{}autoref\{proofsection:prAtEnd\textbackslash{}pratendcountercurrent\}.\}}
+%  \texttt{text\ link=\{See\ \textbackslash{}hyperref{[}proof:prAtEnd\textbackslash{}pratendcountercurrent{]}\{full\ proof\}\ in\ \textbackslash{}pratendSectionlikeCref.\}}
 %\item
 %  \texttt{default\ text\ link}: default text for the link to the proof,
 %  equivalent of
@@ -799,7 +973,7 @@
 %\item
 %  \texttt{default\ text\ proof}: default text for the proof in appendix,
 %  equivalent of
-%  \texttt{text\ proof=\{Proof\ of\ \textbackslash{}string\textbackslash{}autoref\{thm:prAtEnd\textbackslash{}pratendcountercurrent\}\}}
+%  \texttt{text\ proof=\{Proof\ of\ \textbackslash{}string\textbackslash{}pratendRef\{thm:prAtEnd\textbackslash{}pratendcountercurrent\}\}}
 %\item
 %  \texttt{text\ proof\ translated}: like \texttt{default\ text\ proof},
 %  but takes one argument and use it instead of \texttt{Proof\ of}.
@@ -825,6 +999,161 @@
 %  \texttt{bare\ defaults,\ configuration\ options,\ global\ custom\ defaults,\ local\ custom\ defaults}
 %\end{itemize}
 %
+%\hypertarget{package-options}{%
+%\section{Package options}\label{package-options}}
+%
+%The package comes with multiple options: - The
+%\texttt{conf=\{CONFIGURATION\}} option is used to configure the default
+%style. Usage:
+%\texttt{\textbackslash{}usepackage{[}conf=\{normal,\ text\ link\ section\}{]}\{proof-at-the-end\}}
+%- The \texttt{disablePatchSection} is useful to stop the library from
+%patching the section-like commands and chapters (by default, we
+%automatically add a \texttt{\textbackslash{}label} at the end of the
+%section which is used by \texttt{text\ link\ section} to find the
+%Appendix). If you enable this option, you can manually add the label by
+%using \texttt{\textbackslash{}pratendAddLabel} after the appendix
+%section (without any argument). - \texttt{commandRef=NAMECOMMAND}: By
+%default, theorem are referenced to using
+%\texttt{\textbackslash{}autoref\{\}}. You can change the value of
+%\texttt{NAMECOMMAND} to use another command, like
+%\texttt{commandRef=Cref} to use \texttt{\textbackslash{}Cref\{\}}. In
+%that case, make sure to load both \texttt{hyperref} and
+%\texttt{cleveref} (typically at the very end of your preambule) as
+%\texttt{cleveref} needs to be loaded after \texttt{hyperref}.
+%Internally, the library creates and uses
+%\texttt{\textbackslash{}pratendRef} instead of
+%\texttt{\textbackslash{}autoref}. - \texttt{createShortEnv}: creates
+%(using \texttt{newEndThm} and \texttt{newEndProof}) the shortcut
+%environments \texttt{proofE} (to replace \texttt{proof}), \texttt{thmE}
+%(to replace \texttt{thm}), \texttt{theoremE} (to replace\ldots{} ok you
+%got the pattern), \texttt{lemmaE} and \texttt{corollaryE}. Note that it
+%is still your job to define the \texttt{thm}, \texttt{lemma}
+%environments.
+%
+%\hypertarget{troubleshooting}{%
+%\section{Troubleshooting}\label{troubleshooting}}
+%
+%Here are some common issues you may have, with explainations to solve
+%them.
+%
+%\hypertarget{the-link-after-the-proof-does-not-mention-the-section-but-something-else-an-equation-a-figure-etc.}{%
+%\subsection{The link after the proof does not mention the section, but
+%something else (an equation, a figure,
+%etc.)}\label{the-link-after-the-proof-does-not-mention-the-section-but-something-else-an-equation-a-figure-etc.}}
+%
+%Sometimes, you may see something like
+%\texttt{See\ proof\ in\ Equation\ A} instead of
+%`\texttt{See\ proof\ in\ Appendix\ A}. This issue
+%\href{https://github.com/leo-colisson/proof-at-the-end/issues/2}{was
+%reported before} and should be solved on newer versions (starting from
+%2022/01/27) by automatically patching sections. If you have this issue,
+%just upgrade (for instance by copying the
+%\href{https://github.com/leo-colisson/proof-at-the-end}{\texttt{proof-at-the-end.sty}
+%file} at the root of your project). We proceed by patching the
+%\texttt{\textbackslash{}chapter}, \texttt{\textbackslash{}section},
+%\texttt{\textbackslash{}subsection}, \texttt{subsubsection} and
+%\texttt{\textbackslash{}paragraph} commands to add
+%\texttt{\textbackslash{}pratendAddLabel} which will help the package to
+%find the label of the current section. If you prefer the old behavior,
+%you can disable it using the \texttt{disablePatchSection} option (more
+%details in the package options).
+%
+%\hypertarget{i-get-an-error-error-file-ended-while-scanning-use-of-xverbatim.-when-using-verbatim-inside-a-theorem}{%
+%\subsection{\texorpdfstring{I get an error
+%\texttt{ERROR:\ File\ ended\ while\ scanning\ use\ of\ \textbackslash{}@xverbatim.}
+%when using verbatim inside a
+%theorem}{I get an error ERROR: File ended while scanning use of \textbackslash at xverbatim. when using verbatim inside a theorem}}\label{i-get-an-error-error-file-ended-while-scanning-use-of-xverbatim.-when-using-verbatim-inside-a-theorem}}
+%
+%I turns out that this library needs to use the \texttt{+b} option of
+%environments in order to manipulate appropriately the theorem/proof.
+%Unfortunately, it means that it is not possible to use verbatim
+%environments inside. While
+%\href{https://tex.stackexchange.com/questions/489435/use-environment-into-new-xparse-environment}{this
+%answer} suggests that it is impossible to avoid this issue, other people
+%reported that it may be possible to use catcodes to capture the
+%environment body verbatim, before using scantokens to reparse it, or to
+%use
+%\href{https://mirror.ibcp.fr/pub/CTAN/macros/latex/contrib/filecontentsdef/filecontentsdef.pdf}{filecontentsdef}
+%(see for instance
+%\href{https://tex.stackexchange.com/questions/631810/create-a-newdocumentenvironment-programmatically?noredirect=1\#comment1575605_631810}{this
+%comment}{]}, ). However, it may be possible that this make syntex
+%unusable, so it may not worth the effort.
+%
+%In anycase, there exists some workarounds, some of the are for instance
+%give in the \href{https://texfaq.org/FAQ-verbwithin}{TeX FAQ}. The
+%simplest solution, if your code is simple/short enough, is to use
+%\texttt{\textbackslash{}texttt} (you can replace backslash with
+%\texttt{\textbackslash{}textbackslash} inside etc, and include it in a
+%\texttt{verse} if you have multiple lines). If you have a longer text,
+%you may also like \texttt{lrbox} to put your content inside a box, for
+%instance like that:
+%
+%\begin{Shaded}
+%\begin{Highlighting}[]
+%\CommentTok{\%\% Create the box}
+%\FunctionTok{\textbackslash{}newsavebox}\NormalTok{\{}\FunctionTok{\textbackslash{}myEndBox}\NormalTok{\}}
+%
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{lrbox}\NormalTok{\}\{}\FunctionTok{\textbackslash{}myEndBox}\NormalTok{\}}
+%  \KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{minipage}\NormalTok{\}\{1.0}\FunctionTok{\textbackslash{}linewidth}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{verbatim}\NormalTok{\}}
+%\VerbatimStringTok{\textbackslash{}newEndThm[normal]\{thmE\}\{thm\}}
+%\VerbatimStringTok{\textbackslash{}newEndProof\{proofE\}\{proof\}}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{verbatim}\NormalTok{\}}
+%  \KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{minipage}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{lrbox}\NormalTok{\}}
+%
+%\CommentTok{\%\% Create a theorem:}
+%\KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}}
+%\NormalTok{  Insert the box:}
+%  
+%  \KeywordTok{\textbackslash{}begin}\NormalTok{\{}\ExtensionTok{center}\NormalTok{\}}
+%    \FunctionTok{\textbackslash{}usebox}\NormalTok{\{}\FunctionTok{\textbackslash{}myEndBox}\NormalTok{\}}
+%  \KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{center}\NormalTok{\}}
+%\KeywordTok{\textbackslash{}end}\NormalTok{\{}\ExtensionTok{thmE}\NormalTok{\}}
+%\end{Highlighting}
+%\end{Shaded}
+%
+%\hypertarget{changelog}{%
+%\section{Changelog}\label{changelog}}
+%
+%\begin{itemize}
+%\tightlist
+%\item
+%  2022/01/28:
+%
+%  \begin{enumerate}
+%  \def\labelenumi{\arabic{enumi}.}
+%  \tightlist
+%  \item
+%    Fix the issue when using sharps in a proof
+%    https://github.com/leo-colisson/proof-at-the-end/issues/7.
+%  \item
+%    Provide \texttt{\textbackslash{}newEndThm},
+%    \texttt{\textbackslash{}newEndProof} and the option
+%    \texttt{createShortEnv} to quickly create environments.
+%  \end{enumerate}
+%\item
+%  2022/01/27:
+%
+%  \begin{enumerate}
+%  \def\labelenumi{\arabic{enumi}.}
+%  \tightlist
+%  \item
+%    Patch chapters/sections/\ldots{} to better detect the current
+%    section and fix
+%    \href{https://github.com/leo-colisson/proof-at-the-end/issues/2}{issue
+%    2}. This can be disabled using the package option
+%    \texttt{disablePatchSection}.
+%  \item
+%    Add an option \texttt{commandRef} to use other ref libraries, like
+%    \texttt{cleveref} instead of \texttt{autoref}.
+%  \item
+%    Normal restatable theorem do not need to be restated. Fix
+%    \href{https://github.com/leo-colisson/proof-at-the-end/issues/8}{issue
+%    8}.
+%  \end{enumerate}
+%\end{itemize}
+%
 %\hypertarget{contributions}{%
 %\section{Contributions}\label{contributions}}
 %
@@ -837,13 +1166,13 @@
 %
 %\begin{Shaded}
 %\begin{Highlighting}[]
-%\ExtensionTok{%%}\NormalTok{ Compile the demo}
+%\ExtensionTok{\%\%}\NormalTok{ Compile the demo}
 %\FunctionTok{make}\NormalTok{ demo}
-%\ExtensionTok{%%}\NormalTok{ Clean the project}
+%\ExtensionTok{\%\%}\NormalTok{ Clean the project}
 %\FunctionTok{make}\NormalTok{ clean}
-%\ExtensionTok{%%}\NormalTok{ Generate the documentation}
+%\ExtensionTok{\%\%}\NormalTok{ Generate the documentation}
 %\FunctionTok{make}\NormalTok{ doc}
-%\ExtensionTok{%%}\NormalTok{ Generate a package for CTAN}
+%\ExtensionTok{\%\%}\NormalTok{ Generate a package for CTAN}
 %\FunctionTok{make}\NormalTok{ package}
 %\end{Highlighting}
 %\end{Shaded}
@@ -850,6 +1179,7 @@
 %
 %
 %
+%
 %\StopEventually{}
 %\section{The Code}
 %\iffalse
@@ -858,16 +1188,18 @@
 %    \end{macrocode}
 %\fi
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{proof-at-the-end}[2019/05/21 A package to move proofs in appendix]
+\ProvidesPackage{proof-at-the-end}[2022/01/28 A package to move proofs in appendix]
  
 \RequirePackage{etoolbox}
-\RequirePackage{hyperref}
 \RequirePackage{thmtools}
 \RequirePackage{thm-restate}
 \RequirePackage{catchfile}
 \RequirePackage{pgfkeys}
 \RequirePackage{xparse}
-
+% Load hyperref at the end
+\AtEndPreamble{%
+  \RequirePackage{hyperref}
+}%
 \RequirePackage{kvoptions}
 
 %% https://tex.stackexchange.com/questions/109747/put-all-package-options-into-one-command
@@ -876,27 +1208,56 @@
 %% \usepackage[conf={normal}]{proof-at-the-end}
 \SetupKeyvalOptions{
   family=pratendOpt,
-  prefix=pratendOpt,
+  prefix=pratendOpt, % "Namespace": Prefix of the commands, conditions....
 }
 \DeclareStringOption{conf}
 \DeclareLocalOptions{conf}% \pratendOptdefconf contains the proof
+\DeclareBoolOption{disablePatchSection} % Use \ifpratendOptdisablePatchSection ... \else ... \fi
+\DeclareStringOption[autoref]{commandRef} % Use commandRef=cref to use cleveref. Defaults to autoref.
+\DeclareBoolOption{createShortEnv} % To create thmE, theoremE, proofE, lemmaE, corrolaryE
 \ProcessKeyvalOptions*
 
 % \DeclareOption*{\PackageWarning{proof-at-the-end}{Unknown}}
 % \ProcessOptions\relax
 
+%% https://tex.stackexchange.com/a/13289/116348
 \newwrite\appendwrite
+\newcount\pratend at count@makeallother
 
+%%% Loop to make sure all chars are normal letters, including #.
+\newcommand{\makeallother}{%
+  \pratend at count@makeallother0\relax
+  \loop\ifnum\pratend at count@makeallother<255\relax
+  \catcode\pratend at count@makeallother12\relax
+  \advance\pratend at count@makeallother by 1\relax
+  \repeat
+}
+
+%%% This command allows the user to append things to a file. But the content may contain macros that
+%%% will be evaluated before writing them to the file.
+%%% TODO: Efficiency may be improved by writing to the file only before the printProof.
 % The first argument is the file name
 % The second argument is the text to write
 \NewDocumentCommand\appendtofile{m+m}{%
   \begingroup
-  \IfFileExists{#1}%
-  {\CatchFileDef{\filecontent}{#1}{\catcode`\\=12 \endlinechar=`^^J\catcode\endlinechar=12\relax}}% keep existing end-of-lines
-  {\let\filecontent\empty}%
-  \immediate\openout\appendwrite=#1\relax
-  \immediate\write\appendwrite{\detokenize\expandafter{\filecontent}#2}%
-  \immediate\closeout\appendwrite
+  %% Read the content
+  \begingroup%
+  \IfFileExists{#1}{%
+    \newlinechar\endlinechar%
+    \makeallother% Turn all chars into normal letters.
+    \everyeof{\noexpand}%
+    \edef\fileContent{\@@input #1 }%
+  }{%
+    \let\fileContent\empty
+  }%
+  %% Open the file to write in it:
+  \immediate\openout\appendwrite #1\relax%
+  %% Write the text
+  \immediate\write\appendwrite{\fileContent}%
+  \endgroup%
+  \immediate\write\appendwrite{#2}%
+  %% Close the file
+  \immediate\closeout\appendwrite%
   \endgroup
 }
 
@@ -1012,19 +1373,19 @@
     one big link={#1~\pageref*{proof:prAtEnd\pratendcountercurrent}.}
   },
   text link section/.style={%
-      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}
+      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \pratendSectionlikeCref.}
   },
   text link section full proof/.style={%
-      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}
+      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \pratendSectionlikeCref.}
   },
   default text link/.style={
     text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.},
   },
   text proof translated/.style={
-    text proof={#1 \string\autoref{thm:prAtEnd\pratendcountercurrent}},
+    text proof={#1 \string\pratendRef{thm:prAtEnd\pratendcountercurrent}},
   },
   default text proof/.style={
-    text proof={Proof of \string\autoref{thm:prAtEnd\pratendcountercurrent}},
+    text proof={Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}},
   },
   %%%% Defaults
   bare defaults/.style={
@@ -1116,9 +1477,13 @@
     \fi%
     %% Create a custom alias to restate the theorem
     \expandafter\protected at xdef\csname \pratendcustomrestate\endcsname{\noexpand\csname prAtEndRestate\pratendcountercurrent\endcsname}%
-    %% Restate the theorem if needed in appendix
-    \ifrestatethm
-      \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\prAtEndRestate\pratendcountercurrent*}
+    %% Restate the theorem if needed in appendix.
+    %% As explained in https://github.com/leo-colisson/proof-at-the-end/issues/8
+    %% No need to restate of there is no proof at the end.
+    \ifproofend %
+      \ifrestatethm %
+        \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\prAtEndRestate\pratendcountercurrent*}%
+      \fi%
     \fi%
   \fi%  
   %% If the theorem is not stated in the main text,
@@ -1129,7 +1494,7 @@
     \protected at xdef\pratendcountercurrent{\roman{counterAllProofEnd}}
     %% Create a custom alias to restate the theorem
     \expandafter\protected at xdef\csname \pratendcustomrestate\endcsname{\noexpand\csname prAtEndRestate\pratendcountercurrent\endcsname}%
-    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\begin{restatable}[#3]{#2}{prAtEndRestate\pratendcountercurrent}\string\label{thm:prAtEnd\pratendcountercurrent}\detokenize{#4}\string\end{restatable}}%
+    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\begin{restatable}[\detokenize{#3}]{#2}{prAtEndRestate\pratendcountercurrent}\string\label{thm:prAtEnd\pratendcountercurrent}\detokenize{#4}\string\end{restatable}}%
   \fi%
 }{}
 
@@ -1155,7 +1520,13 @@
   \fi%
   %% Write the proof at the end
   \ifproofend%
-    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\label{proofsection:prAtEnd\pratendcountercurrent}\string\begin{proof}[\pratendtextproof]\string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}\detokenize{#2}\string\end{proof}}%
+    %% The label alone adds some space, see e.g.
+    %% https://tex.stackexchange.com/questions/600118/selectlanguage-in-the-middle-of-text-causes-extra-vertical-space/600142#600142
+    %% and https://tex.stackexchange.com/questions/600577/adding-a-label-between-two-proofs-adds-unwanted-space
+    %% The solution is to use \\Hy at SaveLastskip and \Hy at RestoreLastskip from hyperref
+    %% See also
+    %% https://tex.stackexchange.com/questions/553394/reliably-add-a-label-to-the-current-section-even-if-the-label-is-not-placed-rig/600847#600847
+    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\makeatletter\string\Hy at SaveLastskip\string\pratendChangeCurrentLabel\string\label{proofsection:prAtEnd\pratendcountercurrent}\string\Hy at RestoreLastskip\string\makeatother\string\begin{proof}[\pratendtextproof]\string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}\detokenize{#2}\string\end{proof}}%
   \fi%
 }{}
 
@@ -1198,7 +1569,113 @@
 %   }
 % }
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%   Patch sections, chapters...
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% We patch the \section, \subsection and \chapter commands to make sure that
+% the text "See proof in Section XX" points to the appropriate section/subsection.
+% We basically maintain a counter counting how many time we saw a section/subsection/... and use it to label
+% directly the section afterwards.
+\newcounter{pratend at counter@sectionlike}
+%% Command to add after a label like "prAtEnd:sectionlike10". Useful to patch \section, \chapter...
+\NewDocumentCommand\pratendAddLabel{}{%
+  %% First, we get the label
+  %% Cool explaination of expandafter, edef, noexpand:
+  %%% https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf
+  \edef\pratend at current@sectionlike at label{prAtEnd:sectionlike\thepratend at counter@sectionlike}%
+  \expandafter\label{\pratend at current@sectionlike at label}%
+  \let\pratend at sectionlike@stored at label\@currentlabel%
+}%
+\NewDocumentCommand\pratendSectionlikeCref{}{%
+  \pratendRef{proofsection:prAtEnd\pratendcountercurrent}%
+}
+\NewDocumentCommand\pratendChangeCurrentLabel{}{
+  \ifdefined\pratend at sectionlike@stored at label%
+    \let\@currentlabel\pratend at sectionlike@stored at label%
+  \fi%
+}
+\ifpratendOptdisablePatchSection
+\else  
+  %% Add the above command to \chapter if the command exists
+  \ifdef{\@chapter}{
+    \ifpatchable*{\@chapter}{
+      \apptocmd{\@chapter}{\pratendAddLabel}{}{}%
+    }{\PackageWarning{proof-at-the-end}{Chapters are not patchable.}{}}
+  }{}
+  %% patch sections/subsections/paragraph/...
+  %% https://tex.stackexchange.com/questions/631713/patch-section-command-fails/631717?noredirect=1#comment1575337_631717
+  \ifdef{\@sect}{
+    % \apptocmd{\section}{\pratendAddLabel}{}{}%
+    \ifpatchable*{\@sect}{
+      \apptocmd{\@sect}{\pratendAddLabel}{}{}%
+    }{\PackageWarning{proof-at-the-end}{Sections are not patchable.}{}}
+  }{}
+\fi
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Allow cref/autoref/...
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Instead of \autoref{proof:blabla} use \pratendRef{proof:blabla}, it allows the ref command to be customized
+%% as an option of the package.
+\NewDocumentCommand\pratendRef{m}{%
+  \csname \pratendOptcommandRef\endcsname{#1}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create automatically wrapper
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Defines a shortcut to avoid typing the whole theoremEnd environment.
+%% Avoid to manually type \NewDocumentEnvironment...
+%% Usage: \newEndThm[default options]{new environment}{old environment}
+% E.g.: \newEndThm[normal]{thmE}{thm}{}
+\NewDocumentCommand{\newEndThm}{O{}mm}{%
+  % \expandafter\NewDocumentEnvironment{#2}{O{}O{}+b}{%
+    % \begin{theoremEnd}[#1,##2]{#3}[##1]%
+      % ##3%
+    % \end{theoremEnd}%
+  % }{}
+  \NewDocumentEnvironment{#2}{O{}O{}}{%
+    \begin{theoremEnd}[#1,##2]{#3}[##1]%
+    }{\end{theoremEnd}}
+}
+
+% \NewDocumentCommand{\newEndThm}{O{}mm}{%
+%   % \expandafter\NewDocumentEnvironment{#2}{O{}O{}+b}{%
+%     % \begin{theoremEnd}[#1,##2]{#3}[##1]%
+%       % ##3%
+%     % \end{theoremEnd}%
+%   % }{}
+%   \expandafter\NewDocumentEnvironment{#2}{O{}O{}+b}{%
+%     \begin{theoremEnd}[#1,##2]{#3}[##1]%
+%       ##3
+%     \end{theoremEnd}%
+%   }{}
+% }
+
+%% Avoid to manually type \NewDocumentEnvironment...
+%% Usage: \newEndProof[default options]{new proof environment}{old proof environment}
+% E.g.: \newEndProof[]{proofE}{proof}
+\NewDocumentCommand{\newEndProof}{O{}m}{%
+  \NewDocumentEnvironment{#2}{O{}+b}{%
+    \begin{proofEnd}[#1,##1]%
+      ##2%
+    \end{proofEnd}%
+  }{}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create even more automatically wrapper with option "createShortEnv"
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifpratendOptcreateShortEnv
+  %%% We create automatically the environments.
+  \newEndProof{proofE}
+  \newEndThm{thmE}{thm}
+  \newEndThm{lemmaE}{lemmaE}
+  \newEndThm{theoremE}{theorem}
+  \newEndThm{corollaryE}{corollary}
+\fi
+
 \endinput
 %\iffalse
 %    \begin{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.ins	2022-01-28 22:24:07 UTC (rev 61775)
+++ trunk/Master/texmf-dist/source/latex/proof-at-the-end/proof-at-the-end.ins	2022-01-28 22:24:21 UTC (rev 61776)
@@ -1,10 +1,10 @@
-% proof-at-the-end.ins generated using makedtx version 1.2 2019/5/22 12:52
+% proof-at-the-end.ins generated using makedtx version 1.2 2022/1/28 19:43
 \input docstrip
 
 \preamble
 
  proof-at-the-end.dtx
- Copyright 2019 Léo Colisson
+ Copyright 2022 Léo Colisson
 
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty	2022-01-28 22:24:07 UTC (rev 61775)
+++ trunk/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty	2022-01-28 22:24:21 UTC (rev 61776)
@@ -7,7 +7,7 @@
 %% proof-at-the-end.dtx  (with options: `proof-at-the-end.sty,package')
 %% 
 %%  proof-at-the-end.dtx
-%%  Copyright 2019 Léo Colisson
+%%  Copyright 2022 Léo Colisson
 %% 
 %%  This work may be distributed and/or modified under the
 %%  conditions of the LaTeX Project Public License, either version 1.3
@@ -39,16 +39,17 @@
 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
 %%   Right brace   \}     Tilde         \~}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{proof-at-the-end}[2019/05/21 A package to move proofs in appendix]
+\ProvidesPackage{proof-at-the-end}[2022/01/28 A package to move proofs in appendix]
 
 \RequirePackage{etoolbox}
-\RequirePackage{hyperref}
 \RequirePackage{thmtools}
 \RequirePackage{thm-restate}
 \RequirePackage{catchfile}
 \RequirePackage{pgfkeys}
 \RequirePackage{xparse}
-
+\AtEndPreamble{%
+  \RequirePackage{hyperref}
+}%
 \RequirePackage{kvoptions}
 
 %% https://tex.stackexchange.com/questions/109747/put-all-package-options-into-one-command
@@ -57,23 +58,52 @@
 %% \usepackage[conf={normal}]{proof-at-the-end}
 \SetupKeyvalOptions{
   family=pratendOpt,
-  prefix=pratendOpt,
+  prefix=pratendOpt, % "Namespace": Prefix of the commands, conditions....
 }
 \DeclareStringOption{conf}
 \DeclareLocalOptions{conf}% \pratendOptdefconf contains the proof
+\DeclareBoolOption{disablePatchSection} % Use \ifpratendOptdisablePatchSection ... \else ... \fi
+\DeclareStringOption[autoref]{commandRef} % Use commandRef=cref to use cleveref. Defaults to autoref.
+\DeclareBoolOption{createShortEnv} % To create thmE, theoremE, proofE, lemmaE, corrolaryE
 \ProcessKeyvalOptions*
 
 
+%% https://tex.stackexchange.com/a/13289/116348
 \newwrite\appendwrite
+\newcount\pratend at count@makeallother
 
+%%% Loop to make sure all chars are normal letters, including #.
+\newcommand{\makeallother}{%
+  \pratend at count@makeallother0\relax
+  \loop\ifnum\pratend at count@makeallother<255\relax
+  \catcode\pratend at count@makeallother12\relax
+  \advance\pratend at count@makeallother by 1\relax
+  \repeat
+}
+
+%%% This command allows the user to append things to a file. But the content may contain macros that
+%%% will be evaluated before writing them to the file.
+%%% TODO: Efficiency may be improved by writing to the file only before the printProof.
 \NewDocumentCommand\appendtofile{m+m}{%
   \begingroup
-  \IfFileExists{#1}%
-  {\CatchFileDef{\filecontent}{#1}{\catcode`\\=12 \endlinechar=`^^J\catcode\endlinechar=12\relax}}% keep existing end-of-lines
-  {\let\filecontent\empty}%
-  \immediate\openout\appendwrite=#1\relax
-  \immediate\write\appendwrite{\detokenize\expandafter{\filecontent}#2}%
-  \immediate\closeout\appendwrite
+  %% Read the content
+  \begingroup%
+  \IfFileExists{#1}{%
+    \newlinechar\endlinechar%
+    \makeallother% Turn all chars into normal letters.
+    \everyeof{\noexpand}%
+    \edef\fileContent{\@@input #1 }%
+  }{%
+    \let\fileContent\empty
+  }%
+  %% Open the file to write in it:
+  \immediate\openout\appendwrite #1\relax%
+  %% Write the text
+  \immediate\write\appendwrite{\fileContent}%
+  \endgroup%
+  \immediate\write\appendwrite{#2}%
+  %% Close the file
+  \immediate\closeout\appendwrite%
   \endgroup
 }
 
@@ -189,19 +219,19 @@
     one big link={#1~\pageref*{proof:prAtEnd\pratendcountercurrent}.}
   },
   text link section/.style={%
-      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}
+      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} in \pratendSectionlikeCref.}
   },
   text link section full proof/.style={%
-      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \autoref{proofsection:prAtEnd\pratendcountercurrent}.}
+      text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{full proof} in \pratendSectionlikeCref.}
   },
   default text link/.style={
     text link={See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.},
   },
   text proof translated/.style={
-    text proof={#1 \string\autoref{thm:prAtEnd\pratendcountercurrent}},
+    text proof={#1 \string\pratendRef{thm:prAtEnd\pratendcountercurrent}},
   },
   default text proof/.style={
-    text proof={Proof of \string\autoref{thm:prAtEnd\pratendcountercurrent}},
+    text proof={Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}},
   },
   %%%% Defaults
   bare defaults/.style={
@@ -293,9 +323,13 @@
     \fi%
     %% Create a custom alias to restate the theorem
     \expandafter\protected at xdef\csname \pratendcustomrestate\endcsname{\noexpand\csname prAtEndRestate\pratendcountercurrent\endcsname}%
-    %% Restate the theorem if needed in appendix
-    \ifrestatethm
-      \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\prAtEndRestate\pratendcountercurrent*}
+    %% Restate the theorem if needed in appendix.
+    %% As explained in https://github.com/leo-colisson/proof-at-the-end/issues/8
+    %% No need to restate of there is no proof at the end.
+    \ifproofend %
+      \ifrestatethm %
+        \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\prAtEndRestate\pratendcountercurrent*}%
+      \fi%
     \fi%
   \fi%
   %% If the theorem is not stated in the main text,
@@ -306,7 +340,7 @@
     \protected at xdef\pratendcountercurrent{\roman{counterAllProofEnd}}
     %% Create a custom alias to restate the theorem
     \expandafter\protected at xdef\csname \pratendcustomrestate\endcsname{\noexpand\csname prAtEndRestate\pratendcountercurrent\endcsname}%
-    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\begin{restatable}[#3]{#2}{prAtEndRestate\pratendcountercurrent}\string\label{thm:prAtEnd\pratendcountercurrent}\detokenize{#4}\string\end{restatable}}%
+    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\begin{restatable}[\detokenize{#3}]{#2}{prAtEndRestate\pratendcountercurrent}\string\label{thm:prAtEnd\pratendcountercurrent}\detokenize{#4}\string\end{restatable}}%
   \fi%
 }{}
 
@@ -332,7 +366,13 @@
   \fi%
   %% Write the proof at the end
   \ifproofend%
-    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\label{proofsection:prAtEnd\pratendcountercurrent}\string\begin{proof}[\pratendtextproof]\string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}\detokenize{#2}\string\end{proof}}%
+    %% The label alone adds some space, see e.g.
+    %% https://tex.stackexchange.com/questions/600118/selectlanguage-in-the-middle-of-text-causes-extra-vertical-space/600142#600142
+    %% and https://tex.stackexchange.com/questions/600577/adding-a-label-between-two-proofs-adds-unwanted-space
+    %% The solution is to use \\Hy at SaveLastskip and \Hy at RestoreLastskip from hyperref
+    %% See also
+    %% https://tex.stackexchange.com/questions/553394/reliably-add-a-label-to-the-current-section-even-if-the-label-is-not-placed-rig/600847#600847
+    \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\makeatletter\string\Hy at SaveLastskip\string\pratendChangeCurrentLabel\string\label{proofsection:prAtEnd\pratendcountercurrent}\string\Hy at RestoreLastskip\string\makeatother\string\begin{proof}[\pratendtextproof]\string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}\detokenize{#2}\string\end{proof}}%
   \fi%
 }{}
 
@@ -365,6 +405,95 @@
 %%% You can easily modify the defaults:
 %%% Or create new styles to apply:
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%   Patch sections, chapters...
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcounter{pratend at counter@sectionlike}
+%% Command to add after a label like "prAtEnd:sectionlike10". Useful to patch \section, \chapter...
+\NewDocumentCommand\pratendAddLabel{}{%
+  %% First, we get the label
+  %% Cool explaination of expandafter, edef, noexpand:
+  %%% https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf
+  \edef\pratend at current@sectionlike at label{prAtEnd:sectionlike\thepratend at counter@sectionlike}%
+  \expandafter\label{\pratend at current@sectionlike at label}%
+  \let\pratend at sectionlike@stored at label\@currentlabel%
+}%
+\NewDocumentCommand\pratendSectionlikeCref{}{%
+  \pratendRef{proofsection:prAtEnd\pratendcountercurrent}%
+}
+\NewDocumentCommand\pratendChangeCurrentLabel{}{
+  \ifdefined\pratend at sectionlike@stored at label%
+    \let\@currentlabel\pratend at sectionlike@stored at label%
+  \fi%
+}
+\ifpratendOptdisablePatchSection
+\else
+  %% Add the above command to \chapter if the command exists
+  \ifdef{\@chapter}{
+    \ifpatchable*{\@chapter}{
+      \apptocmd{\@chapter}{\pratendAddLabel}{}{}%
+    }{\PackageWarning{proof-at-the-end}{Chapters are not patchable.}{}}
+  }{}
+  %% patch sections/subsections/paragraph/...
+  %% https://tex.stackexchange.com/questions/631713/patch-section-command-fails/631717?noredirect=1#comment1575337_631717
+  \ifdef{\@sect}{
+    % \apptocmd{\section}{\pratendAddLabel}{}{}%
+    \ifpatchable*{\@sect}{
+      \apptocmd{\@sect}{\pratendAddLabel}{}{}%
+    }{\PackageWarning{proof-at-the-end}{Sections are not patchable.}{}}
+  }{}
+\fi
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Allow cref/autoref/...
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Instead of \autoref{proof:blabla} use \pratendRef{proof:blabla}, it allows the ref command to be customized
+%% as an option of the package.
+\NewDocumentCommand\pratendRef{m}{%
+  \csname \pratendOptcommandRef\endcsname{#1}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create automatically wrapper
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Defines a shortcut to avoid typing the whole theoremEnd environment.
+%% Avoid to manually type \NewDocumentEnvironment...
+%% Usage: \newEndThm[default options]{new environment}{old environment}
+\NewDocumentCommand{\newEndThm}{O{}mm}{%
+  % \expandafter\NewDocumentEnvironment{#2}{O{}O{}+b}{%
+    % \begin{theoremEnd}[#1,##2]{#3}[##1]%
+      % ##3%
+    % \end{theoremEnd}%
+  % }{}
+  \NewDocumentEnvironment{#2}{O{}O{}}{%
+    \begin{theoremEnd}[#1,##2]{#3}[##1]%
+    }{\end{theoremEnd}}
+}
+
+
+%% Avoid to manually type \NewDocumentEnvironment...
+%% Usage: \newEndProof[default options]{new proof environment}{old proof environment}
+\NewDocumentCommand{\newEndProof}{O{}m}{%
+  \NewDocumentEnvironment{#2}{O{}+b}{%
+    \begin{proofEnd}[#1,##1]%
+      ##2%
+    \end{proofEnd}%
+  }{}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create even more automatically wrapper with option "createShortEnv"
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifpratendOptcreateShortEnv
+  %%% We create automatically the environments.
+  \newEndProof{proofE}
+  \newEndThm{thmE}{thm}
+  \newEndThm{lemmaE}{lemmaE}
+  \newEndThm{theoremE}{theorem}
+  \newEndThm{corollaryE}{corollary}
+\fi
+
 \endinput
 %%
 %% End of file `proof-at-the-end.sty'.



More information about the tex-live-commits mailing list.