我希望章节编号为numberchapter.numbersection.
所以我输入
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}.}
但如果我想创建一个定理,定理编号显示为。和Theorem numberchapter.numbersection..numbertheorem
之间有一个双点。 我怎样才能让它只显示一个点?numbersection
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
您很可能不希望章节和小节的交叉引用带有尾随句点。因此,您不想在\thesection
和 中硬编码句点\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}}