latex-packages/wip/mkessler-proof.sty

92 lines
3.5 KiB
Text
Raw Normal View History

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mkessler-proof}
2021-09-12 12:36:12 +02:00
%%%% This package will be developed for proofs with automatic references to theorems
% for claims numbered within these profos
% and for nice subproof / proof of claim environments
\newif\ifmkessler@proof@english\mkessler@proof@englishtrue
\DeclareOption{german}{\mkessler@proof@englishfalse}
\DeclareOption*{\PackageWarning{mkessler-proof}{Unknown '\CurrentOption'}}
\ProcessOptions\relax
2021-09-12 19:59:25 +02:00
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
2021-09-12 12:36:12 +02:00
%%Give claim an own counter and let it reset at each proof
%See also at:
%https://tex.stackexchange.com/questions/283502/reset-counter-at-beginning-of-proof
\newtheorem{claim}{\ifmkessler@proof@english Claim\else Behauptung\fi}
\newtheorem*{claim*}{\ifmkessler@proof@english Claim\else Behauptung\fi}
\AtBeginDocument{\def\claimautorefname{\ifmkessler@proof@english Claim\else Behauptung\fi}}
2021-09-12 12:36:12 +02:00
\newif\ifhyperref
\AtBeginDocument{
\@ifpackageloaded{hyperref}{
\hyperreftrue
\def\grab#1{\expandafter\@firstoffive#1}
\def\mkessler@proof@blankref#1{\expandafter\grab\csname r@#1\endcsname}
\let\mkessler@proof@autoref\autoref
}{
\hyperreffalse
\let\mkessler@proof@blankref\ref
\let\mkessler@proof@autoref\ref
}
2021-09-12 12:36:12 +02:00
}
2021-09-17 19:35:12 +02:00
\NewDocumentEnvironment{rproof}{m O{}}{\def\mkessler@proof@aster{\relax}\begin{mkessler@fancythm@rproof@impl}{#1}[#2]}{\end{mkessler@fancythm@rproof@impl}}
\NewDocumentEnvironment{rproof*}{m O{}}{\def\mkessler@proof@aster{*}\begin{mkessler@fancythm@rproof@impl}{#1}[#2]}{\end{mkessler@fancythm@rproof@impl}}
2021-09-12 19:59:25 +02:00
2021-09-17 19:35:12 +02:00
\NewDocumentEnvironment{mkessler@fancythm@rproof@impl}{m O{}}
2021-09-12 12:36:12 +02:00
{
% Restore correct counter for claim
\ifcsdef{themkessler@proof@#1@save@claim}{
\setcounter{claim}{\value{mkessler@proof@#1@save@claim}}
2021-09-12 19:59:25 +02:00
\def\mkessler@proof@proofprefix{\ifmkessler@proof@english Continuation of proof\mkessler@proof@aster\space of\else Fortsetzung des Beweises\mkessler@proof@aster\space zu\fi}
\edef\haha{\value{mkessler@proof@#1@part}}
}{
\newcounter{mkessler@proof@#1@save@claim}
\setcounter{claim}{0}
2021-09-12 19:59:25 +02:00
\def\mkessler@proof@proofprefix{\ifmkessler@proof@english Proof\mkessler@proof@aster\space of\else Beweis\mkessler@proof@aster\space von\fi}
}
% Set up counter number printing as subindexed by numbering of the reference
\let\mkessler@proof@theoldclaim\theclaim
\def\theclaim{\mkessler@proof@blankref{#1}.\mkessler@proof@theoldclaim}
% Now, start the actual proof
2021-09-12 19:59:25 +02:00
\begin{proof}[\mkessler@proof@proofprefix\space\mkessler@proof@autoref{#1}\if\relax\detokenize{#2}\relax\else\space(#2)\fi]
2021-09-12 12:36:12 +02:00
}
{
\end{proof} % End proof
% Save current claim counter for later restoration
\setcounter{mkessler@proof@#1@save@claim}{\value{claim}}
2021-09-12 12:36:12 +02:00
}
%%subproof environment - essentially copied proof environment from amsthm and modified its name + symbol
\DeclareRobustCommand{\blackqed}{%
\ifmmode \mathqed
\else
\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
\quad\hbox{$\blacksquare$}%
\fi
}
\newenvironment{subproof}[1][\ifmkessler@proof@english Subproof\else Unterbeweis\fi]{\par
2021-09-12 12:36:12 +02:00
\pushQED{\blackqed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\itshape
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
%%%% This might be dropped, but for now is collected here
%%Solution (for exercises)
\newenvironment{solution}[1][]{\begin{proof}[\ifmkessler@proof@english{}Solution\else{}Lösung\fi{}#1]}{\end{proof}}