ある定理に従った唯一の注釈である場合、注釈の番号付けから「.1」の部分を削除する

ある定理に従った唯一の注釈である場合、注釈の番号付けから「.1」の部分を削除する

私は原稿のフォーマットにamsthmパッケージとパッケージを使用しています。thmtools

私は定理の中で注釈に番号を付けています。つまり、備考2.1.備考2.2.そしてその後も同様定理2しかし、例えば、定理1、私はそれが備考1.の代わりに備考1.1

numbered=unless uniqueのオプションを使用するとthmtools、番号付けを完全に削除することができ、述べるこれは私が本当に望んでいることではありません。なぜなら、私は「定理1の後の発言「」。

以下は私が行き詰まっており、目的を達成するための迅速な適応方法があるかどうか疑問に思っている MWE です。可能な解決策を事前にお知らせいただければ幸いです。

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\newtheorem{thm}{Theorem}
\theoremstyle{remark}
\declaretheorem[numberwithin=thm, name=Remark, numbered=unless unique]{rmk}


\begin{document}
\begin{thm}
This is a theorem.
\end{thm}

\begin{rmk} % only one remark made
This is the only remark, so number it the same as the previous theorem.
What I want is Remark 1., instead of Remark. or Remark 1.1.
\end{rmk}

\begin{thm}
This is the second theorem.
\end{thm}

\begin{rmk} % Multiple remarks
Multiple remarks follow, and this is the first.
\end{rmk}
\begin{rmk}
Since there are multiple remarks made, all of them are numbered.
\end{rmk}
\begin{rmk}
The style is Remark 2.1., 2.2., and 2.3., etc.
\end{rmk}

\end{document} 

答え1

パッケージを使用して、必要な動作を「手動で」定義できますunique。以下は、thmtoolsで が行うことをエミュレートするだけですが、一意である場合に注釈を番号なしにするのではなく、にnumbered=unless unique設定します。\thermk\thethm

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[unq]{unique}

\newtheorem{thm}{Theorem}
\theoremstyle{remark}
\declaretheorem[numberwithin=thm, name=Remark]{rmk}

\addtotheorempreheadhook[rmk]{%
  \setuniqmark{rmk.\thethm}%
  \ifuniq{rmk.\thethm}
    {\def\thermk{\thethm}}
    {}%
  }

\begin{document}

\begin{thm}
This is a theorem.
\end{thm}

\begin{rmk} % only one remark made
This is the only remark, so number it the same as the previous theorem.
What I want is Remark 1., instead of Remark. or Remark 1.1.
\end{rmk}

\begin{thm}
This is the second theorem.
\end{thm}

\begin{rmk} % Multiple remarks
Multiple remarks follow, and this is the first.
\end{rmk}
\begin{rmk}
Since there are multiple remarks made, all of them are numbered.
\end{rmk}
\begin{rmk}
The style is Remark 2.1., 2.2., and 2.3., etc.
\end{rmk}

\begin{thm}
bla
\end{thm}

\begin{rmk}
more bla
\end{rmk}

\end{document}

定理


同じ効果を持つキーを定義するのはそれほど難しくありません。

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\makeatletter
\define@key{thmdef}{uniquewithparent}{%
  \setkeys{thmdef}{parent=#1}
  \RequirePackage[unq]{unique}
  \addtotheorempreheadhook[\thmt@envname]{%
    \setuniqmark{\thmt@envname.\csname the#1\endcsname}%
    \ifuniq{\thmt@envname.\csname the#1\endcsname}
      {\@xa\def\csname the\thmt@envname\endcsname{\csname the#1\endcsname}}
      {}%
    }
  }
\makeatother

\newtheorem{thm}{Theorem}
\declaretheorem[uniquewithparent=section]{lemma}
\theoremstyle{remark}
\declaretheorem[name=Remark,uniquewithparent=thm]{rmk}

\begin{document}

\section{A section}

\begin{lemma}
Some text.
\end{lemma}

\begin{thm}
This is a theorem.
\end{thm}

\begin{rmk} % only one remark made
This is the only remark, so number it the same as the previous theorem.
What I want is Remark 1., instead of Remark. or Remark 1.1.
\end{rmk}

\begin{thm}
This is the second theorem.
\end{thm}

\begin{rmk} % Multiple remarks
Multiple remarks follow, and this is the first.
\end{rmk}
\begin{rmk}
Since there are multiple remarks made, all of them are numbered.
\end{rmk}

\section{Another section}

\begin{lemma}
More text.
\end{lemma}

\begin{lemma}
Even more text.
\end{lemma}

\end{document}

キー付き

答え2

を使用すると、expl3定理に続く注釈の数をプロパティ リストに格納できます (それ以上の値は上書きされるため、最大値が得られます)。

実行の最後に、これらの値は次の形式でauxファイルに書き込まれます。

\rmklist{1=1,2=3,1=1,}

(例の値) なので、次の実行の開始時に、チェックに使用される別のプロパティ リストを設定できます。保存された数値が 1 より大きい場合は、.\arabic{rmk}が使用されます。


\documentclass{article}

\usepackage{amsthm}

\newtheorem{thm}{Theorem}
\theoremstyle{remark}
\newtheorem{rmk}{Remark}[thm]
\renewcommand{\thermk}{\thethm\checkrmk}

\ExplSyntaxOn

% populate the property list for the checks
\NewDocumentCommand{\rmklist}{m}
 {
  \prop_gset_from_keyval:Nn \g_dustrain_rmk_in_prop { #1 }
 }

% check whether the number of remarks is > 1
\NewExpandableDocumentCommand{\checkrmk}{}
 {
  \__dustrain_rmk_check:e { \arabic{thm} }
 }

% at end of rmk, store the last value of rmk
\AddToHook{env/rmk/after}
 {
  \prop_gput:Nee \g_dustrain_rmk_out_prop { \arabic{thm} } { \arabic{rmk} }
 }

% at end document, write down the values in the aux file
\AtEndDocument
 {
  \iow_now:ce { @auxout }
   {
    \rmklist { \prop_map_function:NN \g_dustrain_rmk_out_prop \__dustrain_rmk_write:nn }
   }
 }

% variables
\prop_new:N \g_dustrain_rmk_out_prop
\prop_new:N \g_dustrain_rmk_in_prop

% internal functions
\cs_new:Nn \__dustrain_rmk_write:nn { #1=#2, }
\cs_new:Nn \__dustrain_rmk_check:n
 {
  \int_compare:nT { 0\prop_item:Nn \g_dustrain_rmk_in_prop { #1 } > 1 } { .\arabic{rmk} }
 }
\cs_generate_variant:Nn \__dustrain_rmk_check:n { e }

\ExplSyntaxOff


\begin{document}

\begin{thm}
This is a theorem.
\end{thm}

\begin{rmk} % only one remark made
This is the only remark, so number it the same as the previous theorem.
What I want is Remark 1., instead of Remark. or Remark 1.1.
\end{rmk}

\begin{thm}
This is the second theorem.
\end{thm}

\begin{rmk} % Multiple remarks
Multiple remarks follow, and this is the first.
\end{rmk}
\begin{rmk}
Since there are multiple remarks made, all of them are numbered.
\end{rmk}
\begin{rmk}
The style is Remark 2.1., 2.2., and 2.3., etc.
\end{rmk}

\begin{thm}
bla
\end{thm}

\begin{rmk}
more bla
\end{rmk}

\end{document}

ここに画像の説明を入力してください

関連情報