`numbersection` 和 `numbertheorem` 之間有一個雙點

`numbersection` 和 `numbertheorem` 之間有一個雙點

我希望章節編號為numberchapter.numbersection.所以我輸入

    \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}.}

但如果我想做一個定理,定理編號就會顯示Theorem numberchapter.numbersection..numbertheoremnumbersection和之間有一個雙點numbertheorem。我怎麼能讓它只顯示一個點?

    \documentclass[twoside,11pt]{book}
    \usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm,papersize={15.5cm,23.5cm}]{geometry}
    \renewcommand{\thechapter}{\Roman{chapter}}
    \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}.}
    \renewcommand{\thesubsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection}.}
    \usepackage{amsthm}
    \newtheorem{definition}{Definition}[section]
    \newtheorem{theorem}{Theorem}[section]
    \begin{document}
        \chapter{ABC}
        blablabla
        \section{ONE}
        \begin{theorem}
            dddd
        \end{theorem}
    \end{document}

編輯:

根據 Egreg 的回答,如果我格式化該部分和小節,則不會出現點。為什麼會發生這種情況以及解決方案是什麼?

\documentclass{book}
\usepackage{amsthm,titlesec}

\titleformat{\section}
[hang]
{\bfseries}
{\bfseries\thesection}{1ex}{\bfseries}
\titlespacing{\section}{1.5pt}{0.2cm}{0.2cm}

\titleformat{\subsection}
[hang]
{\bfseries}
{\bfseries\thesubsection}{1ex}{\bfseries}
\titlespacing{\subsection}{1.5pt}{0.2cm}{0.2cm}

\renewcommand{\thechapter}{\Roman{chapter}}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
    \ifcsname format#1\endcsname
    \csname format#1\endcsname
    \else
    \csname the#1\endcsname
    \fi
    \quad
}
\makeatother

\newcommand{\formatsection}{\thesection.}
\newcommand{\formatsubsection}{\thesubsection.}

\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}

\newtheorem{definition}{Definition}[section]
\newtheorem{theorem}{Theorem}[section]

\begin{document}
    
    \chapter{ABC}
    blablabla with \ref{sec:one} and no period.
    
    \section{ONE}\label{sec:one}
    
    \begin{theorem}
        dddd
    \end{theorem}
    
    \subsection{TWO}
    
    Just to see what happens.
    
\end{document}

在此輸入影像描述

答案1

您很可能不希望對節和小節的交叉引用具有尾隨句點。所以你不想硬連線 in\thesection和 in 中的句點\thesubsection

使用以下程式碼,尾隨句點由 來新增\@seccntformat

\documentclass{book}
\usepackage{amsthm}

\renewcommand{\thechapter}{\Roman{chapter}}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \ifcsname format#1\endcsname
    \csname format#1\endcsname
  \else
    \csname the#1\endcsname
  \fi
  \quad
}
\makeatother

\newcommand{\formatsection}{\thesection.}
\newcommand{\formatsubsection}{\thesubsection.}

\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}

\newtheorem{definition}{Definition}[section]
\newtheorem{theorem}{Theorem}[section]

\begin{document}

\chapter{ABC}
blablabla with \ref{sec:one} and no period.

\section{ONE}\label{sec:one}

\begin{theorem}
dddd
\end{theorem}

\subsection{TWO}

Just to see what happens.

\end{document}

在此輸入影像描述

如果您使用titlesec它會更容易,因為您可以在正確的位置明確添加句點。

\documentclass{book}
\usepackage{amsthm,titlesec}

\titleformat{\section}[hang]
  {\bfseries}
  {\thesection.}
  {1ex}
  {}
\titlespacing{\section}{1.5pt}{0.2cm}{0.2cm}

\titleformat{\subsection}[hang]
  {\bfseries}
  {\thesubsection.}
  {1ex}
  {}
\titlespacing{\subsection}{1.5pt}{0.2cm}{0.2cm}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}

\newtheorem{definition}{Definition}[section]
\newtheorem{theorem}{Theorem}[section]

\begin{document}

\chapter{ABC}
blablabla with \ref{sec:one} and no period.

\section{ONE}\label{sec:one}

\begin{theorem}
dddd
\end{theorem}

\subsection{TWO}

Just to see what happens.

\end{document}

在此輸入影像描述

答案2

嘗試:

\renewcommand{\thetheorem}{\thesection\arabic{theorem}}

相關內容