muzimuzhi / thmtools

New home for LaTeX package bundle thmtools
LaTeX Project Public License v1.3c
18 stars 3 forks source link

Handle beamer's \qedsymbol #17

Open muzimuzhi opened 4 years ago

muzimuzhi commented 4 years ago

beamer has

\def\qedsymbol{\leavevmode\hbox{\usebeamertemplate*{qed symbol}}}

This makes

\declaretheoremstyle[qed=\qedsymbol]{my style}

fail because currently thmtools does https://github.com/muzimuzhi/thmtools/blob/16b11550988fb5d24907572ad17081b7805f8173/source/thm-amsthm.dtx#L140-L151

See TeX-SX question https://tex.stackexchange.com/q/565808.

muzimuzhi commented 4 years ago

qed=<value> will redefine \qedsymbol to <value>. To allow input qed=\qedsymbol and avoid self-reference, currently thmtools uses \protected@edef\qedsymbol{<value>}. This makes strong assumption on not only the definition of \qedsymbol, but also the whole <value>.

A possible fix: always use mirrored \thmqedsymbol in qed=<value>

diff --git a/source/thm-amsthm.dtx b/source/thm-amsthm.dtx
index b45a6c2..3d6c081 100644
--- a/source/thm-amsthm.dtx
+++ b/source/thm-amsthm.dtx
@@ -137,14 +137,19 @@
 %  }
 }

+\@ifl@t@r\fmtversion{2020/10/01}
+  {\def\thmt@let{\DeclareCommandCopy}}
+  {\def\thmt@let{\let}}
+
 \define@key{thmdef}{qed}[\qedsymbol]{%
+  \thmt@let\thmqedsymbol\qedsymbol
   \thmt@trytwice{}{%
     \addtotheorempostheadhook[\thmt@envname]{%
-      \protected@edef\qedsymbol{#1}%
+      \def\qedsymbol{#1}%
       \pushQED{\qed}%
     }%
     \addtotheoremprefoothook[\thmt@envname]{%
-      \protected@edef\qedsymbol{#1}%
+      \def\qedsymbol{#1}%
       \popQED
     }%
   }%