From 20b79660fb560eb1dd8e80d44837e0d4c17ca03c Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Tue, 12 Oct 2021 03:00:58 +0000
Subject: CTAN sync 202110120300

---
 macros/latex/contrib/phfthm/phfthm.dtx | 329 ++++++++++++++++++++++++++++-----
 1 file changed, 280 insertions(+), 49 deletions(-)

(limited to 'macros/latex/contrib/phfthm/phfthm.dtx')

diff --git a/macros/latex/contrib/phfthm/phfthm.dtx b/macros/latex/contrib/phfthm/phfthm.dtx
index 6e9656689b..87495d9d9c 100644
--- a/macros/latex/contrib/phfthm/phfthm.dtx
+++ b/macros/latex/contrib/phfthm/phfthm.dtx
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
+% Copyright (C) 2016 by Philippe Faist, philippe.faist@bluewin.ch
 % -------------------------------------------------------
 % 
 % This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
 %<package>\ProvidesPackage{phfthm}
 %<*package>
-    [2016/08/15 v1.0 phfthm package]
+    [2021/03/01 v1.2 phfthm package]
 %</package>
 %
 %<*driver>
@@ -31,6 +31,9 @@
 \usepackage{phfthm}
 \usepackage[preset=xpkgdoc]{phfnote}
 \usepackage{needspace}
+\expandafter\def\csname eqsign@\endcsname{=}
+\def\eqsign{\expandafter\protect\csname eqsign@\endcsname}
+\robustify\eqsign
 \EnableCrossrefs         
 \CodelineIndex
 \RecordChanges
@@ -150,7 +153,7 @@
 % style adjustments; this allows you to enable features individually and
 % selectively:
 % \begin{verbatim}
-% \usepackage[resetstyle,prooftitleitbf=true]{../phfthm}
+% \usepackage[resetstyle,prooftitleitbf=true]{phfthm}
 % \end{verbatim}
 % 
 %
@@ -168,10 +171,9 @@
 %
 % Possible theorem sets are:
 % \begin{pkgoptions}
-% \item[thmset=]\pkgoptionscombineitem
-% \item[thmset=empty] Do not define any environment at package loading.  You may
-%   of course invoke |\phfLoadThmSet| or |\phfMakeTheorem| manually at any
-%   later point.
+% \item[thmset=,thmset=empty] Do not define any environment at package loading.
+%   You may of course invoke |\phfLoadThmSet| or |\phfMakeTheorem| manually at
+%   any later point.
 % \item[thmset=simple]
 %   \DescribeEnv{theorem} \DescribeEnv{proposition}
 %   \DescribeEnv{lemma} \DescribeEnv{corollary} \DescribeEnv{definition}
@@ -182,14 +184,17 @@
 %   environments |theorem|, |proposition|, |lemma|, |corollary|, |conjecture|,
 %   |remark| as theorem-like environments, and |definition| as a definition-like
 %   environment.
-% \item[thmset=shortnames] For if you like typing less: the same environments
+% \item[thmset=shortnames] \iffalse\DescribeEnv{thm}\DescribeEnv{prop}
+%   \DescribeEnv{lem}\DescribeEnv{cor}\DescribeEnv{conj}\DescribeEnv{rem}
+%   \DescribeEnv{defn}\fi In case you prefer to type less: the same environments
 %   are defined as the default set, but with shorter names.  Define the
 %   environments |thm|, |prop|, |lem|, |cor|, |conj|, |rem| as theorem-like
 %   environments, and |defn| as a definition-like environment.
 % \item[thmset=rich] \DescribeEnv{idea} \DescribeEnv{question}
-%   \DescribeEnv{problem} Provides the same environments as the |default|
-%   theorem set, as well as in addition: |idea|, |question| and |problem| as
-%   theorem-like environments.
+%   \DescribeEnv{claim} \DescribeEnv{observation} \DescribeEnv{problem} Provides
+%   the same environments as the |default| theorem set, as well as in addition:
+%   |idea|, |question|, |claim|, |observation|, and |problem| as theorem-like
+%   environments.
 % \end{pkgoptions}
 %
 % You may also load a theorem set at a later
