texlive[56068] Master/texmf-dist: thmtools

commits+karl at tug.org commits+karl at tug.org
Sat Aug 8 00:18:43 CEST 2020


Revision: 56068
          http://tug.org/svn/texlive?view=revision&revision=56068
Author:   karl
Date:     2020-08-08 00:18:43 +0200 (Sat, 08 Aug 2020)
Log Message:
-----------
thmtools

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/thmtools/README.md
    trunk/Master/texmf-dist/doc/latex/thmtools/VERSION.tex
    trunk/Master/texmf-dist/doc/latex/thmtools/changes.txt
    trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.pdf
    trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.tex
    trunk/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx
    trunk/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx
    trunk/Master/texmf-dist/source/latex/thmtools/thm-llncs.dtx
    trunk/Master/texmf-dist/source/latex/thmtools/thmdef-mdframed.dtx
    trunk/Master/texmf-dist/source/latex/thmtools/unique.dtx
    trunk/Master/texmf-dist/tex/latex/thmtools/aliasctr.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/parseargs.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-amsthm.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-autoref.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-beamer.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-kv.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-listof.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-llncs.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-ntheorem.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-patch.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thm-restate.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-mdframed.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-shaded.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-thmbox.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/thmtools.sty
    trunk/Master/texmf-dist/tex/latex/thmtools/unique.sty

Modified: trunk/Master/texmf-dist/doc/latex/thmtools/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/thmtools/README.md	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/doc/latex/thmtools/README.md	2020-08-07 22:18:43 UTC (rev 56068)
@@ -12,6 +12,6 @@
 
 License: LPPL 1.3c
 
-Currently the package is maintained by Yukai Chou, <span>muzimuzhi at gmail.com</span>
+Currently the package is maintained by Yukai Chou, muzimuzhi at gmail<span></span>.com
 
-Previous Maintainer was Ulrich M. Schwarz, <span>ulmi at absatzen.de</span>
+Previous Maintainer was Ulrich M. Schwarz, ulmi at absatzen<span></span>.de

Modified: trunk/Master/texmf-dist/doc/latex/thmtools/VERSION.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/thmtools/VERSION.tex	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/doc/latex/thmtools/VERSION.tex	2020-08-07 22:18:43 UTC (rev 56068)
@@ -1 +1 @@
-\def\VERSION{2020/07/16 v69}
+\def\VERSION{2020/08/01 v0.72}

Modified: trunk/Master/texmf-dist/doc/latex/thmtools/changes.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/thmtools/changes.txt	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/doc/latex/thmtools/changes.txt	2020-08-07 22:18:43 UTC (rev 56068)
@@ -2,11 +2,40 @@
 
 	* thm-kv.dtx:
 	removed dependency on etexcmds package
-	
-2020-07-16 Yukai Chou <muzimuzhi at gmail.com>
 
+2020-07-16  Yukai Chou <muzimuzhi at gmail.com>
+
   * thm-restate.dtx:
   made compatible with cleveref's \label[]{} syntax
-  
+
   * thmtools-manual.tex (and comment part of dtx files):
   refined manual
+
+  * general:
+  updated license and maintenance status
+
+2020-07-24  Yukai Chou <muzimuzhi at gmail.com>
+  
+  * thm-kv.dtx:
+  made \declaretheorem[<option list>]{<thmname>} accept a clist in <thmname>, #2
+  made \declarethemrem accept an extra optional arg
+  made "numbered=unless unique" compatible with and aware of "numberwithin=<counter>", #3 & #4
+
+  * unique.dtx:
+  adjusted indent
+
+2020-07-29  Yukai Chou <muzimuzhi at gmail.com>
+
+  * thm-list.dtx:
+  provided new option "swapnumber" for \listoftheorems, #5
+
+  * thm-kv.dtx:
+  fixed wrong default value of option "numbered"
+
+2020-08-01  Yukai Chou <muzimuzhi at gmail.com>
+
+  * thm-list.dtx:
+  made \listoftheorems compatible with ams classes, #6
+  
+  * thmtools-manual.tex:
+  documented new changes and keys of \listoftheorems

Modified: trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.tex	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/doc/latex/thmtools/thmtools-manual.tex	2020-08-07 22:18:43 UTC (rev 56068)
@@ -28,17 +28,17 @@
 
 \usepackage{amsmath, amsthm}
 \usepackage{enumitem}
-\setlist[description, 1]{labelindent=2em, leftmargin=2em, rightmargin=2em, labelwidth=!}
+  \setlist[description, 1]{labelindent=2em, leftmargin=2em, rightmargin=2em, labelwidth=!}
 \usepackage{tikz}
-\usetikzlibrary{tikzmark}
+  \usetikzlibrary{tikzmark}
 
 \usepackage{nameref}
 \usepackage{hyperref}
-\hypersetup{
-  colorlinks,
-  linkcolor=RoyalBlue,
-  linktocpage
-}
+  \hypersetup{
+    colorlinks,
+    linkcolor=RoyalBlue,
+    linktoc=all
+  }
 \usepackage{cleveref}[2010/05/01]
 
 \usepackage{thmtools, thm-restate}
