summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/proof-at-the-end/proof-at-the-end_demo.tex
blob: 5ecc5d2c3b9b6d1219ddbe4ca427bf226a0e8dcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
\documentclass{article}

\usepackage{amssymb, amsthm, amsmath}
\usepackage{xparse}
\usepackage{verbatim}

% Load the package (put the proof-at-the-end.sty file in the working directory)
% with default options and shortcuts for thmE/... WARNING: this requires a version above 2022/01/28.
\usepackage[createShortEnv]{proof-at-the-end}
% If you use cref, use instead:
% \usepackage[createShortEnv,commandRef=Cref]{proof-at-the-end}
% You can change the default options in the 'conf' option:
%\usepackage[createShortEnv, conf={text link section}]{proof-at-the-end}
%\usepackage[createShortEnv, conf={normal, one big link}]{proof-at-the-end}
%\usepackage[createShortEnv, conf={normal, one big link=Goto proof}]{proof-at-the-end}
%\usepackage[createShortEnv, conf={one big link translated=Aller à la preuve page}]{proof-at-the-end}

%%% If you want to use options with macros, you cannot
% use directly the package options, so just modify
% the global custom defaults like that:
% \pgfkeys{/prAtEnd/global custom defaults/.style={
%     text link={\hyperref[proof:prAtEnd\pratendcountercurrent]{See proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent}}}
%   }
% }
%%% You can also easily modify the global/locals defaults in other parts of the code using:
% \pgfkeys{/prAtEnd/local custom defaults/.style={
%     category=greattheorem
%   }
% }
%%% Or create new styles to apply:
% \pgfkeys{/prAtEnd/great category/.style={
%     category=greattheorem
%   }
% }

%% Define your theorem/lemma/... environments the way you want:
% Theorems
\newtheorem{thm}{Theorem}[section]
\newtheorem*{thm*}{Theorem}
\providecommand*\thmautorefname{Theorem}
% Lemmata
\newtheorem{lemma}[thm]{Lemma}
\newtheorem*{lemma*}{Lemma}
\providecommand*\lemmaautorefname{Lemma}

%% If you want you can define shortcuts to create new theorem.
%% Since 2022/01/28, the option createShortEnv automatically defines
%% shortcuts for thmE, theoremE, lemmaE...
%% You can define new shortcuts using something like:
%% \newEndThm[normal]{thmE}{thm}
%% This is itself a shortcut for the rather length old way to define new theorem shorcuts, namely:
% And to define new shortcuts, in order to avoid typing:
% \NewDocumentEnvironment{thmE}{O{}O{}+b}{%
%   \begin{theoremEnd}[normal,#2]{thm}[#1]%
%     #3%
%   \end{theoremEnd}%
% }{}

\usepackage{hyperref}
\begin{document}

\section{Demo of proof-at-the-end}

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.

% And use \theoremProofEnd[<package options>]{theorem environment name}[Title]{Theorem}{Optional proof}
\begin{theoremEnd}{thm}[Yes I can have a title]
  \label{thm:ilikelabels}
  Simplicity is luxury, I am a default theorem.
\end{theoremEnd}
\begin{proofEnd}
  Let's be simple.  
\end{proofEnd}

And I can refer to my theorems using classic labels, like in \autoref{thm:ilikelabels}.

\begin{theoremEnd}[text link section]{thm}[Changing link]
  It is possible to change the link.
\end{theoremEnd}
\begin{proofEnd}
  Here I'm using ``text link section''.
\end{proofEnd}

\begin{theoremEnd}[category=greattheorem, end]{thm}[Different categories]
  You can also create several categories, and put the proofs in different sections.
  \[2\Delta = \Delta + \Delta\]
\end{theoremEnd}
\begin{proofEnd}
  See, I am in another section! And I refer to \autoref{thm:ilikelabels} even in the proof.
\end{proofEnd}

\begin{theoremEnd}[restate]{thm}[I am restatable]
  I am a restatable theorem, go in Appendix you will see ;-)
\end{theoremEnd}
\begin{proofEnd}
  I am a proof of a restatable theorem.  
\end{proofEnd}


\begin{theoremEnd}[normal]{thm}
  You can easily turn it back into a normal theorem!
\end{theoremEnd}
\begin{proofEnd}
  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}.}

\begin{textAtEnd}
  You can also use the environment syntax.
\end{textAtEnd}

\textEnd[both]{Or that appears in both and with references \autoref{thm:mytheoremattheend}!}

\begin{theoremEnd}[proof here]{thm}
  And you can duplicate the proof, here AND in appendix ;)  
\end{theoremEnd}
\begin{proofEnd}
  I am a proof that is everywhere, practical if you want to use synctex while you write the proof ;)
\end{proofEnd}

\begin{theoremEnd}{lemma}
  You can mix it with lemmas... Or any other theorem-like environment easily!  
\end{theoremEnd}
\begin{proofEnd}
  See, I'm the proof of a lemma!  
\end{proofEnd}

And also you can put both the theorem and the proof at the end, like for \autoref{thm:mytheoremattheend}!


