Debian Codegraph @

texmf-dist/doc/latex/proof-at-the-end/README.md

raw symbols SCIP
1 # Proof-at-the-end, or how to move proofs in appendix in LaTeX
2
3 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.
4
5 ## Introduction
6
7 This package aims to provide a way to easily move proofs in the appendix. You can:
8
9 - Move proofs in different places/sections by giving different "categories" to the theorems
10 - Create links from theorem to proof, and from proof to theorem (and configure the text)
11 - Restate the theorem in appendix (or before)
12 - Choose what you want to keep in the main text or in appendix (you can put in appendix either everything, just the proof, the theorem and the proof by keeping (or not) a copy in the body of the article...)
13 - Duplicate the proof in appendix and in the current section, practical to use synctex during the proof writting
14 - Add text that would appear only in the appendix (or in both body and appendix)
15 - Easily change the defaults, and create your own styles/environments
16 - Include sketch of proof in the main text, and full proof in appendix
17 - Change the text of the link, for example to translate into another language
18 - Have a nice environment-based commands in order to mimic the usual theorem/proof structure.
19 - Separate the main article and the body in two documents (some journals may ask for a separate file for the appendix)
20
21 NB: This project is hosted on github at [https://github.com/leo-colisson/proof-at-the-end](https://github.com/leo-colisson/proof-at-the-end) . Feel free to contribute, report bugs, or read/copy-paste the documentation/examples from there.
22
23 Disclaimer: This package is still in beta and not considered as stable.
24
25 This package is licensed under LPPL v1.3, and the last version of this package on CTAN is 2019/05/21.
26
27 ## Demo ##
28
29 If you just want to see an example of what you can do, you can directly open the file `demo.pdf` (also available online at [https://github.com/leo-colisson/proof-at-the-end/raw/master/demo.pdf](https://github.com/leo-colisson/proof-at-the-end/raw/master/demo.pdf)) to see what is possible, or generate it with
30
31 ```bash
32 git clone https://github.com/leo-colisson/proof-at-the-end.git
33 pdflatex demo.tex && pdflatex demo.tex
34 ```
35
36 ## Quickstart ##
37
38 ### Super Quick QuickStart ###
39
40 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), just, until [this upstream `thmtool` bug](https://github.com/muzimuzhi/thmtools/issues/70) is fixed, links will be broken unless you do one of the following actions:
41 - call `\hypersetup{hypertexnames=false}` at the end of the preamble (but this may fails if you build an index),
42 - or, possibly cleaner, if you use something like `\newtheorem{thm}{Theorem}[section]`, then you must call `\renewcommand\theHthm{\thesection .\arabic {thm}}`.
43 If you are unhappy with these workarounds, raise your voice in the above `thmtool` issue.
44
45 Then, 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:
46
47 ```latex
48 \begin{thmE}[My title][end, restate]
49 I am a restated theorem whose proof goes in appendix (compile me twice).
50 \end{thmE}
51 \begin{proofE}
52 And I am a proof.
53 \end{proofE}
54 ```
55 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. Note that in case you don't want any title but do want to add options, make sure to insert an empty pair of brackets like in `\begin{thmE}[][end, text link=]` (the option `text link` is used to choose the text of the link to the proof, writting `text link=` is used to display no link at all).
56
57 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.
58
59 ![Screenshot of the quickstart](screenshot.png)
60
61 You can directly copy them (with a more complete demo) in the github page here https://github.com/leo-colisson/proof-at-the-end/.
62
63 ```latex
64 \documentclass{article}
65
66 \usepackage{xparse} % Not needed with recent LaTeX
67 \usepackage{amsthm}
68
69 % Create new theorems, or use ntheorem/thmtools/...
70 \newtheorem{thm}{Theorem}[section]
71 % Default uses autoref, but you can also use cleveref, see the documentation.
72 % Say to autoref that "thm" are Theorems.
73 \newcommand{\thmautorefname}{Theorem}
74
75 %% Load the library. createShortEnv automatically creates the shortcuts
76 %% thmE, theoremE, lemmaE, propositionE, corollaryE, proofE. See \newEndThm for more details.
77 \usepackage[createShortEnv]{proof-at-the-end}
78
79 \begin{document}
80
81 \section{Theorems}
82
83 %% If you don't have any title, leave an empty bracket like \begin{thmE}[][end]
84 \begin{thmE}[My title][end, restate]
85 I am a theorem
86 \end{thmE}
87 \begin{proofE}
88 And I am a proof.
89 \end{proofE}
90
91 \section{Proofs}
92 \printProofs
93
94 \end{document}
95 ```
96
97
98 ### Install ###
99
100 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).
101
102 ``` bash
103 cd <your project>
104 repopratend="https://raw.githubusercontent.com/leo-colisson/proof-at-the-end"
105 wget ${repopratend}/master/proof-at-the-end.sty
106 ```
107
108 It also requires a recent version of xparse (not present in TexLive 2018 and before basically), otherwise you will get an error like:
109
110 ```
111 Unknown argument type 'b' replaced by 'm'
112 ```
113
114 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:
115
116 ``` bash
117 cd <your project>
118 wget http://mirrors.ctan.org/install/macros/latex/contrib/l3packages.tds.zip
119 unzip -d . -j l3packages.tds.zip 'tex/latex/l3packages/xparse/*'
120 rm -f l3packages.tds.zip xparse.ltx
121 ```
122
123 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:
124
125 ```
126 Package xparse Error: Support package l3kernel too old.
127 ```
128
129 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:
130
131 ```bash
132 cd <your project>
133 wget http://mirrors.ctan.org/install/macros/latex/contrib/l3kernel.tds.zip
134 unzip -d . -j l3kernel.tds.zip 'tex/latex/l3kernel/*'
135 rm l3kernel.tds.zip
136 wget http://mirrors.ctan.org/install/macros/latex/contrib/l3backend.tds.zip
137 unzip -d . -j l3backend.tds.zip 'tex/latex/l3backend/*'
138 rm l3backend.tds.zip
139 ```
140
141 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).
142
143 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.
144
145 You can test your install by compiling the `demo.tex` file present in the repository. When it compiles, you are ready to start!
146
147 ### Use in your project ###
148
149 Now, you can load the library in your project by simply using:
150
151 ```latex
152 \usepackage{proof-at-the-end}
153 ```
154
155 Then, you can configure your theorem/lemma/... environments as usual, by using any counter you like...:
156
157 ```latex
158 \usepackage{amssymb, amsthm, amsmath}
159 % Theorems
160 \newtheorem{thm}{Theorem}[section]
161 \newtheorem*{thm*}{Theorem}
162 \providecommand*\thmautorefname{Theorem}
163 % Lemmata
164 \newtheorem{lemma}[thm]{Lemma}
165 \newtheorem*{lemma*}{Lemma}
166 \providecommand*\lemmaautorefname{Lemma}
167 ```
168
169 And inside your document, you can use the following syntax to create a new theorem:
170
171 ```latex
172 \begin{theoremEnd}[OPTIONS]{THEOREM ENVIRONMENT}[OPTIONAL TITLE]
173 YOUR THEOREM, with eventually labels like \label{thm:OPTIONAL LABEL}
174 \end{theoremEnd}
175 \begin{proofEnd} %% Optional environment
176 YOUR (OPTIONAL) PROOF
177 \end{proofEnd}
178 ```
179
180 For example:
181
182 ```latex
183 \begin{theoremEnd}{thm}[Yes I can have a title]
184 \label{thm:ilikelabels}
185 Creating a new theorem is easy
186 \end{theoremEnd}
187 \begin{proofEnd}
188 You want a proof? Here is it!
189 \end{proofEnd}
190 ```
191
192 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`, `propositionE` 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:
193
194 ```latex
195 \begin{thmE}[My title][end, restate]
196 I am a restated theorem whose proof goes in appendix (compile me twice).
197 \end{thmE}
198 \begin{proofE}
199 And I am a proof.
200 \end{proofE}
201 ```
202
203 Finally, to display the proofs, just use `\printProofs` where you like:
204
205 ```latex
206 \printProofs
207 ```
208
209 If you would like to display a lemma instead, just change `{thm}` into `{lemma}`, or into any other theorem environment you defined! You can now compile safely your document ;)
210
211 NB: if you want to make sure all the references are linked correctly, make sure to compile twice the document!
212
213
214 Isn't it simple ?
215
216
217 ### A note on `hyperref`
218
219 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:
220
221 ```latex
222 \usepackage[colorlinks]{hyperref}
223 \usepackage{cleveref}
224 ```
225
226 ## Use cases
227
228 ### Configuration and how to use and create styles ###
229
230 You can very easily configure this package, and choose how each theorem/proof must be displayed by providing a value in `OPTIONS`. For example, if you would like to keep the proof of a theorem in the main text like any normal theorem, use the `normal` option.
231
232 ```latex
233 \begin{theoremEnd}[normal]{thm}[A title]
234 You can easily turn a theorem back into a normal theorem!
235 \end{theoremEnd}
236 \begin{proofEnd}
237 And keep the proof with you!
238 \end{proofEnd}
239 ```
240
241 If you loaded the package using `\usepackage[createShortEnv]{proof-at-the-end}` (starting from 2022/01/28), you also have preconfigured shortcuts for multiple environments, namely `proofE` (to replace `proof`), `thmE` (to replace `thm`), `theoremE` (to replace... ok you got the pattern), `lemmaE`, `propositionE`, `propertyE`, `factE` and `corollaryE`. This way, you can simplify the above as:
242 ```latex
243 \begin{thmE}[A title][normal]
244 You can easily turn a theorem back into a normal theorem!
245 \end{thmE}
246 \begin{proofE}
247 And keep the proof with you!
248 \end{proofE}
249 ```
250
251 (You can of course remove the `[...]` containing the options and the title, however if you want to add options without any title, **make sure to use empty brackets for the title**, like `\begin{thmE}[][normal]`.
252
253 Since 2022/01/28, you can also create new theorem environment that directly come with a preconfigured style (you may also find `\pratendSetLocal` useful if you want to change the style in a whole section). For instance to create a `thmNormal` environment having the `normal` option and a `thmSpecial` environment having the `all end, category=mySpecial` options, just do:
254 ```
255 \newEndThm[normal]{thmNormal}{thm} % 'thm' is the name of the existing thm environment
256 \newEndThm[all end, category=mySpecial]{thmSpecial}{thm}
257 ```
258
259 This way, you can simply use `\begin{thmSpecial}[Special title] ... \end{thmSpecial}` to create a theorem going in the special category (see below). (you also have `\newEndProof[options]{newProofEnv}` to define new proofs, but it is less useful as options are typically given in the theorem).
260
261 The options are in fact a set of keys/values, thanks to `pgfkeys`. So you can combine them with comma separated list like that (order matters, as the right-most values may overwrite configuration set by left-most values):
262
263 ```latex
264 \begin{theoremEnd}[proof at the end,
265 no link to proof,
266 text proof={Difficult proof}
267 ]{thm}[A title]
268 Each theorem can have a custom configuration!
269 \end{theoremEnd}
270 \begin{proofEnd}
271 Quite practical, isn't it?
272 \end{proofEnd}
273 ```
274
275 You can easily create your own styles like that:
276
277 ```latex
278 \pgfkeys{/prAtEnd/my great style/.style={
279 proot at the end,
280 no link to proof,
281 text proof={Difficult proof},
282 }
283 }
284 ```
285
286 You can also change the default configuration when you load the package by nesting the configuration into a `conf` key:
287
288 ```latex
289 \usepackage[conf={normal, one big link}]{proof-at-the-end}
290 ```
291
292 Note however that for now it is *not* possible to use macros directly inside the options when you load the package, so if you need to use more complicated configuration, you can overwrite the `global custom defaults` style for global configuration, and the `local custom defaults` style for local configuration (useful for example if you want to define a category for a single section):
293
294 ```latex
295 \pgfkeys{/prAtEnd/global custom defaults/.style={
296 one big link={Go to proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent}}
297 }
298 }
299 ```
300
301 or, for short (needs version > 2022/02/04):
302 ```latex
303 \pratendSetGlobal{one big link="blabla"}
304 ```
305
306 and for local configuration:
307 ```latex
308 \pgfkeys{/prAtEnd/local custom defaults/.style={
309 category=greattheorem
310 }
311 }
312 ```
313
314 for short (needs version > 2022/02/04):
315 ```latex
316 \pratendSetLocal{category=greattheorem}
317 ```
318
319 Then you can use like that:
320
321 ```latex
322 \begin{thmE}[Title]
323 Here is a normal theorem with the proof in the main text.
324 \end{thmE}
325 \begin{proofE}
326 The (optional) proof
327 \end{proofE}
328
329 \begin{thmE}[Title][end]
330 Here is a theorem whose proof goes to the end.
331 \end{thmE}
332 \begin{proofE}
333 The proof
334 \end{proofE}
335
336 \begin{thmE}[Title][all end]
337 Here is a theorem that goes with the proof at the end.
338 \end{thmE}
339 \begin{proofE}
340 The proof
341 \end{proofE}
342 ```
343
344 Note also that it is possible to give options to the `proofEnd` environment, but it is usually useless, as it will automatically pick the parameters from the last `theoremEnd` environment. However, if for some reasons you want to change the options of the proof only, you can do it, but do it as your own risks ;)
345
346 ### Usual styles ###
347
348 We predefined some pretty common styles/options. The full list is at the end of this document, but here is a list of the most practical ones:
349
350 - `normal`: turn the theorem into a "normal" theorem, with the proof in the main text and nothing in appendix
351 - `category=yourowncategory`: change the category of the theorem (see next sub-section)
352 - `end`: put the proof in appendix
353 - `all end`: put both the theorem and the proof in appendix
354 - `debug`: make sure the proof is written in the main text as well. Practical when you write the proof to be able to use synctex (if you use synctex with the proof in appendix, your will be unfortunately moved to a temporary file that this library is using... so **make sure you don't modify the files named like `*prattheenddefaultcategory.tex` or all your changes will be lost at the next compilation**!).
355 - `one big link`: if you prefer to have a single big link instead of two links (one for the proof, one for the page)
356 - `one big link translated=Your translation`: to change/translate the text of the link easily
357 - `text link section`: put a link looking like "See proof in section XX.". You can use `text link=` to remove this link.
358 - `text link section full proof`: put a link looking like "See full proof in section XX."
359 - `text proof translated=Your translation`: to change/translate the text of the proof at the end easily
360 - `global custom defaults`: empty style that you can modify to change the configuration (globally)
361 - `local custom defaults`: empty style that you can modify to change the configuration (locally). Practical to set a category for a single section.
362
363 ### Categories, or how to move proofs in different sections ###
364
365 Let's imagine that you have some proofs that are easy to do, and some proofs that are long but interesting. You may want to put the easy proofs in a different place that the long proofs. It is super easy to do, you just need to give a category name to the option `category` like here:
366
367 ```latex
368 \begin{theoremEnd}[category=mylongproofs]{thm}[A title]
369 You can easily change the place of the proofs
370 \end{theoremEnd}
371 \begin{proofEnd}
372 Just use a different category name!
373 \end{proofEnd}
374 ```
375
376 and give this category name to `\printProofs` in the section where you would like to display the proofs:
377
378 ```latex
379 \printProofs[mylongproofs]
380 ```
381
382 ### Comments ###
383
384 You can also move some text in the appendix by using:
385
386 ```latex
387 \textEnd{Your text that should go in appendix}
388 ```
389
390 You can also give it a category as explained above, or configure it to be displayed in both the main text and at the end of the file with:
391
392 ```latex
393 \textEnd[both]{I am a comment that is written in both the main text
394 and the appendix}
395 ```
396
397 You can also use the environment notation like that:
398
399 ```latex
400 \begin{textAtEnd}[options]
401 You can also use the environment syntax.
402 \end{textAtEnd}
403 ```
404
405 ### Restate a theorem ###
406
407 It is easy to restate a theorem in the appendix, to have both the theorem in the main text and in the appendix: just use the option `restate`:
408
409 ```latex
410 \begin{theoremEnd}[end, restate]{thm}[A title]
411 This theorem will be displayed both in main text and appendix.
412 \end{theoremEnd}
413 \begin{proofEnd}
414 Just use restate option.
415 \end{proofEnd}
416 ```
417
418 You can also use the option `restate command=yourcustomcommand` in order to create a macro `\yourcustomcommand` that will restate the theorem wherever you want (but after the definition).
419
420 If you want to (re)state a theorem *before* its definition (say in the introduction), there is also a special environment `theoremEndRestateBefore` that requires a (unique) custom name that you need to provide also later on in place of the real theorem with the option `restated before`:
421
422 ```latex
423 \section{Introduction}
424 \begin{theoremEndRestateBefore}{thm}[Title]{anamethatisusedtorestate}
425 It is possible to state the theorem before
426 in the introduction, and restate it later
427 \end{theoremEndRestateBefore}
428
429 \section{Real definition}
430 \begin{theoremEnd}[restated before]{thm}
431 anamethatisusedtorestate
432 \end{theoremEnd}
433 \begin{proofEnd}
434 Proof of the theorem, put in place of the theorem the unique name
435 \end{proofEnd}
436 ```
437
438 ### Translate the links ###
439
440 The more powerful way to change the text of the links is to redefine `text link` and `text proof` (see section List of options for more details). However we defined also some easy way to redefine the text using `one big link translated` and `text proof translated`. For example, to create your `french` style you can do:
441
442 ```latex
443 \pgfkeys{/prAtEnd/french/.style={
444 one big link translated={Voir preuve page},
445 text proof translated={Preuve du}
446 }
447 }
448 ```
449
450 ### Write a sketch of proof in the main text ###
451
452 You can include a sketch of proof in the main text by simply adding a proof in between `theoremEnd` and `proofEnd`. An alias option `see full proof` can also be used to change the link into "See full proof on page X.":
453
454 ```latex
455 \begin{theoremEnd}[see full proof]{thm}
456 I can also write a sketch of proof, and put the full proof in appendix.
457 \end{theoremEnd}
458 \begin{proof}
459 Hint: look at the alias options.
460 \end{proof}
461 \begin{proofEnd}
462 You just use ``see full proof'' as an option
463 \end{proofEnd}
464 ```
465
466 ### Split the article in two documents, one for the main body and one for the appendix ###
467
468 Since 2022/02/04, it is possible to include the appendix in a separate file. Internally, this library creates a new file having the form `NAME_OF_FILE-pratendNAME_CATEGORY.tex` containing the proofs to include (then, `\printProofs` only input that file). You can input that file from other files if you want to separate the body from the proof, but it won't work if you have restate theorems. You should use the option `external appendix` (starting from version 2022/02/04) to restate appropriately the theorem:
469
470 ```latex
471 \usepackage[createShortEnv,conf={external appendix}]{proof-at-the-end}
472 ```
473
474 Then, compile your main file and create a new file for the appendix, load the theorems environments as for the main file, in the preambule load the `xr` package to properly have references (otherwise you won't have the appropriate number for the theorems) using something like:
475 ```
476 \usepackage{xr}
477 \externaldocument{name_of_main_file_without_extension}
478 ```
479
480 and in this new document just add the appendix wherever you want:
481 ```latex
482 \includeExternalAppendix{name_of_main_file_without_extension}
483 ```
484
485 You can see an exemple in the github repository, with the two files `demo_external_appendix.tex` and `demo_external_appendix_part2.tex`. Whenever your proofs change in the main paper, make sure to compile first the main document (so that the auxiliary file gets updated), and then compile the appendix document. Note that you can still use `\printProofs` in the main document if you like (while writting your paper, it is certainly easier to keep the proofs and theorems in the same document).
486
487 ## List of options ##
488
489 Here is the list of fundamental options supported. Most options have a `no` version, with `no ` written before. Note that you may prefer to use directly the alias/styles (see next paragraph) as the options listed here are quite fundamental and atomic.
490
491 - `category`: category of the proof (if you want to put proofs at several places), can be anything
492 - `proof here`/`no proof here`: put (or not) the proof in the main text
493 - `proof end`/`no proof end`: display the proof in appendix
494 - `restate`/`no restate`: restate the theorem in appendix
495 - `link to proof`/`no link to proof`: Display a link to the proof in the main text
496 - `opt all end`/`no opt all end`: put the theorem and proof only in appendix. You may prefer the alias `all end`, that also makes sure that the proof is indeed displayed in appendix.
497 - `text link`: text of the link to the proof, defaults to
498
499 `{See \hyperref[proof:prAtEnd\pratendcountercurrent]{proof} on page~\pageref{proof:prAtEnd\pratendcountercurrent}.}`
500 - `text proof`: text displayed in place of "Proof" in the appendix. Defaults to `{Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}}`
501 - `restate command`: name of a unique macro (without backslash) that will be defined as an alias to restate the theorem wherever you want
502 - `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
503 - `both`/`no both`: only for `\textInAppendix`, specifies that the text must be present in both the main text and the appendix.
504 - `external appendix`: to ensure the appendix can be included in another file (see details above), starting from version 2022/02/04.
505
506 Here are all the alias/styles (you can create you own as well), they are practical to quickly define a behaviours, but are made of the basic options listed above:
507
508 - `normal`: like a 'normal' theorem, without any proof in the appendix, and with a proof displayed in the main text. Shortcut for `proof here, no all end, no proof end, no link to proof, no restate, no both`.
509 - `end`: theorems whose proof need to go in the appendix. Shorcut for `proof at the end, link to proof`.
510 - `all end`: makes sure both the theorem and the proof are in appendix. Alias of `end, opt all end`.
511 - `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`.
512 - `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.
513 - `no link to theorem`: Remove the link from the proof to the theorem, alias of `text proof={\proofname}`
514 - `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}}}`
515 - `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}.}`
516 - `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.}`.
517 - `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`.
518 - `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.}`
519 - `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.}`
520 - `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}.}`
521 - `default text proof`: default text for the proof in appendix, equivalent of `text proof={Proof of \string\pratendRef{thm:prAtEnd\pratendcountercurrent}}`
522 - `text proof only theorem`: equivalent of `text proof={\string\pratendRef{thm:prAtEnd\pratendcountercurrent}}`, helpful if the class uses a custom proof environment that would write `Proof (Proof of Lemma X)` instead of `Proof of Lemma X.`: adding this style turns it into `Proof (Lemma X)`. See more details in the troubleshooting section.
523 - `text proof translated`: like `default text proof`, but takes one argument and use it instead of `Proof of`. Example: `text proof translated={Preuve du}`
524 - `text link external appendix`: style used to configure the text to display when the appendix is in an external file. Defaults to `text link={The proof is in the appendix.}`.
525 - `external appendix`: useful when the the proofs are moved in an external file (read more above). In particular, it will ensure that normal theorems are used instead of restate since restate does not work across files. This will also apply `text link external appendix` to change the text accordingly.
526 - `only external appendix`: like `external appendix`, but without changing the text.
527 - `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`.
528 - `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
529 - `global custom defaults`: empty style that you can overwrite to change the global defaults
530 - `local custom defaults`: empty style that you can overwrite to change the "local" defaults, like category
531 - `all defaults`: all the defaults, equivalent of `bare defaults, configuration options, global custom defaults, local custom defaults`
532
533 ## Package options
534
535 The package comes with multiple options:
536 - The `conf={CONFIGURATION}` option is used to configure the default style. Usage: `\usepackage[conf={normal, text link section}]{proof-at-the-end}`
537 - 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).
538 - `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`.
539 - `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.
540
541 ## Troubleshooting
542
543 Here are some common issues you may have, with explainations to solve them.
544
545 ### The link after the proof does not mention the section, but something else (an equation, a figure, etc.)
546
547 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).
548
549 ### I get an error `ERROR: File ended while scanning use of \@xverbatim.` when using verbatim inside a theorem
550
551 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.
552
553 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:
554
555
556 ```latex
557 %% Create the box
558 \newsavebox{\myEndBox}
559
560 \begin{lrbox}{\myEndBox}
561 \begin{minipage}{1.0\linewidth}
562 \begin{verbatim}
563 \newEndThm[normal]{thmE}{thm}
564 \newEndProof{proofE}{proof}
565 \end{verbatim}
566 \end{minipage}
567 \end{lrbox}
568
569 %% Create a theorem:
570 \begin{thmE}
571 Insert the box:
572
573 \begin{center}
574 \usebox{\myEndBox}
575 \end{center}
576 \end{thmE}
577 ```
578
579 ### The proof writes `Proof (Proof of Lemma X)` (or something else) instead of `Proof of Lemma X.`
580
581 If the proof starts with something different from `Proof of Lemma X`, you are likely to use a class/package that defines a `proof` environment different from the one defined in `amsthm`, like `svjour3` by Springer. To fix this, you have two options: if you want to keep using the original `proof` environment, and get something like `Proof (Lemma X)`, you can either configure:
582
583 ```
584 \pratendSetGlobal{
585 text proof={\string\pratendRef{thm:prAtEnd\pratendcountercurrent}},
586 }
587 ```
588
589 or, if you use a version greater than 2025/06/11 (included), you can simply call the `text proof only theorem`, either like in `\pratendSetGlobal{text proof only theorem}` or directly when loading the package:
590 ```
591 \usepackage[createShortEnv, conf={text proof only theorem}]{proof-at-the-end}
592 ```
593
594 Another option is to replace your class `proof` environment with, for instance, the one provided by `amsthm` like in:
595 ```
596 % Removes the environment 'proof' defined by the class and replaces it with the one of amsthm:
597 \let\proof\undefined
598 \let\endproof\undefined
599 \usepackage{amsthm}
600 ```
601 but ensure that `amsthm` does not produce additional conflicts. This method will write `Proof of Lemma X.` before starting the proof.
602
603 ## Changelog
604
605 - 2026/01/12: Fix a bug that was not allowing stuff like `\cite[foo]{bar}` in theorem titles by introducing an extra group around the title
606 - 2025/06/11: Add `text proof only theorem`
607 - 2022/02/07:
608 1. [issue 2](https://github.com/leo-colisson/proof-at-the-end/issues/2) was not really solved in fact... Now, I use a more robust method to detect the current section: I write in an AUX file the label of the proof section. This way, I don't need anymore to use dirty tricks to recover the section label.
609 2. Change the default text when the appendix is in an external file, and add options like `text link external appendix` to customize the text appearing when the appendix is in an external file. Of course, you can still change it using `text link` directly.
610 - 2022/02/04:
611 1. Add a way to put theorems in different files. (see `external appendix`)
612 2. Change the path for auxiliary files (should be transparent for the user)
613 3. Add commands to change local/global configuration easily (see `\pratendSetLocal`,`\pratendSetGlobal`)
614 - 2022/02/01:
615 1. Fix a typo when defining the shortcut for lemma
616 2. Add a shortcut for proposition
617 3. Fix a small spacing issue in the text before the proof in Appendix
618 - 2022/01/28:
619 1. Fix the issue when using sharps in a proof https://github.com/leo-colisson/proof-at-the-end/issues/7.
620 2. Provide `\newEndThm`, `\newEndProof` and the option `createShortEnv` to quickly create environments.
621 - 2022/01/27:
622 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`.
623 2. Add an option `commandRef` to use other ref libraries, like `cleveref` instead of `autoref`.
624 3. Normal restatable theorem do not need to be restated. Fix [issue 8](https://github.com/leo-colisson/proof-at-the-end/issues/8).
625
626 ## Contributions ##
627
628 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) !
629
630 NB: the documentation is generated from the Markdown file `README.md` thanks to pandoc. These commands may help you:
631 ```bash
632 %% Compile the demo
633 make demo
634 %% Clean the project
635 make clean
636 %% Generate the documentation
637 make doc
638 %% Generate a package for CTAN
639 make package
640 ```