如何根据 Latex 中的 section.subsection.subsubsection.number 获取定理编号

如何根据 Latex 中的 section.subsection.subsubsection.number 获取定理编号

我对 Latex 不太熟悉。我的定理、定义、注释等的编号显示为 1.0.0.1,表示第一个定义。如果没有小节或小节,我不希望出现零。以下是序言中的内容

\documentclass[12pt]{article}
\usepackage{amsthm,amsmath}
\usepackage{amscd}
\usepackage{hyperref}
\usepackage[all]{xypic}
\usepackage{mathtools}
\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,mathrsfs}
\usepackage{hyperref}
\usepackage[all]{xypic}
\usepackage{times}
\usepackage{inputenc}
\usepackage{lipsum}
\usepackage{titlesec}
\DeclareUnicodeCharacter{0308}{HERE!HERE!}
\setcounter{MaxMatrixCols}{10}

\newtheorem{lemma}{Lemma}[subsubsection]
\newtheorem{corollary}[lemma]{Corollary}
\newtheorem{fact}[lemma]{Fact}
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{proposition}[lemma]{Proposition}
\newtheorem{definition}[lemma]{Definition}
\newtheorem{remark}[lemma]{Remark}
\newtheorem{example}[lemma]{Example}
\newtheorem{examples}[lemma]{Examples}
\newtheorem{question}[lemma]{Question}

请帮忙。

编辑:在我的第一节(例如)中,没有子节,因此我希望编号为 1.1、1.2 等,而不是 1.0.0.1、1.0.0.2 等。在我的第二节中,我有子节但没有子子节,我希望定理编号为“定理 2.1.1”等。我希望当有子子节时,从四位数开始编号”。我希望我的问题现在清楚了。

答案1

我真的不鼓励这样做。但你可以尝试一下

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{mathtools}
\newtheorem{lemma}{Lemma}[subsubsection]
\newcounter{lemmaaux}
\setcounter{lemmaaux}{0}
\begin{document}
\section{first}
\counterwithin{lemma}{section}
\begin{lemma}\addtocounter{lemmaaux}{1}
My nice lemma
\end{lemma}
\subsection{The fist sub}
\counterwithin{lemma}{subsection}\setcounter{lemma}{\thelemmaaux}
\begin{lemma}\addtocounter{lemmaaux}{1}
My nice second lemma
\end{lemma}
\subsubsection{The fist subsub}
\counterwithin{lemma}{subsubsection}\setcounter{lemma}{\thelemmaaux}
\begin{lemma}\addtocounter{lemmaaux}{1}
My new lemma
\end{lemma}
\section{second}
\counterwithin{lemma}{section}\setcounter{lemma}{\thelemmaaux}
\begin{lemma}\addtocounter{lemmaaux}{1}
My nice third lemma
\end{lemma}
\subsection{The second sub}
\counterwithin{lemma}{subsection}\setcounter{lemma}{\thelemmaaux}
\begin{lemma}\addtocounter{lemmaaux}{1}
My nice fourth lemma
\end{lemma}
\end{document} 

在此处输入图片描述

相关内容