Eliminar la parte ".1" en la numeración de una observación, si es la observación única que sigue algún teorema

Eliminar la parte ".1" en la numeración de una observación, si es la observación única que sigue algún teorema

Estoy usando el amsthmpaquete y thmtoolsel paquete para formatear mi manuscrito.

Estoy numerando comentarios dentro de teoremas, es decir, teniendoObservación 2.1.,Observación 2.2.y así sucesivamente despuésTeorema 2. Sin embargo, cuando sólo se hace una observación después de, digamos,Teorema 1, espero que pueda ser numerado comoObservación 1.en lugar deObservación 1.1.

Utilizando la opción numbered=unless uniqueen thmtools, se puede eliminar por completo la numeración, consiguiendoObservación. Esto no es lo que realmente deseo porque espero poder referirme al comentario más adelante cómodamente por su numeración, en lugar de decir algo como "la observación hecha después del teorema 1".

A continuación se muestra un MWE, donde estoy estancado y me pregunto si existe alguna adaptación rápida para realizar mi propósito. Gracias de antemano por las posibles soluciones.

\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} 

Respuesta1

Puede definir el comportamiento que desee "a mano" utilizando el uniquepaquete. Lo siguiente simplemente emula lo thmtoolsque hace con numbered=unless unique, pero en lugar de hacer que la observación no esté numerada si es única, se establece \thermken \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}

teoremas


No es demasiado difícil definir una clave que tenga el mismo efecto.

\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}

con llave

Respuesta2

Con expl3podemos almacenar el número de comentarios que siguen a un teorema en una lista de propiedades (otros valores se sobrescribirán, por lo que obtenemos el máximo).

Al final de la ejecución, estos valores se escriben en el archivo auxiliar en el formulario

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

(valores del ejemplo), de modo que al comienzo de la siguiente ejecución podamos completar otra lista de propiedades que se utiliza para la verificación. Si el número almacenado es mayor que 1, .\arabic{rmk}se utiliza.


\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}

ingrese la descripción de la imagen aquí

información relacionada