在第 3 章(节)中,我希望将小节编号为 3.1 、3.2 、3.3 等。但显示为2.4、2.5。我尝试使用\setcounter{subsection}{3},但没有帮助。
以下是代码:
%previous code
\cleardoublepage
\section*{Chapter 3}
\subsection*{Product Design}
\line(1,0){400}
\setcounter{subsection}{3}
\subsection{Product Perspective}
%rest of the code
Run Code Online (Sandbox Code Playgroud)
输出如下:

这个答案可能很长,但是从这个问题和上一个问题来看,我想我知道你真正想要什么。如果这是完全错误的,请告诉我,我将删除此答案。
我假设您希望您的文档如下所示:
为了实现这一点,您应该使用report文档类,它为您提供了额外的分段级别,即\chapter. 每章包含多个节,每个节又包含小节、小节、段落等。您的文档的基本设置是
\documentclass{report}
\begin{document}
% Frontmatter
\tableofcontents
% Main part
\chapter{Introduction}
My project is awesome! In this chapter, I am telling you why.
\chapter{Product Design}
\section{Product Perspective}
The product is supposed to be very nice and cool.
It shall satisfy all conditions and look awesome.
\end{document}
Run Code Online (Sandbox Code Playgroud)
现在,为了实现您在这个问题中要求的标题格式,我们加载包titlesec并进行配置,\chapter如下所示:
% Title formating
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\bfseries} % Make title \large and bold
{\huge Chapter~\thechapter} % Write Chapter X in \huge font
{20pt} % 20pt distance between Chapter X and title
{}
[\vspace{1ex}\titlerule] % Add a line below chapter title
Run Code Online (Sandbox Code Playgroud)
如果您双面打印文档,并且希望所有章节都从双页的右侧开始,那么您可以简单地\documentclass{report}通过以下行更改替换,并且不需要\cleardoublepage在每个章节之前调用。这也使得边距对称。
\documentclass[twoside, openright]{report}
Run Code Online (Sandbox Code Playgroud)
然后,在上一个问题中,您还有摘要和致谢,其中有罗马页码。默认情况下,LaTeX 不会将未编号的章节(如“摘要”)放入目录中,因此我们必须手动执行此操作。这是按如下方式完成的:
% Frontmatter
\pagenumbering{roman} % Frontmatter with roman page numbering
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract} % Add unnumbered chapter to table of contents
This is the short version of my work.
\chapter*{Acknowledgement}
\addcontentsline{toc}{chapter}{Acknowledgement} % Add unnumbered chapter to table of contents
I would like to thank everybody who helped me.
Run Code Online (Sandbox Code Playgroud)
当然,您必须在第一章之前切换回阿拉伯文页码。包含上述部分的完整代码如下所示。
\documentclass{report}
% Title formating
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\bfseries} % Make title \large and bold
{\huge Chapter~\thechapter} % Write Chapter X in \huge font
{20pt} % 20pt distance between Chapter X and title
{}
[\vspace{1ex}\titlerule] % Add a line below chapter title
\begin{document}
% Frontmatter
\pagenumbering{roman} % Frontmatter with roman page numbering
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract} % Add unnumbered chapter to table of contents
This is the short version of my work.
\chapter*{Acknowledgement}
\addcontentsline{toc}{chapter}{Acknowledgement} % Add unnumbered chapter to table of contents
I would like to thank everybody who helped me.
\tableofcontents
% Main part
\cleardoublepage
\pagenumbering{arabic} % Main part with arabic page numbering
\chapter{Introduction}
My project is awesome! In this chapter, I am telling you why.
\chapter{Product Design}
\section{Product Perspective}
The product is supposed to be very nice and cool.
It shall satisfy all conditions and look awesome.
\end{document}
Run Code Online (Sandbox Code Playgroud)
我希望这确实是您想要的文档外观。如果没有 - 或者如果您对我在这里向您展示的内容有任何其他疑问,请发表评论。最后还有一个单独的站点,专门针对TeX、LaTeX和朋友的问题,关于LaTeX的问题应该发布在那里。
| 归档时间: |
|
| 查看次数: |
29004 次 |
| 最近记录: |