\begin{theoremEnd}[all end]{thm}
  \label{thm:mytheoremattheend}
  $\delta = b^2-4ac$
  You can also put theorems only at the end.  
\end{theoremEnd}
\begin{proofEnd}
  See, I'm the proof of a lemma that is only at the end!
\end{proofEnd}


You can also remove the link to the theorem:
\begin{theoremEnd}[no link to theorem, restate]{thm}
  I don't like links in proofs.  
\end{theoremEnd}
\begin{proofEnd}
  Yes, I like being lost, but not too lost, so I prefer to restate as well!
\end{proofEnd}

Or keep the link, but remove the reference (practical for stared versions):
\begin{theoremEnd}[stared]{thm*}
  I don't like numbers.
\end{theoremEnd}
\begin{proofEnd}
  Yes, I hate numbers, but I like links.
\end{proofEnd}


\pgfkeys{/prAtEnd/french/.style={
    one big link translated={Voir preuve page},
    text proof translated={Preuve du}
  }
}
\begin{theoremEnd}[french]{thm}%% See how "french" is defined just above
  Change the text/languages of the link: Il est même possible de changer la langue du texte du lien!  
\end{theoremEnd}
\begin{proofEnd}
  Si c'est pas beau ;)
\end{proofEnd}

And of course it is easy to define custom shortcuts, using in prelude:
\begin{verbatim}
\NewDocumentEnvironment{frenchthm}{O{}+b}{%
  \begin{theoremEnd}[french]{thm}[#1]%
    #2%
  \end{theoremEnd}%
}{}
\end{verbatim}

\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{thmE}[My own environment][end]
  You can use options also with your custom environments.
\end{thmE}
\begin{proofEnd}
  That's quicker with the proof at the end :D
\end{proofEnd}

\begin{thmE}[][end]
  And you can remove the title and have options.
\end{thmE}
\begin{proofE}
  Just leave empty title.
\end{proofE}

\begin{thmE}[My second own environment][all end]
  My normal theorem is moved at the end!
\end{thmE}
\begin{proofE}
  Custom environments are practical no ;)
\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 ;)\\
  \begin{tabular}{ c c } 
    A & B \\ 
    C & D \\ 
  \end{tabular}
\end{theoremEnd}

\begin{theoremEnd}[restate command=mymanualrestate]{thm}[Manual restate]
  A theorem can be manually restated  
\end{theoremEnd}
\begin{proofEnd}
  Use restate command for that! (see \autoref{sec:manualrestate} for an example)
\end{proofEnd}

\begin{theoremEnd}[see full proof]{thm}
  I can also write a sketch of proof, and put the full proof in appendix.
\end{theoremEnd}
\begin{proof}
  Hint: look at the alias options.
\end{proof}
\begin{proofEnd}
  You just use ``see full proof'' as an option
\end{proofEnd}

It should also deal with protected commands: $\mathtt{mathtt}$:
\begin{theoremEnd}[end]{thm}[Title $\Delta$ et $\mathtt{Gad}$]
  You can use commands that should be protected $\mathtt{See}$!
\end{theoremEnd}

\begin{theoremEnd}[end]{thm}[Deal with paragraphs]
  You can have a theorem

  with several paragraphs.
\end{theoremEnd}
\begin{proofEnd}
  And I also like to have big proofs.
  
  With several paragraphs.
\end{proofEnd}

\section{Section with restate before theorem}\label{sec:restatebefore}

\begin{theoremEndRestateBefore}{thm}[Title]{laterrestatable}
  \label{thm:laterrestatable}
  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}.
\end{theoremEndRestateBefore}


\begin{theoremEnd}{thm}
  And this is a normal theorem  
\end{theoremEnd}
\begin{proofEnd}
  With a normal proof  
\end{proofEnd}

\section{Section with late theorems}\label{sec:restateafter}
\begin{theoremEnd}[restated before]{thm}
  laterrestatable
\end{theoremEnd}
\begin{proofEnd}
  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.  
\end{proofEnd}

\pratendEnableDebugSynctex{}

\begin{thmE}[My own environment][end]
  This proof

  should go

  in appendix.

  But to make synctex work

  we can force the environments

  to behave like normal theorems or proofs

  using \texttt{pratendEnableDebugSynctex} and \texttt{pratendDisableDebugSynctex} around the theorem.

  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}).
\end{thmE}
\begin{proofED}
  See

  how this

  long proof works

  with synctex now. And solve \href{https://github.com/leo-colisson/proof-at-the-end/issues/10}{Issue 10}.
\end{proofED}


\pratendDisableDebugSynctex{}

You can also use shortcuts like:

\begin{thmED}[My own environment][end]
  Here

  Is

  An

  example to test synctex.
\end{thmED}
\begin{proofEndDebug}
  See

  how this

  long proof works

  with synctex now.
\end{proofEndDebug}


\section{Section with standard proofs}
% \verbatiminput{defaultcategory}
\printProofs

\section{Section with important proofs only}
\printProofs[greattheorem]

\section{Section with manual restate}\label{sec:manualrestate}

I like to manually restate theorems:
\mymanualrestate*


\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: