Debian Codegraph @

texmf-dist/doc/latex/proof-at-the-end/proof-at-the-end_demo.tex

raw
1 \documentclass{article}
2
3 \usepackage{amssymb, amsthm, amsmath}
4 \usepackage{xparse}
5 \usepackage{verbatim}
6
7
8 % Load the package (put the proof-at-the-end.sty file in the working directory)
9 % with default options and shortcuts for thmE/... WARNING: this requires a version above 2022/01/28.
10
11 \usepackage[createShortEnv]{proof-at-the-end}
12
13 % If you use cref, use instead:
14 % \usepackage[createShortEnv,commandRef=Cref]{proof-at-the-end}
15 % You can change the default options in the 'conf' option:
16 %\usepackage[createShortEnv, conf={text link section}]{proof-at-the-end}
17 %\usepackage[createShortEnv, conf={normal, one big link}]{proof-at-the-end}
18 %\usepackage[createShortEnv, conf={normal, one big link=Goto proof}]{proof-at-the-end}
19 %\usepackage[createShortEnv, conf={one big link translated=Aller à la preuve page}]{proof-at-the-end}
20
21 %%% If you want to use options with macros, you cannot
22 % use directly the package options, so just modify
23 % the global custom defaults like that:
24 % \pgfkeys{/prAtEnd/global custom defaults/.style={
25 % text link={\hyperref[proof:prAtEnd\pratendcountercurrent]{See proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent}}}
26 % }
27 % }
28 %%% You can also easily modify the global/locals defaults in other parts of the code using:
29 % \pgfkeys{/prAtEnd/local custom defaults/.style={
30 % category=greattheorem
31 % }
32 % }
33 %%% Or create new styles to apply:
34 % \pgfkeys{/prAtEnd/great category/.style={
35 % category=greattheorem
36 % }
37 % }
38
39 %% If you want you can define shortcuts to create new theorem.
40 %% Since 2022/01/28, the option createShortEnv automatically defines
41 %% shortcuts for thmE, theoremE, lemmaE...
42 %% You can define new shortcuts using something like:
43 %% \newEndThm[normal]{thmE}{thm}
44 %% This is itself a shortcut for the rather length old way to define new theorem shorcuts, namely:
45 % And to define new shortcuts, in order to avoid typing:
46 % \NewDocumentEnvironment{thmE}{O{}O{}+b}{%
47 % \begin{theoremEnd}[normal,#2]{thm}[#1]%
48 % #3%
49 % \end{theoremEnd}%
50 % }{}
51
52 % Last loaded package (except cleveref that must be loaded even later)
53 \usepackage{hyperref}
54
55 %% Define your theorem/lemma/... environments the way you want (must be called after hyperref https://tex.stackexchange.com/q/757925/116348):
56 % Theorems
57 \newtheorem{thm}{Theorem}[section]
58 \newtheorem*{thm*}{Theorem}
59 \providecommand*\thmautorefname{Theorem}
60 \renewcommand\theHthm{\thesection .\arabic {thm}} % Needed until https://github.com/muzimuzhi/thmtools/issues/70 is fixed or use \hypersetup{hypertexnames=false}
61 % Lemmata
62 \newtheorem{lemma}[thm]{Lemma}
63 \newtheorem*{lemma*}{Lemma}
64 \providecommand*\lemmaautorefname{Lemma}
65 \renewcommand\theHlemma{\thesection .\arabic {lemma}} % Needed until https://github.com/muzimuzhi/thmtools/issues/70 is fixed or use \hypersetup{hypertexnames=false}
66 \begin{document}
67
68 \section{Demo of proof-at-the-end}
69
70 NB: This file is just a demo of proof-at-the-end. You can find the documentation, sources, and example of proof-at-the-end at \url{https://github.com/leo-colisson/proof-at-the-end}. Note that this file is getting a bit big but it should contain more or less everything that is possible in this lib as it's also used to ``test'' the library.
71
72 % And use \theoremProofEnd[<package options>]{theorem environment name}[Title]{Theorem}{Optional proof}
73 \begin{theoremEnd}{thm}[Yes I can have a title]
74 \label{thm:ilikelabels}
75 Simplicity is luxury, I am a default theorem.
76 \end{theoremEnd}
77 \begin{proofEnd}
78 Let's be simple.
79 \end{proofEnd}
80
81 And I can refer to my theorems using classic labels, like in \autoref{thm:ilikelabels}.
82
83 \begin{theoremEnd}[text link section]{thm}[Changing link]
84 It is possible to change the link.
85 \end{theoremEnd}
86 \begin{proofEnd}
87 Here I'm using ``text link section''.
88 \end{proofEnd}
89
90 \begin{theoremEnd}[category=greattheorem, end]{thm}[Different categories]
91 You can also create several categories, and put the proofs in different sections.
92 \[2\Delta = \Delta + \Delta\]
93 \end{theoremEnd}
94 \begin{proofEnd}
95 See, I am in another section! And I refer to \autoref{thm:ilikelabels} even in the proof.
96 \end{proofEnd}
97
98 \begin{theoremEnd}[restate]{thm}[I am restatable]
99 I am a restatable theorem, go in Appendix you will see ;-)
100 \end{theoremEnd}
101 \begin{proofEnd}
102 I am a proof of a restatable theorem.
103 \end{proofEnd}
104
105
106 \begin{theoremEnd}[normal]{thm}
107 You can easily turn it back into a normal theorem!
108 \end{theoremEnd}
109 \begin{proofEnd}
110 And keep the proof with you!
111 \end{proofEnd}
112
113 \begin{theoremEnd}[normal,restate]{thm}[I am restatable but normal]
114 See, if you are both normal and restatable, then no need to restate the theorem at the end!
115 \end{theoremEnd}
116 \begin{proofEnd}
117 I am a proof of a restatable but normal theorem.
118 \end{proofEnd}
119
120 You can also put comments that appear only in the appendix.
121
122 \textEnd{See, I am a simple comments with math $\delta = b^2-ac$ and references \autoref{thm:mytheoremattheend}.}
123
124 \begin{textAtEnd}
125 You can also use the environment syntax.
126 \end{textAtEnd}
127
128 \textEnd[both]{Or that appears in both and with references \autoref{thm:mytheoremattheend}!}
129
130 \begin{theoremEnd}[proof here]{thm}
131 And you can duplicate the proof, here AND in appendix ;)
132 \end{theoremEnd}
133 \begin{proofEnd}
134 I am a proof that is everywhere, practical if you want to use synctex while you write the proof ;)
135 \end{proofEnd}
136
137 \begin{theoremEnd}{lemma}
138 You can mix it with lemmas... Or any other theorem-like environment easily!
139 \end{theoremEnd}
140 \begin{proofEnd}
141 See, I'm the proof of a lemma!
142 \end{proofEnd}
143
144 And also you can put both the theorem and the proof at the end, like for \autoref{thm:mytheoremattheend}!
145
146
147 \begin{theoremEnd}[all end]{thm}
148 \label{thm:mytheoremattheend}
149 $\delta = b^2-4ac$
150 You can also put theorems only at the end.
151 \end{theoremEnd}
152 \begin{proofEnd}
153 See, I'm the proof of a lemma that is only at the end!
154 \end{proofEnd}
155
156
157 You can also remove the link to the theorem:
158 \begin{theoremEnd}[no link to theorem, restate]{thm}
159 I don't like links in proofs.
160 \end{theoremEnd}
161 \begin{proofEnd}
162 Yes, I like being lost, but not too lost, so I prefer to restate as well!
163 \end{proofEnd}
164
165 Or keep the link, but remove the reference (practical for stared versions):
166 \begin{theoremEnd}[stared]{thm*}
167 I don't like numbers.
168 \end{theoremEnd}
169 \begin{proofEnd}
170 Yes, I hate numbers, but I like links.
171 \end{proofEnd}
172
173
174 \pgfkeys{/prAtEnd/french/.style={
175 one big link translated={Voir preuve page},
176 text proof translated={Preuve du}
177 }
178 }
179 \begin{theoremEnd}[french]{thm}%% See how "french" is defined just above
180 Change the text/languages of the link: Il est même possible de changer la langue du texte du lien!
181 \end{theoremEnd}
182 \begin{proofEnd}
183 Si c'est pas beau ;)
184 \end{proofEnd}
185
186 And of course it is easy to define custom shortcuts, using in prelude:
187 \begin{verbatim}
188 \NewDocumentEnvironment{frenchthm}{O{}+b}{%
189 \begin{theoremEnd}[french]{thm}[#1]%
190 #2%
191 \end{theoremEnd}%
192 }{}
193 \end{verbatim}
194
195 \newsavebox{\myEndBox}
196
197 \begin{lrbox}{\myEndBox}
198 \begin{minipage}{1.0\linewidth}
199 \begin{verbatim}
200 \newEndThm[normal]{thmE}{thm}
201 \newEndProof{proofE}
202 \end{verbatim}
203 \end{minipage}
204 \end{lrbox}
205
206 \newsavebox{\myEndBoxB}
207
208 \begin{lrbox}{\myEndBoxB}
209 \begin{minipage}{1.0\linewidth}
210 \begin{verbatim}
211 \begin{thmE}[Title][optional options]
212 Theorem
213 \end{thmE}
214 \begin{proofE}
215 Your proof
216 \end{proofE}
217 \end{verbatim}
218 \end{minipage}
219 \end{lrbox}
220
221 \begin{thmE}[My own environment][normal]
222 You can then create a wrapper to avoid typing the full theoremEnd environment, and to add custom options by using:
223
224 \begin{center}
225 \usebox{\myEndBox}
226 \end{center}
227
228 \noindent (see that we need to use \texttt{\textbackslash textt} or \texttt{lrbox} to typeset verbatim inside theorem)
229
230 Then, you can simply use:
231 \end{thmE}
232 \begin{proofEnd}
233 That's quicker :D
234 \end{proofEnd}
235
236 \begin{thmE}[My own environment][end]
237 You can use options also with your custom environments.
238 \end{thmE}
239 \begin{proofEnd}
240 That's quicker with the proof at the end :D
241 \end{proofEnd}
242
243 \begin{thmE}[][end]
244 And you can remove the title and have options.
245 \end{thmE}
246 \begin{proofE}
247 Just leave empty title.
248 \end{proofE}
249
250 \begin{thmE}[My second own environment][all end]
251 My normal theorem is moved at the end!
252 \end{thmE}
253 \begin{proofE}
254 Custom environments are practical no ;)
255 \end{proofE}
256
257 \begin{theoremEnd}[]{thm}[Yes I can have no proof]
258 Proof is useless. You can do do it. And see, I can include other environments inside me ;)\\
259 \begin{tabular}{ c c }
260 A & B \\
261 C & D \\
262 \end{tabular}
263 \end{theoremEnd}
264
265 \begin{theoremEnd}[restate command=mymanualrestate]{thm}[Manual restate]
266 A theorem can be manually restated
267 \end{theoremEnd}
268 \begin{proofEnd}
269 Use restate command for that! (see \autoref{sec:manualrestate} for an example)
270 \end{proofEnd}
271
272 \begin{theoremEnd}[see full proof]{thm}
273 I can also write a sketch of proof, and put the full proof in appendix.
274 \end{theoremEnd}
275 \begin{proof}
276 Hint: look at the alias options.
277 \end{proof}
278 \begin{proofEnd}
279 You just use ``see full proof'' as an option
280 \end{proofEnd}
281
282 It should also deal with protected commands: $\mathtt{mathtt}$:
283 \begin{theoremEnd}[end]{thm}[Title $\Delta$ et $\mathtt{Gad}$]
284 You can use commands that should be protected $\mathtt{See}$!
285 \end{theoremEnd}
286
287 \begin{theoremEnd}[end]{thm}[Deal with paragraphs]
288 You can have a theorem
289
290 with several paragraphs.
291 \end{theoremEnd}
292 \begin{proofEnd}
293 And I also like to have big proofs.
294
295 With several paragraphs.
296 \end{proofEnd}
297
298 \section{Section with restate before theorem}\label{sec:restatebefore}
299
300 \begin{theoremEndRestateBefore}{thm}[Title]{laterrestatable}
301 \label{thm:laterrestatable}
302 This theorem has been introduced in \autoref{sec:restatebefore} before the real definition, but the real definition is in \autoref{sec:restateafter}, more precisely here: \autoref{thm:laterrestatable}.
303 \end{theoremEndRestateBefore}
304
305 \begin{theoremEnd}{thm}
306 And this is a normal theorem
307 \end{theoremEnd}
308 \begin{proofEnd}
309 With a normal proof
310 \end{proofEnd}
311
312 \section{Section with late theorems}\label{sec:restateafter}
313 \begin{theoremEnd}[restated before]{thm}
314 laterrestatable
315 \end{theoremEnd}
316 \begin{proofEnd}
317 To state a theorem before the initial definition, use theoremEndRestateBefore environment where you first want to state the theorem, with a unique name in the second mandatory argument, and when you want to insert the theorem for the second time, use the usual theoremProofEnd command with the same unique name as before in place of the theorem definition and the ``restated before'' option.
318 \end{proofEnd}
319
320 \pratendEnableDebugSynctex{}
321
322 \begin{thmE}[My own environment][end]
323 This proof
324
325 should go
326
327 in appendix.
328
329 But to make synctex work
330
331 we can force the environments
332
333 to behave like normal theorems or proofs
334
335 using \texttt{pratendEnableDebugSynctex} and \texttt{pratendDisableDebugSynctex} around the theorem.
336
337 You can try now (note that restate is not compatible with this mode as the restate library is not working with synctex due to a quite \href{https://tex.stackexchange.com/questions/643294/synctex-make-it-work-with-environment-accessing-its-content-e-g-environ-or-xp}{fundamental limitation of LaTeX}).
338 \end{thmE}
339 \begin{proofED}
340 See
341
342 how this
343
344 long proof works
345
346 with synctex now. And solves \href{https://github.com/leo-colisson/proof-at-the-end/issues/10}{Issue 10}.
347 \end{proofED}
348
349
350 \pratendDisableDebugSynctex{}
351
352 You can also use shortcuts like:
353
354 \begin{thmED}[My own environment][end]
355 Here
356
357 Is
358
359 An
360
361 example to test synctex.
362 \end{thmED}
363 \begin{proofEndDebug}
364 See
365
366 how this
367
368 long proof works
369
370 with synctex now.
371 \end{proofEndDebug}
372
373
374 \section{Section with standard proofs}
375 % \verbatiminput{defaultcategory}
376 \printProofs
377
378 \section{Section with important proofs only}
379 \printProofs[greattheorem]
380
381 \section{Section with manual restate}\label{sec:manualrestate}
382
383 I like to manually restate theorems:
384 \mymanualrestate*
385
386
387 \end{document}
388
389 %%% Local Variables:
390 %%% mode: latex
391 %%% TeX-master: t
392 %%% End: