我有一份文件,其各部分如下
\section*{\S 1. Introduction}
\section*{\S 2. Main Results}
我如何使用本节编号将定理、定义、命题编号为定理 2.1、定义 3.2 等?
答案1
以下解决方案借鉴了我的答案查询在节或章标题前插入 \S。
\documentclass{article}
% Automatically prefix "\S" to numbers in section-level headers:
\makeatletter
%% See pp. 26f. of 'The LaTeX Companion,' 2nd. ed.
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\space}% default
{\csname #1@cntformat\endcsname}}% individual control
\newcommand{\section@cntformat}{\S\thesection.\space}
%\newcommand{\subsection@cntformat}{\S\thesubsection.\space}
%\newcommand{\subsubsection@cntformat}{\S\thesubsubsection.\space}
%\newcommand{\paragraph@cntformat}{\S\theparagraph.\space}
%\newcommand{\subparagraph@cntformat}{\S\thesubparagraph.\space}
\makeatletter
\usepackage{amsthm}
\newtheorem{thm}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\begin{document}
\section{Introduction}
\dots
\section{Main Results}
\begin{thm} Hello \dots \end{thm}
\section{Additional Results}
\stepcounter{defn} % just for this example
\begin{defn} World \dots \end{defn}
\end{document}