@@ -222,21 +227,28 @@
 %   \pkgoptionfmt{thmset} package option will use a separate counter if this
 %   option is set; otherwise (the default), there is a single counter which is
 %   shared by all those theorem environments.
+% \item[parentcounter=\meta{counter name}] Theorem counters will reset each time
+%   the parent counter is increased.  Use this option for per-chapter or
+%   per-section numbering (use parent counter |parentcounter=chapter| or
+%   |parentcounter=section|).  See also the \pkgoptionfmt{countpersection}
+%   package option.
 % \end{pkgoptions}
 %
 % The \pkgoptionfmt{proofref} package option allows to specify a comma-separated
 % list of attributes to apply to the proof reference (``proof on page XYZ'')
 % displayed along with the theorem.  The following attributes may be specified:
 % \begin{pkgoptions}
-% \item[proofref=\pkgoptattribempty{}]\pkgoptionscombineitem
-% \item[proofref=\pkgoptattribnodots{default}] Do not change the default
-%   proof reference appearance.
+% \item[proofref=\pkgoptattribempty{},proofref=\pkgoptattribnodots{default}] Do
+%   not change the default proof reference appearance.
 %
 % \item[proofref=false] Deactivate the proof-ref mechanism.
 %
 % \item[proofref=\pkgoptattrib{margin}] The proof reference is displayed in
 %   the margin, instead of after the theorem.
 %
+% \item[proofref=\pkgoptattrib{marginbottom}] The proof reference is displayed
+%   in the margin, but aligned with the bottom of the theorem statement.
+%
 % \item[proofref=\pkgoptattrib{longref}] The proof reference is displayed as
 %   a full sentence (``The proof of this \meta{Theorem Name} can be found on
 %   page \meta{XYZ}.'').
@@ -430,8 +442,10 @@
 %   the margin, long sentence, ...).  Possible styles are
 %   \cmdoptionfmt{proofrefstyle=default} (the default),
 %   \cmdoptionfmt{proofrefstyle=margin} (display the proof ref in the margin of
-%   the page) and \cmdoptionfmt{proofrefstyle=longref} (as by default but with a
-%   full sentence).  See \autoref{sec:proof-ref-customize-appearance} for how to
+%   the page), \cmdoptionfmt{proofrefstyle=marginbottom} (display the proof ref
+%   in the margin of the page aligned with the bottom of the theorem statement)
+%   and \cmdoptionfmt{proofrefstyle=longref} (as by default but with a full
+%   sentence).  See \autoref{sec:proof-ref-customize-appearance} for how to
 %   further customize the appearance of the proof reference.
 %
 % \end{cmdoptions}
@@ -456,8 +470,8 @@
 % |\phfLoadThmSet| is:
 %
 % \noindent |\phfLoadThmSet|\hspace{0pt}\marg{options to
-% \phfverb{\phfLoadThmSet} for theorem-like
-% environments}\hspace{0pt}\marg{options to \phfverb{\phfLoadThmSet} for
+% \phfverb{\phfMakeTheorem} for theorem-like
+% environments}\hspace{0pt}\marg{options to \phfverb{\phfMakeTheorem} for
 % definition-like environments}\hspace{0pt}\marg{name of theorem set to load}
 %
 % The first and second argument to this macro are tokens to expand in front of
@@ -490,6 +504,7 @@
 % \DescribeMacro{\definitionname}
 % \DescribeMacro{\ideaname}
 % \DescribeMacro{\questionname}
+% \DescribeMacro{\claimname}
 % \DescribeMacro{\problemname}
 %
 % This package is language agnostic (with titles defined by default in English),
@@ -498,9 +513,9 @@
 % the relevant names to the corresponding |\captions|\meta{language name} macro,
 % for example:
 % \begin{verbatim}
