From c0e4705c6360fb42045b8826f7b0b810ee4be134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 9 Jan 2022 21:45:25 +0100 Subject: [PATCH] fix refproof bugs: correct restoring of counter values and claim style numberings in stacked proofs --- src/wip/refproof.pysty | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/wip/refproof.pysty b/src/wip/refproof.pysty index 1db7bdd..f7e20ce 100644 --- a/src/wip/refproof.pysty +++ b/src/wip/refproof.pysty @@ -12,6 +12,7 @@ __END_OPTIONS_X__ \RequirePackage{xparse} \RequirePackage{refcount} \RequirePackage{translator} +\RequirePackage{fifo-stack} \usedictionary{translator-proof-dictionary} @@ -32,12 +33,12 @@ __END_OPTIONS_X__ \newcounter{__PACKAGE_PREFIX__proofdepth} \setcounter{__PACKAGE_PREFIX__proofdepth}{0} -\newcounter{__PACKAGE_PREFIX__save@claim} -\setcounter{__PACKAGE_PREFIX__save@claim}{0} \let__PACKAGE_MACRO__(saved@proof)\proof \let__PACKAGE_MACRO__(saved@endproof)\endproof +\FSCreate{__PACKAGE_PREFIX__save@claim}{-1} + %%subproof environment - essentially copied proof environment from amsthm and modified its name + symbol \DeclareRobustCommand{\blackqed}{% \ifmmode \mathqed @@ -78,8 +79,9 @@ __END_OPTIONS_X__ { \stepcounter{__PACKAGE_PREFIX__proofdepth} %Save the current claim counter - \setcounter{__PACKAGE_PREFIX__save@claim}{\value{claim}} - % Restore correct counter for claim + \protected@edef__PACKAGE_MACRO__(dummy@expand){\arabic{claim}} + \FSPush{__PACKAGE_PREFIX__save@claim}{__PACKAGE_MACRO__(dummy@expand)} + % Restore correct counter for claims in this refproof \ifcsdef{the__PACKAGE_PREFIX__#2@save@claim}{ \setcounter{claim}{\value{__PACKAGE_PREFIX__#2@save@claim}} \def__PACKAGE_MACRO__(proofprefix){ @@ -101,6 +103,7 @@ __END_OPTIONS_X__ } } % Set up counter number printing as subindexed by numbering of the reference + \let__PACKAGE_MACRO__(saved@theclaim)\theclaim \def\theclaim{\getrefnumber{#2}.\arabic{claim}} % Now, start the actual proof __PACKAGE_MACRO__(saved@proof)[% @@ -113,8 +116,10 @@ __END_OPTIONS_X__ % Save current claim counter for later restoration \setcounter{__PACKAGE_PREFIX__#2@save@claim}{\value{claim}} %Restore previous claim counter - \setcounter{claim}{\value{__PACKAGE_PREFIX__save@claim}} + \setcounter{claim}{\FSTop{__PACKAGE_PREFIX__save@claim}} + \FSPop{__PACKAGE_PREFIX__save@claim} \addtocounter{__PACKAGE_PREFIX__proofdepth}{-1} + \let\theclaim__PACKAGE_MACRO__(saved@theclaim) } \def\proofdepth{Depth:~\the__PACKAGE_PREFIX__proofdepth} @@ -125,7 +130,8 @@ __END_OPTIONS_X__ { \stepcounter{__PACKAGE_PREFIX__proofdepth} %Save the current claim counter - \setcounter{__PACKAGE_PREFIX__save@claim}{\value{claim}} + \protected@edef__PACKAGE_MACRO__(dummy@expand){\arabic{claim}} + \FSPush{__PACKAGE_PREFIX__save@claim}{__PACKAGE_MACRO__(dummy@expand)} \setcounter{claim}{0} \def\theclaim{\arabic{claim}} \ifnum\value{__PACKAGE_PREFIX__proofdepth}>1% @@ -151,8 +157,8 @@ __END_OPTIONS_X__ { __PACKAGE_MACRO__(saved@endproof) %Restore previous claim counter - \setcounter{claim}{\value{__PACKAGE_PREFIX__save@claim}} - \addtocounter{__PACKAGE_PREFIX__proofdepth}{-1} + \setcounter{claim}{\FSTop{__PACKAGE_PREFIX__save@claim}} + \FSPop{__PACKAGE_PREFIX__save@claim} } }