![从章节和小节编号中删除章节编号](https://linux22.com/image/413797/%E4%BB%8E%E7%AB%A0%E8%8A%82%E5%92%8C%E5%B0%8F%E8%8A%82%E7%BC%96%E5%8F%B7%E4%B8%AD%E5%88%A0%E9%99%A4%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7.png)
我尝试使用章节和小节对文档的每个段落进行编号,但它仍然会输入章节编号......这不是我想要的。
以下是 MWE
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\setlength{\parskip}{0.5cm}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection}{0.5em}{}[\quad]
\title{Contract Doc}
\date{May 2020}
\begin{document}
\part{Introduction}
\setcounter{chapter}{4}
\chapter{Liabilities}
\setcounter{section}{1}
The section number is: \thesection (Chapter.Section)
%\section{Test}
\subsection{}I want something like this, but with the "Chapter" number removed; kind of like "chapter a verse" in a Bible, but it's actually section and subsection in this doc.
\noindent\normalfont\textbf{1.2}~~~More like this...followed by:
\noindent\normalfont\textbf{1.3}~~~etc.
\setcounter{section}{2}
Then the next Bible-like 'chapter' (section really) would look like:
\noindent\normalfont\textbf{2.1}~~~Blah blah. Even though it's still Chapter 5, Liabilities.
\end{document}
答案1
为什么不让 LaTeX 为您设置数字?\chapter
宏将节号设置为零,并\section
增加节号,从而将子节号设置为零。
以下是您的解决方案 MWE 的修订版本。
% secnumprob.tex SE 543955
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\renewcommand*{\thesection}{\arabic{section}}
\setlength{\parskip}{0.5cm}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection}{0.5em}{}[\quad]
\title{Contract Doc}
\date{May 2020}
\newcommand{\anonsec}{\refstepcounter{section}} % increment the section number
\begin{document}
\part{Introduction}
\setcounter{chapter}{4}
\chapter{Liabilities}
% \setcounter{section}{1}
\anonsec % increment the section number and set subsection number to zero
The section number is: \thesection (Chapter.Section)
%\section{Test}
\subsection{}I want something like this, but with the "Chapter" number removed; kind of like "chapter a verse" in a Bible, but it's actually section and subsection in this doc.
\subsection{}More like this...followed by:
\subsection{}etc.
% \setcounter{section}{2} % Set "Chapter" counter
\anonsec % increment section counter and set subsection to zero
% \setcounter{subsection}{0} % Reset "Verse" counter
Then the next Bible-like 'chapter' (section really) would look like:
\subsection{}Blah blah. Even though it's still Chapter 5, Liabilities.
\end{document}
当然,如果您确实喜欢手动操作章节和小节编号,那么请忽略上述内容。
答案2
我已经找到答案了:
添加:
\renewcommand*{\thesection}{\arabic{section}}
到序言,然后设置每个部分编号来代表“章节”,例如:
\setcounter{section}{2} %just before the first \subsection
这是MWE:
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\renewcommand*{\thesection}{\arabic{section}}
\setlength{\parskip}{0.5cm}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection}{0.5em}{}[\quad]
\title{Contract Doc}
\date{May 2020}
\begin{document}
\part{Introduction}
\setcounter{chapter}{4}
\chapter{Liabilities}
\setcounter{section}{1}
The section number is: \thesection (Chapter.Section)
%\section{Test}
\subsection{}I want something like this, but with the "Chapter" number removed; kind of like "chapter a verse" in a Bible, but it's actually section and subsection in this doc.
\subsection{}More like this...followed by:
\subsection{}etc.
\setcounter{section}{2} % Set "Chapter" counter
\setcounter{subsection}{0} % Reset "Verse" counter
Then the next Bible-like 'chapter' (section really) would look like:
\subsection{}Blah blah. Even though it's still Chapter 5, Liabilities.
\end{document}
干杯!