-% \usepackage[francais,...]{babel}
+% \usepackage[french,...]{babel}
 % ...
-% \addto\captionsfrancais{%
+% \addto\captionsfrench{%
 %   \def\theoremname{Th\'eor\`eme}%
 %   \def\propositionname{Proposition}%
 %   \def\lemmaname{Lemme}%
@@ -510,9 +525,10 @@
 %   \def\definitionname{D\'efinition}%
 %   \def\ideaname{Id\'ee}%
 %   \def\questionname{Question}%
+%   \def\claimname{Affirmation}%
 %   \def\problemname{Probl\`eme}%
 % }
-% ... \selectlanguage{francais} ...
+% ... \selectlanguage{french} ...
 % \end{verbatim}
 %
 % 
@@ -690,12 +706,16 @@
 % \newcommand\proofofname[1]{\proofname{} of #1}
 % \end{verbatim}
 % You may override this to obtain something fancier, of you wish to display the
-% document in a different language:
+% document in a different language.  For instance, you might want to display
+% (``D\'emonstration (Th\'eor\`eme 5)'' in french:
 % \begin{verbatim}
-% \def\proofofnamefrancais#1{\proofname{} (#1)}
-% \addto\captionsfrancais{\let\proofofname\proofofnamefrancais}
+% \def\proofofnameinparentheses#1{\proofname\ (#1)}
+% \addto\captionsfrench{%
+%   \def\proofname{D\'emonstration}%
+%   \let\proofofname\proofofnameinparentheses%
+% }
 % ...
-% \selectlanguage{francais} ...
+% \selectlanguage{french} ...
 % \end{verbatim}
 %
 %
@@ -799,9 +819,9 @@
 %   \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
 %     \textbf{Theorem 17} (Gauss). For a closed surface $S$ enclosing a
 %     volume $V$, we have
-%     \setcounter{equation}{41}
 %     \begin{equation}
 %       \oint_S\vec u\cdot d\vec S = \int_V(\vec\nabla\cdot\vec u)\,dV\ .
+%       \tag*{(41)}
 %     \end{equation}
 %     \hfill{\small\itshape (Proof on page XXX.)}\hfilneg
 %     {\par\vspace{1ex}\relax
@@ -810,6 +830,41 @@
 %   \end{minipage}
 % }\endgroup
 %
+% A positive side-effect is that in your LaTeX source, if you consistently
+% label your proofs then you always know what theorem a proof refers to.  If
+% you would like to simply output ``Proof.'' instead of ``Proof of Theorem
+% X.'', for instance, because the proof immediately succeeds the theorem in
+% question, you may use the syntax |[**thm:label]| instead.  In this case, the
+% proof-reference mechanism will know that this is the proof of the theorem
+% labeled |thm:label| and will avoid undefined references.  For example,
+% the following code:
+% \begin{verbatim}
+% \begin{theorem}[Gauss]
+%   \label{thm:Gauss}
+%   For a closed surface $S$ enclosing a volume $V$, we have
+%   \begin{equation}
+%     \oint_S\vec u\cdot d\vec S = \int_V(\vec\nabla\cdot\vec u)\,dV\ .
+%   \end{equation}
+% \end{theorem}
+% \begin{proof}[**thm:Gauss]
+%   ...
+% \end{proof}
+% \end{verbatim}
+% might output:
+% \begingroup\setlength{\fboxsep}{1em}
+% \par\noindent\fbox{%
+%   \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
+%     \textbf{Theorem 17} (Gauss). For a closed surface $S$ enclosing a
+%     volume $V$, we have
+%     \begin{equation}
+%       \oint_S\vec u\cdot d\vec S = \int_V(\vec\nabla\cdot\vec u)\,dV\ .
+%       \tag*{(41)}
+%     \end{equation}
+%     \par\textit{Proof.}\hspace{2em}\ldots
+%   \end{minipage}
+% }\endgroup
+%
+%
 % \subsection{On the theorem side}
 %
 % On the theorem side, the proof-ref mechanism works by hacking into the
@@ -875,6 +930,17 @@
 % \ldots},'' where the page number corresponds to the page on which this proof
 % is located.
 %
+% You may also use the syntax |\begin{proof}[**|\meta{label}|]|, which has the
+% effect of producing the simple output ``Proof.'' (this is desirable e.g.\@
+% if the proof immediately follows the theorem statement) but which still
+% informs the proof-reference mechanism that this proof is associated with the
+% given theorem labeled by \meta{label}.  This can avoid undefined references,
+% and can simplify your job if you want to move proofs around in your document.
+%
+% (It would be nice, of course, to have the package automatically output
+% ``Proof'' only if the proof immediately follows the theorem and output ``Proof
+% of XXX'' if the proof is further away.  Unfortunately this is hard to detect
+% in \LaTeX\ and I currently have no plans to try to implement this.)
 %
 % \subsection{Customizing appearance of the proof reference text}
 % \label{sec:proof-ref-customize-appearance}
@@ -1048,6 +1114,7 @@
 \define@boolkey{phfmkthm}{defnostar}[true]{}
 \define@boolkey{phfmkthm}{defstar}[true]{}
 \define@boolkey{phfmkthm}{proofref}[true]{}
+\define@cmdkey{phfmkthm}{parentcounter}{}
 \define@cmdkey{phfmkthm}{proofrefstyle}{}
 %    \end{macrocode}
 % 
@@ -1067,6 +1134,7 @@
   \KV@phfmkthm@defnostartrue%
   \KV@phfmkthm@defstartrue%
   \KV@phfmkthm@proofreftrue%
+  \def\cmdKV@phfmkthm@parentcounter{}%
   \def\cmdKV@phfmkthm@proofrefstyle{default}%
   \setkeys{phfmkthm}{#1}%
 %    \end{macrocode}
@@ -1096,9 +1164,16 @@
   \ifKV@phfmkthm@defnostar%
     \if\relax\detokenize\expandafter{\cmdKV@phfmkthm@counter}\relax%
 %    \end{macrocode}
-% ---in case we use a separate counter (if \cmdoptionfmt{counter=}):
+% ---in case we use a separate given counter (if \cmdoptionfmt{counter=} is
+% given empty or not specified). Also check if we want a parent counter
+% (per-section or per-chapter numbering) and take that into account:
 %    \begin{macrocode}
-      \newtheorem{phfthm@#2}{#3}%
+      \if\relax\detokenize\expandafter{\cmdKV@phfmkthm@parentcounter}\relax%
+        \edef\x{\noexpand\newtheorem{phfthm@#2}{#3}}%
+      \else
+        \edef\x{\noexpand\newtheorem{phfthm@#2}{#3}[\expandonce\cmdKV@phfmkthm@parentcounter]}%
+      \fi
+      \x
       \csdef{phfthm@#2autorefname}{#3}%
     \else%
       \ifKV@phfmkthm@aliascounter%
@@ -1111,7 +1186,8 @@
         \csdef{#2autorefname}{#3}%
       \else%
 %    \end{macrocode}
-% ---in case we directly instruct |\newtheorem| to use the other counter (does not work with |\autoref|):
+% ---in case we directly instruct |\newtheorem| to use the other counter (does
+% not work with |\autoref|):
 %    \begin{macrocode}
         \newtheorem{phfthm@#2}[\cmdKV@phfmkthm@counter]{#3}%
       \fi%
@@ -1121,7 +1197,7 @@
 % And also define the actual theorem environment, adding calls to hooks.
 %    \begin{macrocode}
     \newenvironment{#2}[1][]{%
-      \begin{phfthm@#2}[##1]%
+      \begin{phfthm@#2}[{##1}]%
         \begingroup%
           \csname phfthm@hook@start@#2\endcsname{##1}%
       }{%
@@ -1430,10 +1506,15 @@
     \else
       \noexpand\phfthm@proof@noparselabel{##1}%
     \fi
-    \noexpand\def\noexpand\phfthm@val@displayargs{[{%
-        \expandafter\noexpand\csname phfthm@prfenv@#2@val@proofofname\endcsname
-        {\noexpand\phfthm@val@prooftitle}%
-      }]}%
+    \noexpand\if\noexpand\relax\noexpand\detokenize%
+            \noexpand\expandafter{\noexpand\phfthm@val@prooftitle}\noexpand\relax
+      \noexpand\def\noexpand\phfthm@val@displayargs{}
+    \noexpand\else
+      \noexpand\def\noexpand\phfthm@val@displayargs{[{%
+          \expandafter\noexpand\csname phfthm@prfenv@#2@val@proofofname\endcsname
+          {\noexpand\phfthm@val@prooftitle}%
+        }]}%
+    \noexpand\fi
   }
 %    \end{macrocode}
 % 
@@ -1645,15 +1726,29 @@
 \def\phfthm@proof@parselabel#1{%
   \phfthm@proof@parselabel@maybelabel#1\phfthm@proof@parselabel@END%
 }
+%    \end{macrocode}
+% If the argument is |[*thm-label]| we want ``Proof of \meta{ref to
+% thm-label}.''.  If the argument is |[**thm-label]| we want ``Proof.'' but
+% we're informing the proofref-system that this is the proof of \meta{thm-label}
+% (e.g., to avoid undefined references to proofs).  Otherwise if we get %
+% |[Some Custom Theorem]| then we want ``Proof of Some Custom Theorem.''.
+%    \begin{macrocode}
 \def\phfthm@proof@parselabel@maybelabel{%
   \@ifnextchar*\phfthm@proof@parselabel@label\phfthm@proof@parselabel@title%
 }
-\def\phfthm@proof@parselabel@label*#1\phfthm@proof@parselabel@END{%
+\def\phfthm@proof@parselabel@label*{%
+  \@ifnextchar*\phfthm@proof@parselabel@labelsilent\phfthm@proof@parselabel@labelnormal%
+}
+\def\phfthm@proof@parselabel@labelsilent*#1\phfthm@proof@parselabel@END{%
 %    \end{macrocode}
 % The use of |\detokenize| here is a trick to make sure that all chars in the
 % label text have a non-active category (e.g.\@ we would have problems, e.g., if
 % in the label ``|thm:gauss|'' the ``|:|'' is an active char---such as in French):
 %    \begin{macrocode}
+  \edef\phfthm@val@proofoflabel{\detokenize{#1}}%
+  \def\phfthm@val@prooftitle{}% 
+}
+\def\phfthm@proof@parselabel@labelnormal#1\phfthm@proof@parselabel@END{%
   \edef\phfthm@val@proofoflabel{\detokenize{#1}}%
   \def\phfthm@val@prooftitle{\phfthm@autoref{#1}}%
 }
@@ -1679,12 +1774,14 @@
 % 
 %
 % In order to look up what we are a proof of, we use |\autoref| provided by the
-% \pkgname{hyperref} package.  If it is not available, fall back to the regular
-% |\ref| command.
+% \pkgname{hyperref} package.  Crucially, it is NOT the job of \pkgname{phfthm}
+% to load this package, and we should only use them if they are available (we
+% don't want to depend on it).  If it is not available, then we fall back to the
+% regular |\ref| command.
 %    \begin{macrocode}
 \def\phfthm@autoref{\ref}
 \AtBeginDocument{%
-  \@ifpackageloaded{hyperref}{\def\phfthm@autoref{\autoref}}{}
+  \@ifpackageloaded{hyperref}{\def\phfthm@autoref{\autoref}}{}%
 }
 %    \end{macrocode}
 % 
@@ -1983,11 +2080,53 @@
 % \end{macro}
 % 
 %
-% \subsubsection{Other proof-ref styles: only \phfverb{margin} for now}
+% \subsubsection{Other proof-ref styles: \phfverb{margin} and \phfverb{marginbottom}}
 %
 % These styles simply use the same mechanism as the default style, but plug in
 % different sub-callbacks.
 %
+% Here's a command that actually places the marginpar:
+% \begin{macro}{\phfthmproofref@placemarginpar}
+%    \begin{macrocode}
+\newcommand\phfthmproofref@placemarginpar[2]{%
+  \marginpar[%
+    \raggedleft #1%
+  ]{%
+    \raggedright #2%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\phfthmproofref@placephantommarginpar}
+%   In the |marginbottom| proof-ref style, we place an invisible |\marginpar| at
+%   the top of the proof so that the proof-ref margin note will not be shifted
+%   too high when we try to align it to the bottom of the theorem statement.  To
+%   work around a weird bug in Rev\TeX, where I get the error message `command
+%   sequence undefined: |\@captype|', I have found that a fix is to override
+%   this local invisible |\marginpar| to locally make sure the |\@captype| is
+%   defined.  The wild fix I've found---no guarantees, there are dark magic
+%   forces at work here---is the following, which you can include in your
+%   document preamble if you're banging your head against this problem and
+%   you're desperate:
+% \begin{verbatim}
+%   \makeatletter
+%   \renewcommand\phfthmproofref@placephantommarginpar{%
+%     \begingroup\csdef{@captype}{figure}\marginpar{%
+%       \vspace{-\baselineskip}\rule{0pt}{0pt}}\endgroup%
+%   }
+%   \makeatother
+% \end{verbatim}
+%    \begin{macrocode}
+\newcommand\phfthmproofref@placephantommarginpar{%
+    \leavevmode\marginpar{\vspace{-\baselineskip}\rule{\z@}{\z@}}%
+}%
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \paragraph{The \phfverb{margin} style}
+%
 % \begin{macro}{\phfthm@proofrefstyle@margin@setup}
 %   Set-up macro for the ``|margin|'' proof-ref style (displays the proof
 %   reference in the margin of the page).
@@ -2011,12 +2150,65 @@
 % \url{http://tex.stackexchange.com/a/16161/32188}}
 %    \begin{macrocode}
   \def\phfthm@proofref@impl@fmt##1##2{%
-    \leavevmode\marginpar{\proofrefsize{\proofonname{##1}{##2}}}%
+    \leavevmode\phfthmproofref@placemarginpar{%
+      \proofrefsize{\proofonname{##1}{##2}}%
+    }{%
+      \proofrefsize{\proofonname{##1}{##2}}%
+    }%
   }%
 }
 %    \end{macrocode}
 % \end{macro}
 % 
+% \paragraph{The \phfverb{marginbottom} style}
+%
+% \begin{macro}{\phfthm@proofrefstyle@marginbottom@setup}
+%   Set-up macro for the ``|marginbottom|'' proof-ref style (displays the proof
+%   reference in the margin of the page).
+%    \begin{macrocode}
+\def\phfthm@proofrefstyle@marginbottom@setup{%
+  \phfthm@proofrefstyle@default@setup
+%    \end{macrocode}
+% 
+% The proof reference should be displayed directly at the bottom, not at the end
+% of the theorem, so plug in |\phfthm@proofref@default@main| onto |...@end| and
+% not onto |...@afterlabel|.  Don't forget that these macros accept one
+% argument, the theorem label.  In |...@afterlabel| we place a dummy marginpar
+% with an invisible rule one |\baselineskip| upwards, so that we force any
+% proof-ref marginpar not to extend above the top of the theorem statement.
+%    \begin{macrocode}
+  \def\phfthm@proofref@impl@afterlabel##1{%
+    \phfthmproofref@placephantommarginpar
+  }%
+  \let\phfthm@proofref@impl@end\phfthm@proofrefstyle@default@main
+%    \end{macrocode}
+% 
+% Define the formatting callback to put the note in the margin of the page using
+% a |\marginpar|.  We use a trick to align the margin note with the bottom of
+% the paragraph.\footnote{\url{https://tex.stackexchange.com/a/388018/32188}}
+%    \begin{macrocode}
+  \def\phfthm@proofref@impl@fmt##1##2{%
+    \phfthmproofref@marginbottom@domarginpar{##1}{##2}%
+  }%
+}
+\def\phfthmproofref@marginbottom@domarginpar#1#2{%
+  \setbox\phfthm@tmp@boxa=\hbox to \marginparwidth{%
+    \parbox[b]{\marginparwidth}{\raggedleft\sloppy
+      \proofrefsize{\strut\proofonname{#1}{#2}\strut}}}%
+  \setbox\phfthm@tmp@box=\hbox to \marginparwidth{%
+    \parbox[b]{\marginparwidth}{\raggedright\sloppy
+      \proofrefsize{\strut\proofonname{#1}{#2}\strut}}}%
+  \phfthmproofref@placemarginpar{%
+    \box\phfthm@tmp@boxa%
+  }{%
+    \box\phfthm@tmp@box%
+  }%
+}
+\newbox\phfthm@tmp@box
+\newbox\phfthm@tmp@boxa
+%    \end{macrocode}
+% \end{macro}
+%
 %
 % \subsection{Thmheading definition-like environments}
 %
@@ -2150,6 +2342,8 @@
 \def\definitionname{Definition}
 \def\ideaname{Idea}
 \def\questionname{Question}
+\def\claimname{Claim}
+\def\observationname{Observation}
 \def\problemname{Problem}
 %    \end{macrocode}
 % 
@@ -2230,6 +2424,8 @@
   \phfthm@thmset@default
   \phfthm@def@thmset@mktheorem{idea}{\ideaname}
   \phfthm@def@thmset@mktheorem{question}{\questionname}
+  \phfthm@def@thmset@mktheorem{claim}{\claimname}
+  \phfthm@def@thmset@mktheorem{observation}{\observationname}
   \phfthm@def@thmset@mktheorem{problem}{\problemname}
 }
 %    \end{macrocode}
@@ -2291,6 +2487,7 @@
   \KV@phfthmpkg@qedsymbolblacksquarefalse%
   \KV@phfthmpkg@prooftitleitbffalse%
   \KV@phfthmpkg@sepcountersfalse%
+  \KV@phfthmpkg@countpersectionfalse%
   \KV@phfthmpkg@proofreffalse%
   \if\relax\detokenize{#1}\relax\else%
     \PackageError{phfthm}{'resetstyle' does not take any argument.}{You
@@ -2312,13 +2509,18 @@
 \KV@phfthmpkg@sepcountersfalse
 %    \end{macrocode}
 % 
+% The \pkgoptionfmt{countpersection} option, off by default.
+%    \begin{macrocode}
+\define@boolkey{phfthmpkg}{countpersection}[true]{}
+\KV@phfthmpkg@countpersectionfalse
+%    \end{macrocode}
+% 
 %
-% The \pkgoptionfmt{proofref} option.  The proof-ref is off initially by
-% default.
+% The \pkgoptionfmt{proofref} option.  The proof-ref is on initially by default.
 %    \begin{macrocode}
 \newif\ifKV@phfthmpkg@proofref
-\KV@phfthmpkg@proofreffalse
-\def\cmdKV@phfthmpkg@proofref@style{}
+\KV@phfthmpkg@proofreftrue
+\def\cmdKV@phfthmpkg@proofref@style{default}
 %    \end{macrocode}
 % Actually define the option itself.  Here we do some customized parsing of the
 % value of the |proofref=...| option, to treat the cases |proofref=| (empty
@@ -2451,6 +2653,9 @@
   \def\phfthm@proofref@style@margin{
     \def\phfthm@val@mkthmopt@proofrefstyle{proofrefstyle=margin}
   }
+  \def\phfthm@proofref@style@marginbottom{
+    \def\phfthm@val@mkthmopt@proofrefstyle{proofrefstyle=marginbottom}
+  }
   \def\phfthm@proofref@style@longref{
 %    \end{macrocode}
 % For |longref|: by setting |\proofonname| globally, this option can be combined
@@ -2476,6 +2681,16 @@
   \def\x{%
     \phfthm@internal@execattribs{phfthm@proofref@style@}{ProofRef Style}}
   \expandafter\x\expandafter{\cmdKV@phfthmpkg@proofref@style}
+%    \end{macrocode}
+% 
+% Prepare the proof-ref option in case we don't want any proof reference
+% mechanism on.
+%
+% \changed[chg-bugfix-pkgopt-proofreffalse]{v1.1}{2019/03/12}{Bug fix: package
+% option \texttt{proofref\eqsign false} didn't have any effect}
+%    \begin{macrocode}
+\else
+  \def\phfthm@val@mkthmopt@proofrefstyle{proofref=false}
 \fi
 %    \end{macrocode}
 % 
@@ -2490,12 +2705,28 @@
 %    \end{macrocode}
 % 
 % Prepare an argument to |\phfMakeTheorem| according to the
-% \pkgoptionfmt{sepcounters} option.
+% \pkgoptionfmt{countpersection} and \pkgoptionfmt{sepcounters} options.  First
+% determine the parent counter in case \pkgoptionfmt{countpersection} is set
+% (|chapter| if |chapter| counter exists, else |section|).
 %    \begin{macrocode}
+\ifKV@phfthmpkg@countpersection
+  \ifcsname c@chapter\endcsname
+    \def\phfthm@tmp@parentcountername{chapter}
+  \else
+    \def\phfthm@tmp@parentcountername{section}
+  \fi
+\fi
 \ifKV@phfthmpkg@sepcounters
-  \def\phfthm@val@mkthmopt@counteropts{}
+  \ifKV@phfthmpkg@countpersection
+    \edef\phfthm@val@mkthmopt@counteropts{parentcounter=\phfthm@tmp@parentcountername}
+  \else
+    \def\phfthm@val@mkthmopt@counteropts{}
+  \fi
 \else
   \def\phfthm@val@mkthmopt@counteropts{counter=phfthmcounter}
+  \ifKV@phfthmpkg@countpersection
+    \numberwithin{phfthmcounter}{\phfthm@tmp@parentcountername}
+  \fi
 \fi
 %    \end{macrocode}
 % 
@@ -2525,19 +2756,19 @@
   \fi
 }
 \ifKV@phfthmpkg@smallproofs
-  \phfthm@pkgopterr@require@proofenv{smallproofs}
+  %\phfthm@pkgopterr@require@proofenv{smallproofs}
   \apptocmd\phfthm@hookproof@startcommon{%
     \def\baselinestretch{1.2}\footnotesize}{}{%
     Failed to change command \string\phfthm@hook@start@proof}
 \fi
 \ifKV@phfthmpkg@qedsymbolblacksquare
-  \phfthm@pkgopterr@require@proofenv{qedsymbolblacksquare}
+  %\phfthm@pkgopterr@require@proofenv{qedsymbolblacksquare}
   \RequirePackage{amssymb}
   \providecommand\filledsquare{\ensuremath{\blacksquare}}
   \renewcommand\qedsymbol{\text{\tiny\ensuremath{\filledsquare}}}
 \fi
 \ifKV@phfthmpkg@prooftitleitbf
-  \phfthm@pkgopterr@require@proofenv{prooftitleitbf}
+  %\phfthm@pkgopterr@require@proofenv{prooftitleitbf}
   \def\phfthm@ProofTitleFmt#1{{\itshape\bfseries#1.}}
 \fi
 %    \end{macrocode}
-- 
cgit v1.2.3

