Нумерация пунктов в главе

Нумерация пунктов в главе

Я пишу свою диссертацию в классе книг. Все главы, кроме одной, имеют подразделы. Для конкретной главы без подраздела первый номер определения — 2.0.1. 0 — это подраздел. Как мне сделать его просто 2.1 вместо 2.0.1? Вот что у меня есть:

\documentclass[oneside, openany,12pt]{book}

\usepackage{amsthm,amsmath,latexsym,amsfonts,mathrsfs,graphics,graphicx,amssymb}

\usepackage[mathcal]{eucal}

\usepackage{setspace,titlesec,float,indentfirst,tocloft}

\usepackage[top=1in, left=1in, bottom=1in, right=1in]{geometry}

\usepackage{etoolbox}

\titleformat{\chapter}[display] {\normalfont\LARGE\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\LARGE}

\renewcommand\contentsname{Table of Contents}

\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}

\renewcommand{\cftchappresnum}{\MakeUppercase{\chaptername}~}

\renewcommand{\cftchapaftersnumb}{\qquad}

\renewcommand{\cftchapfont}{\bfseries}

\renewcommand{\cftchappagefont}{\bfseries}

\renewcommand{\cftchapaftersnum}{:}

\setlength{\cftchapnumwidth}{5.8em}

\renewcommand{\cftsecindent}{6.1em}

\setlength{\cftsecnumwidth}{2.1em}

\renewcommand{\cftsubsecindent}{6.1em}

\setlength{\cftsubsecnumwidth}{2.1em}

\theoremstyle{plain}

\newtheorem{thm}{Theorem}[section]

\newtheorem{mthm}[thm]{Main Theorem}

\newtheorem{clm}[thm]{Claim}

\newtheorem{lem}[thm]{Lemma}

\newtheorem{cor}[thm]{Corollary}

\newtheorem{rmk}[thm]{Remark}\theoremstyle{remark}

\newtheorem{exm}[thm]{Example}\theoremstyle{definition}

\newtheorem{case}[thm]{Case}\theoremstyle{definition}

\newtheorem{defn}[thm]{Definition}

\begin{document}

\chapter{CHAPTER WITH NO SUBSECTION}

\defn blah blah blah

Спасибо.

решение1

Переопределите \thethm, чтобы не добавлять номер раздела, если он равен 0.

\documentclass[oneside, openany,12pt]{book}

\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}

\renewcommand{\thethm}{%
  \ifnum\value{section}=0
    \thechapter.%
  \else
    \thesection.%
  \fi
  \arabic{thm}%
}

\begin{document}

\chapter{Title}

\begin{defn}
blah blah blah
\end{defn}


\chapter{Another}
\section{Title}

\begin{thm}
Blah blah
\end{thm}

\end{document}

Обратите внимание, что следует использовать \begin{defn}и \end{defn}, а не \defn.

Я оставил только нужный код, остальное добавьте обратно, вам нужно.

введите описание изображения здесь

решение2

У меня были похожие проблемы с нумерацией подписей к изображениям. Возможно, пакет chngcntrмог бы вам помочь.

\usepackage{chngcntr}
...
\chapter{CHAPTER WITH NO SUBSECTION}
\counterwithout{defn}{section}
\defn blah blah blah

Связанный контент