
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}