问题描述
我是LateX的新手.我知道如何通过使用\section*{heading}
而不是\section{heading}
删除节号.但是,当我在目录中显示节标题时,它不会打印节号.我希望在下面显示的目录中的项目简介"和公司简介"之前显示部分编号.
I am new to LateX. I know how to remove the section number by using \section*{heading}
instead of \section{heading}
.But when I display the section heading in the Table of Contents , it does not print the section number. I want the section number to be displayed before "Introduction to Project" and "Introduction to company" in the Table of Contents shown below.
推荐答案
titlesec
软件包对修改您的章节标题非常有用.一个重要的命令是\titleformat
,它在手册的第4页上进行了描述.该命令如下所示:
The titlesec
package is very useful to modify your chapter and section titles. An important command is \titleformat
, which is described on page 4 of the manual. The command looks like this:
\titleformat{⟨command⟩}[⟨shape⟩]{⟨format⟩}{⟨label⟩}{⟨sep⟩}{⟨before-code⟩}[⟨after-code⟩]
在这里,我们要更改\section
命令,即<command>
是\section
.<shape>
设置是可选的-我们将保留默认值.在<format>
中,我们定义标题的格式. \section
的默认值为\normalfont\Large\bfseries
,因此我们将其设置为该值.如果要更改外观,可以在此处进行.现在,有趣的部分:<label>
是节号-我们不想打印它,因此我们将该字段留空. <sep>
是标签和标题之间的分隔符,如果没有标签,则应为零.最后,使用<before-code>
和<after-code>
,我们可以添加应该在打印标题之前或之后运行的任何代码.我们也不需要.因此,我们的命令是:
here, we want to change the \section
command, i.e. <command>
is \section
.The <shape>
setting is optional - we'll just leave the default value. In <format>
, we define how the title shall be formatted. The default for \section
is \normalfont\Large\bfseries
, so we'll set it to that. If you want to change the appearance, you can do that here. Now, the interesting part: the <label>
is the section number - we don't want to print it, so we'll lave that field empty. The <sep>
is the separation between label and title, which should be zero if we don't have a label. Finally, with <before-code>
and <after-code>
we can add any code which should be run before or after printing the title. We don't need that either. So, our command is:
\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}
在这里,对此进行演示:
Here, a demonstration of that:
\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}
\begin{document}
\tableofcontents
\section{Introduction to Company}
This is the company.
\section{Introduction to Project}
My project is very nice.
\end{document}
这篇关于删除部分编号,但在LaTeX的目录中显示该编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!