summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/proof-at-the-end
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-02-07 21:40:18 +0000
committerKarl Berry <karl@freefriends.org>2022-02-07 21:40:18 +0000
commita4c5c9826e217b374234a296a1c0c7fcfe91ef93 (patch)
tree36fa9fde52d3c3824e011caefb19770610a32ca6 /Master/texmf-dist/tex/latex/proof-at-the-end
parent088ca7f8f3fc260fc202e63151a4cd1d61db4046 (diff)
proof-at-the-end (7feb22)
git-svn-id: svn://tug.org/texlive/trunk@61933 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/proof-at-the-end')
-rw-r--r--Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty105
1 files changed, 92 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty b/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty
index 0a8180406d2..7e6015b4188 100644
--- a/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty
+++ b/Master/texmf-dist/tex/latex/proof-at-the-end/proof-at-the-end.sty
@@ -39,7 +39,7 @@
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{proof-at-the-end}[2022/02/01 A package to move proofs in appendix]
+\ProvidesPackage{proof-at-the-end}[2022/02/07 A package to move proofs in appendix]
\RequirePackage{etoolbox}
\RequirePackage{thmtools}
@@ -107,10 +107,15 @@
\endgroup
}
+%% Get the prefix of the file, given the jobname.
+\NewDocumentCommand\pratendGeneratePrefixFile{m}{#1-pratend}
+
+\def\prefixPrAtEndFiles{\pratendGeneratePrefixFile{\jobname}}
+
%% This functions takes one input: the category (without .tex),
%% If it's the first time we write in this
%% category file, it "blanks" it.
-\def\prefixPrAtEndFiles{pratend}
+
\newcommand*\eraseIfNeeded[1]{%
% A macro 'pratendmacrocat{category}' is created to check
% if it's the first time we write in this category file.
@@ -127,6 +132,7 @@
\newif\ifproofhere
\newif\ifproofend
\newif\ifrestatethm
+\newif\ifexternalAppendix% True if the output file should me inputable in another file (using xr for crossref). Useful to remote restate.
\newif\iflinktoproof
\newif\ifboth
\newif\ifallattheend
@@ -145,6 +151,15 @@
proof end/.is if=proofend,
no proof end/.style={proof end=false},
%% Restate the theorem when using \printProofs
+ only external appendix/.is if=externalAppendix,
+ text link external appendix/.style={
+ text link={The proof is in the appendix.}
+ },
+ external appendix/.style={
+ only external appendix,
+ text link external appendix,
+ },
+ %% Restate the theorem when using \printProofs
restate/.is if=restatethm,
no restate/.style={restate=false},
%% Put a link to the proof after the theorem
@@ -326,9 +341,13 @@
%% 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*}%
+ \ifproofend%
+ \ifrestatethm%
+ \ifexternalAppendix% We write the full theorem, useful to compile in a separate file (use xr for references)
+ \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\begingroup\string\renewcommand\string\the\detokenize{#2}{\string\ref{thm:prAtEnd\pratendcountercurrent}}\string\begin{\detokenize{#2}}[#3]\detokenize{#4}\string\end{\detokenize{#2}}\string\endgroup}%
+ \else%
+ \appendtofile{\prefixPrAtEndFiles\category.tex}{\string\prAtEndRestate\pratendcountercurrent*}%
+ \fi%
\fi%
\fi%
\fi%
@@ -366,13 +385,41 @@
\fi%
%% Write the proof at the end
\ifproofend%
+ \appendtofile{\prefixPrAtEndFiles\category.tex}{%
%% 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@SaveLastskip and \Hy@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@SaveLastskip\string\pratendChangeCurrentLabel\string\label{proofsection:prAtEnd\pratendcountercurrent}\string\Hy@RestoreLastskip\string\makeatother\string\begin{proof}[\pratendtextproof]\string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}\detokenize{#2}\string\end{proof}}%
+ \string\makeatletter\string\Hy@SaveLastskip%
+ %% This tries to recover the label of the current section... But it is very bad. I keep it only for backward compatibility. I tried to fix it by changing the value of \@counter, but it's not always working
+ %% as cref is not using it apparently, and it turns Appendix A into appendix a after using phantomsection.
+ %% https://github.com/leo-colisson/proof-at-the-end/issues/2
+ \string\label{proofsection:prAtEnd\pratendcountercurrent}% WARNING <-- do not use this label in new documents!
+ % the problem is that setting the \@currentlabel does not work for cref, and turns Appendix A
+ % into section A when a phantomsection lies in between (not sure why):
+ % https://github.com/leo-colisson/proof-at-the-end/issues/2
+ %% Now, we prefer a different method: instead we generate a single label per section, and we generate
+ %% a new macro in the aux file that will save this label, by creating one such macro per theorem.
+ %% This is basically doing something like \pratend@section@for@proofiii{prAtEnd:sectionlike3}
+ %% Note that I need sometimes 3 \string because I write two times: the first time I write in the FILE-pratendCATEGORY.tex
+ %% file, and this file will be in charge of writting into the .aux file.
+ \string\ifdefined\string\pratend@current@sectionlike@label% But before, we check if the section was defined, or the code may fail if no section are defined.
+ \string\immediate\string\write\string\@auxout{%
+ \string\string\string\gdef\string\string\string\pratend@section@for@proof\pratendcountercurrent{\string\pratend@current@sectionlike@label}%
+ }%
+ \string\fi
+ % See above
+ \string\Hy@RestoreLastskip\string\makeatother%
+ % We start the proof
+ \string\begin{proof}[\pratendtextproof]%
+ % We add a label to have a reference to the section
+ \string\phantomsection\string\label{proof:prAtEnd\pratendcountercurrent}%
+ % We add the proof
+ \detokenize{#2}%
+ % We end the proof
+ \string\end{proof}}%
\fi%
}{}
@@ -414,17 +461,21 @@
%% First, we get the label
%% Cool explaination of expandafter, edef, noexpand:
%%% https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf
+ %% The label \pratend@current@sectionlike@label is used later.
\edef\pratend@current@sectionlike@label{prAtEnd:sectionlike\thepratend@counter@sectionlike}%
\expandafter\label{\pratend@current@sectionlike@label}%
- \let\pratend@sectionlike@stored@label\@currentlabel%
+ \stepcounter{pratend@counter@sectionlike}%
}%
-\NewDocumentCommand\pratendSectionlikeCref{}{%
- \pratendRef{proofsection:prAtEnd\pratendcountercurrent}%
-}
-\NewDocumentCommand\pratendChangeCurrentLabel{}{%
- \ifdefined\pratend@sectionlike@stored@label%
- \let\@currentlabel\pratend@sectionlike@stored@label%
+%% Returns the label of the section (in appendix) that contains the proof of the current theorem.
+%% The first time, it will return an empty label.
+\NewDocumentCommand\pratendLabelProofSection{}{%
+ \ifcsname pratend@section@for@proof\pratendcountercurrent\endcsname%
+ \csname pratend@section@for@proof\pratendcountercurrent\endcsname%
\fi%
+}%
+\NewDocumentCommand\pratendSectionlikeCref{}{%
+ % \pratendRef{proofsection:prAtEnd\pratendcountercurrent}% This is not robust enough. Lets change strategy.
+ \expandafter\pratendRef{\pratendLabelProofSection}
}
\ifpratendOptdisablePatchSection%
\else %
@@ -493,8 +544,36 @@
\newEndThm{theoremE}{theorem}
\newEndThm{corollaryE}{corollary}
\newEndThm{propositionE}{proposition}
+ \newEndThm{propertyE}{proposition}
+ \newEndThm{factE}{proposition}
\fi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create functions to easily overwrite defaults
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\NewDocumentCommand\pratendSetGlobal{m}{%
+ \pgfkeys{/prAtEnd/global custom defaults/.style={
+ #1
+ }%
+ }%
+}
+
+\NewDocumentCommand\pratendSetLocal{m}{%
+ \pgfkeys{/prAtEnd/local custom defaults/.style={
+ #1
+ }%
+ }%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Create functions to load the category file in another file (external bibliography)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\NewDocumentCommand\includeExternalAppendix{O{defaultcategory}m}{%
+ \expandafter\input{\pratendGeneratePrefixFile{#2}#1}
+}
+
\endinput
%%
%% End of file `proof-at-the-end.sty'.