@@ -58,6 +58,10 @@
   \paragraph*{\texttt{#2}}
 }
 
+\newcommand\change[2]{%
+  (\textbf{#1: \textsf{#2}})%
+}
+
 \lstloadlanguages{[LaTeX]TeX}
 \lstset{language=[LaTeX]TeX,basicstyle=\small\ttfamily,keywordstyle=\mdseries,aboveskip=0pt}
 
@@ -77,8 +81,10 @@
 }
 \newenvironment{result}{%
   \hfill\minipage[t]{0.37\linewidth}
+  \vspace{1pt}%
 }{%
   \endminipage\strut\par
+  \vspace{3pt}%
 }
 %\MakeShortVerb{\|}
 \lstMakeShortInline{|}
@@ -119,7 +125,37 @@
 \declaretheorem[name=Theorem, refname={theorem,theorems},
     Refname={Theorem,Theorems}]{callmeal}
 
+% make the full toc entry clickable while only the page number part is colored
+% based on my own TeX-SX answer https://tex.stackexchange.com/a/555695
+\usepackage{xpatch}
 
+\makeatletter
+
+\xpatchcmd\contentsline
+  {%
+    \csname l@#1\endcsname{%
+      \hyper at linkstart{link}{\Hy at tocdestname}{#2}\hyper at linkend
+    }{%
+      \hyper at linkstart{link}{\Hy at tocdestname}{#3}\hyper at linkend
+    }%
+  }
+  {%
+    \csname l@#1\endcsname{%
+      \begingroup
+        \def\@linkcolor{black}%
+        \hyper at linkstart{link}{\Hy at tocdestname}{#2}\hyper at linkend
+      \endgroup
+    }{%
+      \hyper at linkstart{link}{\Hy at tocdestname}{#3}\hyper at linkend
+    }%
+  }
+  {}{\fail}
+
+% set default input path
+\def\input at path{{../source/}}
+\makeatother
+
+
 \input{VERSION.tex}
 
 \title{\Thmtools Users' Guide}
@@ -258,7 +294,7 @@
   \end{result}
   
   To save you from having to look up the name of the key every time, you can
-  also use ``title='' and ``heading='' instead of ``name=''; they do exactly
+  also use |title=| and |heading=| instead of |name=|; they do exactly
   the same and hopefully one of these will be easy to remember for you.
 
   Of course, you do not have to follow the abominal practice of numbering
@@ -347,7 +383,20 @@
       Buck \& Britta
     \end{couple}
   \end{result}
-
+  
+  \change{New}{2020/08/01} Actually, the mandatory argument of |\declaretheorem| accepts a list of environment names, so you can define similar theorems at once. Moreover, similar to |\setmainfont| from \pkg{fontspec} package, the key-value interface can be used both before and after the mandatory argument.
+  \begin{source}
+  \begin{preamble}[gobble=4]
+    \declaretheorem[numberwithin=section]
+      {theorem, definition}
+    \declaretheorem{lemma, proposition, corollary}[
+      style=plain, 
+      numberwithin=theorem
+    ]
+  \end{preamble}
+  \end{source}
+  
+  \clearpage
   \section{Frilly references}
 
   In case you didn't know, you should: \pkg{hyperref}, \pkg{nameref} and
@@ -366,8 +415,6 @@
     \begin{preamble}[gobble=6]
       \usepackage{amsthm, thmtools}
       \usepackage{
-        % nameref,%\nameref
-        % n.b. usually nameref is autoloaded by hyperref
         hyperref,%\autoref
         % n.b. \Autoref is defined by thmtools
         cleveref,% \cref
@@ -426,13 +473,15 @@
   \end{source}
   \begin{result}
     \begin{Theorem}
-      This is a theorem.
+      Note how it still retains the default style, 
+      `plain'.
     \end{Theorem}
     \begin{remark}
-      Note how it still retains the default style, `plain'.
+      This is a remark.
     \end{remark}
   \end{result}
   
+  \newpage
   Thmtools also supports the \pkg{shadethm} and \pkg{thmbox} packages:
   \begin{source}
   \begin{preamble}[gobble=4]
@@ -470,8 +519,8 @@
   name of a color that is already defined, without curly braces, or it can
   start with a curly brace, in which case it is assumed that
   |\definecolor{colorname}|$\langle$\textsl{what you said}$\rangle$ will be
-  valid \LaTeX\ code. In our case, we use the rbg model to manually specify
-  white. (|shadethm|'s default value is {\fboxsep=0pt \fcolorbox{black}[gray]{0.92}{\phantom{XX}}} |[gray]{0.92}|)
+  valid \LaTeX\ code. In our case, we use the |rgb| model to manually specify
+  white. (|shadethm|'s default background color is {\fboxsep=0pt \fcolorbox{black}[gray]{0.92}{\phantom{XX}}} |[gray]{0.92}|)
   
   For the \pkg{thmbox} package, use the |thmbox| key:
   \begin{source}
@@ -717,6 +766,7 @@
   \end{result}
 
   As might be expected, the heading given is defined in |\listtheoremname|.
+  %And finally, you can configure |\listoftheorems| in advance by |\setlisttheoremstyle{keys}|.
 
   \section{Extended arguments to theorem environments}
   
@@ -837,11 +887,11 @@
   
   \DocInput{thmdef-shaded.dtx}
 
-  \section{Case in point: the thmbox key}
+  \section{Case in point: the \texttt{thmbox} key}
 
   \DocInput{thmdef-thmbox.dtx}
 
-  \section{Case in point: the mdframed key}
+  \section{Case in point: the \texttt{mdframed} key}
   \DocInput{thmdef-mdframed.dtx}
   
   \section{How \thmtools\ finds your extensions}
@@ -983,16 +1033,15 @@
     this if your title starts with an accented character, for example.
 
   \key{name}
-    (Same as title.)
+    (Same as |title|.)
 
   \key{heading}
-    (Same as title.)
+    (Same as |title|.)
   
   \key{numbered}
     Value: one of the keywords |yes|, |no| or |unless unique|. The theorem
     will be numbered, not numbered, or only numbered if it occurs more than
-    once in the document. (The latter requires another \LaTeX\ run and will
-    not work well combined with |sibling|.)
+    once in the document. (The latter requires another \LaTeX\ run and works well combined with |sibling|.)
   
   \key{style}
     Value: the name of a style defined with |\declaretheoremstyle| or
@@ -1077,6 +1126,40 @@
   An all-around |listhack| that handles both situations might come in a
   cleaner rewrite of the style system.
 
+  \section{Known keys to \texttt{\textbackslash listoftheorems}}
+  \def\keydefaultcontext{listof}
+  
+  \key{title} Value: title of |\listoftheorems|. Initially |List of Theorems|.
+  
+  \key{ignore} Value: list of theorem environment names. Filter out things by environment names. Default value is list of all defined theorem environments.
+  
+  \key{ignoreall} Ignore every theorem environment. This key is usually followed by keys |show| and |onlynamed|.
+  
+  \key{show} Value: list of theorem environments. Leave theorems that belong to specified list and filter out others. Default value is list of all defined theorem environments.
+  
+  \key{showall} The opposite effect of |ignoreall|.
+  
+  \key{onlynamed} Value: list of theorem environments. Leave things that are given an optional argument and belong to specified list, and filter out others. Default value is list of all defined theorem environments.
+  
+  \key{swapnumber} Value: |true| or |false|. Initially |false| and default value is |true|. No default.
+  \begin{source}
+    \begin{body}[gobble=6]
+      \listoftheorems[ignoreall, onlynamed={lemma}]
+      \listoftheorems[ignoreall, onlynamed={lemma},
+        swapnumber
+      ]
+    \end{body}
+  \end{source}
+  \begin{result}
+    \let\chapter\section
+    \let\clearpage\relax
+    \listoftheorems[ignoreall, onlynamed={lemma}]
+    \vspace{-1ex}
+    \listoftheorems[ignoreall, onlynamed={lemma}, swapnumber]
+  \end{result}
+  
+  \key{numwidth} Value: a length. If |swapnumber=false|, the theorem number is typeset in a box of of width |numwidth|. Initially |1.5pc| for AMS classes and |2.3em| for others.
+
   \section{Restatable -- hints and caveats}
 
   TBD.

Modified: trunk/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx	2020-08-07 22:18:43 UTC (rev 56068)
@@ -210,25 +210,47 @@
 }
 
 \@for\tmp at keyname:=parent,numberwithin,within\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setparent{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{%
+    \thmt at trytwice{%
+      \thmt at setparent{#1}
+      \thmt at setsibling{}%
+    }{}%
+  }%
 }
+\newcommand\thmt at setparent{%
+  \def\thmt at parent
+}
 
 \@for\tmp at keyname:=sibling,numberlike,sharenumber\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setsibling{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{%
+    \thmt at trytwice{%
+      \thmt at setsibling{#1}%
+      \thmt at setparent{}%
+    }{}%
+  }%
 }
+\newcommand\thmt at setsibling{%
+  \def\thmt at sibling
+}
 
 \@for\tmp at keyname:=title,name,heading\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setthmname{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setthmname{#1}}{}}%
 }
+\newcommand\thmt at setthmname{%
+  \def\thmt at thmname
+}
 
 \@for\tmp at keyname:=unnumbered,starred\do{%
-\define at key{thmdef}{\tmp at keyname}[]{\thmt at trytwice{\thmt at isnumberedfalse}{}}%
+  \define at key{thmdef}{\tmp at keyname}[]{\thmt at trytwice{\thmt at isnumberedfalse}{}}%
 }
 
 \def\thmt at YES{yes}
 \def\thmt at NO{no}
 \def\thmt at UNIQUE{unless unique}
-\define at key{thmdef}{numbered}[\thmt at YES]{
+\newif\ifthmt at isnumbered
+\newif\ifthmt at isunlessunique
+
+\define at key{thmdef}{numbered}[yes]{
   \def\thmt at tmp{#1}%
   \thmt at trytwice{%
     \ifx\thmt at tmp\thmt at YES
@@ -237,27 +259,38 @@
       \thmt at isnumberedfalse
     \else\ifx\thmt at tmp\thmt at UNIQUE
       \RequirePackage[unq]{unique}
-      \ifuniq{\thmt at envname}{%
-        \thmt at isnumberedfalse
-      }{%
-        \thmt at isnumberedtrue
-      }%
+      \thmt at isunlessuniquetrue
     \else
       \PackageError{thmtools}{Unknown value `#1' to key numbered}{}%
     \fi\fi\fi
   }{% trytwice: after definition
     \ifx\thmt at tmp\thmt at UNIQUE
-      \addtotheorempreheadhook[\thmt at envname]{\setuniqmark{\thmt at envname}}%
-      \addtotheorempreheadhook[\thmt at envname]{\def\thmt at dummyctrautorefname{\thmt at thmname\@gobble}}
+      \ifx\thmt at parent\@empty
+        \addtotheorempreheadhook[\thmt at envname]{\setuniqmark{\thmt at envname}}%
+      \else
+        \protected at edef\thmt at tmp{%
+          % expand \thmt at envname and \thmt at parent
+          \@nx\addtotheorempreheadhook[\thmt at envname @unique]{\@nx\setuniqmark{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @numbered]{\@nx\setuniqmark{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @unique]{\def\@nx\thmt at dummyctrautorefname{\thmt at thmname\@nx\@gobble}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @numbered]{\def\@nx\thmt at dummyctrautorefname{\thmt at thmname\@nx\@gobble}}%
+        }%
+        \thmt at tmp
+      \fi
+      % \addtotheorempreheadhook[\thmt at envname]{\def\thmt at dummyctrautorefname{\thmt at thmname\@gobble}}%
     \fi
   }%
 }
 
 
-\define at key{thmdef}{preheadhook}{\thmt at trytwice{}{\addtotheorempreheadhook[\thmt at envname]{#1}}}
-\define at key{thmdef}{postheadhook}{\thmt at trytwice{}{\addtotheorempostheadhook[\thmt at envname]{#1}}}
-\define at key{thmdef}{prefoothook}{\thmt at trytwice{}{\addtotheoremprefoothook[\thmt at envname]{#1}}}
-\define at key{thmdef}{postfoothook}{\thmt at trytwice{}{\addtotheorempostfoothook[\thmt at envname]{#1}}}
+\define at key{thmdef}{preheadhook}{%
+  \thmt at trytwice{}{\addtotheorempreheadhook[\thmt at envname]{#1}}}
+\define at key{thmdef}{postheadhook}{%
+  \thmt at trytwice{}{\addtotheorempostheadhook[\thmt at envname]{#1}}}
+\define at key{thmdef}{prefoothook}{%
+  \thmt at trytwice{}{\addtotheoremprefoothook[\thmt at envname]{#1}}}
+\define at key{thmdef}{postfoothook}{%
+  \thmt at trytwice{}{\addtotheorempostfoothook[\thmt at envname]{#1}}}
 
 \define at key{thmdef}{style}{\thmt at trytwice{\thmt at setstyle{#1}}{}}
 
@@ -296,53 +329,117 @@
   }
 \fi
 
-\newif\ifthmt at isnumbered
-\newcommand\thmt at setparent[1]{%
-  \def\thmt at parent{#1}%
-}
-\newcommand\thmt at setsibling{%
-  \def\thmt at sibling
-}
-\newcommand\thmt at setthmname{%
-  \def\thmt at thmname
-}
 
 \thmt at mkextendingkeyhandler{thmdef}{thmdef}{\string\declaretheorem\space key}
 
 \let\thmt at newtheorem\newtheorem
 
+% \declaretheorem[option list 1]{thmname list}[option list 1]
+% #1 = option list 1
+% #2 = thmname list
 \newcommand\declaretheorem[2][]{%
+  % TODO: use \NewDocumentCommand from xparse? 
+  % xparse will be part of latex2e format from latex2e 2020 Oct.
+  \@ifnextchar[%
+    {\declaretheorem at i{#1}{#2}}
+    {\declaretheorem at i{#1}{#2}[]}%
+}
+\@onlypreamble\declaretheorem
+
+% #1 = option list 1
+% #2 = thmname list
+% #3 = option list 2
+\def\declaretheorem at i#1#2[#3]{%
+  \@for\thmt at tmp:=#2\do{%
+    % strip spaces, \KV@@sp at def is defined in keyval.sty
+    \@xa\KV@@sp at def\@xa\thmt at tmp\@xa{\thmt at tmp}%
+    \@xa\declaretheorem at ii\@xa{\thmt at tmp}{#1,#3}%
+  }%
+}
+
+% #1 = single thmname (#1 and #2 are exchanged)
+% #2 = option list
+\def\declaretheorem at ii#1#2{%
   % why was that here?
   %\let\thmt at theoremdefiner\thmt at original@newtheorem
-  \def\thmt at envname{#2}%
-  \thmt at setthmname{\thmt at modifycase #2}%
+  % init options
   \thmt at setparent{}%
   \thmt at setsibling{}%
-  \thmt at isnumberedtrue%
-  \@thmt at firstkeysettrue%
-  \kvsetkeys{thmdef0}{#1}%
-  \kvsetkeys{thmdef}{#1}%
+  \thmt at isnumberedtrue
+  \thmt at isunlessuniquefalse
+  \def\thmt at envname{#1}%
+  \thmt at setthmname{\thmt at modifycase #1}%
+  % use true code in \thmt at trytwice{<true>}{<false>}
+  \@thmt at firstkeysettrue
+  % parse options
+  \kvsetkeys{thmdef0}{#2}% parse option "style" first
+  \kvsetkeys{thmdef}{#2}%
+  % call patched \newtheorem
+  \ifthmt at isunlessunique
+    \ifx\thmt at parent\@empty
+    % define normal "unless unique" thm env
+    \ifuniq{#1}{\thmt at isnumberedfalse}{\thmt at isnumberedtrue}%
+    \declaretheorem at iii{#1}%
+    \else
+      % define special "unless unique" thm env, 
+      % when "numbered=unless unique" and "numberwithin=<counter>" are both used
+      \declaretheorem at iv{#1}%
+      \thmt at isnumberedtrue
+      \declaretheorem at iii{#1 at numbered}%
+      \thmt at isnumberedfalse
+      \declaretheorem at iii{#1 at unique}%
+    \fi
+  \else
+    % define normal thm env
+    \declaretheorem at iii{#1}%
+  \fi
+  % use false code in \thmt at trytwice{<true>}{<false>}
+  \def\thmt at envname{#1}%
+  \@thmt at firstkeysetfalse
+  % uniquely ugly kludge: some keys make only sense afterwards.
+  % and it gets kludgier: again, the default-inherited 
+  % keys need to have a go at it.
+  \kvsetkeys{thmdef0}{#2}%
+  \kvsetkeys{thmdef}{#2}%
+}
+
+% define normal thm env, call \thmt at newtheorem
+\def\declaretheorem at iii#1{%
   \protected at edef\thmt at tmp{%
     \@nx\thmt at newtheorem
-    \ifthmt at isnumbered\else *\fi
-    {#2}%
-    \ifx\thmt at sibling\@empty\else [\thmt at sibling]\fi
-    {\thmt at thmname}%
-    \ifx\thmt at parent\@empty\else [\thmt at parent]\fi
+    \ifthmt at isnumbered
+      {#1}%
+      \ifx\thmt at sibling\@empty\else [\thmt at sibling]\fi
+      {\thmt at thmname}%
+      \ifx\thmt at parent\@empty\else [\thmt at parent]\fi
+    \else
+      *{#1}{\thmt at thmname}%
+    \fi
     \relax% added so we can delimited-read everything later
-    % (recall newtheorem is patched)
-  }%\show\thmt at tmp
+  }%
+  \thmt at debug{Define theorem `#1' by ^^J\meaning\thmt at tmp}%
   \thmt at tmp
-  % uniquely ugly kludge: some keys make only sense
-  % afterwards.
-  % and it gets kludgier: again, the default-inherited
-  % keys need to have a go at it.
-  \@thmt at firstkeysetfalse%
-  \kvsetkeys{thmdef0}{#1}%
-  \kvsetkeys{thmdef}{#1}%
 }
-\@onlypreamble\declaretheorem
 
+% define special thm env
+\def\declaretheorem at iv#1{%
+  \protected at edef\thmt at tmp{%
+    % expand \thmt at envname and \thmt at parent
+    \@nx\newenvironment{#1}{%
+      \@nx\ifuniq{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}{%
+        \def\@nx\thmt at rawenvname{#1 at unique}%
+      }{%
+        \def\@nx\thmt at rawenvname{#1 at numbered}%
+      }%
+      \begin{\@nx\thmt at rawenvname}%
+    }{%
+      \end{\@nx\thmt at rawenvname}%
+    }%
+  }%
+  \thmt at debug{Define special theorem `#1' by ^^J\meaning\thmt at tmp}%
+  \thmt at tmp
+}
+
 \providecommand\thmt at quark{\thmt at quark}
 
 % in-document keyval, i.e. \begin{theorem}[key=val,key=val]
@@ -379,13 +476,14 @@
     \def\thmt at shortoptarg{#1}%
   \fi
 }
-\def\thmt at splitopt#1=#2\thmt at quark{%
-  \def\thmt at tmpkey{#1}%
-  \ifx\thmt at tmpkey\@empty
-    \def\thmt at tmpkey{\thmt at quark}%
-  \fi
-  \@onelevel at sanitize\thmt at tmpkey
-}
+% FIXME: not used?
+% \def\thmt at splitopt#1=#2\thmt at quark{%
+%   \def\thmt at tmpkey{#1}%
+%   \ifx\thmt at tmpkey\@empty
+%     \def\thmt at tmpkey{\thmt at quark}%
+%   \fi
+%   \@onelevel at sanitize\thmt at tmpkey
+% }
 
 \def\thmt at thmuse@families{thm at track@keys}
 

Modified: trunk/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx	2020-08-07 22:18:43 UTC (rev 56068)
@@ -80,7 +80,7 @@
 \newcommand\listoftheorems[1][]{%
   %% much hacking here to pick up the definition from the class
   %% without oodles of conditionals.
-  \bgroup
+  \begingroup
   \setlisttheoremstyle{#1}%
   \let\listfigurename\listtheoremname
   \def\contentsline##1{%
@@ -87,10 +87,9 @@
     \csname thmt at contentsline@##1\endcsname{##1}%
   }%
   \@for\thmt at envname:=\thmt at allenvs\do{%
-  \@xa\protected at edef\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
-    \@nx\@dottedtocline{1}{1.5em}{\@nx\thmt at listnumwidth}%
+    % CHECK: is \cs{l@\thmt at envname} repeatedly defined?
+    \thmtlo at newentry
   }%
-  }%
   \let\thref at starttoc\@starttoc
   \def\@starttoc##1{\thref at starttoc{loe}}%
   % new hack: to allow multiple calls, we defer the opening of the
@@ -108,7 +107,7 @@
   }%
   %\expandafter
   \listoffigures
-  \egroup
+  \endgroup
 }
 
 \newcommand\setlisttheoremstyle[1]{%
@@ -123,25 +122,60 @@
 % FMi 2019-09-31 allow local title
 \define at key{thmt-listof}{title}{\def\listtheoremname{#1}}
 % -- FMi
+\newif\ifthmt at listswap
+\def\thmt at TRUE{true}
+\def\thmt at FALSE{false}
+\define at key{thmt-listof}{swapnumber}[true]{%
+  \def\thmt at tmp{#1}%
+  \ifx\thmt at tmp\thmt at TRUE
+    \thmt at listswaptrue
+  \else\ifx\thmt at tmp\thmt at FALSE
+    \thmt at listswapfalse
+  \else
+    \PackageError{thmtools}{Unknown value `#1' to key swapnumber}{}%
+  \fi\fi
+}
 
-\providecommand\thmt at listnumwidth{2.3em}
+\ifdefined\@tocline
+  % for ams classes (amsart.cls, amsproc.cls, amsbook.cls) which 
+  % don't use \@dottedtocline and don't provide \@dotsep
+  \def\thmtlo at newentry{%
+    \@xa\def\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
+      % similar to \l at figure defined in ams classes
+      \@tocline{0}{3pt plus2pt}{0pt}{\thmt at listnumwidth}{}%
+    }%
+  }
+  \providecommand*\thmt at listnumwidth{1.5pc}
+\else
+  \def\thmtlo at newentry{%
+    \@xa\def\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
+      \@dottedtocline{1}{1.5em}{\thmt at listnumwidth}%
+    }%
+  }
+  \providecommand*\thmt at listnumwidth{2.3em}
+\fi
 
 \providecommand\thmtformatoptarg[1]{ (#1)}
 
 \newcommand\thmt at mklistcmd{%
-  \@xa\protected at edef\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
-    \@nx\@dottedtocline{1}{1.5em}{\@nx\thmt at listnumwidth}%
-  }%
+  \thmtlo at newentry
   \ifthmt at isstarred
     \@xa\def\csname ll@\thmt at envname\endcsname{%
-      \protect\numberline{\protect\let\protect\autodot\protect\@empty}%
+      \protect\ifthmt at listswap
+      \protect\else
+        \protect\numberline{\protect\let\protect\autodot\protect\@empty}%
+      \protect\fi
       \thmt at thmname
       \ifx\@empty\thmt at shortoptarg\else\protect\thmtformatoptarg{\thmt at shortoptarg}\fi
     }%
   \else
     \@xa\def\csname ll@\thmt at envname\endcsname{%
-      \protect\numberline{\csname the\thmt at envname\endcsname}%
-      \thmt at thmname
+      \protect\ifthmt at listswap
+        \thmt at thmname~\csname the\thmt at envname\endcsname
+      \protect\else
+        \protect\numberline{\csname the\thmt at envname\endcsname}%
+        \thmt at thmname
+      \protect\fi
       \ifx\@empty\thmt at shortoptarg\else\protect\thmtformatoptarg{\thmt at shortoptarg}\fi
     }%
   \fi

Modified: trunk/Master/texmf-dist/source/latex/thmtools/thm-llncs.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/thmtools/thm-llncs.dtx	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/source/latex/thmtools/thm-llncs.dtx	2020-08-07 22:18:43 UTC (rev 56068)
@@ -71,7 +71,7 @@
     {\thmt at thmname}%
     \ifthmt at hasparent [\thmt at parent]\fi
     {\thmt at style@headfont}{\thmt at style@bodyfont}%
-  }
+  }%
   \thmt at args
   \thmt at newtheorem@postdefinition
 }

Modified: trunk/Master/texmf-dist/source/latex/thmtools/thmdef-mdframed.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/thmtools/thmdef-mdframed.dtx	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/source/latex/thmtools/thmdef-mdframed.dtx	2020-08-07 22:18:43 UTC (rev 56068)
@@ -24,8 +24,7 @@
   \thmt at trytwice{}{%
     \RequirePackage{mdframed}%
     \RequirePackage{thm-patch}%
-    \addtotheorempreheadhook[\thmt at envname]{%
-      \begin{mdframed}[#1]}%
+    \addtotheorempreheadhook[\thmt at envname]{\begin{mdframed}[#1]}%
     \addtotheorempostfoothook[\thmt at envname]{\end{mdframed}}%
   }%
 }

Modified: trunk/Master/texmf-dist/source/latex/thmtools/unique.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/thmtools/unique.dtx	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/source/latex/thmtools/unique.dtx	2020-08-07 22:18:43 UTC (rev 56068)
@@ -15,7 +15,7 @@
 %<*code>
 %\fi
 %    Two macros are provided: |\setuniqmark| takes a single parameter,
-%    the name, which should be a string of letters. |\ifuniqmark| takes
+%    the name, which should be a string of letters. |\ifuniq| takes
 %    three parameters: a name, a true-part and a false-part. The true
 %    part is executed if and only if there was exactly one call to
 %    |\setuniqmark| with the given name during the previous \LaTeX\ run.
@@ -58,18 +58,19 @@
 %    \begin{macrocode}
 \newcommand\setuniqmark[1]{%
   \expandafter\ifx\csname uniq at now@#1\endcsname\relax
-  \global\@namedef{uniq at now@#1}{\uniq at ONE}%
+    \global\@namedef{uniq at now@#1}{\uniq at ONE}%
   \else
-  \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY\else
-  \immediate\write\uniq at channel{%
-    \string\uniq at setmany{#1}%
-  }%
-  \ifuniq{#1}{%
-    \uniq at warnnotunique{#1}%
-  }{}%
+    \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY
+    \else
+      \immediate\write\uniq at channel{%
+        \string\uniq at setmany{#1}%
+      }%
+      \ifuniq{#1}{%
+        \uniq at warnnotunique{#1}%
+      }{}%
+    \fi
+    \global\@namedef{uniq at now@#1}{\uniq at MANY}%
   \fi
-  \global\@namedef{uniq at now@#1}{\uniq at MANY}%
-  \fi
 }
 %    \end{macrocode}
 %    \end{macro}
@@ -77,19 +78,19 @@
 %    \begin{macro}{\ifuniq}
 %    Companion to |\setuniqmark|: if the uniqmark given in the first
 %    argument was called more than once, execute the second argument,
-%    otherwise execute the first argument. Note than no call to
+%    otherwise execute the third argument. Note that no call to
 %    |\setuniqmark| for a particular uniqmark at all means that this
 %    uniqmark is unique.
 %    
-%    This is a lazy version: we could always say false if we already had two calls
-%    to setuniqmark this run, but we have to rerun for any ifuniq prior
-%    to the first setuniqmark anyway, so why bother?
+%    This is a lazy version: we could always say false if we already had two
+%    calls to |\setuniqmark| this run, but we have to rerun for any |\ifuniq|
+%    prior to the first setuniqmark anyway, so why bother?
 %    \begin{macrocode}
 \newcommand\ifuniq[1]{%
   \expandafter\ifx\csname uniq at last@#1\endcsname\uniq at MANY
-  \expandafter \@secondoftwo
+    \expandafter\@secondoftwo
   \else
-  \expandafter\@firstoftwo
+    \expandafter\@firstoftwo
   \fi
 }
 %    \end{macrocode}
@@ -124,11 +125,11 @@
 %    \begin{macrocode}
 \def\uniq at warnifunique#1{%
   \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY\else
-  \PackageWarningNoLine{uniq}{%
-    `#1' is unique now.\MessageBreak
-    Rerun LaTeX to pick up the change%
-  }%
-  \@uniq at reruntrue
+    \PackageWarningNoLine{uniq}{%
+      `#1' is unique now.\MessageBreak
+      Rerun LaTeX to pick up the change%
+    }%
+    \@uniq at reruntrue
   \fi
 }
 %    \end{macrocode}
@@ -153,10 +154,10 @@
 %    \begin{macrocode}
 \def\uniq at maybesuggestrerun{%
   \if at uniq@rerun
-  \PackageWarningNoLine{uniq}{%
-    Uniquenesses have changed. \MessageBreak
-    Rerun LaTeX to pick up the change%
-  }%
+    \PackageWarningNoLine{uniq}{%
+      Uniquenesses have changed. \MessageBreak
+      Rerun LaTeX to pick up the change%
+    }%
   \fi
 }
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/aliasctr.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/aliasctr.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/aliasctr.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {aliasctr}[2020/07/16 v69]
+\ProvidesPackage {aliasctr}[2020/08/01 v0.72]
 \def\aliasctr at f@llow#1#2\@nil#3{%
   \ifx#1\@elt
   \noexpand #3%

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/parseargs.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/parseargs.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/parseargs.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {parseargs}[2020/07/16 v69]
+\ProvidesPackage {parseargs}[2020/08/01 v0.72]
 
 \newtoks\@parsespec
 \def\parse at endquark{\parse at endquark}

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-amsthm.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-amsthm.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-amsthm.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-amsthm}[2020/07/16 v69]
+\ProvidesPackage {thm-amsthm}[2020/08/01 v0.72]
 \providecommand\thmt at space{ }
 
 \define at key{thmstyle}{spaceabove}{%

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-autoref.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-autoref.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-autoref.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-autoref}[2020/07/16 v69]
+\ProvidesPackage {thm-autoref}[2020/08/01 v0.72]
 
 \RequirePackage{thm-patch, aliasctr, parseargs, keyval}
 

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-beamer.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-beamer.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-beamer.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-beamer}[2020/07/16 v69]
+\ProvidesPackage {thm-beamer}[2020/08/01 v0.72]
 \newif\ifthmt at hasoverlay
 \def\thmt at parsetheoremargs#1{%
   \parse{%

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-kv.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-kv.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-kv.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-kv}[2020/07/16 v69]
+\ProvidesPackage {thm-kv}[2020/08/01 v0.72]
 
 \let\@xa\expandafter
 \let\@nx\noexpand
@@ -208,25 +208,47 @@
 }
 
 \@for\tmp at keyname:=parent,numberwithin,within\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setparent{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{%
+    \thmt at trytwice{%
+      \thmt at setparent{#1}
+      \thmt at setsibling{}%
+    }{}%
+  }%
 }
+\newcommand\thmt at setparent{%
+  \def\thmt at parent
+}
 
 \@for\tmp at keyname:=sibling,numberlike,sharenumber\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setsibling{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{%
+    \thmt at trytwice{%
+      \thmt at setsibling{#1}%
+      \thmt at setparent{}%
+    }{}%
+  }%
 }
+\newcommand\thmt at setsibling{%
+  \def\thmt at sibling
+}
 
 \@for\tmp at keyname:=title,name,heading\do{%
-\define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setthmname{#1}}{}}%
+  \define at key{thmdef}{\tmp at keyname}{\thmt at trytwice{\thmt at setthmname{#1}}{}}%
 }
+\newcommand\thmt at setthmname{%
+  \def\thmt at thmname
+}
 
 \@for\tmp at keyname:=unnumbered,starred\do{%
-\define at key{thmdef}{\tmp at keyname}[]{\thmt at trytwice{\thmt at isnumberedfalse}{}}%
+  \define at key{thmdef}{\tmp at keyname}[]{\thmt at trytwice{\thmt at isnumberedfalse}{}}%
 }
 
 \def\thmt at YES{yes}
 \def\thmt at NO{no}
 \def\thmt at UNIQUE{unless unique}
-\define at key{thmdef}{numbered}[\thmt at YES]{
+\newif\ifthmt at isnumbered
+\newif\ifthmt at isunlessunique
+
+\define at key{thmdef}{numbered}[yes]{
   \def\thmt at tmp{#1}%
   \thmt at trytwice{%
     \ifx\thmt at tmp\thmt at YES
@@ -235,26 +257,37 @@
       \thmt at isnumberedfalse
     \else\ifx\thmt at tmp\thmt at UNIQUE
       \RequirePackage[unq]{unique}
-      \ifuniq{\thmt at envname}{%
-        \thmt at isnumberedfalse
-      }{%
-        \thmt at isnumberedtrue
-      }%
+      \thmt at isunlessuniquetrue
     \else
       \PackageError{thmtools}{Unknown value `#1' to key numbered}{}%
     \fi\fi\fi
   }{% trytwice: after definition
     \ifx\thmt at tmp\thmt at UNIQUE
-      \addtotheorempreheadhook[\thmt at envname]{\setuniqmark{\thmt at envname}}%
-      \addtotheorempreheadhook[\thmt at envname]{\def\thmt at dummyctrautorefname{\thmt at thmname\@gobble}}
+      \ifx\thmt at parent\@empty
+        \addtotheorempreheadhook[\thmt at envname]{\setuniqmark{\thmt at envname}}%
+      \else
+        \protected at edef\thmt at tmp{%
+          % expand \thmt at envname and \thmt at parent
+          \@nx\addtotheorempreheadhook[\thmt at envname @unique]{\@nx\setuniqmark{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @numbered]{\@nx\setuniqmark{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @unique]{\def\@nx\thmt at dummyctrautorefname{\thmt at thmname\@nx\@gobble}}%
+          \@nx\addtotheorempreheadhook[\thmt at envname @numbered]{\def\@nx\thmt at dummyctrautorefname{\thmt at thmname\@nx\@gobble}}%
+        }%
+        \thmt at tmp
+      \fi
+      % \addtotheorempreheadhook[\thmt at envname]{\def\thmt at dummyctrautorefname{\thmt at thmname\@gobble}}%
     \fi
   }%
 }
 
-\define at key{thmdef}{preheadhook}{\thmt at trytwice{}{\addtotheorempreheadhook[\thmt at envname]{#1}}}
-\define at key{thmdef}{postheadhook}{\thmt at trytwice{}{\addtotheorempostheadhook[\thmt at envname]{#1}}}
-\define at key{thmdef}{prefoothook}{\thmt at trytwice{}{\addtotheoremprefoothook[\thmt at envname]{#1}}}
-\define at key{thmdef}{postfoothook}{\thmt at trytwice{}{\addtotheorempostfoothook[\thmt at envname]{#1}}}
+\define at key{thmdef}{preheadhook}{%
+  \thmt at trytwice{}{\addtotheorempreheadhook[\thmt at envname]{#1}}}
+\define at key{thmdef}{postheadhook}{%
+  \thmt at trytwice{}{\addtotheorempostheadhook[\thmt at envname]{#1}}}
+\define at key{thmdef}{prefoothook}{%
+  \thmt at trytwice{}{\addtotheoremprefoothook[\thmt at envname]{#1}}}
+\define at key{thmdef}{postfoothook}{%
+  \thmt at trytwice{}{\addtotheorempostfoothook[\thmt at envname]{#1}}}
 
 \define at key{thmdef}{style}{\thmt at trytwice{\thmt at setstyle{#1}}{}}
 
@@ -288,53 +321,106 @@
   }
 \fi
 
-\newif\ifthmt at isnumbered
-\newcommand\thmt at setparent[1]{%
-  \def\thmt at parent{#1}%
-}
-\newcommand\thmt at setsibling{%
-  \def\thmt at sibling
-}
-\newcommand\thmt at setthmname{%
-  \def\thmt at thmname
-}
-
 \thmt at mkextendingkeyhandler{thmdef}{thmdef}{\string\declaretheorem\space key}
 
 \let\thmt at newtheorem\newtheorem
 
 \newcommand\declaretheorem[2][]{%
+  % TODO: use \NewDocumentCommand from xparse?
+  % xparse will be part of latex2e format from latex2e 2020 Oct.
+  \@ifnextchar[%
+    {\declaretheorem at i{#1}{#2}}
+    {\declaretheorem at i{#1}{#2}[]}%
+}
+\@onlypreamble\declaretheorem
+
+\def\declaretheorem at i#1#2[#3]{%
+  \@for\thmt at tmp:=#2\do{%
+    % strip spaces, \KV@@sp at def is defined in keyval.sty
+    \@xa\KV@@sp at def\@xa\thmt at tmp\@xa{\thmt at tmp}%
+    \@xa\declaretheorem at ii\@xa{\thmt at tmp}{#1,#3}%
+  }%
+}
+
+\def\declaretheorem at ii#1#2{%
   % why was that here?
   %\let\thmt at theoremdefiner\thmt at original@newtheorem
-  \def\thmt at envname{#2}%
-  \thmt at setthmname{\thmt at modifycase #2}%
+  % init options
   \thmt at setparent{}%
   \thmt at setsibling{}%
-  \thmt at isnumberedtrue%
-  \@thmt at firstkeysettrue%
-  \kvsetkeys{thmdef0}{#1}%
-  \kvsetkeys{thmdef}{#1}%
+  \thmt at isnumberedtrue
+  \thmt at isunlessuniquefalse
+  \def\thmt at envname{#1}%
+  \thmt at setthmname{\thmt at modifycase #1}%
+  % use true code in \thmt at trytwice{<true>}{<false>}
+  \@thmt at firstkeysettrue
+  % parse options
+  \kvsetkeys{thmdef0}{#2}% parse option "style" first
+  \kvsetkeys{thmdef}{#2}%
+  % call patched \newtheorem
+  \ifthmt at isunlessunique
+    \ifx\thmt at parent\@empty
+    % define normal "unless unique" thm env
+    \ifuniq{#1}{\thmt at isnumberedfalse}{\thmt at isnumberedtrue}%
+    \declaretheorem at iii{#1}%
+    \else
+      % define special "unless unique" thm env,
+      % when "numbered=unless unique" and "numberwithin=<counter>" are both used
+      \declaretheorem at iv{#1}%
+      \thmt at isnumberedtrue
+      \declaretheorem at iii{#1 at numbered}%
+      \thmt at isnumberedfalse
+      \declaretheorem at iii{#1 at unique}%
+    \fi
+  \else
+    % define normal thm env
+    \declaretheorem at iii{#1}%
+  \fi
+  % use false code in \thmt at trytwice{<true>}{<false>}
+  \def\thmt at envname{#1}%
+  \@thmt at firstkeysetfalse
+  % uniquely ugly kludge: some keys make only sense afterwards.
+  % and it gets kludgier: again, the default-inherited
+  % keys need to have a go at it.
+  \kvsetkeys{thmdef0}{#2}%
+  \kvsetkeys{thmdef}{#2}%
+}
+
+\def\declaretheorem at iii#1{%
   \protected at edef\thmt at tmp{%
     \@nx\thmt at newtheorem
-    \ifthmt at isnumbered\else *\fi
-    {#2}%
-    \ifx\thmt at sibling\@empty\else [\thmt at sibling]\fi
-    {\thmt at thmname}%
-    \ifx\thmt at parent\@empty\else [\thmt at parent]\fi
+    \ifthmt at isnumbered
+      {#1}%
+      \ifx\thmt at sibling\@empty\else [\thmt at sibling]\fi
+      {\thmt at thmname}%
+      \ifx\thmt at parent\@empty\else [\thmt at parent]\fi
+    \else
+      *{#1}{\thmt at thmname}%
+    \fi
     \relax% added so we can delimited-read everything later
-    % (recall newtheorem is patched)
-  }%\show\thmt at tmp
+  }%
+  \thmt at debug{Define theorem `#1' by ^^J\meaning\thmt at tmp}%
   \thmt at tmp
-  % uniquely ugly kludge: some keys make only sense
-  % afterwards.
-  % and it gets kludgier: again, the default-inherited
-  % keys need to have a go at it.
-  \@thmt at firstkeysetfalse%
-  \kvsetkeys{thmdef0}{#1}%
-  \kvsetkeys{thmdef}{#1}%
 }
-\@onlypreamble\declaretheorem
 
+\def\declaretheorem at iv#1{%
+  \protected at edef\thmt at tmp{%
+    % expand \thmt at envname and \thmt at parent
+    \@nx\newenvironment{#1}{%
+      \@nx\ifuniq{\thmt at envname.\@nx\@nameuse{the\thmt at parent}}{%
+        \def\@nx\thmt at rawenvname{#1 at unique}%
+      }{%
+        \def\@nx\thmt at rawenvname{#1 at numbered}%
+      }%
+      \begin{\@nx\thmt at rawenvname}%
+    }{%
+      \end{\@nx\thmt at rawenvname}%
+    }%
+  }%
+  \thmt at debug{Define special theorem `#1' by ^^J\meaning\thmt at tmp}%
+  \thmt at tmp
+}
+
 \providecommand\thmt at quark{\thmt at quark}
 
 
@@ -370,13 +456,6 @@
     \def\thmt at shortoptarg{#1}%
   \fi
 }
-\def\thmt at splitopt#1=#2\thmt at quark{%
-  \def\thmt at tmpkey{#1}%
-  \ifx\thmt at tmpkey\@empty
-    \def\thmt at tmpkey{\thmt at quark}%
-  \fi
-  \@onelevel at sanitize\thmt at tmpkey
-}
 
 \def\thmt at thmuse@families{thm at track@keys}
 

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-listof.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-listof.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-listof.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-listof}[2020/07/16 v69]
+\ProvidesPackage {thm-listof}[2020/08/01 v0.72]
 \let\@xa=\expandafter
 \let\@nx=\noexpand
 \RequirePackage{thm-patch,keyval,kvsetkeys}
@@ -45,7 +45,7 @@
 \newcommand\listoftheorems[1][]{%
   %% much hacking here to pick up the definition from the class
   %% without oodles of conditionals.
-  \bgroup
+  \begingroup
   \setlisttheoremstyle{#1}%
   \let\listfigurename\listtheoremname
   \def\contentsline##1{%
@@ -52,10 +52,9 @@
     \csname thmt at contentsline@##1\endcsname{##1}%
   }%
   \@for\thmt at envname:=\thmt at allenvs\do{%
-  \@xa\protected at edef\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
-    \@nx\@dottedtocline{1}{1.5em}{\@nx\thmt at listnumwidth}%
+    % CHECK: is \cs{l@\thmt at envname} repeatedly defined?
+    \thmtlo at newentry
   }%
-  }%
   \let\thref at starttoc\@starttoc
   \def\@starttoc##1{\thref at starttoc{loe}}%
   % new hack: to allow multiple calls, we defer the opening of the
@@ -73,7 +72,7 @@
   }%
   %\expandafter
   \listoffigures
-  \egroup
+  \endgroup
 }
 
 \newcommand\setlisttheoremstyle[1]{%
@@ -86,25 +85,60 @@
 \define at key{thmt-listof}{ignoreall}[true]{\ignoretheorems{\thmt at allenvs}}
 \define at key{thmt-listof}{showall}[true]{\showtheorems{\thmt at allenvs}}
 \define at key{thmt-listof}{title}{\def\listtheoremname{#1}}
+\newif\ifthmt at listswap
+\def\thmt at TRUE{true}
+\def\thmt at FALSE{false}
+\define at key{thmt-listof}{swapnumber}[true]{%
+  \def\thmt at tmp{#1}%
+  \ifx\thmt at tmp\thmt at TRUE
+    \thmt at listswaptrue
+  \else\ifx\thmt at tmp\thmt at FALSE
+    \thmt at listswapfalse
+  \else
+    \PackageError{thmtools}{Unknown value `#1' to key swapnumber}{}%
+  \fi\fi
+}
 
-\providecommand\thmt at listnumwidth{2.3em}
+\ifdefined\@tocline
+  % for ams classes (amsart.cls, amsproc.cls, amsbook.cls) which
+  % don't use \@dottedtocline and don't provide \@dotsep
+  \def\thmtlo at newentry{%
+    \@xa\def\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
+      % similar to \l at figure defined in ams classes
+      \@tocline{0}{3pt plus2pt}{0pt}{\thmt at listnumwidth}{}%
+    }%
+  }
+  \providecommand*\thmt at listnumwidth{1.5pc}
+\else
+  \def\thmtlo at newentry{%
+    \@xa\def\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
+      \@dottedtocline{1}{1.5em}{\thmt at listnumwidth}%
+    }%
+  }
+  \providecommand*\thmt at listnumwidth{2.3em}
+\fi
 
 \providecommand\thmtformatoptarg[1]{ (#1)}
 
 \newcommand\thmt at mklistcmd{%
-  \@xa\protected at edef\csname l@\thmt at envname\endcsname{% CHECK: why p at edef?
-    \@nx\@dottedtocline{1}{1.5em}{\@nx\thmt at listnumwidth}%
-  }%
+  \thmtlo at newentry
   \ifthmt at isstarred
     \@xa\def\csname ll@\thmt at envname\endcsname{%
-      \protect\numberline{\protect\let\protect\autodot\protect\@empty}%
+      \protect\ifthmt at listswap
+      \protect\else
+        \protect\numberline{\protect\let\protect\autodot\protect\@empty}%
+      \protect\fi
       \thmt at thmname
       \ifx\@empty\thmt at shortoptarg\else\protect\thmtformatoptarg{\thmt at shortoptarg}\fi
     }%
   \else
     \@xa\def\csname ll@\thmt at envname\endcsname{%
-      \protect\numberline{\csname the\thmt at envname\endcsname}%
-      \thmt at thmname
+      \protect\ifthmt at listswap
+        \thmt at thmname~\csname the\thmt at envname\endcsname
+      \protect\else
+        \protect\numberline{\csname the\thmt at envname\endcsname}%
+        \thmt at thmname
+      \protect\fi
       \ifx\@empty\thmt at shortoptarg\else\protect\thmtformatoptarg{\thmt at shortoptarg}\fi
     }%
   \fi

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-llncs.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-llncs.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-llncs.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-llncs}[2020/07/16 v69]
+\ProvidesPackage {thm-llncs}[2020/08/01 v0.72]
 \@ifclasslater{llncs}{2010/04/15}{}{%
   \PackageWarningNoLine{thmtools}{%
     LLNCS.cls too old, not supported by thmtools
@@ -70,7 +70,7 @@
     {\thmt at thmname}%
     \ifthmt at hasparent [\thmt at parent]\fi
     {\thmt at style@headfont}{\thmt at style@bodyfont}%
-  }
+  }%
   \thmt at args
   \thmt at newtheorem@postdefinition
 }

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-ntheorem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-ntheorem.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-ntheorem.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-ntheorem}[2020/07/16 v69]
+\ProvidesPackage {thm-ntheorem}[2020/08/01 v0.72]
 
 \providecommand\thmt at space{ }
 

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-patch.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-patch.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-patch.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-patch}[2020/07/16 v69]
+\ProvidesPackage {thm-patch}[2020/08/01 v0.72]
 \RequirePackage{parseargs}
 
 \newif\ifthmt at isstarred

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thm-restate.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thm-restate.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thm-restate.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thm-restate}[2020/07/16 v69]
+\ProvidesPackage {thm-restate}[2020/08/01 v0.72]
 \RequirePackage{thmtools}
 \let\@xa\expandafter
 \let\@nx\noexpand

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-mdframed.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-mdframed.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-mdframed.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,13 +22,12 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thmdef-mdframed}[2020/07/16 v69]
+\ProvidesPackage {thmdef-mdframed}[2020/08/01 v0.72]
 \define at key{thmdef}{mdframed}[{}]{%
   \thmt at trytwice{}{%
     \RequirePackage{mdframed}%
     \RequirePackage{thm-patch}%
-    \addtotheorempreheadhook[\thmt at envname]{%
-      \begin{mdframed}[#1]}%
+    \addtotheorempreheadhook[\thmt at envname]{\begin{mdframed}[#1]}%
     \addtotheorempostfoothook[\thmt at envname]{\end{mdframed}}%
   }%
 }

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-shaded.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-shaded.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-shaded.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thmdef-shaded}[2020/07/16 v69]
+\ProvidesPackage {thmdef-shaded}[2020/08/01 v0.72]
   \define at key{thmdef}{shaded}[{}]{%
   \thmt at trytwice{}{%
     \RequirePackage{shadethm}%

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-thmbox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-thmbox.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thmdef-thmbox.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thmdef-thmbox}[2020/07/16 v69]
+\ProvidesPackage {thmdef-thmbox}[2020/08/01 v0.72]
 \define at key{thmdef}{thmbox}[L]{%
   \thmt at trytwice{%
     \let\oldproof=\proof

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/thmtools.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/thmtools.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/thmtools.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {thmtools}[2020/07/16 v69]
+\ProvidesPackage {thmtools}[2020/08/01 v0.72]
 \DeclareOption{debug}{%
   \def\thmt at debug{\typeout}%
 }

Modified: trunk/Master/texmf-dist/tex/latex/thmtools/unique.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/thmtools/unique.sty	2020-08-07 21:37:39 UTC (rev 56067)
+++ trunk/Master/texmf-dist/tex/latex/thmtools/unique.sty	2020-08-07 22:18:43 UTC (rev 56068)
@@ -22,7 +22,7 @@
 %% 
 %% 
 \NeedsTeXFormat {LaTeX2e}
-\ProvidesPackage {unique}[2020/07/16 v69]
+\ProvidesPackage {unique}[2020/08/01 v0.72]
 
 \DeclareOption{unq}{%
   \newwrite\uniq at channel
@@ -38,24 +38,25 @@
 
 \newcommand\setuniqmark[1]{%
   \expandafter\ifx\csname uniq at now@#1\endcsname\relax
-  \global\@namedef{uniq at now@#1}{\uniq at ONE}%
+    \global\@namedef{uniq at now@#1}{\uniq at ONE}%
   \else
-  \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY\else
-  \immediate\write\uniq at channel{%
-    \string\uniq at setmany{#1}%
-  }%
-  \ifuniq{#1}{%
-    \uniq at warnnotunique{#1}%
-  }{}%
+    \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY
+    \else
+      \immediate\write\uniq at channel{%
+        \string\uniq at setmany{#1}%
+      }%
+      \ifuniq{#1}{%
+        \uniq at warnnotunique{#1}%
+      }{}%
+    \fi
+    \global\@namedef{uniq at now@#1}{\uniq at MANY}%
   \fi
-  \global\@namedef{uniq at now@#1}{\uniq at MANY}%
-  \fi
 }
 \newcommand\ifuniq[1]{%
   \expandafter\ifx\csname uniq at last@#1\endcsname\uniq at MANY
-  \expandafter \@secondoftwo
+    \expandafter\@secondoftwo
   \else
-  \expandafter\@firstoftwo
+    \expandafter\@firstoftwo
   \fi
 }
 \def\uniq at ONE{\uniq at ONE}
@@ -69,11 +70,11 @@
 }
 \def\uniq at warnifunique#1{%
   \expandafter\ifx\csname uniq at now@#1\endcsname\uniq at MANY\else
-  \PackageWarningNoLine{uniq}{%
-    `#1' is unique now.\MessageBreak
-    Rerun LaTeX to pick up the change%
-  }%
-  \@uniq at reruntrue
+    \PackageWarningNoLine{uniq}{%
+      `#1' is unique now.\MessageBreak
+      Rerun LaTeX to pick up the change%
+    }%
+    \@uniq at reruntrue
   \fi
 }
 \def\uniq at warnnotunique#1{%
@@ -85,10 +86,10 @@
 }
 \def\uniq at maybesuggestrerun{%
   \if at uniq@rerun
-  \PackageWarningNoLine{uniq}{%
-    Uniquenesses have changed. \MessageBreak
-    Rerun LaTeX to pick up the change%
-  }%
+    \PackageWarningNoLine{uniq}{%
+      Uniquenesses have changed. \MessageBreak
+      Rerun LaTeX to pick up the change%
+    }%
   \fi
 }
 \AtEndDocument{%



More information about the tex-live-commits mailing list.