如何重置未編號小節的計數器?

如何重置未編號小節的計數器?
\documentclass{amsart}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\subsection*{1}

\begin{theorem}
blah is blah
\end{theorem}

\begin{theorem}
bloo is bloo
\end{theorem}

\subsection*{2}

\begin{theorem}
bleh is bleh
\end{theorem}

\begin{theorem}
blih is blih
\end{theorem}

\end{document}

這顯示為:

1. 

Theorem 0.1. blah is blah

Theorem 0.2. bloo is bloo

2. 

Theorem 0.3. bleh is bleh

Theorem 0.4. blih is blih

如何重置計數器,以便在第二個未編號的小節中,將定理 0.3 重設為定理 0.1(並將定理 0.4 設為定理 0.2)?

(我放置了未編號的小節,因為對於這個特定的文檔類,這些節是居中的,這是我不喜歡的,所以我首先使用小節,但是小節編號從0.1 開始,我希望它從1 開始。所以我取消了各小節的編號並輸入了我自己的編號。

答案1

我不確定我是否理解你在問什麼,因為你似乎在說你想要兩個定理 0.1 和兩個定理 0.2s。這對我來說沒有意義,所以我認為您可能想要這樣的東西:

在此輸入影像描述

為此,我定義了一個\section使用mysection計數器的偽命令,該計數器也用於對定理進行編號。

\documentclass{amsart}

\newcounter{mysection}
\let\realsection=\section
\renewcommand\section[1]{\refstepcounter{mysection}%
  \subsection*{\themysection.\space #1}
}
\newtheorem{theorem}{Theorem}[mysection]

\begin{document}

\section{First section}

\begin{theorem}
blah is blah
\end{theorem}

\begin{theorem}
bloo is bloo
\end{theorem}

\section{Second section}

\begin{theorem}
bleh is bleh
\end{theorem}

\begin{theorem}
blih is blih
\end{theorem}

\end{document}

答案2

更改命令的格式\section很簡單,並且是比跳過該級別並使用\subsection.

\section這是in的定義amsart.cls

\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\scshape\centering}}

只需刪除\centering命令:

\makeatletter
\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\scshape}}
\makeatother

如果您希望使用小型大寫字母以外的其他字體樣式,您可以同時更改它,例如更改為\bfseries.

\patchcmd包中的命令提供了僅更改命令定義的一部分的替代方法etoolbox;詳細資訊請參閱文件。

相關內容