rework proof package: refproof and proof environments functional
This commit is contained in:
parent
14c4939841
commit
c592a7f8ac
2 changed files with 55 additions and 30 deletions
|
@ -1,6 +1,7 @@
|
|||
__HEADER__(Automatic references to theorems in proofs. Claim counters within proofs)
|
||||
|
||||
\RequirePackage{xkeyval}
|
||||
\RequirePackage{refcount}
|
||||
|
||||
__LANGUAGE_OPTIONS_X__
|
||||
|
||||
|
@ -22,52 +23,59 @@ __NEW_IF__(hyperref,false)
|
|||
\AtBeginDocument{
|
||||
\@ifpackageloaded{hyperref}{
|
||||
__SET_IF__(hyperref,true)
|
||||
\def\grab#1{\expandafter\@firstoffive#1}
|
||||
\def__PACKAGE_MACRO__(blankref)#1{\expandafter\grab\csname r@#1\endcsname}
|
||||
\let__PACKAGE_MACRO__(autoref)\autoref
|
||||
}{
|
||||
__SET_IF__(hyperref,true)
|
||||
\let__PACKAGE_MACRO__(blankref)\ref
|
||||
\let__PACKAGE_MACRO__(autoref)\ref
|
||||
}
|
||||
}
|
||||
|
||||
\NewDocumentEnvironment{rproof}{m O{}}{\def__PACKAGE_MACRO__(aster){\relax}\begin{__PACKAGE_PREFIX__rproof@impl}{#1}[#2]}{\end{__PACKAGE_PREFIX__rproof@impl}}
|
||||
\NewDocumentEnvironment{rproof*}{m O{}}{\def__PACKAGE_MACRO__(aster){*}\begin{__PACKAGE_PREFIX__rproof@impl}{#1}[#2]}{\end{__PACKAGE_PREFIX__rproof@impl}}
|
||||
\let__PACKAGE_MACRO__(saved@proof)\proof
|
||||
\let__PACKAGE_MACRO__(saved@endproof)\endproof
|
||||
|
||||
\NewDocumentEnvironment{__PACKAGE_PREFIX__rproof@impl}{m O{}}
|
||||
\NewDocumentEnvironment{refproof}{s m o}
|
||||
{
|
||||
% Restore correct counter for claim
|
||||
\ifcsdef{the__PACKAGE_PREFIX__#1@save@claim}{
|
||||
\setcounter{claim}{\value{__PACKAGE_PREFIX__#1@save@claim}}
|
||||
\def__PACKAGE_MACRO__(proofprefix){__IF__(english) Continuation of proof__PACKAGE_MACRO__(aster)\space of\else Fortsetzung des Beweises__PACKAGE_MACRO__(aster)\space zu\fi}
|
||||
\edef\haha{\value{__PACKAGE_PREFIX__#1@part}}
|
||||
\ifcsdef{the__PACKAGE_PREFIX__#2@save@claim}{
|
||||
\setcounter{claim}{\value{__PACKAGE_PREFIX__#2@save@claim}}
|
||||
\def__PACKAGE_MACRO__(proofprefix){__IF__(english) Continuation of proof\IfBooleanT{#1}{*}\space of\else Fortsetzung des Beweises\IfBooleanT{#1}{*}\space zu\fi}
|
||||
}{
|
||||
\newcounter{__PACKAGE_PREFIX__#1@save@claim}
|
||||
\newcounter{__PACKAGE_PREFIX__#2@save@claim}
|
||||
\setcounter{claim}{0}
|
||||
\def__PACKAGE_MACRO__(proofprefix){__IF__(english) Proof__PACKAGE_MACRO__(aster)\space of\else Beweis__PACKAGE_MACRO__(aster)\space von\fi}
|
||||
\def__PACKAGE_MACRO__(proofprefix){__IF__(english) Proof\ifBooleanT{#1}{*}\space of\else Beweis\IfBooleanT{#1}{*}\space von\fi}
|
||||
}
|
||||
% Set up counter number printing as subindexed by numbering of the reference
|
||||
\let__PACKAGE_MACRO__(theoldclaim)\theclaim
|
||||
\def\theclaim{__PACKAGE_MACRO__(blankref){#1}.__PACKAGE_MACRO__(theoldclaim)}
|
||||
\def\theclaim{\getrefnumber{#2}.__PACKAGE_MACRO__(theoldclaim)}
|
||||
% Now, start the actual proof
|
||||
\begin{proof}[__PACKAGE_MACRO__(proofprefix)\space__PACKAGE_MACRO__(autoref){#1}\if\relax\detokenize{#2}\relax\else\space(#2)\fi]
|
||||
__PACKAGE_MACRO__(saved@proof)[__PACKAGE_MACRO__(proofprefix)\space__PACKAGE_MACRO__(autoref){#2}\IfValueT{#3}{\space(#3)}]
|
||||
}
|
||||
{
|
||||
\end{proof} % End proof
|
||||
__PACKAGE_MACRO__(saved@endproof) % End proof
|
||||
% Save current claim counter for later restoration
|
||||
\setcounter{__PACKAGE_PREFIX__#1@save@claim}{\value{claim}}
|
||||
\setcounter{__PACKAGE_PREFIX__#2@save@claim}{\value{claim}}
|
||||
}
|
||||
|
||||
% Proof (with asterisk)
|
||||
\NewDocumentEnvironment{proof*}{O{}}
|
||||
{
|
||||
\if\relax\detokenize{#1}\relax\begin{proof}[__IF__(english) Proof\emph{*}\else Beweis\emph{*}\fi]\else\begin{proof}[#1\emph{*}]\fi
|
||||
\AtBeginDocument{
|
||||
\RenewDocumentEnvironment{proof}{s o}
|
||||
{
|
||||
\IfNoValueTF{#2}{
|
||||
__PACKAGE_MACRO__(saved@proof)[
|
||||
__IF__(english)
|
||||
Proof\IfBooleanT{#1}{\emph{*}}
|
||||
\else
|
||||
Beweis\IfBooleanT{#1}{\emph{*}}
|
||||
\fi
|
||||
]
|
||||
}{
|
||||
__PACKAGE_MACRO__(saved@proof)[__IF__(english) Proof\else Beweis\fi\IfBooleanT{#1}{\emph{*}}\space(#2)]
|
||||
}
|
||||
}
|
||||
{
|
||||
__PACKAGE_MACRO__(saved@endproof)
|
||||
}
|
||||
}
|
||||
{
|
||||
\end{proof}
|
||||
}
|
||||
|
||||
|
||||
%%subproof environment - essentially copied proof environment from amsthm and modified its name + symbol
|
||||
\DeclareRobustCommand{\blackqed}{%
|
||||
|
|
|
@ -12,18 +12,18 @@
|
|||
Man sollte nach Würzburg fahren.
|
||||
\end{theorem}
|
||||
|
||||
\begin{rproof}{thm:krass}
|
||||
\begin{refproof}*{thm:krass}[hi]
|
||||
\begin{claim}\label{cl:qed}
|
||||
Der QED ist toll.
|
||||
\end{claim}
|
||||
Um \autoref{cl:qed} zu beweisen, brauchen wir zunächst ein Lemma.
|
||||
\end{rproof}
|
||||
\end{refproof}
|
||||
|
||||
\begin{lemma}\label{lm:krass}
|
||||
Mathevereine sind krass.
|
||||
\end{lemma}
|
||||
|
||||
\begin{rproof}{lm:krass}
|
||||
\begin{refproof}{lm:krass}[quasi ein Fakt]
|
||||
\begin{claim}
|
||||
Mathe ist cool.
|
||||
\end{claim}
|
||||
|
@ -31,11 +31,11 @@
|
|||
trivial.
|
||||
\end{subproof}
|
||||
Damit folgt nun das Lemma.
|
||||
\end{rproof}
|
||||
\end{refproof}
|
||||
|
||||
Nun kommen wir wieder zurück zum eigentlichen Beweis:
|
||||
|
||||
\begin{rproof}{thm:krass}
|
||||
\begin{refproof}{thm:krass}[hi]
|
||||
\begin{claim}\label{cl:würzburg}
|
||||
Der QED macht ein Seminar in Würzburg
|
||||
\end{claim}
|
||||
|
@ -43,6 +43,23 @@ Nun kommen wir wieder zurück zum eigentlichen Beweis:
|
|||
Zu prüfen in der DB. Fakt!
|
||||
\end{subproof}
|
||||
Aus \autoref{cl:qed} und \autoref{cl:würzburg} folgt nun die Aussage.
|
||||
\end{rproof}
|
||||
test
|
||||
\end{refproof}
|
||||
|
||||
a
|
||||
\begin{proof}
|
||||
first
|
||||
\end{proof}
|
||||
a
|
||||
\begin{proof}[anm]
|
||||
second
|
||||
\end{proof}
|
||||
a
|
||||
\begin{proof}*
|
||||
third
|
||||
\end{proof}
|
||||
a
|
||||
\begin{proof}*[anm]
|
||||
fourth
|
||||
\end{proof}
|
||||
|
||||
\end{document}
|
||||
|
|
Loading…
Reference in a new issue